diff --git a/db.py b/db.py index ea1a5f0..9fc350b 100644 --- a/db.py +++ b/db.py @@ -2,7 +2,7 @@ import os import json if not os.path.exists('conf.json'): - db = {'api_token': 'None'} + db = {'api_token': 'None', 'ytdlp_way': 'None'} js = json.dumps(db, indent=2) with open("conf.json", "w") as outfile: outfile.write(js) diff --git a/yt_downloader.py b/yt_downloader.py index 6c0a64a..b643897 100644 --- a/yt_downloader.py +++ b/yt_downloader.py @@ -15,6 +15,7 @@ logger = logging.getLogger(__name__) # Bot token from @BotFather CONFIG = read() BOT_TOKEN = CONFIG['api_token'] +YT_DLP = CONFIG['ytdlp_way'] bot = telebot.TeleBot(BOT_TOKEN) @@ -45,7 +46,7 @@ def handle_youtube_music_link(message): # Step 1: Get metadata using yt-dlp in simulate mode result = subprocess.run( - ["yt-dlp", "--print-json", "--skip-download", "--restrict-filenames", url], + [YT_DLP, "--print-json", "--skip-download", "--restrict-filenames", url], capture_output=True, text=True ) @@ -73,7 +74,7 @@ def handle_youtube_music_link(message): output_template = f"{user.id}_%(title)s.%(ext)s" download_result = subprocess.run( [ - "yt-dlp", + YT_DLP, "-x", "--audio-format", "mp3", "--audio-quality", "0", "--output", output_template, "--restrict-filenames",