Исправление пару багов

This commit is contained in:
justuser-31 2025-08-13 10:46:02 +00:00
parent 4dbeebdfcf
commit adb8a32840
2 changed files with 4 additions and 3 deletions

2
db.py
View File

@ -2,7 +2,7 @@ import os
import json import json
if not os.path.exists('conf.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) js = json.dumps(db, indent=2)
with open("conf.json", "w") as outfile: with open("conf.json", "w") as outfile:
outfile.write(js) outfile.write(js)

View File

@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
# Bot token from @BotFather # Bot token from @BotFather
CONFIG = read() CONFIG = read()
BOT_TOKEN = CONFIG['api_token'] BOT_TOKEN = CONFIG['api_token']
YT_DLP = CONFIG['ytdlp_way']
bot = telebot.TeleBot(BOT_TOKEN) 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 # Step 1: Get metadata using yt-dlp in simulate mode
result = subprocess.run( result = subprocess.run(
["yt-dlp", "--print-json", "--skip-download", "--restrict-filenames", url], [YT_DLP, "--print-json", "--skip-download", "--restrict-filenames", url],
capture_output=True, capture_output=True,
text=True text=True
) )
@ -73,7 +74,7 @@ def handle_youtube_music_link(message):
output_template = f"{user.id}_%(title)s.%(ext)s" output_template = f"{user.id}_%(title)s.%(ext)s"
download_result = subprocess.run( download_result = subprocess.run(
[ [
"yt-dlp", YT_DLP,
"-x", "--audio-format", "mp3", "--audio-quality", "0", "-x", "--audio-format", "mp3", "--audio-quality", "0",
"--output", output_template, "--output", output_template,
"--restrict-filenames", "--restrict-filenames",