From 1e9969f4f517eab4077f0b03eee9ef3afa493486 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 19 Apr 2022 02:57:20 +0530 Subject: [PATCH] bugfix for a44ca5a470e09b5170fc9c3a46733f050fadbfae, 19a0394044bfad36cd665450271b8eb048a41c02, 77f9033095cd8e1092a80db67f2b577cf13f95a8 Closes #3472 --- yt_dlp/extractor/facebook.py | 6 ++---- yt_dlp/postprocessor/ffmpeg.py | 2 +- yt_dlp/postprocessor/metadataparser.py | 6 +++--- yt_dlp/utils.py | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/yt_dlp/extractor/facebook.py b/yt_dlp/extractor/facebook.py index f15a36424..de45f9298 100644 --- a/yt_dlp/extractor/facebook.py +++ b/yt_dlp/extractor/facebook.py @@ -394,10 +394,8 @@ class FacebookIE(InfoExtractor): r'handleWithCustomApplyEach\(\s*ScheduledApplyEach\s*,\s*(\{.+?\})\s*\);', webpage)] post = traverse_obj(post_data, ( ..., 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or [] - media = traverse_obj( - post, - (..., 'attachments', ..., 'media', lambda _, m: str(m['id']) == video_id and m['__typename'] == 'Video'), - expected_type=dict) + media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: ( + k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict) title = get_first(media, ('title', 'text')) description = get_first(media, ('creation_story', 'comet_sections', 'message', 'story', 'message', 'text')) uploader_data = get_first(media, 'owner') or get_first(post, ('node', 'actors', ...)) or {} diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 6fe1b6cdd..d909149ef 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -1151,7 +1151,7 @@ class FFmpegConcatPP(FFmpegPostProcessor): entries = info.get('entries') or [] if not any(entries) or (self._only_multi_video and info['_type'] != 'multi_video'): return [], info - elif traverse_obj(entries, (..., 'requested_downloads', lambda _, v: len(v) > 1)): + elif traverse_obj(entries, (..., lambda k, v: k == 'requested_downloads' and len(v) > 1)): raise PostProcessingError('Concatenation is not supported when downloading multiple separate formats') in_files = traverse_obj(entries, (..., 'requested_downloads', 0, 'filepath')) or [] diff --git a/yt_dlp/postprocessor/metadataparser.py b/yt_dlp/postprocessor/metadataparser.py index 98885bd19..51b927b91 100644 --- a/yt_dlp/postprocessor/metadataparser.py +++ b/yt_dlp/postprocessor/metadataparser.py @@ -6,12 +6,12 @@ from ..utils import Namespace class MetadataParserPP(PostProcessor): def __init__(self, downloader, actions): - super().__init__(self, downloader) + super().__init__(downloader) self._actions = [] for f in actions: action, *args = f assert action in self.Actions - self._actions.append(action(*args)) + self._actions.append(action(self, *args)) @classmethod def validate_action(cls, action, *data): @@ -21,7 +21,7 @@ class MetadataParserPP(PostProcessor): """ if action not in cls.Actions: raise ValueError(f'{action!r} is not a valid action') - getattr(cls, action.value)(cls, *data) # So this can raise error to validate + action(cls, *data) # So this can raise error to validate @staticmethod def field_to_template(tmpl): diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index cf52fb2b6..e1db7b868 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import asyncio import atexit import base64 import binascii @@ -41,6 +40,7 @@ import xml.etree.ElementTree import zlib from .compat import ( + asyncio, compat_brotli, compat_chr, compat_cookiejar,