mirror of
https://github.com/tropicoo/yt-dlp-bot.git
synced 2024-12-26 00:51:17 +08:00
Fix rare yt-dlp glitch
This commit is contained in:
parent
14b668cf6d
commit
b6cdf76219
4 changed files with 13 additions and 3 deletions
|
@ -14,3 +14,5 @@
|
|||
LICENSE
|
||||
README.md
|
||||
pyproject.toml
|
||||
rsync_exclude.txt
|
||||
rsync.sh
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
|||
# Byte-compiled / optimized / DLL files
|
||||
|
||||
rsync.sh
|
||||
rsync_exclude.txt
|
||||
*tmp*
|
||||
*.session
|
||||
*.session-journal
|
||||
|
|
|
@ -210,7 +210,7 @@ class AudioUploadTask(AbstractUploadTask):
|
|||
)
|
||||
|
||||
def _cache_data(self, message: Message) -> None:
|
||||
self._log.info('Saving telegram file cache')
|
||||
self._log.info('Saving Telegram file cache')
|
||||
audio = message.audio
|
||||
if not audio:
|
||||
err_msg = 'Telegram message response does not contain audio'
|
||||
|
@ -291,7 +291,7 @@ class VideoUploadTask(AbstractUploadTask):
|
|||
return self._bot.send_video(**kwargs)
|
||||
|
||||
def _cache_data(self, message: Message) -> None:
|
||||
self._log.info('Saving telegram file cache')
|
||||
self._log.info('Saving Telegram file cache')
|
||||
video = message.video or message.animation
|
||||
if not video:
|
||||
err_msg = 'Telegram message response does not contain video or animation'
|
||||
|
|
|
@ -247,6 +247,10 @@ class MediaDownloader:
|
|||
def _get_requested_video(self, requested_downloads: list[dict]) -> dict | None:
|
||||
for download_obj in requested_downloads:
|
||||
if download_obj['ext'] != FINAL_AUDIO_FORMAT:
|
||||
# Attempt to handle yt-dlp glitch.
|
||||
download_obj['filepath'] = download_obj.get(
|
||||
'filepath', download_obj.get('filename', download_obj['_filename'])
|
||||
)
|
||||
return download_obj
|
||||
|
||||
# When video was converted to audio but video kept.
|
||||
|
@ -258,7 +262,9 @@ class MediaDownloader:
|
|||
download_obj['filepath'],
|
||||
download_obj['_filename'],
|
||||
)
|
||||
download_obj['filepath'] = download_obj['_filename']
|
||||
download_obj['filepath'] = download_obj.get(
|
||||
'filename', download_obj['_filename']
|
||||
)
|
||||
return download_obj
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in a new issue