before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
item_time = None
for meta in try_get(media, lambda x: x['metadata']['items'], list) or []:
if try_get(meta, lambda x: x['label']) == 'Published':
item_time = unified_timestamp(meta.get('timestamp'))
b... | confusing indentation
```suggestion
for block in traverse_obj(resp, (
'data', (None, ('content', 'model')), 'blocks',
lambda _, v: v['type'] in ('media', 'video'),
'model', {dict})):
``` | 'subtitles': subtitles,
'timestamp': item_time,
'description': strip_or_none(item_desc),
'duration': int_or_none(item.get('duration')),
})
for resp in traverse_obj(initial_data, ('data', lamb... | @@ -1235,18 +1360,19 @@ def parse_media(media):
'timestamp': item_time,
'description': strip_or_none(item_desc),
})
+
+ for resp in traverse_obj(initial_data, ('data', lambda _, v: v.get('name'))):
+ name = resp['name']
... | yt_dlp/extractor/bbc.py | 26 | Python | 0.929 | suggestion | 296 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kylegustavo |
})
for resp in traverse_obj(initial_data, ('data', lambda _, v: v.get('name'))):
name = resp['name']
for resp in (initial_data.get('data') or {}).values():
name = resp.get('name')
if name == 'media-experience':
... | ```suggestion
next_data = traverse_obj(self._search_nextjs_data(webpage, playlist_id, default={}),
('props', 'pageProps', 'page'))
``` | is_type('media', 'video'), 'model', {dict})):
parse_media(block)
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
# extract from SIMORGH_DATA hydration JSON
simorgh_data = self._searc... | @@ -1255,6 +1381,26 @@ def extract_all(pattern):
lambda s: self._parse_json(s, playlist_id, fatal=False),
re.findall(pattern, webpage))))
+ # US accessed article with single embedded video (e.g.
+ # https://www.bbc.com/news/uk-68546268)
+ next_data = traverse_obj... | yt_dlp/extractor/bbc.py | 26 | Python | 0.714 | suggestion | 178 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kylegustavo |
preload_state = self._search_json(
r'window\.__(?:PWA_)?PRELOADED_STATE__\s*=', webpage,
'preload state', playlist_id, transform_source=js_to_json, default={})
# PRELOADED_STATE with current programmme
current_programme = traverse_obj(preload_state, (
'program... | ```suggestion
'tracklist', 'tracks', lambda _, v: float(v['offset']['start']), {
```
no need to handle error in filter | current_programme = traverse_obj(preload_state, ('programmes', 'current', {dict}))
programme_id = traverse_obj(current_programme, ('id', {str}))
if programme_id and current_programme.get('type') == 'playable_item':
title = traverse_obj(current_programme, ('titles', ('tertiary', 'seco... | @@ -1069,84 +1099,142 @@ def _real_extract(self, url):
}
# Morph based embed (e.g. http://www.bbc.co.uk/sport/live/olympics/36895975)
- # There are several setPayload calls may be present but the video
- # seems to be always related to the first one
- morph_payload = sel... | yt_dlp/extractor/bbc.py | 26 | Python | 0.857 | suggestion | 149 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kylegustavo |
for resp in (initial_data.get('data') or {}).values():
name = resp.get('name')
if name == 'media-experience':
parse_media(try_get(resp, lambda x: x['data']['initialItem']['mediaItem'], dict))
elif name == 'article':
for ... | It may be worth creating a helper
```py
def is_type(*types):
return lambda _, v: v['type'] in types
```
Then all these lambdas become `is_type('video')` etc. There is a lot of this code |
# extract from SIMORGH_DATA hydration JSON
simorgh_data = self._search_json(
r'window\s*\.\s*SIMORGH_DATA\s*=', webpage,
'simorgh data', playlist_id, default={})
if simorgh_data:
done = False
for video_data in traverse_obj(simorgh_data, (
... | @@ -1255,6 +1381,26 @@ def extract_all(pattern):
lambda s: self._parse_json(s, playlist_id, fatal=False),
re.findall(pattern, webpage))))
+ # US accessed article with single embedded video (e.g.
+ # https://www.bbc.com/news/uk-68546268)
+ next_data = traverse_obj... | yt_dlp/extractor/bbc.py | 26 | Python | 0.857 | refactor | 196 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kylegustavo |
elif name == 'article':
for block in traverse_obj(resp, ('data', (
None, ('content', 'model')), 'blocks',
lambda _, v: v.get('type') in {'media', 'video'},
'model', {dict})):
p... | ```suggestion
if entry := parse_model(model):
``` | 'simorgh data', playlist_id, default={})
if simorgh_data:
done = False
for video_data in traverse_obj(simorgh_data, (
'pageData', 'content', 'model', 'blocks', is_type('video', 'legacyMedia'))):
model = traverse_obj(video_data, (
... | @@ -1255,6 +1381,26 @@ def extract_all(pattern):
lambda s: self._parse_json(s, playlist_id, fatal=False),
re.findall(pattern, webpage))))
+ # US accessed article with single embedded video (e.g.
+ # https://www.bbc.com/news/uk-68546268)
+ next_data = traverse_obj... | yt_dlp/extractor/bbc.py | 26 | Python | 0.571 | suggestion | 63 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kylegustavo |
for block in traverse_obj(resp, ('data', (
None, ('content', 'model')), 'blocks',
lambda _, v: v.get('type') in {'media', 'video'},
'model', {dict})):
parse_media(block)
return sel... | ```suggestion
if not entry.get('timestamp'):
``` | if simorgh_data:
done = False
for video_data in traverse_obj(simorgh_data, (
'pageData', 'content', 'model', 'blocks', is_type('video', 'legacyMedia'))):
model = traverse_obj(video_data, (
'model', 'blocks', is_type('aresMedia'),
... | @@ -1255,6 +1381,26 @@ def extract_all(pattern):
lambda s: self._parse_json(s, playlist_id, fatal=False),
re.findall(pattern, webpage))))
+ # US accessed article with single embedded video (e.g.
+ # https://www.bbc.com/news/uk-68546268)
+ next_data = traverse_obj... | yt_dlp/extractor/bbc.py | 26 | Python | 0.571 | suggestion | 66 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | kylegustavo |
'timestamp': 1427219242,
'upload_date': '20150324',
'thumbnail': 'https://ichef.bbci.co.uk/news/1024/media/images/81879000/jpg/_81879090_81879089.jpg',
},
'params': {
'skip_download': True,
}
}, {
# article with single video embedded wi... | In this test, we should have these values (using the asset ID instead of the slug for the 'id'):
```diff
- 'id': '150619_video_honduras_militares_hospitales_corrupcion_aw',
+ 'id': '39275083',
+ 'display_id': '150619_video_honduras_militares_hospitales_corrupcion_aw',
``` | 'upload_date': '20150324',
'thumbnail': 'https://ichef.bbci.co.uk/news/1024/media/images/81879000/jpg/_81879090_81879089.jpg',
},
'params': {
'skip_download': True,
}
}, {
# article with single video embedded with data-playable containing XML playl... | @@ -656,7 +658,8 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
},
'params': {
'skip_download': True,
- }
+ },
+ 'skip': 'now SIMORGH_DATA with no video',
}, {
# single video embedded with data-playable containing XML playlists (regi... | yt_dlp/extractor/bbc.py | 26 | Python | 0.857 | suggestion | 310 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
'title': 'Honduras militariza sus hospitales por nuevo escándalo de corrupción',
'description': 'md5:1525f17448c4ee262b64b8f0c9ce66c8',
'timestamp': 1434713142,
'upload_date': '20150619',
},
'params': {
'skip_download': True,
},
... | Tell it like it is:
```suggestion
# single video story with __PWA_PRELOADED_STATE__
``` | 'title': 'Honduras militariza sus hospitales por nuevo escándalo de corrupción',
'description': 'Honduras militariza sus hospitales por nuevo escándalo de corrupción',
'timestamp': 1434713142,
'upload_date': '20150619',
'thumbnail': 'https://a.files.bbci.co.uk... | @@ -683,22 +688,22 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
},
'params': {
'skip_download': True,
- }
+ },
+ 'skip': '404 Not Found',
}, {
# single video story with digitalData | yt_dlp/extractor/bbc.py | 26 | Python | 0.571 | suggestion | 98 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
}, {
# single video embedded with Morph
# TODO: replacement test page
'url': 'http://www.bbc.co.uk/sport/live/olympics/36895975',
'info_dict': {
'id': 'p041vhd0',
'ext': 'mp4',
'title': "Nigeria v Japan - Men's First Round",
'descriptio... | ```suggestion
'thumbnail': r're:https://(?:[^/]+/)+/media/images/69320000/png/_69320754_mmgossipcolumnextraaugust18.png',
'duration': 140,
``` | # TODO: replacement test page
'url': 'http://www.bbc.co.uk/sport/live/olympics/36895975',
'info_dict': {
'id': 'p041vhd0',
'ext': 'mp4',
'title': "Nigeria v Japan - Men's First Round",
'description': 'Live coverage of the first round from Group B a... | @@ -726,34 +729,44 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'uploader': 'BBC Sport',
'uploader_id': 'bbc_sport',
},
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
- 'skip': 'Georestricted to UK',
+ ... | yt_dlp/extractor/bbc.py | 26 | Python | 0.714 | suggestion | 169 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
'playlist_count': 3,
}, {
# lead item from above playlist
'url': 'http://www.bbc.com/sport/0/football/34475836',
'info_dict': {
'id': 'p034ppnv',
'ext': 'mp4',
'title': 'All you need to know about Jurgen Klopp',
'timestamp': 1444335081,... | In the test below (`'p02xzws1'`):
```diff
'timestamp': 1437785037,
'upload_date': '20150725',
+ 'duration': 105,
},
``` | # Testing noplaylist
'url': 'http://www.bbc.com/sport/0/football/34475836',
'info_dict': {
'id': 'p034ppnv',
'ext': 'mp4',
'title': 'All you need to know about Jurgen Klopp',
'timestamp': 1444335081,
'upload_date': '20151008',
... | @@ -762,6 +775,7 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'title': 'School which breaks down barriers in Jerusalem',
},
'playlist_count': 1,
+ 'skip': 'redirects to Young Reporter home page https://www.bbc.co.uk/news/topics/cg41ylwv43pt',
}, {
... | yt_dlp/extractor/bbc.py | 26 | Python | 0.714 | suggestion | 163 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
'url': 'http://www.bbc.com/weather/features/33601775',
'only_matching': True,
}, {
# custom redirection to www.bbc.com
# also, video with window.__INITIAL_DATA__
'url': 'http://www.bbc.co.uk/news/science-environment-33661876',
'info_dict': {
'id': 'p02xzws... | ```suggestion
'upload_date': '20211130',
'duration': 125,
``` | }, {
# custom redirection to www.bbc.com
# also, video with window.__INITIAL_DATA__
'url': 'http://www.bbc.co.uk/news/science-environment-33661876',
'info_dict': {
'id': 'p02xzws1',
'ext': 'mp4',
'title': "Pluto may have 'nitrogen glaciers'",
... | @@ -783,14 +797,27 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
# video with window.__INITIAL_DATA__ and value as JSON string
'url': 'https://www.bbc.com/news/av/world-europe-59468682',
'info_dict': {
- 'id': 'p0b71qth',
+ 'id': 'p0b779gc', # was ... | yt_dlp/extractor/bbc.py | 26 | Python | 0.571 | suggestion | 88 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
'url': 'http://www.bbc.co.uk/learningenglish/chinese/features/lingohack/ep-181227',
'info_dict': {
'id': 'p06w9tws',
'ext': 'mp4',
'title': 'md5:2fabf12a726603193a2879a055f72514',
'description': 'Learn English words and phrases from this story',
... | Below, valid replacement test for BBC Sounds:
```diff
# BBC Sounds
- 'url': 'https://www.bbc.co.uk/sounds/play/m001q78b',
+ 'url': 'https://www.bbc.co.uk/sounds/play/w3ct5rgx',
'info_dict': {
- 'id': 'm001q789',
+ 'id': 'p0hrw4nr',
'ext': 'mp4',... | 'uploader_id': 'bbc_radio_three',
},
'skip': '404 Not Found',
}, {
'url': 'http://www.bbc.co.uk/learningenglish/chinese/features/lingohack/ep-181227',
'info_dict': {
'id': 'p06w9tws',
'ext': 'mp4',
'title': 'md5:2fabf12a726603193a2879a0... | @@ -836,7 +861,7 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'alt_title': 'The downsides of positive thinking',
'description': 'md5:fad74b31da60d83b8265954ee42d85b4',
'duration': 235,
- 'thumbnail': r're:https?://.+/p07c9dsr.jpg',
+ 't... | yt_dlp/extractor/bbc.py | 26 | Python | 0.857 | suggestion | 1,259 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
}
)),
**traverse_obj(video_data, {
'thumbnail': (('iChefImage', 'image'), {url_or_none}, any),
'title': (('title', 'caption'), {str}, any),
'duration': ('duration', {parse_duration}),
... | For the BBC Sounds test:
```suggestion
title = traverse_obj(current_programme, ('titles', ('tertiary', 'secondary'), {str}, any)) or playlist_title
```
There's also an `entity_title` which in the test case is the same as `secondary`. If extracted with `BBCCoUkIE`, the title is `{primary}, {secondary}`, ... | entry.update({
'timestamp': traverse_obj(morph_payload, (
'body', 'content', 'article', 'dateTimeInfo', 'dateTime', {parse_iso8601})
),
**traverse_obj(video_data, {
'thumbnail': (('iChefImage', 'i... | @@ -1069,83 +1095,137 @@ def _real_extract(self, url):
}
# Morph based embed (e.g. http://www.bbc.co.uk/sport/live/olympics/36895975)
- # There are several setPayload calls may be present but the video
- # seems to be always related to the first one
- morph_payload = sel... | yt_dlp/extractor/bbc.py | 26 | Python | 0.857 | refactor | 380 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
'body', 'content', 'article', 'headline', {str})) or playlist_title
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
# various PRELOADED_STATE JSON
preload_state = self._search_json(
r'window\.__... | For the BBC Sounds test:
```suggestion
'uploader_id': ('network', 'id', {str}),
'timestamp': ((('availability', 'from'), ('release', 'date')), {parse_iso8601}, any),
'series': ('titles', 'primary', {str}),
``` | if entries:
playlist_title = traverse_obj(morph_payload, (
'body', 'content', 'article', 'headline', {str})) or playlist_title
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
# various P... | @@ -1069,83 +1095,137 @@ def _real_extract(self, url):
}
# Morph based embed (e.g. http://www.bbc.co.uk/sport/live/olympics/36895975)
- # There are several setPayload calls may be present but the video
- # seems to be always related to the first one
- morph_payload = sel... | yt_dlp/extractor/bbc.py | 26 | Python | 0.786 | suggestion | 274 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
item_desc = '\n\n'.join(summary)
item_time = None
for meta in try_get(media, lambda x: x['metadata']['items'], list) or []:
if try_get(meta, lambda x: x['label']) == 'Published':
item_time = unified_t... | Support SIMORGH_DATA:
```suggestion
# extract from SIMORGH_DATA hydration JSON
simorgh_data = self._search_json(
r'window\s*\.\s*SIMORGH_DATA\s*=', webpage,
'simorgh data', playlist_id, default={})
if simorgh_data:
added, done = False, False
... | if try_get(meta, lambda x: x['label']) == 'Published':
item_time = unified_timestamp(meta.get('timestamp'))
break
entries.append({
'id': item_id,
'title': item_title,
... | @@ -1235,18 +1353,17 @@ def parse_media(media):
'timestamp': item_time,
'description': strip_or_none(item_desc),
})
+
for resp in (initial_data.get('data') or {}).values():
name = resp.get('name')
if na... | yt_dlp/extractor/bbc.py | 26 | Python | 1 | refactor | 2,692 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
'info_dict': {
'id': 'p07c6sb9',
'ext': 'mp4',
'title': 'How positive thinking is harming your happiness',
'alt_title': 'The downsides of positive thinking',
'description': 'md5:fad74b31da60d83b8265954ee42d85b4',
'duration': 235,
... | After replacing the test:
```suggestion
``` | 'add_ie': [BBCCoUkIE.ie_key()],
}, {
# BBC Reel
'url': 'https://www.bbc.com/reel/video/p07c6sb6/how-positive-thinking-is-harming-your-happiness',
'info_dict': {
'id': 'p07c6sb9',
'ext': 'mp4',
'title': 'The downsides of positive thinking',
... | @@ -854,6 +879,7 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'duration': 1800,
'uploader_id': 'bbc_radio_three',
},
+ 'skip': '404 Not Found', | yt_dlp/extractor/bbc.py | 26 | Python | 0.429 | suggestion | 45 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | kylegustavo |
_BASE_URL = 'https://www.crunchyroll.com'
_API_BASE = 'https://api.crunchyroll.com'
_NETRC_MACHINE = 'crunchyroll'
_REFRESH_TOKEN = None
_AUTH_HEADERS = None
_AUTH_EXPIRY = None
_API_ENDPOINT = None
_BASIC_AUTH = 'Basic ' + base64.b64encode(':'.join((
't-kdgp2h8c3jub8fn0fq',
... | I thought curl-cffi works for crunchyroll, no? | _BASE_URL = 'https://www.crunchyroll.com'
_API_BASE = 'https://api.crunchyroll.com'
_NETRC_MACHINE = 'crunchyroll'
_REFRESH_TOKEN = None
_AUTH_HEADERS = None
_AUTH_EXPIRY = None
_API_ENDPOINT = None
_BASIC_AUTH = 'Basic ' + base64.b64encode(':'.join((
't-kdgp2h8c3jub8fn0fq',
... | @@ -42,70 +46,73 @@ class CrunchyrollBaseIE(InfoExtractor):
'ru': 'ru-RU',
'hi': 'hi-IN',
}
+ _CF_HINT = 'Request blocked by Cloudflare; navigate to Crunchyroll in your browser, then pass the fresh cookies (with --cookies-from-browser or --cookies) and your browser\'s User-Agent (with --user-a... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.071 | question | 46 | 51 | 51 | false | [ie/crunchyroll] Fix auth and remove cookies support | 9,749 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
@param fp: Original, file-like, response.
@param url: URL that this is a response of.
@param headers: response headers.
@param status: Response HTTP status code. Default is 200 OK.
@param reason: HTTP status reason. Will use built-in reasons based on status code if not provided.
"""
def __i... | I would also expose this as a parameter for Response, same as Request
+ add in docstring | @param fp: Original, file-like, response.
@param url: URL that this is a response of.
@param headers: response headers.
@param status: Response HTTP status code. Default is 200 OK.
@param reason: HTTP status reason. Will use built-in reasons based on status code if not provided.
@param extension... | @@ -517,6 +517,7 @@ def __init__(
self.reason = reason or HTTPStatus(status).phrase
except ValueError:
self.reason = None
+ self.extensions = {} | yt_dlp/networking/common.py | 26 | Python | 0.214 | suggestion | 89 | 51 | 51 | false | [networking] Add response extensions for impersonate info | 9,756 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | bashonly |
self.report_warning(
'Received incomplete data for a comment reply thread and retrying did not help. '
'Ignoring to let other comments be downloaded. Pass --no-ignore-errors to not ignore.')
return
... | I would use a var for `mutations`, set it above / outside of the `for` loop, and use traversal so it's safe and can always be passed to `extract_thread`.
above:
```diff
is_forced_continuation = False
continuation = None
+ mutations = traverse_obj(response, ('frameworkUpdates'... |
for entry in extract_thread(continuation_items, mutations):
if not entry:
return
yield entry
continuation = self._extract_continuation({'contents': continuation_items})
if continuation:
b... | @@ -3527,10 +3594,16 @@ def extract_thread(contents):
break
continue
- for entry in extract_thread(continuation_items):
+ if 'frameworkUpdates' in response:
+ _iterator = extract_thread(continuation_items, response['framewo... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | performance | 603 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
sort_menu_item = try_get(
comments_header_renderer,
lambda x: x['sortMenu']['sortFilterSubMenuRenderer']['subMenuItems'][comment_sort_index], dict) or {}
sort_continuation_ep = sort_menu_item.get('serviceEndpoint') or {}
_continuat... | ```suggestion
if not entity_payloads:
``` | if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
# old comment format
if not entity_payloads:
comment_renderer... | @@ -3388,21 +3437,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 59 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer =... | we don't yet know that `content` is a dict, shouldn't use `get`
```suggestion
view_model = (
traverse_obj(comment_thread_renderer, ('commentViewModel', 'commentViewModel', {dict}))
or traverse_obj(content, ('commentViewModel', {dict})))
... | or traverse_obj(content, ('commentViewModel', {dict})))
comment_keys = traverse_obj(view_model, (('commentKey', 'toolbarStateKey'), {str}))
if not comment_keys:
continue
entities = traverse_obj(entity_payloads, l... | @@ -3388,21 +3437,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | suggestion | 387 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
sort_text = str_or_none(sort_menu_item.get('title'))
if not sort_text:
sort_text = 'top comments' if comment_sort_index == 0 else 'newest first'
self.to_screen('Sorting comments by %s' % sort_text.lower())
break
return _con... | we should pull this out of the `if` block and use it afterward for either result; see below suggestion
```suggestion
``` | expected_type=dict, default={})
comment = self._extract_comment_old(comment_renderer, parent)
# new comment format
else:
view_model = (
traverse_obj(comment_thread_renderer, ('commentViewModel', 'co... | @@ -3388,21 +3437,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 122 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
# old comment format
if entity_payloads is None:
comment_renderer = get_first(
(comment_thread_renderer, content), [['commentRenderer', ('comment'... | ```suggestion
comment_keys = filter(None, [view_model.get('commentKey'), view_model.get('toolbarStateKey')])
entities = traverse_obj(entity_payloads, lambda _, v: v['entityKey'] in comment_keys)
comment = self._extract_comment(view_model, entities, parent)
... | if comment:
comment['is_pinned'] = traverse_obj(view_model, ('pinnedText', {str})) is not None
if not comment:
continue
comment_id = comment['id']
if comment.get('is_pinned'):
tracker['p... | @@ -3388,21 +3437,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | refactor | 324 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
sort_continuation_ep = sort_menu_item.get('serviceEndpoint') or {}
_continuation = self._extract_continuation_ep_data(sort_continuation_ep) or self._extract_continuation(sort_menu_item)
if not _continuation:
continue
sort_text = str_o... | after we attempt old or new comment extraction, we should do this here
```suggestion
if not comment:
continue
comment_id = comment['id']
``` |
# old comment format
if not entity_payloads:
comment_renderer = get_first(
(comment_thread_renderer, content), [['commentRenderer', ('comment', 'commentRenderer')]],
expected_type=dict, default={})
... | @@ -3388,21 +3437,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | refactor | 201 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
content_list = traverse_obj(
data,
('engagementPanels', ..., 'engagementPanelSectionListRenderer', 'content', 'macroMarkersListRenderer', 'contents'),
expected_type=list)
chapter_time = lambda chapter: parse_duration(self._get_text(chapter, 'timeDescription'))
... | - use the same "early exit `if not comment_id`" pattern from the old method
- use `get_first`, which is equivalent to `traverse_obj(obj, (..., path), get_all=False)`
- never use `.get` chains, use traversal
```suggestion
comment_entity_payload = get_first(entities, ('payload', 'commentEntityPayload', {dic... | def _extract_chapters_from_engagement_panel(self, data, duration):
content_list = traverse_obj(
data,
('engagementPanels', ..., 'engagementPanelSectionListRenderer', 'content', 'macroMarkersListRenderer', 'contents'),
expected_type=list)
chapter_time = lambda chap... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | suggestion | 592 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
chapter_time, chapter_title, duration)
for contents in content_list)), [])
def _extract_heatmap(self, data):
return traverse_obj(data, (
'frameworkUpdates', 'entityBatchUpdate', 'mutations',
lambda _, v: v['payload']['macroMarker... | use a single traversal
```suggestion
'parent': parent or 'root',
**traverse_obj(comment_entity_payload, {
'text': ('properties', 'content', 'content', {str}),
'like_count': ('toolbar', 'likeCountA11y', {parse_count}),
'author_id': ('author'... | self._extract_chapters_helper(traverse_obj(contents, (..., 'macroMarkersListItemRenderer')),
chapter_time, chapter_title, duration)
for contents in content_list)), [])
def _extract_heatmap(self, data):
return traverse_obj(data, (
... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 525 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
return traverse_obj(data, (
'frameworkUpdates', 'entityBatchUpdate', 'mutations',
lambda _, v: v['payload']['macroMarkersListEntity']['markersList']['markerType'] == 'MARKER_TYPE_HEATMAP',
'payload', 'macroMarkersListEntity', 'markersList', 'markers', ..., {
'... | ```suggestion
time_text = traverse_obj(comment_entity_payload, ('properties', 'publishedTime', {str})) or ''
``` | def _extract_heatmap(self, data):
return traverse_obj(data, (
'frameworkUpdates', 'entityBatchUpdate', 'mutations',
lambda _, v: v['payload']['macroMarkersListEntity']['markersList']['markerType'] == 'MARKER_TYPE_HEATMAP',
'payload', 'macroMarkersListEntity', 'markersList... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 122 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
'like_count': parse_count(try_get(comment_entity_payload, lambda x: x['toolbar']['likeCountA11y'], str)) or 0,
'author_id': traverse_obj(comment_entity_payload, ('author', 'channelId', {self.ucid_or_none})),
'author': try_get(comment_entity_payload, lambda x: x['author']['displayName... | ```suggestion
info['author_url'] = urljoin(
'https://www.youtube.com',
traverse_obj(comment_entity_payload, ('author', 'channelCommand', 'innertubeCommand', (
('browseEndpoint', 'canonicalBaseUrl'), ('commandMetadata', 'webCommandMetadata', 'url'))),
... |
return {
'id': comment_id,
'parent': parent or 'root',
**traverse_obj(comment_entity_payload, {
'text': ('properties', 'content', 'content', {str}),
'like_count': ('toolbar', 'likeCountA11y', {parse_count}),
'author_id': ('auth... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.929 | security | 359 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
'author': try_get(comment_entity_payload, lambda x: x['author']['displayName'], str),
'author_thumbnail': traverse_obj(comment_entity_payload, ('author', 'avatarThumbnailUrl', {url_or_none})),
'parent': parent or 'root',
}
# Timestamp is an estimate calculated from t... | ```suggestion
author_is_uploader = traverse_obj(comment_entity_payload, ('author', 'isCreator', {bool}))
``` | 'id': comment_id,
'parent': parent or 'root',
**traverse_obj(comment_entity_payload, {
'text': ('properties', 'content', 'content', {str}),
'like_count': ('toolbar', 'likeCountA11y', {parse_count}),
'author_id': ('author', 'channelId', ... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | security | 118 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
timestamp = self._parse_time_text(time_text)
info.update({
# FIXME: non-standard, but we need a way of showing that it is an estimate.
'_time_text': time_text,
'timestamp': timestamp,
})
info['author_url'] = urljoin(
'https://www.youtube.... | are you sure it's a string like `'true'` instead of a boolean value? I had this in my WIP branch:
```suggestion
if traverse_obj(comment_entity_payload, ('author', 'isVerified', {bool})):
info['author_is_verified'] = True
``` | 'author_thumbnail': ('author', 'avatarThumbnailUrl', {url_or_none}),
'author_is_uploader': ('author', 'isCreator', {bool}),
'author_is_verified': ('author', 'isVerified', {bool}),
'author_url': ('author', 'channelCommand', 'innertubeCommand', (
... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 248 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
# FIXME: non-standard, but we need a way of showing that it is an estimate.
'_time_text': time_text,
'timestamp': timestamp,
})
info['author_url'] = urljoin(
'https://www.youtube.com',
traverse_obj(comment_entity_payload,
... | ```suggestion
if traverse_obj(view_model, 'pinnedText'):
``` | 'author_url': ('author', 'channelCommand', 'innertubeCommand', (
('browseEndpoint', 'canonicalBaseUrl'), ('commandMetadata', 'webCommandMetadata', 'url')
), {lambda x: urljoin('https://www.youtube.com', x)}),
}, get_all=False),
'is_favorited': ... | @@ -3307,7 +3306,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 70 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
import base64
import calendar
import collections
import copy
import datetime as dt
import enum
import hashlib
import itertools
import json
import math
import os.path
import random
import re
import shlex
import sys
import threading
import time
import traceback
import urllib.parse
from .common import InfoExtractor, Searc... | revert unnecessary change
```suggestion
import urllib.parse
``` | import base64
import calendar
import collections
import copy
import datetime as dt
import enum
import hashlib
import itertools
import json
import math
import os.path
import random
import re
import shlex
import sys
import threading
import time
import traceback
import urllib.parse
from .common import InfoExtractor, Sear... | @@ -17,7 +17,6 @@
import time
import traceback
import urllib.parse | yt_dlp/extractor/youtube.py | 19 | Python | 0.643 | suggestion | 68 | 44 | 44 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
info.update({
# FIXME: non-standard, but we need a way of showing that it is an estimate.
'_time_text': time_text,
'timestamp': timestamp,
})
info['author_url'] = urljoin(
'https://www.youtube.com',
traverse_obj(comment_entity_payload,... | ```suggestion
comment_entity_payload = get_first(entities, ('payload', 'commentEntityPayload', {dict}))
if not (comment_id := traverse_obj(comment_entity_payload, ('properties', 'commentId', {str}))):
return
toolbar_entity_payload = get_first(entities, ('payload', 'engagementTo... | 'is_favorited': (None if toolbar_entity_payload is None else
toolbar_entity_payload.get('heartState') == 'TOOLBAR_HEART_STATE_HEARTED'),
'_time_text': time_text, # FIXME: non-standard, but we need a way of showing that it is an estimate.
'timestamp': sel... | @@ -3307,7 +3307,57 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | security | 1,919 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | jakeogh |
expected_type=list)
chapter_time = lambda chapter: parse_duration(self._get_text(chapter, 'timeDescription'))
chapter_title = lambda chapter: self._get_text(chapter, 'title')
return next(filter(None, (
self._extract_chapters_helper(traverse_obj(contents, (..., 'macroMark... | ```suggestion
toolbar_entity_payload = get_first(entities, ('payload', 'engagementToolbarStateEntityPayload', {dict}))
time_text = traverse_obj(comment_entity_payload, ('properties', 'publishedTime', {str})) or ''
``` | expected_type=list)
chapter_time = lambda chapter: parse_duration(self._get_text(chapter, 'timeDescription'))
chapter_title = lambda chapter: self._get_text(chapter, 'title')
return next(filter(None, (
self._extract_chapters_helper(traverse_obj(contents, (..., 'macroMark... | @@ -3307,7 +3307,35 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 240 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | jakeogh |
def _extract_comment(self, view_model, entities, parent=None):
comment_entity_payload = get_first(entities, ('payload', 'commentEntityPayload', {dict}))
if not (comment_id := traverse_obj(comment_entity_payload, ('properties', 'commentId', {str}))):
return
toolbar_entity_payloa... | This todo is to be addressed b4 merge |
def _extract_comment(self, entities, parent=None):
comment_entity_payload = get_first(entities, ('payload', 'commentEntityPayload', {dict}))
if not (comment_id := traverse_obj(comment_entity_payload, ('properties', 'commentId', {str}))):
return
toolbar_entity_payload = get_firs... | @@ -3307,7 +3307,37 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None):
+ comment_entity_payload... | yt_dlp/extractor/youtube.py | 26 | Python | 0.071 | suggestion | 37 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | jakeogh |
duration=duration)
def _extract_chapters_from_engagement_panel(self, data, duration):
content_list = traverse_obj(
data,
('engagementPanels', ..., 'engagementPanelSectionListRenderer', 'content', 'macroMarkersListRenderer', 'contents'),
expected_type=list)
... | ```suggestion
def _extract_comment(self, entities, parent=None):
``` | duration=duration)
def _extract_chapters_from_engagement_panel(self, data, duration):
content_list = traverse_obj(
data,
('engagementPanels', ..., 'engagementPanelSectionListRenderer', 'content', 'macroMarkersListRenderer', 'contents'),
expected_type=list)
... | @@ -3307,7 +3307,35 @@ def _extract_heatmap(self, data):
'value': ('intensityScoreNormalized', {float_or_none}),
})) or None
- def _extract_comment(self, comment_renderer, parent=None):
+ def _extract_comment(self, view_model, entities, parent=None): | yt_dlp/extractor/youtube.py | 26 | Python | 0.643 | refactor | 74 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer =... | ```suggestion
comment = self._extract_comment(entities, parent)
if comment:
comment['is_pinned'] = traverse_obj(view_model, ('pinnedText', {str})) is not None
``` |
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer ... | @@ -3388,21 +3416,37 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | refactor | 230 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer ... | `commentKey` and `toolbarStateKey` appear to always be the same value (and logically should be); the latter is just a fallback, right?
~~in that case, this would be simpler:~~ obsolete, do not commit:
```suggestion
view_model = (
traverse_obj(comment_thread_renderer, ... |
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer ... | @@ -3388,21 +3417,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | suggestion | 718 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
return _continuation
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
... | I was not seeing this clearly when I originally reviewed...this is better IMO:
```suggestion
comment_keys = traverse_obj(view_model, (('commentKey', 'toolbarStateKey'), {str}))
if not comment_keys:
continue
``` | return _continuation
def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
... | @@ -3388,21 +3417,39 @@ def extract_header(contents):
break
return _continuation
- def extract_thread(contents):
+ def extract_thread(contents, entity_payloads):
if not parent:
tracker['current_page_thread'] = 0
for content in cont... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | suggestion | 279 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jakeogh |
tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
# old com... | About this.... Does this mean that there will be a key `is_pinned` for each and every single comment? I don't think this is necessary since only one comment will ever be pinned. Why have this key in every single comment dict? It will bloat the final comments data.
Perhaps the same should also apply to keys:
`autho... | tracker['current_page_thread'] = 0
for content in contents:
if not parent and tracker['total_parent_comments'] >= max_parents:
yield
comment_thread_renderer = try_get(content, lambda x: x['commentThreadRenderer'])
# old com... | @@ -3443,7 +3442,9 @@ def extract_thread(contents, entity_payloads):
continue
comment_keys = list(filter(None, [view_model.get('commentKey'), view_model.get('toolbarStateKey')]))
entities = traverse_obj(entity_payloads, lambda _, v: v['entityKey'] in co... | yt_dlp/extractor/youtube.py | 26 | Python | 0.643 | security | 721 | 51 | 51 | false | [ie/youtube] Extract comments with or without new format | 9,775 | yt-dlp/yt-dlp | 132,642 | Python | shoxie007 | jakeogh |
def _extract_video(self, video_id, x_ua):
data = self._download_json(
'https://www.taptap.cn/webapiv2/video-resource/v1/multi-get', video_id,
query={'video_ids': video_id, 'X-UA': x_ua})
video = traverse_obj(data, ('data', 'list', 0, {
'id': ('video_id', {str_or... | I think instead of parsing the hydration data it would be better to call the API directly
`https://www.taptap.cn/webapiv2/app/v4/detail`
`https://www.taptap.cn/webapiv2/moment/v3/detail`
I haven't looked too much in to the structure of the returned data, but it could make sense to put the `_extract_video` in to a ba... | }
}],
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.taptap.cn/moment/521630629209573493',
'info_dict': {
'id': '521630629209573493',
'title': '《崩坏:星穹铁道》黄泉角色PV——「你的颜色」',
'description': 'md5:2c81245da864428c904d53ae4ad2182... | @@ -0,0 +1,148 @@
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.taptap\.cn/(?P<section>moment|app)/(?P<id>\d+)'
+ _TESTS = [{
+... | yt_dlp/extractor/taptap.py | 26 | Python | 0.643 | refactor | 381 | 47 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
def _deserialize_nuxt_data(self, serialized_nuxt):
for row in serialized_nuxt:
if isinstance(row, dict):
for key, value_or_ref in row.items():
if isinstance(value_or_ref, int):
row[key] = serialized_nuxt[value_or_ref]
elif ... | I would extract both the AVC and HEVC formats every time. I think that additional request is worth it, or is there any reason like excessive rate limiting not to do this? | 'id': '2202584',
'ext': 'mp4',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'description': 'md5:cf66f7819d413641b8b28c8543f4ecda',
'duration': 66,
'timestamp': 1633453402,
'upload_date': '20211005',
... | @@ -0,0 +1,148 @@
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.taptap\.cn/(?P<section>moment|app)/(?P<id>\d+)'
+ _TESTS = [{
+... | yt_dlp/extractor/taptap.py | 26 | Python | 0.429 | refactor | 170 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
parse_qs,
str_or_none,
traverse_obj,
url_or_none,
)
class TapTapIE(InfoExtractor):
_VALID_URL = r'https?://www\.taptap\.cn/(?P<section>moment|app)/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.tapta... | Could we also support taptap.io? The site structure is very similar. I think this should be doable with only minimal adjustments. | import re
import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Androi... | @@ -0,0 +1,148 @@
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.taptap\.cn/(?P<section>moment|app)/(?P<id>\d+)' | yt_dlp/extractor/taptap.py | 13 | Python | 0.429 | suggestion | 129 | 38 | 38 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API =... | We can use the `uuid` module from stdlib.
```suggestion
query = {**query, 'X-UA': self._X_UA.format(uuid=uuid.uuid4())}
return self._download_json(url, video_id, query=query, **kwargs)['data']
```
I would also adjust this to directly return the `data` dict as that is seemingly required for all api ... | import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uui... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.857 | suggestion | 329 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import random
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
... | With that we need to adjust:
```suggestion
_DATA_PATH = None
``` | import re
import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Androi... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 19 | Python | 0.571 | suggestion | 71 | 44 | 44 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'playlist': [{
'info_dict': {
'id': '4058443',
'ext': 'mp4',
'title': '原神',
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab',
'duration': 26,
'thumbnail': r're:^https?://.*\.(png|jpg)',
}... | ```suggestion
_DATA_PATH = 'app'
``` | 'upload_date': '20240517',
'modified_timestamp': 1715942225,
'modified_date': '20240517',
'uploader': 'TapTap 编辑',
'uploader_id': '7159244',
},
'params': {'skip_download': 'm3u8'},
}]
class TapTapAppIE(TapTapBaseIE):
_VALID_URL = r'ht... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.429 | suggestion | 42 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'thumbnail': r're:^https?://.*\.(png|jpg)',
}
}, {
'info_dict': {
'id': '4058462',
'ext': 'mp4',
'title': '原神',
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab',
'duration': 295,
... | ```suggestion
_DATA_PATH = 'post'
``` | }]
class TapTapAppIE(TapTapBaseIE):
_VALID_URL = r'https?://www\.taptap\.cn/app/(?P<id>\d+)'
_INFO_API = 'https://www.taptap.cn/webapiv2/app/v4/detail'
_ID_PATH = (('app_videos', 'videos'), ..., 'video_id')
_META_PATH = {
'title': ('title', {str}),
'description': ('description', 't... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.429 | suggestion | 43 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-resour... | ```suggestion
video_data = self._get_api(self._VIDEO_API, video_id, query={'video_ids': video_id})['list'][0]
``` | from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'h... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | suggestion | 123 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://w... | `is_intl` is unused
```suggestion
def _extract_video(self, video_id):
``` | from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.643 | refactor | 80 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-resource/v1/multi-get'
_INFO_API = None
... | Let's add a comment
```suggestion
# h265 playlist contains both h265 and h264 formats
video_url = traverse_obj(video_data, ('play_url', ('url_h265', 'url'), {url_or_none}))[0]
``` | int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-re... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | suggestion | 199 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
if re.search(r'^(hev|hvc|hvt)\d', format.get('vcodec', '')):
format['format_id'] = join_nonempty(format.get('format_id'), 'h265', delim='_')
return {
'id': str(video_id),
'formats': formats,
**traverse_obj(video_data, ({
'duration'... | I would combine these functions since `_extract_entries` is only used once.
```suggestion
def _real_extract(self, url):
video_id = self._match_id(url)
query = {self._INFO_QUERY_KEY: video_id}
data = traverse_obj(
self._get_api(self._INFO_API, video_id, query=query), self.... | if re.search(r'^(hev|hvc|hvt)\d', format.get('vcodec', '')):
format['format_id'] = join_nonempty(format.get('format_id'), 'h265', delim='_')
return {
'id': str(video_id),
'formats': formats,
**traverse_obj(video_data, ({
'duration'... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.857 | refactor | 614 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
}
def _extract_entries(self, video_ids, metainfo, list_id):
entries = [{**metainfo, **self._extract_video(id)} for id in set(video_ids)]
return self.playlist_result(entries, **metainfo, id=list_id)
def _real_extract(self, url):
video_id = self._match_id(url)
query = {se... | Some additional metadata
```suggestion
'modified_timestamp': ('edited_time', {int_or_none}),
'uploader': ('author', 'user', 'name', {str}),
'uploader_id': ('author', 'user', 'id', {int}, {str_or_none}),
``` | }
def _real_extract(self, url):
video_id = self._match_id(url)
query = {self._INFO_QUERY_KEY: video_id}
data = traverse_obj(
self._get_api(self._INFO_API, video_id, query=query), self._DATA_PATH)
metainfo = traverse_obj(data, self._META_PATH)
entries = ... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.857 | security | 235 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
return self._extract_entries(video_ids, metainfo, video_id)
class TapTapIntlBase(TapTapBaseIE):
_X_UA = 'V=1&PN=WebAppIntl2&LANG=zh_TW&VN_CODE=115&VN=0.1.0&LOC=CN&PLT=PC&DS=Android&UID={uuid}&CURR=&DT=PC&OS=Windows&OSV=NT%208.0.0'
_VIDEO_API = 'https://www.taptap.io/webapiv2/video-resource/v1/multi-ge... | ```suggestion
'modified_timestamp': 1633453402,
'modified_date': '20211005',
'uploader': '乌酱',
'uploader_id': '532896',
``` | return self.playlist_result(entries, **metainfo, id=video_id)
class TapTapMomentIE(TapTapBaseIE):
_VALID_URL = r'https?://www\.taptap\.cn/moment/(?P<id>\d+)'
_INFO_API = 'https://www.taptap.cn/webapiv2/moment/v3/detail'
_ID_PATH = ('moment', 'topic', (('videos', ...), 'pin_video'), 'video_id')
... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | suggestion | 176 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'title': ('topic', 'title', {str}),
'description': ('topic', 'summary', {str}),
})
_TESTS = [{
'url': 'https://www.taptap.cn/moment/194618230982052443',
'info_dict': {
'id': '194618230982052443',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'descri... | ```suggestion
'modified_timestamp': 1633453402,
'modified_date': '20211005',
'uploader': '乌酱',
'uploader_id': '532896',
``` | _TESTS = [{
'url': 'https://www.taptap.cn/moment/194618230982052443',
'info_dict': {
'id': '194618230982052443',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'description': 'md5:cf66f7819d413641b8b28c8543f4ecda',
'timestamp': 1633453402,
'uploa... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | suggestion | 192 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'id': '2202584',
'ext': 'mp4',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'description': 'md5:cf66f7819d413641b8b28c8543f4ecda',
'duration': 66,
'timestamp': 1633453402,
'upload_date': '20211005',
... | ```suggestion
'modified_timestamp': 1711425600,
'modified_date': '20240326',
'uploader': '崩坏:星穹铁道',
'uploader_id': '414732580',
``` | 'id': '2202584',
'ext': 'mp4',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'description': 'md5:cf66f7819d413641b8b28c8543f4ecda',
'duration': 66,
'timestamp': 1633453402,
'upload_date': '20211005',
... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | suggestion | 184 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'title': '《崩坏:星穹铁道》黄泉角色PV——「你的颜色」',
'description': 'md5:2c81245da864428c904d53ae4ad2182b',
'timestamp': 1711425600,
'upload_date': '20240326',
'uploader': '崩坏:星穹铁道',
},
'playlist_count': 1,
'playlist': [{
'info_dict': {
... | ```suggestion
'modified_timestamp': 1711425600,
'modified_date': '20240326',
'uploader': '崩坏:星穹铁道',
'uploader_id': '414732580',
``` | }, {
'url': 'https://www.taptap.cn/moment/521630629209573493',
'info_dict': {
'id': '521630629209573493',
'title': '《崩坏:星穹铁道》黄泉角色PV——「你的颜色」',
'description': 'md5:2c81245da864428c904d53ae4ad2182b',
'timestamp': 1711425600,
'upload_date': '20... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | suggestion | 200 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'description': ('topic', 'summary', {str}),
})
_TESTS = [{
'url': 'https://www.taptap.cn/moment/194618230982052443',
'info_dict': {
'id': '194618230982052443',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'description': 'md5:cf66f7819d413641b8b28c8543f4ecd... | Let's skip downloading, since otherwise the tests can fail
```suggestion
}],
'params': {'skip_download': 'm3u8'},
``` | 'url': 'https://www.taptap.cn/moment/194618230982052443',
'info_dict': {
'id': '194618230982052443',
'title': '《崩坏3》开放世界「后崩坏书」新篇章 于淹没之地仰视辰星',
'description': 'md5:cf66f7819d413641b8b28c8543f4ecda',
'timestamp': 1633453402,
'upload_date': '202110... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | bug | 137 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
}]
}, {
'url': 'https://www.taptap.cn/moment/521630629209573493',
'info_dict': {
'id': '521630629209573493',
'title': '《崩坏:星穹铁道》黄泉角色PV——「你的颜色」',
'description': 'md5:2c81245da864428c904d53ae4ad2182b',
'timestamp': 1711425600,
'upload... | I also went ahead and added another test with more than one video:
```suggestion
}],
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.taptap.cn/moment/540493587511511299',
'playlist_count': 2,
'info_dict': {
'id': '540493587511511299',
... | 'uploader_id': '532896',
'thumbnail': r're:^https?://.*\.(png|jpg)',
}
}],
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.taptap.cn/moment/521630629209573493',
'info_dict': {
'id': '521630629209573493',
... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | suggestion | 745 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'url': 'https://www.taptap.cn/app/168332',
'info_dict': {
'id': '168332',
'title': '原神',
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab',
},
'playlist_count': 2,
'playlist': [{
'info_dict': {
'id': '4058443',
... | ```suggestion
}],
'params': {'skip_download': 'm3u8'},
``` | 'url': 'https://www.taptap.cn/moment/540493587511511299',
'playlist_count': 2,
'info_dict': {
'id': '540493587511511299',
'title': '中式民俗解谜《纸嫁衣7》、新系列《纸不语》公布!',
'description': 'md5:d60842350e686ddb242291ddfb8e39c9',
'timestamp': 1715920200,
... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.571 | suggestion | 77 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab',
},
'playlist_count': 2,
'playlist': [{
'info_dict': {
'id': '4058443',
'ext': 'mp4',
'title': '原神',
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab'... | You should never inherit from a concrete class.
```suggestion
class TapTapAppIntlIE(TapTapIntlBase):
``` | 'title': '中式民俗解谜《纸嫁衣7》、新系列《纸不语》公布!',
'description': 'md5:d60842350e686ddb242291ddfb8e39c9',
'timestamp': 1715920200,
'upload_date': '20240517',
'modified_timestamp': 1715942225,
'modified_date': '20240517',
'uploader': 'TapTap 编辑',
... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | suggestion | 107 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'ext': 'mp4',
'title': '原神',
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab',
'duration': 26,
'thumbnail': r're:^https?://.*\.(png|jpg)',
}
}, {
'info_dict': {
'id': '4058462',
... | ```suggestion
class TapTapPostIntlIE(TapTapIntlBase):
``` | 'uploader': 'TapTap 编辑',
'uploader_id': '7159244',
},
'params': {'skip_download': 'm3u8'},
}]
class TapTapAppIE(TapTapBaseIE):
_VALID_URL = r'https?://www\.taptap\.cn/app/(?P<id>\d+)'
_INFO_API = 'https://www.taptap.cn/webapiv2/app/v4/detail'
_ID_PATH = (('app_v... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.571 | suggestion | 59 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import random
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
... | I think this little bit of duplication is fine. Let's also add a test case.
```suggestion
_ID_PATH = (('app_videos', 'videos'), ..., 'video_id')
_META_PATH = {
'title': ('title', {str}),
'description': ('description', 'text', {str}, {clean_html}),
}
_TESTS = [{
'url': 'ht... | _ID_PATH = (('app_videos', 'videos'), ..., 'video_id')
_META_PATH = {
'title': ('title', {str}),
'description': ('description', 'text', {str}, {clean_html}),
}
_TESTS = [{
'url': 'https://www.taptap.io/app/233287',
'info_dict': {
'id': '233287',
't... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | suggestion | 962 | 210 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import random
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
... | Again the additional metadata fields
```suggestion
'modified_timestamp': ('edited_time', {int_or_none}),
'uploader': ('user', 'name', {str}),
'uploader_id': ('user', 'id', {int}, {str_or_none}),
``` | },
'playlist_count': 1,
'playlist': [{
'info_dict': {
'id': '2149708997',
'ext': 'mp4',
'title': '《虹彩六號 M》',
'description': 'md5:418285f9c15347fc3cf3e3a3c649f182',
'duration': 78,
'thumbna... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.857 | suggestion | 227 | 210 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import random
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
... | ```suggestion
'modified_timestamp': 1614664951,
'modified_date': '20210302',
'uploader': 'TapTap Editor',
'uploader_id': '80224473',
``` |
class TapTapPostIntlIE(TapTapIntlBase):
_VALID_URL = r'https?://www\.taptap\.io/post/(?P<id>\d+)'
_INFO_API = 'https://www.taptap.io/webapiv2/creation/post/v1/detail'
_INFO_QUERY_KEY = 'id_str'
_DATA_PATH = 'post'
_ID_PATH = ((('videos', ...), 'pin_video'), 'video_id')
_META_PATH = {
't... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.714 | suggestion | 189 | 210 | 48 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import random
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
... | ```suggestion
'modified_timestamp': 1614664951,
'modified_date': '20210302',
'uploader': 'TapTap Editor',
'uploader_id': '80224473',
``` | _TESTS = [{
'url': 'https://www.taptap.io/post/571785',
'info_dict': {
'id': '571785',
'title': 'Arknights x Rainbow Six Siege | Event PV',
'description': 'md5:f7717c13f6d3108e22db7303e6690bf7',
'timestamp': 1614664951,
'upload_date': '2021... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | suggestion | 205 | 210 | 33 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'description': ('list_fields', 'summary', {str}),
}
_TESTS = [{
'url': 'https://www.taptap.io/post/571785',
'info_dict': {
'id': '571785',
'title': 'Arknights x Rainbow Six Siege | Event PV',
'description': 'md5:f7717c13f6d3108e22db7303e6690bf7',
... | ```suggestion
}],
'params': {'skip_download': 'm3u8'},
``` | 'ext': 'mp4',
'title': '原神',
'description': 'md5:e345f39a5fea5de2a46923f70d5f76ab',
'duration': 295,
'thumbnail': r're:^https?://.*\.(png|jpg)',
}
}],
'params': {'skip_download': 'm3u8'},
}]
class TapTapInt... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={... | yt_dlp/extractor/taptap.py | 26 | Python | 0.571 | suggestion | 77 | 28 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import random
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
traverse_obj,
url_or_none,
)
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
... | ```suggestion
import re
import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
``` | import re
import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Androi... | @@ -0,0 +1,209 @@
+import random
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ traverse_obj,
+ url_or_none,
+) | yt_dlp/extractor/taptap.py | 11 | Python | 0.857 | refactor | 240 | 36 | 36 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
import re
import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Androi... | might we want to reuse the same `uuid4`? | import re
import uuid
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Androi... | @@ -0,0 +1,275 @@
+import re
+import uuid
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ str_or_none,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&V... | yt_dlp/extractor/taptap.py | 25 | Python | 0.286 | question | 40 | 50 | 50 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-re... | ```suggestion
video_url = traverse_obj(video_data, ('play_url', ('url_h265', 'url'), {url_or_none}, any))
```
That way the `None` will cause `self._extract_m3u8_formats` to fail gracefully | int_or_none,
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-re... | @@ -0,0 +1,275 @@
+import re
+import uuid
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ str_or_none,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&V... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | bug | 199 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
'formats': formats,
**traverse_obj(video_data, ({
'duration': ('info', 'duration', {int_or_none}),
'thumbnail': ('thumbnail', ('original_url', 'url'), {url_or_none}),
}), get_all=False)
}
def _real_extract(self, url):
video_id = se... | Id probably move this lower so its directly in front of the extractors that use it | 'formats': formats,
**traverse_obj(video_data, ({
'duration': ('info', 'duration', {int_or_none}),
'thumbnail': ('thumbnail', ('original_url', 'url'), {url_or_none}),
}), get_all=False)
}
def _real_extract(self, url):
video_id = se... | @@ -0,0 +1,275 @@
+import re
+import uuid
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ str_or_none,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&V... | yt_dlp/extractor/taptap.py | 26 | Python | 0.286 | refactor | 82 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | c-basalt |
join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-resource/v1/multi-g... | this should be non-fatal or else 1 bad m3u8 url will break playlist extraction
```suggestion
formats = self._extract_m3u8_formats(video_url, video_id, fatal=False)
``` | join_nonempty,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class TapTapBaseIE(InfoExtractor):
_X_UA = 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&LOC=CN&PLT=PC&DS=Android&UID={uuid}&OS=Windows&OSV=10&DT=PC'
_VIDEO_API = 'https://www.taptap.cn/webapiv2/video-resource/v1/multi-g... | @@ -0,0 +1,275 @@
+import re
+import uuid
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ str_or_none,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class TapTapBaseIE(InfoExtractor):
+ _X_UA = 'V=1&PN=WebApp&LANG=zh_CN&V... | yt_dlp/extractor/taptap.py | 26 | Python | 0.786 | refactor | 180 | 51 | 51 | false | [ie/taptap] Add extractors | 9,776 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
urlencode_postdata,
)
class BrilliantpalaBaseIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEPAGE = f'https://{self._DOMAIN}'
self._LOGIN_API = f'{self._HOMEPAGE}/login/'
self._LOGOUT_DEVI... | ```suggestion
if urlh.status != 401 and not urlh.url.startswith(self._LOGIN_API):
```
This could reduce cognitive overhead | urlencode_postdata,
)
class BrilliantpalaBaseIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEPAGE = f'https://{self._DOMAIN}'
self._LOGIN_API = f'{self._HOMEPAGE}/login/'
self._LOGOUT_DEVI... | @@ -27,8 +27,18 @@ def _get_logged_in_username(self, url, video_id):
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'logged-in username')
def _perform_login(self, username, password):
- login_form = self._hidden_inputs(self._download_webpage(
- self._LOGIN_API, None, 'Download... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.786 | suggestion | 133 | 51 | 51 | false | [ie/brilliantpala] Fix login | 9,788 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | pzhlkj6612 |
def _initialize_pre_login(self):
self._HOMEPAGE = f'https://{self._DOMAIN}'
self._LOGIN_API = f'{self._HOMEPAGE}/login/'
self._LOGOUT_DEVICES_API = f'{self._HOMEPAGE}/logout_devices/?next=/'
self._CONTENT_API = f'{self._HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
self._HLS_... | ```suggestion
self.write_debug('Got HTTP Error 401; cookies have been invalidated')
login_page = self._download_webpage(self._LOGIN_API, None, 'Re-downloading login page')
``` |
def _initialize_pre_login(self):
self._HOMEPAGE = f'https://{self._DOMAIN}'
self._LOGIN_API = f'{self._HOMEPAGE}/login/'
self._LOGOUT_DEVICES_API = f'{self._HOMEPAGE}/logout_devices/?next=/'
self._CONTENT_API = f'{self._HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
self._HLS_... | @@ -27,8 +27,18 @@ def _get_logged_in_username(self, url, video_id):
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'logged-in username')
def _perform_login(self, username, password):
- login_form = self._hidden_inputs(self._download_webpage(
- self._LOGIN_API, None, 'Download... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.929 | bug | 202 | 51 | 51 | false | [ie/brilliantpala] Fix login | 9,788 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
'"',
'\\',
'!',
'^!',
'a \\ b',
'a \\" b',
'a \\ b\\',
# We replace \r with \n
('a\r\ra', 'a\n\na'),
]
def run_shell(args):
stdout, stderr, error = Popen.run(
args, te... | Instead of opening a subprocess each time, we could process all the tests in one go, right? | '"',
'\\',
'!',
'^!',
'a \\ b',
'a \\" b',
'a \\ b\\',
# We replace \r with \n
('a\r\ra', 'a\n\na'),
]
def run_shell(args):
stdout, stderr, error = Popen.run(
args, te... | @@ -2060,22 +2060,40 @@ def test_extract_basic_auth(self):
@unittest.skipUnless(compat_os_name == 'nt', 'Only relevant on Windows')
def test_Popen_windows_escaping(self):
+ tests = [
+ 'test"&',
+ '%CMDCMDLINE:~-1%&',
+ 'a\nb',
+ '"',
+ '\\',
+ ... | test/test_utils.py | 26 | Python | 0.286 | question | 91 | 35 | 35 | false | [core:windows] Improve shell quoting and tests | 9,802 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
'test"&',
'%CMDCMDLINE:~-1%&',
'a\nb',
'"',
'\\',
'!',
'^!',
'a \\ b',
'a \\" b',
'a \\ b\\',
# We replace \r with \n
('a\r\ra', 'a\n\na'),
]
def run_shell(arg... | I'd prefer
```suggestion
if isinstance(argument, str):
expected = argument
else:
argument, expected = argument
```
to handle lists. Not that it really matters here | 'test"&',
'%CMDCMDLINE:~-1%&',
'a\nb',
'"',
'\\',
'!',
'^!',
'a \\ b',
'a \\" b',
'a \\ b\\',
# We replace \r with \n
('a\r\ra', 'a\n\na'),
]
def run_shell(arg... | @@ -2060,22 +2060,40 @@ def test_extract_basic_auth(self):
@unittest.skipUnless(compat_os_name == 'nt', 'Only relevant on Windows')
def test_Popen_windows_escaping(self):
+ tests = [
+ 'test"&',
+ '%CMDCMDLINE:~-1%&',
+ 'a\nb',
+ '"',
+ '\\',
+ ... | test/test_utils.py | 26 | Python | 1 | suggestion | 226 | 38 | 38 | false | [core:windows] Improve shell quoting and tests | 9,802 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
temp_file = tempfile.NamedTemporaryFile(suffix='.tmp', delete=False, dir=path or None)
temp_file.close()
try:
success, _ = self.dl(temp_file.name, f, test=True)
except (DownloadError, OSError, ValueError) + network_exceptions:
success = Fal... | Fails when IE returns URL directly
```suggestion
formats = self._get_formats(info_dict)
``` | path = self.get_output_path('temp')
if not self._ensure_dir_exists(f'{path}/'):
continue
temp_file = tempfile.NamedTemporaryFile(suffix='.tmp', delete=False, dir=path or None)
temp_file.close()
try:
success, _ = self.dl(temp_fil... | @@ -2163,6 +2166,18 @@ def can_merge():
merger = FFmpegMergerPP(self)
return merger.available and merger.can_merge()
+ def evaluate_formats(format_spec):
+ formats = info_dict.get('formats') or [] | yt_dlp/YoutubeDL.py | 26 | Python | 0.714 | bug | 108 | 51 | 51 | false | [core] Warn user when FFmpeg is missing | 9,805 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | seproDev |
if os.path.exists(temp_file.name):
try:
os.remove(temp_file.name)
except OSError:
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
if success:
f['__working'] = ... | This may cause some unnecessary network calls when `--check-formats` is used without ffmpeg. But ig that's fine | except (DownloadError, OSError, ValueError) + network_exceptions:
success = False
finally:
if os.path.exists(temp_file.name):
try:
os.remove(temp_file.name)
except OSError:
sel... | @@ -2163,6 +2166,18 @@ def can_merge():
merger = FFmpegMergerPP(self)
return merger.available and merger.can_merge()
+ def evaluate_formats(format_spec):
+ formats = info_dict.get('formats') or []
+ return list(self.build_format_selector(format_spec)({
+ ... | yt_dlp/YoutubeDL.py | 26 | Python | 0.571 | style | 111 | 51 | 51 | false | [core] Warn user when FFmpeg is missing | 9,805 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | seproDev |
finally:
if os.path.exists(temp_file.name):
try:
os.remove(temp_file.name)
except OSError:
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
if success:
... | Imo, this is complex enough for DRY and should be pulled out to a method:
```suggestion
def _select_formats(self, formats, selector)
return list(selector({
'formats': formats,
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in form... | success, _ = self.dl(temp_file.name, f, test=True)
except (DownloadError, OSError, ValueError) + network_exceptions:
success = False
finally:
if os.path.exists(temp_file.name):
try:
os.remove(temp_file.na... | @@ -2163,6 +2166,18 @@ def can_merge():
merger = FFmpegMergerPP(self)
return merger.available and merger.can_merge()
+ def evaluate_formats(format_spec):
+ formats = info_dict.get('formats') or []
+ return list(self.build_format_selector(format_spec)({
+ ... | yt_dlp/YoutubeDL.py | 26 | Python | 0.857 | refactor | 582 | 51 | 51 | false | [core] Warn user when FFmpeg is missing | 9,805 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | seproDev |
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
def _select_formats(self, formats, selector):
return list(selector({
'formats': formats,
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
... | This could trigger an unnecessary and misleading warning if the user is passing `-o -` and doesn't have ffmpeg installed. Since the default format selection becomes `best/bestvideo+bestaudio` when piping to stdout, the warning would be incorrect: installing ffmpeg will not change the quality of what's piped. And I thin... | if success:
yield f
else:
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
def _select_formats(self, formats, selector):
return list(selector({
'formats': formats,
'has_merged_format': any('no... | @@ -2153,16 +2155,32 @@ def _check_formats(self, formats):
except OSError:
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
if success:
+ f['__working'] = True
yield f
else:
... | yt_dlp/YoutubeDL.py | 26 | Python | 0.857 | bug | 1,342 | 51 | 51 | false | [core] Warn user when FFmpeg is missing | 9,805 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
return list(selector({
'formats': formats,
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
'incomplete_formats': (all(f.get('vcodec') == 'none' for f in formats) # No formats with video
or all(f.... | Side note: I think having `simulate` result in a different default format spec should be considered a bug. A dry-run should be no different than the real thing, right?
It looks like we can trace this logic back to https://github.com/ytdl-org/youtube-dl/commit/0017d9ad6de831384e74db14a821e4c94020c9ac
Back then, up... | self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
def _select_formats(self, formats, selector):
return list(selector({
'formats': formats,
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
... | @@ -2153,23 +2155,42 @@ def _check_formats(self, formats):
except OSError:
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
if success:
+ f['__working'] = True
yield f
else:
... | yt_dlp/YoutubeDL.py | 26 | Python | 0.786 | bug | 842 | 51 | 51 | false | [core] Warn user when FFmpeg is missing | 9,805 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
def _select_formats(self, formats, selector):
return list(selector({
'formats': formats,
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
... | I'd slightly change the wording, since hypothetically the `bv+ba` formats could have the exact same res/bitrate/etc as the `best` format
```suggestion
self.report_warning('ffmpeg not found. The downloaded format may not be the best available. '
``` | if success:
yield f
else:
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
def _select_formats(self, formats, selector):
return list(selector({
'formats': formats,
'has_merged_format': any('no... | @@ -2153,32 +2155,43 @@ def _check_formats(self, formats):
except OSError:
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
if success:
+ f['__working'] = True
yield f
else:
... | yt_dlp/YoutubeDL.py | 26 | Python | 0.857 | suggestion | 267 | 51 | 51 | false | [core] Warn user when FFmpeg is missing | 9,805 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
},
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://zen.yandex.ru/media/id/606fd806cc13cb3c58c05cf5/novyi-samsung-fold-3-moskvich-barahlit-612f93b7f8d48e7e945792a2?from=channel&rid=2286618386.482.1630817595976.42360',
'only_matching': True,
}, {
'url': 'https://d... | Let's use new/better helpers for edited code
```suggestion
item_id = traverse_obj(data_json, (serverstate, 'videoViewer', 'openedItemId', {str}))
video_json = traverse_obj(data_json, (serverstate, 'videoViewer', 'items', item_id, {dict}))
``` | },
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://zen.yandex.ru/media/id/606fd806cc13cb3c58c05cf5/novyi-samsung-fold-3-moskvich-barahlit-612f93b7f8d48e7e945792a2?from=channel&rid=2286618386.482.1630817595976.42360',
'only_matching': True,
}, {
'url': 'https://d... | @@ -260,11 +260,12 @@ def _real_extract(self, url):
data_json = self._search_json(
r'("data"\s*:|data\s*=)', webpage, 'metadata', video_id, contains_pattern=r'{["\']_*serverState_*video.+}')
serverstate = self._search_regex(r'(_+serverState_+video-site_[^_]+_+)',
- ... | yt_dlp/extractor/yandexvideo.py | 26 | Python | 0.857 | refactor | 264 | 51 | 51 | false | [ie/yandexvideo] Fix extractor | 9,813 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | src-tinkerer |
}, {
'note': 'a making-of which falls outside main section',
'url': 'https://www.bilibili.com/bangumi/play/ep345120',
'info_dict': {
'id': '345120',
'ext': 'mp4',
'series': '鬼灭之刃',
'series_id': '4358',
'season': '立志篇',
'... | since it doesn't make much sense to pass a self-referential referer header, I would do this (with the below suggestion too)
```suggestion
headers = self.geo_verification_headers()
webpage = self._download_webpage(url, episode_id, headers=headers)
``` | }, {
'note': 'a making-of which falls outside main section',
'url': 'https://www.bilibili.com/bangumi/play/ep345120',
'info_dict': {
'id': '345120',
'ext': 'mp4',
'series': '鬼灭之刃',
'series_id': '4358',
'season': '立志篇',
'... | @@ -666,14 +667,14 @@ class BiliBiliBangumiIE(BilibiliBaseIE):
def _real_extract(self, url):
episode_id = self._match_id(url)
- webpage = self._download_webpage(url, episode_id)
+ headers = {'Referer': url, **self.geo_verification_headers()}
+ webpage = self._download_webpage(url, e... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | suggestion | 270 | 51 | 51 | false | [ie/bilibili] apply geo-verification-proxy to webpage download | 9,817 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | fireattack |
'season': '立志篇',
'season_id': '26801',
'season_number': 1,
'episode': '炭治郎篇',
'episode_id': '345120',
'episode_number': 27,
'title': '#1 炭治郎篇',
'duration': 1922.129,
'timestamp': 1602853860,
'upload_d... | ```suggestion
headers['Referer'] = url
play_info = self._download_json(
``` | 'season': '立志篇',
'season_id': '26801',
'season_number': 1,
'episode': '炭治郎篇',
'episode_id': '345120',
'episode_number': 27,
'title': '#1 炭治郎篇',
'duration': 1922.129,
'timestamp': 1602853860,
'upload_d... | @@ -666,14 +667,14 @@ class BiliBiliBangumiIE(BilibiliBaseIE):
def _real_extract(self, url):
episode_id = self._match_id(url)
- webpage = self._download_webpage(url, episode_id)
+ headers = {'Referer': url, **self.geo_verification_headers()}
+ webpage = self._download_webpage(url, e... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.571 | suggestion | 94 | 51 | 51 | false | [ie/bilibili] apply geo-verification-proxy to webpage download | 9,817 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | fireattack |
if format_id == 'hls':
hls_formats = self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
self._check_formats(hls_formats, video_id)
formats.extend(hls_format... | ```suggestion
_VALID_URL = r'https?://(?P<domain>(?:[^/?#]+\.)?xvideos2?\.com)/(?:profiles/|amateur-channels/)?[^#]+#quickies/a/(?P<id>\w+)'
``` | if format_id == 'hls':
hls_formats = self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
self._check_formats(hls_formats, video_id)
formats.extend(hls_format... | @@ -173,20 +173,20 @@ def _real_extract(self, url):
class XVideosQuickiesIE(InfoExtractor):
IE_NAME = 'xvideos:quickies'
- _VALID_URL = r'https?://(?P<domain>(?:[^/]+\.)?xvideos2?\.com)/amateur-channels/[^#]+#quickies/a/(?P<id>\d+)'
+ _VALID_URL = r'https?://(?P<domain>(?:[^/?#]+\.)?xvideos2?\.com)/(?:pro... | yt_dlp/extractor/xvideos.py | 26 | Python | 0.714 | suggestion | 150 | 43 | 51 | false | [ie/XVideosQuickies] Fix extractor | 9,834 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | JakeFinley96 |
'url': 'https://www.xvideos.com/amateur-channels/lili_love#quickies/a/hfmffmd7661',
'md5': '92428518bbabcb4c513e55922e022491',
'info_dict': {
'id': 'hfmffmd7661',
'ext': 'mp4',
'title': 'Chichona mexican slut',
'age_limit': 18,
'duratio... | ```suggestion
return self.url_result(f'https://{domain}/video{"." if id_.isdigit() else ""}{id_}/_', XVideosIE, id_)
``` | 'url': 'https://www.xvideos.com/amateur-channels/lili_love#quickies/a/hfmffmd7661',
'md5': '92428518bbabcb4c513e55922e022491',
'info_dict': {
'id': 'hfmffmd7661',
'ext': 'mp4',
'title': 'Chichona mexican slut',
'age_limit': 18,
'duratio... | @@ -189,4 +222,4 @@ class XVideosQuickiesIE(InfoExtractor):
def _real_extract(self, url):
domain, id_ = self._match_valid_url(url).group('domain', 'id')
- return self.url_result(f'https://{domain}/video{id_}/_', XVideosIE, id_)
+ return self.url_result(f'https://{domain}/video{"." if int_o... | yt_dlp/extractor/xvideos.py | 26 | Python | 0.714 | suggestion | 130 | 27 | 27 | false | [ie/XVideosQuickies] Fix extractor | 9,834 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | JakeFinley96 |
'url': 'https://www.xvideos.com/amateur-channels/lili_love#quickies/a/hfmffmd7661',
'md5': '92428518bbabcb4c513e55922e022491',
'info_dict': {
'id': 'hfmffmd7661',
'ext': 'mp4',
'title': 'Chichona mexican slut',
'age_limit': 18,
'duratio... | `isdecimal` is more precise
```suggestion
return self.url_result(f'https://{domain}/video{"" if id_.isdecimal() else "."}{id_}/_', XVideosIE, id_)
``` | 'url': 'https://www.xvideos.com/amateur-channels/lili_love#quickies/a/hfmffmd7661',
'md5': '92428518bbabcb4c513e55922e022491',
'info_dict': {
'id': 'hfmffmd7661',
'ext': 'mp4',
'title': 'Chichona mexican slut',
'age_limit': 18,
'duratio... | @@ -189,4 +222,4 @@ class XVideosQuickiesIE(InfoExtractor):
def _real_extract(self, url):
domain, id_ = self._match_valid_url(url).group('domain', 'id')
- return self.url_result(f'https://{domain}/video{id_}/_', XVideosIE, id_)
+ return self.url_result(f'https://{domain}/video{"" if id_.is... | yt_dlp/extractor/xvideos.py | 26 | Python | 0.714 | suggestion | 161 | 27 | 27 | false | [ie/XVideosQuickies] Fix extractor | 9,834 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JakeFinley96 |
if format_id == 'hls':
hls_formats = self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
self._check_formats(hls_formats, video_id)
formats.extend(hls_format... | I know this part of the pattern is old code, but we should probably do this, yeah?
```suggestion
_VALID_URL = r'https?://(?P<domain>(?:[^/?#]+\.)?xvideos2?\.com)/(?:profiles/|amateur-channels/)?[^/?#]+#quickies/a/(?P<id>\w+)'
``` | if format_id == 'hls':
hls_formats = self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
self._check_formats(hls_formats, video_id)
formats.extend(hls_format... | @@ -173,8 +173,41 @@ def _real_extract(self, url):
class XVideosQuickiesIE(InfoExtractor):
IE_NAME = 'xvideos:quickies'
- _VALID_URL = r'https?://(?P<domain>(?:[^/]+\.)?xvideos2?\.com)/amateur-channels/[^#]+#quickies/a/(?P<id>\d+)'
+ _VALID_URL = r'https?://(?P<domain>(?:[^/?#]+\.)?xvideos2?\.com)/(?:prof... | yt_dlp/extractor/xvideos.py | 26 | Python | 0.857 | suggestion | 238 | 51 | 51 | false | [ie/XVideosQuickies] Fix extractor | 9,834 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JakeFinley96 |
)
class EplusIbIE(InfoExtractor):
_NETRC_MACHINE = 'eplus'
IE_NAME = 'eplus'
IE_DESC = 'e+ (イープラス)'
_VALID_URL = [r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)',
r'https?://live\.eplus\.jp/(?P<id>sample|\d+)']
_TESTS = [{
'url': 'https://live.e... | `expected_warnings` are checked w/ regex, so we can trim these down a bit
```suggestion
'This event may not be accessible',
'No video formats found',
'Requested format is not available',
``` | )
class EplusIbIE(InfoExtractor):
_NETRC_MACHINE = 'eplus'
IE_NAME = 'eplus'
IE_DESC = 'e+ (イープラス)'
_VALID_URL = [r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)',
r'https?://live\.eplus\.jp/(?P<id>sample|\d+)']
_TESTS = [{
'url': 'https://live.e... | @@ -16,13 +16,31 @@ class EplusIbIE(InfoExtractor):
_VALID_URL = [r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)',
r'https?://live\.eplus\.jp/(?P<id>sample|\d+)']
_TESTS = [{
- 'url': 'https://live.eplus.jp/ex/player?ib=YEFxb3Vyc2Dombnjg7blkrLlrablnJLjgrnjg... | yt_dlp/extractor/eplus.py | 26 | Python | 0.786 | suggestion | 231 | 51 | 51 | false | [ie/eplus] Check if it's a pass ticket url; replace a dead url in test | 9,855 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
'loginId': username,
'loginPassword': password,
'Token.Default': cltft_token,
'op': 'nextPage',
}), headers={'Referer': urlh.url})
def _real_extract(self, url):
video_id = self._match_id(url)
webpage, urlh = self._download_... | ```suggestion
'This URL is for a pass ticket instead of a player page', expected=True)
``` | 'loginId': username,
'loginPassword': password,
'Token.Default': cltft_token,
'op': 'nextPage',
}), headers={'Referer': urlh.url})
def _real_extract(self, url):
video_id = self._match_id(url)
webpage, urlh = self._download_... | @@ -124,6 +142,10 @@ def _real_extract(self, url):
if data_json.get('drm_mode') == 'ON':
self.report_drm(video_id)
+ if data_json.get('is_pass_ticket') == 'YES':
+ raise ExtractorError(
+ 'Pass ticket url is not supported, please use a url points to the player pa... | yt_dlp/extractor/eplus.py | 26 | Python | 0.786 | suggestion | 108 | 51 | 51 | false | [ie/eplus] Check if it's a pass ticket url; replace a dead url in test | 9,855 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
if timezone is not None:
date_str = date_str[:-len(m.group('tz'))]
timezone = dt.timedelta(hours=timezone)
else:
date_str = date_str[:-len(m.group('tz'))]
if m.group('sign'):
sign = 1 if m.group('sign') == '+' else -1
timezone = dt.timedelta(
... | > NOTE: I'm not sure why the default timezone overrides any that is extracted. No other extractors make use of this parameter. It seems to have been added years ago for an extractor that no longer uses it, and even then there was no need for it to override. | if timezone is not None:
date_str = date_str[:-len(m.group('tz'))]
timezone = dt.timedelta(hours=timezone)
else:
date_str = date_str[:-len(m.group('tz'))]
if m.group('sign'):
sign = 1 if m.group('sign') == '+' else -1
timezone = dt.timedelta(
... | @@ -1172,8 +1173,7 @@ def parse_iso8601(date_str, delimiter='T', timezone=None):
date_str = re.sub(r'\.[0-9]+', '', date_str)
- if timezone is None:
- timezone, date_str = extract_timezone(date_str)
+ timezone, date_str = extract_timezone(date_str, timezone) | yt_dlp/utils/_utils.py | 26 | Python | 0.5 | refactor | 257 | 51 | 51 | false | [ie/youtube] Extract upload date timestamp if available | 9,856 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | coletdjnz |
if sys.version_info < (3, 9):
return dt.timedelta(hours=-7)
from zoneinfo import ZoneInfo
return dt.datetime.now(ZoneInfo('US/Pacific')).utcoffset()
# We only want timestamp IF it has second precision
# Additionally, if there is no timezone present, w... | How should this compat opt work now?
```
upload_date = (
dt.datetime.fromtimestamp(timestamp, dt.timezone.utc).strftime('%Y%m%d') if (timestamp and 'no-youtube-prefer-utc-upload-date' not in self.get_param('compat_opts', []) else
(
unified_strdate(get_first(microf... | 'videoActions', 'menuRenderer', 'topLevelButtons', ...,
'segmentedLikeDislikeButtonViewModel', 'likeButtonViewModel', 'likeButtonViewModel',
'toggleButtonViewModel', 'toggleButtonViewModel', 'defaultButtonViewModel',
'buttonViewModel', 'accessibilityText',... | @@ -4552,19 +4552,43 @@ def process_language(container, base_url, lang_code, sub_name, query):
'uploader_id': channel_handle,
'uploader_url': format_field(channel_handle, None, 'https://www.youtube.com/%s', default=None),
})
+
+ def get_pacific_tz():
+ # Python 3.8 s... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | question | 492 | 51 | 51 | false | [ie/youtube] Extract upload date timestamp if available | 9,856 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | coletdjnz |
is_private = (self._has_badge(badges, BadgeType.AVAILABILITY_PRIVATE)
or get_first(video_details, 'isPrivate', expected_type=bool))
info['availability'] = (
'public' if self._has_badge(badges, BadgeType.AVAILABILITY_PUBLIC)
else self._availability(
... | If `timestamp`, don't set `upload_date` at all. Core code will do it | elif mrr_title == 'Artist':
info['artists'] = [mrr_contents_text] if mrr_contents_text else None
elif mrr_title == 'Song':
info['track'] = mrr_contents_text
owner_badges = self._extract_badges(traverse_obj(vsir, ('owner'... | @@ -4552,19 +4552,43 @@ def process_language(container, base_url, lang_code, sub_name, query):
'uploader_id': channel_handle,
'uploader_url': format_field(channel_handle, None, 'https://www.youtube.com/%s', default=None),
})
+
+ def get_pacific_tz():
+ # Python 3.8 s... | yt_dlp/extractor/youtube.py | 26 | Python | 0.357 | suggestion | 68 | 51 | 51 | false | [ie/youtube] Extract upload date timestamp if available | 9,856 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | coletdjnz |
syncid = self._extract_account_syncid(player_ytcfg, master_ytcfg, initial_pr)
sts = self._extract_signature_timestamp(video_id, player_url, master_ytcfg, fatal=False) if player_url else None
headers = self.generate_api_headers(
ytcfg=player_ytcfg, account_syncid=syncid, session_index... | guessing this was done for testing purposes and accidentally left in
```suggestion
default = ['ios', 'android', 'web']
``` | if sts is not None:
context['signatureTimestamp'] = sts
return {
'playbackContext': {
'contentPlaybackContext': context
},
**cls._get_checkok_params()
}
@staticmethod
def _is_agegated(player_response):
if traverse_o... | @@ -3621,7 +3648,7 @@ def _extract_player_response(self, client, video_id, master_ytcfg, player_ytcfg,
def _get_requested_clients(self, url, smuggled_data):
requested_clients = []
- default = ['ios', 'android', 'web']
+ default = ['ios', 'web'] | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 133 | 51 | 51 | false | [ie/youtube] Extract upload date timestamp if available | 9,856 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'fr': 'fr-FR',
'it': 'it-IT',
'pt-br': 'pt-BR',
'pt-pt': 'pt-PT',
'ru': 'ru-RU',
'hi': 'hi-IN',
}
def _set_auth_info(self, response):
CrunchyrollBaseIE._IS_PREMIUM = 'cr_premium' in traverse_obj(response, ('access_token', {jwt_decode_hs256}, 'benefits', .... | do we want to mention impersonation in this message as well? or is the `_request_webpage` warning good enough? | 'fr': 'fr-FR',
'it': 'it-IT',
'pt-br': 'pt-BR',
'pt-pt': 'pt-PT',
'ru': 'ru-RU',
'hi': 'hi-IN',
}
def _set_auth_info(self, response):
CrunchyrollBaseIE._IS_PREMIUM = 'cr_premium' in traverse_obj(response, ('access_token', {jwt_decode_hs256}, 'benefits', .... | @@ -53,13 +53,15 @@ def _set_auth_info(self, response):
CrunchyrollBaseIE._AUTH_EXPIRY = time_seconds(seconds=traverse_obj(response, ('expires_in', {float_or_none}), default=300) - 10)
def _request_token(self, headers, data, note='Requesting token', errnote='Failed to request token'):
- try: # T... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.5 | question | 110 | 51 | 51 | false | [ie/crunchyroll] Add impersonation support | 9,857 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bashonly |
**traverse_obj(data, {
'title': ('liveInfo', 'title', {str}),
'comment_count': ('liveInfo', 'comments', {int_or_none}),
'view_count': ('liveInfo', 'visitor', {int_or_none}),
'timestamp': ('liveInfo', 'created', {int_or_none}),
'... | * It is better to have `id=None` than `id=""`.
* `author_id` should be returned as as a `str`, not `int`.
* `{TYPE_or_none}` converts the data into `TYPE` while `{TYPE}` verifies the data is `TYPE` without converting
Considering these, I believe this is the proper impl:
```suggestion
'author': ('... | **traverse_obj(data, {
'title': ('liveInfo', 'title', {str}),
'comment_count': ('liveInfo', 'comments', {int_or_none}),
'view_count': ('liveInfo', 'visitor', {int_or_none}),
'timestamp': ('liveInfo', 'created', {int_or_none}),
'... | @@ -48,8 +57,20 @@ def _real_extract(self, url):
'protocol': 'm3u8',
}],
'is_live': True,
+ '__post_extractor': self.extract_comments(video_id=video_id),
}
+ def _get_comments(self, video_id):
+ yield from traverse_obj(self._download_json(
+ ... | yt_dlp/extractor/mixch.py | 26 | Python | 1 | security | 567 | 51 | 51 | false | [ie/mixch] Add comment extraction; update a test | 9,860 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | pzhlkj6612 |
for idx in _extract_m3u8_playlist_indices(manifest_url):
format_id = [m3u8_id, None, idx]
# Bandwidth of live streams may differ over time thus making
# format_id unpredictable. So it's better to keep provided
# format_id in... | ```suggestion
if yt_audio_content_id := last_stream_inf.get('YT-EXT-AUDIO-CONTENT-ID'):
f['language'] = yt_audio_content_id.split('.')[0]
if last_stream_inf.get('DEFAULT') == 'YES':
# Keep value in sync with YoutubeIE._e... | last_stream_inf.get('AVERAGE-BANDWIDTH')
or last_stream_inf.get('BANDWIDTH'), scale=1000)
manifest_url = format_url(line.strip())
for idx in _extract_m3u8_playlist_indices(manifest_url):
format_id = [m3u8_id, None, idx]
... | @@ -2211,6 +2211,12 @@ def build_stream_name():
'quality': quality,
'has_drm': has_drm,
}
+
+ # YouTube Specific
+ if last_stream_inf.get('YT-EXT-AUDIO-CONTENT-ID'):
+ # Strip anything aft... | yt_dlp/extractor/common.py | 26 | Python | 0.857 | refactor | 412 | 51 | 51 | false | [ie/youtube] Extract all formats from multi-language m3u8s | 9,875 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | clienthax |
h = '___' + hashlib.md5(basen.encode('utf-8')).hexdigest()
basen = basen[:trim_length - len(h)] + h
filename = sanitize_filename(f'{basen}.dump', restricted=True)
# Working around MAX_PATH limitation on Windows (see
# http://msdn.microsoft.com/en-us/library/windows/deskto... | I think it might be cleaner to do this, together with the below suggestion
(just fixing my own earlier suggestion)
```suggestion
url_or_request = self._create_request(url_or_request, data)
``` | h = '___' + hashlib.md5(basen.encode('utf-8')).hexdigest()
basen = basen[:trim_length - len(h)] + h
filename = sanitize_filename(f'{basen}.dump', restricted=True)
# Working around MAX_PATH limitation on Windows (see
# http://msdn.microsoft.com/en-us/library/windows/deskto... | @@ -1028,16 +1031,19 @@ def __decode_webpage(self, webpage_bytes, encoding, headers):
except LookupError:
return webpage_bytes.decode('utf-8', 'replace')
- def _webpage_read_content(self, urlh, url_or_request, video_id, note=None, errnote=None, fatal=True, prefix=None, encoding=None):
+ de... | yt_dlp/extractor/common.py | 26 | Python | 0.786 | suggestion | 204 | 51 | 51 | false | Apends the hash of the POST data to the dump file name with --write-pages | 9,879 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | minamotorin |
absfilepath = os.path.abspath(filename)
if len(absfilepath) > 259:
filename = fR'\\?\{absfilepath}'
return filename
def __decode_webpage(self, webpage_bytes, encoding, headers):
if not encoding:
encoding = self._guess_encoding_from_content(headers... | to be applied with the above suggestion
```suggestion
filename = self._request_dump_filename(urlh.url, video_id, url_or_request.data)
``` | absfilepath = os.path.abspath(filename)
if len(absfilepath) > 259:
filename = fR'\\?\{absfilepath}'
return filename
def __decode_webpage(self, webpage_bytes, encoding, headers):
if not encoding:
encoding = self._guess_encoding_from_content(headers... | @@ -1028,16 +1031,19 @@ def __decode_webpage(self, webpage_bytes, encoding, headers):
except LookupError:
return webpage_bytes.decode('utf-8', 'replace')
- def _webpage_read_content(self, urlh, url_or_request, video_id, note=None, errnote=None, fatal=True, prefix=None, encoding=None):
+ de... | yt_dlp/extractor/common.py | 26 | Python | 0.714 | suggestion | 152 | 51 | 51 | false | Apends the hash of the POST data to the dump file name with --write-pages | 9,879 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | minamotorin |
timestamp = unified_timestamp(self._html_search_regex(
r'class=["\']mv_info_date[^>]+>([^<]+)(?:<|from)', info_page,
'upload date', default=None)) or int_or_none(data.get('date'))
view_count = str_to_int(self._search_regex(
r'class=["\']mv_views_count[^>]+>\s*([\d,.]... | `elif format_id.startswith('hls') `
Like the dash format, this should probably be startswith as well, I have come across such before though I don't have any examples. I vaguely remember it being a live stream about a half a year ago and thus been autopatching it since.
I also have `"raise ExtractorError(clean_ht... | timestamp = unified_timestamp(self._html_search_regex(
r'class=["\']mv_info_date[^>]+>([^<]+)(?:<|from)', info_page,
'upload date', default=None)) or int_or_none(data.get('date'))
view_count = str_to_int(self._search_regex(
r'class=["\']mv_views_count[^>]+>\s*([\d,.]... | @@ -462,20 +463,28 @@ def _real_extract(self, url):
formats.append({
'format_id': format_id,
'url': format_url,
+ 'ext': 'mp4',
+ 'source_preference': 1,
'height': height,
})
... | yt_dlp/extractor/vk.py | 26 | Python | 0.786 | refactor | 436 | 51 | 51 | false | [ie/vk] Improve format extraction | 9,885 | yt-dlp/yt-dlp | 132,642 | Python | CeruleanSky | seproDev |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.