Исправление пару багов
This commit is contained in:
parent
4dbeebdfcf
commit
adb8a32840
2
db.py
2
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)
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user