Closes #3472
This commit is contained in:
pukkandan 2022-04-19 02:57:20 +05:30
parent 43cc91ad75
commit 1e9969f4f5
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39
4 changed files with 7 additions and 9 deletions

View File

@ -394,10 +394,8 @@ def extract_metadata(webpage):
r'handleWithCustomApplyEach\(\s*ScheduledApplyEach\s*,\s*(\{.+?\})\s*\);', webpage)] r'handleWithCustomApplyEach\(\s*ScheduledApplyEach\s*,\s*(\{.+?\})\s*\);', webpage)]
post = traverse_obj(post_data, ( post = traverse_obj(post_data, (
..., 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or [] ..., 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or []
media = traverse_obj( media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: (
post, k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict)
(..., 'attachments', ..., 'media', lambda _, m: str(m['id']) == video_id and m['__typename'] == 'Video'),
expected_type=dict)
title = get_first(media, ('title', 'text')) title = get_first(media, ('title', 'text'))
description = get_first(media, ('creation_story', 'comet_sections', 'message', 'story', 'message', '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 {} uploader_data = get_first(media, 'owner') or get_first(post, ('node', 'actors', ...)) or {}

View File

@ -1151,7 +1151,7 @@ def run(self, info):
entries = info.get('entries') or [] entries = info.get('entries') or []
if not any(entries) or (self._only_multi_video and info['_type'] != 'multi_video'): if not any(entries) or (self._only_multi_video and info['_type'] != 'multi_video'):
return [], info 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') raise PostProcessingError('Concatenation is not supported when downloading multiple separate formats')
in_files = traverse_obj(entries, (..., 'requested_downloads', 0, 'filepath')) or [] in_files = traverse_obj(entries, (..., 'requested_downloads', 0, 'filepath')) or []

View File

@ -6,12 +6,12 @@
class MetadataParserPP(PostProcessor): class MetadataParserPP(PostProcessor):
def __init__(self, downloader, actions): def __init__(self, downloader, actions):
super().__init__(self, downloader) super().__init__(downloader)
self._actions = [] self._actions = []
for f in actions: for f in actions:
action, *args = f action, *args = f
assert action in self.Actions assert action in self.Actions
self._actions.append(action(*args)) self._actions.append(action(self, *args))
@classmethod @classmethod
def validate_action(cls, action, *data): def validate_action(cls, action, *data):
@ -21,7 +21,7 @@ def validate_action(cls, action, *data):
""" """
if action not in cls.Actions: if action not in cls.Actions:
raise ValueError(f'{action!r} is not a valid action') 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 @staticmethod
def field_to_template(tmpl): def field_to_template(tmpl):

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import asyncio
import atexit import atexit
import base64 import base64
import binascii import binascii
@ -41,6 +40,7 @@
import zlib import zlib
from .compat import ( from .compat import (
asyncio,
compat_brotli, compat_brotli,
compat_chr, compat_chr,
compat_cookiejar, compat_cookiejar,