pushing old yt.py instead due to always error.

This commit is contained in:
Umiko 2025-05-05 10:06:38 +07:00
parent 167389067d
commit 6458f19226
2 changed files with 7 additions and 28 deletions

View File

@ -44,43 +44,23 @@ class YtService(_Service):
def initialize(self):
self._ydl_config = {
"format": "bestaudio/best",
"outtmpl": "%(title)s.%(ext)s",
"skip_download": True,
"format": "m4a/bestaudio/best[protocol!=m3u8_native]/best",
"socket_timeout": 5,
"logger": logging.getLogger("root"),
"cookiefile": "/home/ttbot/data/cookies.txt",
"postprocessors": [
{
"key": "FFmpegExtractAudio",
"preferredcodec": "mp3",
"preferredquality": "192",
}
],
"postprocessor_args": [
"-ar", "44100"
],
"prefer_ffmpeg": True,
"keepvideo": False,
"cookiefile": "/home/ttbot/data/cookies.txt"
}
def download(self, track: Track, file_path: str) -> None:
try:
info = track.extra_info
if not info:
# fallback ke parent class kalo gak ada info
super().download(track, file_path)
return
ydl_opts = self._ydl_config.copy()
ydl_opts["outtmpl"] = file_path.rsplit(".", 1)[0] + ".mp3"
with YoutubeDL(ydl_opts) as ydl:
# Download langsung pakai URL dari info
url = info.get("webpage_url")
if not url:
raise errors.ServiceError("Missing webpage_url in track info")
ydl.download([url])
with YoutubeDL(self._ydl_config) as ydl:
dl = get_suitable_downloader(info)(ydl, self._ydl_config)
dl.download(file_path, info)
except Exception as e:
logging.error(f"Download error: {str(e)}", exc_info=True)
raise errors.ServiceError("Download failed")

View File

@ -1,6 +1,5 @@
This change log is written to find out the changes that have been made by Pandora, and the source code still refers to TTMediaBot.
5/5/2025
Change the download from m4a to mp3, if it's work.
Added new command: e, to add either link or new song to the extended track. if nothing is playing, it plays the track directly.
Fix user rights to upload file, hopefully...