From fd4ac8896d4e2ce32b29b590857474df7eadcaa4 Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 24 Dec 2019 19:22:51 -0600 Subject: [PATCH] ipv4 only fix for youtube 429 ratelimiting probably not gonna work in the long run --- app/models.py | 1 - app/sound_models.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models.py b/app/models.py index e8897cf..a40b7e9 100644 --- a/app/models.py +++ b/app/models.py @@ -3,7 +3,6 @@ from flask_login import UserMixin from datetime import datetime from app import db, login from werkzeug.security import generate_password_hash, check_password_hash -import os # Just a note, my role system is really quite terrible, but I've implemented as good as a system as I can for a simple RBAC without Hierarchy. # Once could create a complex system, but it would be better to properly work with SQLAlchemy to create proper permissions, hierarchy, parent/child etc. rather than to work with simple strings. diff --git a/app/sound_models.py b/app/sound_models.py index daeacfd..08411ce 100644 --- a/app/sound_models.py +++ b/app/sound_models.py @@ -35,11 +35,11 @@ class YouTubeAudio(db.Model): print(f'Filling out metadata for {self.id}') # Use stdout=PIPE, [Python 3.6] production server support instead of 'capture_output=True' => 'process.stdout' self.url = f'https://www.youtube.com/watch?v={self.id}' - processFilename = subprocess.Popen(['youtube-dl', '-x', '--audio-format', 'mp3', '--restrict-filenames', '--get-filename', self.url], + processFilename = subprocess.Popen(f'youtube-dl -4 -x --audio-format mp3 --restrict-filenames --get-filename {self.url}'.split(' '), encoding='utf-8', stdout=subprocess.PIPE) self.filename = processFilename.communicate()[0].split('.')[0] + '.mp3' print(f'Filename acquired for {self.id}') - processJSON = subprocess.Popen(['youtube-dl', '-x', '--audio-format', 'mp3', '--restrict-filenames', '--dump-json', self.url], + processJSON = subprocess.Popen(f'youtube-dl -4 -x --audio-format mp3 --restrict-filenames --dump-json {self.url}'.split(' '), encoding='utf-8', stdout=subprocess.PIPE) data = json.loads(processJSON.communicate()[0]) print(f'JSON acquired for {self.id}, beginning to fill.')