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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
internal_id, note='Downloading chapter info', fatal=False, errnote=False)
if not skip_events:
return None
chapters = []
for event in ('recap', 'intro', 'credits', 'preview'):
start = traverse_obj(skip_events, (event, 'start', {float_or_none}))
end... | ```suggestion
for hardsub_lang, stream in traverse_obj(stream_response, ('hardSubs', {dict.items}, lambda _, v: v[1]['url'])):
``` | internal_id, note='Downloading chapter info', fatal=False, errnote=False)
if not skip_events:
return None
chapters = []
for event in ('recap', 'intro', 'credits', 'preview'):
start = traverse_obj(skip_events, (event, 'start', {float_or_none}))
end... | @@ -135,17 +142,37 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
- def _extract_formats(self, stream_response, display_id=None):
- requested_formats = self._configuration_ar... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.714 | suggestion | 140 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
}, {
'url': 'https://beta.crunchyroll.com/pt-br/watch/G8WUN8VKP/the-ruler-of-conspiracy',
'only_matching': True,
}]
# We want to support lazy playlist filtering and movie listings cannot be inside a playlist
_RETURN_TYPE = 'video'
def _real_extract(self, url):
lang, internal... | have you / has anyone tested if many logged-in requests to the switch endpoint results in a soft ban? (like unsigned cms endpoint requests would do before) | 'only_matching': True,
}]
# We want to support lazy playlist filtering and movie listings cannot be inside a playlist
_RETURN_TYPE = 'video'
def _real_extract(self, url):
lang, internal_id = self._match_valid_url(url).group('lang', 'id')
# We need to use unsigned API call to al... | @@ -359,31 +383,15 @@ def entries():
else:
raise ExtractorError(f'Unknown object type {object_type}')
- # There might be multiple audio languages for one object (`<object>_metadata.versions`),
- # so we need to get the id from `streams_link` instead or we dont know which language t... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.357 | question | 155 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
# if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
f'https://static.crunchyroll.com/skip-events/production/{internal_id}.json',
internal_id, note='Downloading chapter info', fatal=False, errnote=False)
if not skip_events:
... | ```suggestion
display_id, note='Downloading stream info', headers=CrunchyrollBaseIE._AUTH_HEADERS)
``` | # if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
f'https://static.crunchyroll.com/skip-events/production/{internal_id}.json',
internal_id, note='Downloading chapter info', fatal=False, errnote=False)
if not skip_events:
... | @@ -135,17 +142,37 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
- def _extract_formats(self, stream_response, display_id=None):
- requested_formats = self._configuration_ar... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.714 | security | 116 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
for format_id, hardsub_lang, stream_url in available_formats.values():
if hardsub_lang.lower() in full_format_langs:
adaptive_formats, subtitles = self._extract_mpd_formats_and_subtitles(
stream_url, display_id, mpd_id=format_id, headers=CrunchyrollBaseIE._AUTH_HE... | on second thought, this is cleaner
```suggestion
for locale, caption in traverse_obj(stream_response, (('subtitles', 'captions'), {dict.items}, ...)):
subtitles.setdefault(locale, []).append(traverse_obj(subtitle, {'url': 'url', 'ext': 'format'}))
``` | hardsub_preference = qualities(requested_hardsubs[::-1])
formats, subtitles = [], {}
for format_id, hardsub_lang, stream_url in available_formats.values():
if hardsub_lang.lower() in full_format_langs:
adaptive_formats, dash_subs = self._extract_mpd_formats_and_subtit... | @@ -158,39 +185,37 @@ def _extract_formats(self, stream_response, display_id=None):
else:
full_format_langs = set(map(str.lower, available_formats))
- audio_locale = traverse_obj(stream_response, ((None, 'meta'), 'audio_locale'), get_all=False)
+ audio_locale = traverse_obj(stream_... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.786 | suggestion | 275 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
hardsub_preference = qualities(requested_hardsubs[::-1])
formats, subtitles = [], {}
for format_id, hardsub_lang, stream_url in available_formats.values():
if hardsub_lang.lower() in full_format_langs:
adaptive_formats, subtitles = self._extract_mpd_formats_and_subtit... | ```suggestion
for locale, subtitle in traverse_obj(stream_response, (('subtitles', 'captions'), {dict.items}, ...)):
subtitles.setdefault(locale, []).append(traverse_obj(subtitle, {'url': 'url', 'ext': 'format'}))
``` |
audio_locale = traverse_obj(stream_response, ('audioLocale', {str}))
hardsub_preference = qualities(requested_hardsubs[::-1])
formats, subtitles = [], {}
for format_id, hardsub_lang, stream_url in available_formats.values():
if hardsub_lang.lower() in full_format_langs:
... | @@ -158,39 +185,35 @@ def _extract_formats(self, stream_response, display_id=None):
else:
full_format_langs = set(map(str.lower, available_formats))
- audio_locale = traverse_obj(stream_response, ((None, 'meta'), 'audio_locale'), get_all=False)
+ audio_locale = traverse_obj(stream_... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.786 | suggestion | 240 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
import functools
from .common import InfoExtractor
from ..utils import (
format_field,
int_or_none,
js_to_json,
make_archive_id,
url_basename,
url_or_none,
urlencode_postdata,
)
from ..utils.traversal import traverse_obj
class JioSaavnBaseIE(InfoExtractor):
_VALID_BITRATES = ('16', '3... | If we make the above be a set, or if we call set, we can simplify
```suggestion
if invalid_bitrates := set(requested_bitrates).difference(self._VALID_BITRATES):
```
We can call `sorted()` later to make it show nicely. This would also remove duplicates. | import functools
from .common import InfoExtractor
from ..utils import (
format_field,
int_or_none,
js_to_json,
make_archive_id,
smuggle_url,
unsmuggle_url,
url_basename,
url_or_none,
urlencode_postdata,
)
from ..utils.traversal import traverse_obj
class JioSaavnBaseIE(InfoExtract... | @@ -1,93 +1,120 @@
+import functools
+
from .common import InfoExtractor
from ..utils import (
+ format_field,
int_or_none,
js_to_json,
- orderedSet,
+ make_archive_id,
+ url_basename,
url_or_none,
urlencode_postdata,
- urljoin,
)
from ..utils.traversal import traverse_obj
cl... | yt_dlp/extractor/jiosaavn.py | 22 | Python | 0.857 | refactor | 264 | 47 | 47 | false | [ie/jiosaavn] Support playlists | 9,622 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bashonly |
class JioSaavnSongIE(JioSaavnBaseIE):
IE_NAME = 'jiosaavn:song'
_VALID_URL = r'https?://(?:www\.)?(?:jiosaavn\.com/song/[^/?#]+/|saavn\.com/s/song/(?:[^/?#]+/){3})(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://www.jiosaavn.com/song/leja-re/OQsEfQFVUXk',
'md5': '3b84396d15ed9e083c3106f1fa589c04... | A pattern like this would remove the need for the bool parameter in `self._extract_song`:
```suggestion
song_data = self._extract_initial_data(url, self._match_id(url))['song']['song']
return {
**self._extract_song(song_data),
'formats': list(self._extract_formats(song_data)... | 'ext': 'm4a',
'title': 'Leja Re',
'album': 'Leja Re',
'thumbnail': 'https://c.saavncdn.com/258/Leja-Re-Hindi-2018-20181124024539-500x500.jpg',
'duration': 205,
'view_count': int,
'release_year': 2018,
'artists': ['Sandesh Sh... | @@ -1,93 +1,120 @@
+import functools
+
from .common import InfoExtractor
from ..utils import (
+ format_field,
int_or_none,
js_to_json,
- orderedSet,
+ make_archive_id,
+ url_basename,
url_or_none,
urlencode_postdata,
- urljoin,
)
from ..utils.traversal import traverse_obj
cl... | yt_dlp/extractor/jiosaavn.py | 26 | Python | 0.857 | refactor | 338 | 51 | 51 | false | [ie/jiosaavn] Support playlists | 9,622 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bashonly |
import functools
from .common import InfoExtractor
from ..utils import (
format_field,
int_or_none,
js_to_json,
make_archive_id,
url_basename,
url_or_none,
urlencode_postdata,
)
from ..utils.traversal import traverse_obj
class JioSaavnBaseIE(InfoExtractor):
_VALID_BITRATES = ('16', '3... | Why `ValueError`? Won't it behave like `expected=False`?
```suggestion
raise ExtractorError(
f'Invalid bitrate(s): {", ".join(invalid_bitrates)}. '
f'Valid bitrates are: {", ".join(self._VALID_BITRATES)}', expected=True)
``` | import functools
from .common import InfoExtractor
from ..utils import (
format_field,
int_or_none,
js_to_json,
make_archive_id,
smuggle_url,
unsmuggle_url,
url_basename,
url_or_none,
urlencode_postdata,
)
from ..utils.traversal import traverse_obj
class JioSaavnBaseIE(InfoExtract... | @@ -1,93 +1,120 @@
+import functools
+
from .common import InfoExtractor
from ..utils import (
+ format_field,
int_or_none,
js_to_json,
- orderedSet,
+ make_archive_id,
+ url_basename,
url_or_none,
urlencode_postdata,
- urljoin,
)
from ..utils.traversal import traverse_obj
cl... | yt_dlp/extractor/jiosaavn.py | 25 | Python | 1 | refactor | 273 | 50 | 50 | false | [ie/jiosaavn] Support playlists | 9,622 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'playlist_mincount': 20,
}, {
'url': 'https://www3.nhk.or.jp/nhkworld/en/shows/10yearshayaomiyazaki/',
'only_matching': True,
}]
@classmethod
def suitable(cls, url):
return False if NhkVodIE.suitable(url) else super().suitable(url)
def _extract_meta_from_class_eleme... | ```suggestion
for episode in episodes:
if episode_path := episode.get('url'):
yield self._extract_episode_info(urljoin(url, episode_path), episode)
``` | 'description': 'md5:47b3b3a9f10d4ac7b33b53b70a7d2837',
},
'playlist_mincount': 20,
}, {
'url': 'https://www3.nhk.or.jp/nhkworld/en/shows/10yearshayaomiyazaki/',
'only_matching': True,
}]
@classmethod
def suitable(cls, url):
return False if NhkVodIE.su... | @@ -293,40 +379,70 @@ class NhkVodProgramIE(NhkBaseIE):
'playlist_mincount': 12,
}, {
# video program clips
- 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway/?type=clip',
+ 'url': 'https://www3.nhk.or.jp/nhkworld/en/shows/japanrailway/?type=clip',
... | yt_dlp/extractor/nhk.py | 26 | Python | 0.857 | refactor | 203 | 51 | 51 | false | [ie/nhk] Fix NHK World extractors | 9,623 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bashonly |
'id': vod_id,
})
else:
if fetch_episode:
# From https://www3.nhk.or.jp/nhkworld/common/player/radio/inline/rod.html
audio_path = remove_end(episode['audio']['audio'], '.m4a')
info['formats'] = self._extract_m3u8_formats(
... | ```suggestion
_VALID_URL = [
rf'{NhkBaseIE._BASE_URL_REGEX}shows/(?:(?P<type>video)/)?(?P<id>\d{{4}}[\da-z]\d+)/?(?:$|[?#])',
rf'{NhkBaseIE._BASE_URL_REGEX}(?:ondemand|shows)/(?P<type>audio)/(?P<id>[^/?#]+?-\d{{8}}-[\da-z]+)',
rf'{NhkBaseIE._BASE_URL_REGEX}ondemand/(?P<type>video)/(?P<id... | 'id': vod_id,
})
else:
if fetch_episode:
# From https://www3.nhk.or.jp/nhkworld/common/player/radio/inline/rod.html
audio_path = remove_end(episode['audio']['audio'], '.m4a')
info['formats'] = self._extract_m3u8_formats(
... | @@ -155,9 +156,9 @@ def get_clean_field(key):
class NhkVodIE(NhkBaseIE):
- # the 7-character IDs can have alphabetic chars too: assume [a-z] rather than just [a-f], eg
- _VALID_URL = [rf'{NhkBaseIE._BASE_URL_REGEX}/(?P<type>video)/(?P<id>[0-9a-z]+)',
- rf'{NhkBaseIE._BASE_URL_REGEX}/(?P<type... | yt_dlp/extractor/nhk.py | 26 | Python | 0.929 | suggestion | 367 | 51 | 51 | false | [ie/nhk] Fix NHK World extractors | 9,623 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bashonly |
def _real_extract(self, url):
display_id = self._match_id(url)
# the website is oddly giving all request as 404 at first and then loaded with js
webpage, _ = self._download_webpage_handle(url, display_id, expected_status=404)
api_data = self._download_json(
f'https://ap... | ```suggestion
extraction_result = {'formats': [{
'url': video_url,
'ext': 'mp4'
}]}
```
is prefered | }]
def _real_extract(self, url):
display_id = self._match_id(url)
api_data = self._download_json(
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
video_url = api_data['streamUrl']
is_live = api_data.get('isLive') or False
if (ext := det... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ merge_dicts,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
+ _TE... | yt_dlp/extractor/godresource.py | 26 | Python | 0.786 | refactor | 161 | 44 | 38 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
'thumbnail': 'https://cdn-02.godresource.com/e42968ac-9e8b-4231-ab86-f4f9d775841f/thumbnail.jpg',
'channel': 'Stedfast Baptist Church',
'upload_date': '20240320',
'title': 'GodResource',
}
}, {
# mp4 link
'url': 'https://new.godresource.com/vid... | ```suggestion
# the website is oddly giving all request as 404 at first and then loaded with js
webpage = self._download_webpage(url, display_id, expected_status=404)
``` | 'channel_id': '5',
'thumbnail': 'https://cdn-02.godresource.com/e42968ac-9e8b-4231-ab86-f4f9d775841f/thumbnail.jpg',
'channel': 'Stedfast Baptist Church',
'upload_date': '20240320',
'title': 'GodResource video #A01mTKjyf6w',
}
}, {
# mp4 li... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ merge_dicts,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
+ _TE... | yt_dlp/extractor/godresource.py | 26 | Python | 0.714 | suggestion | 189 | 51 | 51 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
def _real_extract(self, url):
display_id = self._match_id(url)
# the website is oddly giving all request as 404 at first and then loaded with js
webpage, _ = self._download_webpage_handle(url, display_id, expected_status=404)
api_data = self._download_json(
f'https://ap... | ```suggestion
video_url = api_data['streamUrl']
if (ext := determine_ext(video_url)) == 'm3u8':
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
api_data['streamUrl'], display_id)
elif ext == 'mp4':
formats, subtitles = [{
... | }]
def _real_extract(self, url):
display_id = self._match_id(url)
api_data = self._download_json(
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
video_url = api_data['streamUrl']
is_live = api_data.get('isLive') or False
if (ext := det... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ merge_dicts,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
+ _TE... | yt_dlp/extractor/godresource.py | 26 | Python | 1 | refactor | 477 | 44 | 38 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
webpage, _ = self._download_webpage_handle(url, display_id, expected_status=404)
api_data = self._download_json(
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
video_url = api_data['streamUrl']
# TODO: better name?
extraction_result = {}
... | ```suggestion
'formats': formats,
'subtitles': subtitles,
``` |
api_data = self._download_json(
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
video_url = api_data['streamUrl']
is_live = api_data.get('isLive') or False
if (ext := determine_ext(video_url)) == 'm3u8':
formats, subtitles = self._extract_m3... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ merge_dicts,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
+ _TE... | yt_dlp/extractor/godresource.py | 26 | Python | 0.571 | suggestion | 88 | 40 | 34 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
extraction_result = {
'formats': formats,
'subtitles': subtitles
}
elif determine_ext(video_url) == 'mp4':
extraction_result = {
'url': video_url,
'ext': 'mp4'
}
return {
'id': d... | traverse_obj doesnt actually return the None. So merge_dicts is unncessary
```suggestion
# This title is not reliable (only give the site name)
'title': self._html_extract_title(webpage),
**traverse_obj(api_data, {
'title': ('title', {str}), # can be None in A... | from .common import InfoExtractor
from ..utils import (
ExtractorError,
determine_ext,
str_or_none,
unified_timestamp,
url_or_none
)
from ..utils.traversal import traverse_obj
class GodResourceIE(InfoExtractor):
_VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
_TESTS = [{
... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ merge_dicts,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
+ _TE... | yt_dlp/extractor/godresource.py | 26 | Python | 0.857 | refactor | 722 | 28 | 80 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
from .common import InfoExtractor
from ..utils import (
determine_ext,
merge_dicts,
unified_timestamp,
url_or_none
)
from ..utils.traversal import traverse_obj
class GodResourceIE(InfoExtractor):
_VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
_TESTS = [{
# hls stream
... | This is worse than our auto-generated title `GodResource video #A01mTKjyf6w` and should not be used imo | from .common import InfoExtractor
from ..utils import (
ExtractorError,
determine_ext,
str_or_none,
unified_timestamp,
url_or_none
)
from ..utils.traversal import traverse_obj
class GodResourceIE(InfoExtractor):
_VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
_TESTS = [{
... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ merge_dicts,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
+ _TE... | yt_dlp/extractor/godresource.py | 25 | Python | 0.571 | suggestion | 103 | 50 | 50 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
url_or_none
)
from ..utils.traversal import traverse_obj
class GodResourceIE(InfoExtractor):
_VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
_TESTS = [{
# hls stream
'url': 'https://new.godresource.com/video/A01mTKjyf6w',
'info_dict': {
'id': 'A01mTKjyf... | An md5 check can be added for this (they don't work for hls)
```diff
'url': 'https://new.godresource.com/video/01DXmBbQv_X',
+ 'md5': 'xxx',
``` | url_or_none
)
from ..utils.traversal import traverse_obj
class GodResourceIE(InfoExtractor):
_VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
_TESTS = [{
# hls stream
'url': 'https://new.godresource.com/video/A01mTKjyf6w',
'info_dict': {
'id': 'A01mTKjyf... | @@ -0,0 +1,76 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ str_or_none,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/... | yt_dlp/extractor/godresource.py | 26 | Python | 0.714 | suggestion | 162 | 51 | 51 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
'title': 'GodResource video #A01mTKjyf6w',
}
}, {
# mp4 link
'url': 'https://new.godresource.com/video/01DXmBbQv_X',
'md5': '0e8f72aa89a106b9d5c011ba6f8717b7',
'info_dict': {
'id': '01DXmBbQv_X',
'ext': 'mp4',
'channel_id': '12'... | ```suggestion
video_url = api_data['streamUrl']
is_live = api_data.get('isLive') or False
``` | 'title': 'GodResource video #A01mTKjyf6w',
}
}, {
# mp4 link
'url': 'https://new.godresource.com/video/01DXmBbQv_X',
'md5': '0e8f72aa89a106b9d5c011ba6f8717b7',
'info_dict': {
'id': '01DXmBbQv_X',
'ext': 'mp4',
'channel_id': '12'... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ str_or_none,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/... | yt_dlp/extractor/godresource.py | 26 | Python | 0.714 | suggestion | 112 | 51 | 51 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
# mp4 link
'url': 'https://new.godresource.com/video/01DXmBbQv_X',
'md5': '0e8f72aa89a106b9d5c011ba6f8717b7',
'info_dict': {
'id': '01DXmBbQv_X',
'ext': 'mp4',
'channel_id': '12',
'view_count': int,
'timestamp': 1687996800,
... | ```suggestion
video_url, display_id, live=is_live)
``` | # mp4 link
'url': 'https://new.godresource.com/video/01DXmBbQv_X',
'md5': '0e8f72aa89a106b9d5c011ba6f8717b7',
'info_dict': {
'id': '01DXmBbQv_X',
'ext': 'mp4',
'channel_id': '12',
'view_count': int,
'timestamp': 1687996800,
... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ str_or_none,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/... | yt_dlp/extractor/godresource.py | 26 | Python | 0.571 | suggestion | 72 | 50 | 51 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
}]
def _real_extract(self, url):
display_id = self._match_id(url)
api_data = self._download_json(
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
video_url = api_data['streamUrl']
if (ext := determine_ext(video_url)) == 'm3u8':
form... | ```suggestion
'title': '',
'is_live': is_live,
``` | }]
def _real_extract(self, url):
display_id = self._match_id(url)
api_data = self._download_json(
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
video_url = api_data['streamUrl']
is_live = api_data.get('isLive') or False
if (ext := det... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ str_or_none,
+ unified_timestamp,
+ url_or_none
+)
+from ..utils.traversal import traverse_obj
+
+
+class GodResourceIE(InfoExtractor):
+ _VALID_URL = r'https?://new\.godresource\.com/video/... | yt_dlp/extractor/godresource.py | 26 | Python | 0.571 | suggestion | 77 | 36 | 38 | false | [ie/GodResource] Add extractor | 9,629 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
'info_dict': {
'id': 'NTSRadio_absolute-fiction-23rd-july-2022',
'ext': 'webm',
'like_count': int,
'title': 'Absolute Fiction - 23rd July 2022',
'comment_count': int,
'uploader_url': 'https://www.mixcloud.com/NTS... | I would instead parse the react state:
```suggestion
data = self._search_json(r'window\._REACT_STATE_\s*=', webpage, 'react state', video_id)
```
Hopefully, that is more reliable than extracting from the HTML | {
# embedded mixcloud
'url': 'https://www.nts.live/shows/absolute-fiction/episodes/absolute-fiction-23rd-july-2022',
'info_dict': {
'id': 'NTSRadio_absolute-fiction-23rd-july-2022',
'ext': 'webm',
'like_count': int,
... | @@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import extract_attributes
+
+
+class NTSLiveIE(InfoExtractor):
+ IE_NAME = 'nts.live'
+ _VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/]+/episodes/(?P<id>[^./?#]+)'
+ _TESTS = [
+ {
+ # embedded soundcloud
+ 'u... | yt_dlp/extractor/nts.py | 26 | Python | 0.857 | refactor | 220 | 29 | 45 | false | [ie/NTSLive] Add extractor | 9,641 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | lostfictions |
'ext': 'webm',
'like_count': int,
'title': 'Absolute Fiction - 23rd July 2022',
'comment_count': int,
'uploader_url': 'https://www.mixcloud.com/NTSRadio/',
'description': 'md5:a8cb9d9f040adb6525d33a6604fc759c',
... | And then instead of just returning the URL we can also extract additional metadata:
```suggestion
return {
'_type': 'url_transparent',
**traverse_obj(data, ('episode', {
'url': ('audio_sources', ..., 'url', {url_or_none}, any),
'title': ('name', {str... | 'url': 'https://www.nts.live/shows/absolute-fiction/episodes/absolute-fiction-23rd-july-2022',
'info_dict': {
'id': 'NTSRadio_absolute-fiction-23rd-july-2022',
'ext': 'webm',
'like_count': int,
'title': 'Absolute Fiction',
... | @@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import extract_attributes
+
+
+class NTSLiveIE(InfoExtractor):
+ IE_NAME = 'nts.live'
+ _VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/]+/episodes/(?P<id>[^./?#]+)'
+ _TESTS = [
+ {
+ # embedded soundcloud
+ 'u... | yt_dlp/extractor/nts.py | 26 | Python | 1 | refactor | 804 | 27 | 43 | false | [ie/NTSLive] Add extractor | 9,641 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | lostfictions |
from .common import InfoExtractor
from ..utils import extract_attributes
class NTSLiveIE(InfoExtractor):
IE_NAME = 'nts.live'
_VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/]+/episodes/(?P<id>[^./?#]+)'
_TESTS = [
{
# embedded soundcloud
'url': 'https://www.nts.live/s... | Updated imports
```suggestion
from .common import InfoExtractor
from ..utils import parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
``` | from .common import InfoExtractor
from ..utils import parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class NTSLiveIE(InfoExtractor):
IE_NAME = 'nts.live'
_VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/?#]+/episodes/(?P<id>[^/?#]+)'
_TESTS = [
{
# embedded s... | @@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import extract_attributes | yt_dlp/extractor/nts.py | 2 | Python | 0.786 | refactor | 162 | 27 | 27 | false | [ie/NTSLive] Add extractor | 9,641 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | lostfictions |
from .common import InfoExtractor
from ..utils import parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class NTSLiveIE(InfoExtractor):
IE_NAME = 'nts.live'
_VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/]+/episodes/(?P<id>[^./?#]+)'
_TESTS = [
{
# embedded so... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/?#]+/episodes/(?P<id>[^./?#]+)'
```
btw why `[^.]`? | from .common import InfoExtractor
from ..utils import parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class NTSLiveIE(InfoExtractor):
IE_NAME = 'nts.live'
_VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/?#]+/episodes/(?P<id>[^/?#]+)'
_TESTS = [
{
# embedded s... | @@ -0,0 +1,76 @@
+from .common import InfoExtractor
+from ..utils import parse_iso8601, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class NTSLiveIE(InfoExtractor):
+ IE_NAME = 'nts.live'
+ _VALID_URL = r'https?://(?:www\.)?nts\.live/shows/[^/]+/episodes/(?P<id>[^./?#]+)' | yt_dlp/extractor/nts.py | 8 | Python | 0.714 | question | 127 | 33 | 33 | false | [ie/NTSLive] Add extractor | 9,641 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | lostfictions |
'tbr': 'avgBitrate',
'format': 'qualityType',
'filesize': 'size',
'duration': ('duration', {lambda x: float_or_none(x, scale=1000)})
})
})
thumbnails = []
for image_info i... | Maybe this should also have `default=None`?? Idk whether you want the warning if thumbnail's missing or not | 'format': ('qualityType', {str}),
'filesize': ('size', {int_or_none}),
'duration': ('duration', {functools.partial(float_or_none, scale=1000)})
})
formats.extend(traverse_obj(info, (('mediaUrl', ('backupUrls', ...)), {
lambda u: ur... | @@ -0,0 +1,86 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE_DESC = '小红书'
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.571 | suggestion | 107 | 36 | 33 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
IE_DESC = '小红书'
_TESTS = [{
'url': 'https://www.xiaohongshu.com/explore/6411cf99000000001300b6d9',
'md5': '2a87a77ddbedcaeeda8d7eae61b61228',
'info_dict': {
'id': '... | This fails regularly for me with a captcha being served.
While using their API at `https://edith.xiaohongshu.com/api/sns/web/v1/feed` would be nice, it seems like we need to calculate some signature parameters for that. Doesn't look too complicated, but I don't think it needs to be done as part of this PR. | from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
IE_DESC = '小红书'
_TESTS = [{
'url': 'https://www.xiaohongshu.com/explore/6411cf99000000001300b6d9',
'md5': '2a87a77ddbedcaeeda8d7eae61b61228... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE_DESC = '小红书'
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.571 | bug | 311 | 51 | 51 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
}
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note... | I would add some validation for the data types
```suggestion
'fps': ('fps', {int_or_none}),
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', {str}),
... | 'tags': ['今日快乐今日发', '吃货薯看这里', '香妃蛋糕', '小五卷蛋糕', '新手蛋糕卷'],
'duration': 101.726,
'thumbnail': r're:https?://sns-webpic-qc\.xhscdn\.com/\d+/[a-z0-9]+/[\w]+',
}
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webp... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE_DESC = '小红书'
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.929 | suggestion | 663 | 51 | 51 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = traverse_obj(initial_state, ('note', 'noteDetailMap', display_id, 'note'))
vi... | I think it is better to not hard-code the extension. If they switched to say webm we would otherwise be forcing it to be mp4.
```suggestion
lambda url: url_or_none(url) and {'url': url, **format_info}})))
``` |
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = traverse_... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE_DESC = '小红书'
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.857 | suggestion | 227 | 51 | 51 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
formats = []
for info in video_info:
format_info = traverse_obj(info, {
'fps': 'fps',
'width': 'width',
'height': 'height',
'vcodec': 'videoCodec',
'acodec': 'audioCodec',
'abr': 'audioBitrate',
... | ```suggestion
'height': ('height', {int_or_none}),
'width': ('width', {int_or_none}),
``` |
note_info = traverse_obj(initial_state, ('note', 'noteDetailMap', display_id, 'note'))
video_info = traverse_obj(note_info, ('video', 'media', 'stream', ('h264', 'av1', 'h265'), ...))
formats = []
for info in video_info:
format_info = traverse_obj(info, {
'f... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE_DESC = '小红书'
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.714 | suggestion | 124 | 51 | 49 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
for image_info in traverse_obj(note_info, ('imageList', ...)):
thumbnail_info = traverse_obj(image_info, {
'height': 'height',
'width': 'width'
})
for url in traverse_obj(image_info, (('urlDefault', 'urlPre'), {url_or_none})):
t... | ```suggestion
'title': ('title', {str}),
'description': ('desc', {str}),
'tags': ('tagList', ..., 'name', {str}),
'uploader_id': ('user', 'userId', {str}),
``` | lambda u: url_or_none(u) and {'url': u, **format_info}})))
thumbnails = []
for image_info in traverse_obj(note_info, ('imageList', ...)):
thumbnail_info = traverse_obj(image_info, {
'height': ('height', {int_or_none}),
'width': ('width', {int_... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE_DESC = '小红书'
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.857 | suggestion | 228 | 29 | 27 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
from .common import InfoExtractor
from ..utils import (
float_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
IE_DESC = '小红书'
_TESTS = [{
'url': 'h... | Updated imports
```suggestion
float_or_none,
int_or_none,
``` | import functools
from .common import InfoExtractor
from ..utils import (
float_or_none,
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
IE_DESC = '小红书... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none, | yt_dlp/extractor/xiaohongshu.py | 5 | Python | 0.571 | suggestion | 73 | 30 | 30 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
from .common import InfoExtractor
from ..utils import (
float_or_none,
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
IE_DESC = '小红书'
_TESTS = [{
... | ```suggestion
_VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
``` | import functools
from .common import InfoExtractor
from ..utils import (
float_or_none,
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
IE_DESC = '小红书... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ int_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)' | yt_dlp/extractor/xiaohongshu.py | 12 | Python | 0.571 | suggestion | 95 | 37 | 37 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = traverse_obj(initial_state, ('note', 'noteDetailMap', display_id, 'note'))
vi... | ```suggestion
formats.extend(traverse_obj(info, (('mediaUrl', ('backupUrls', ...)), {
lambda u: url_or_none(u) and {'url': u, **format_info}})))
``` | def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = traverse_o... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ int_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.714 | suggestion | 179 | 51 | 51 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'fps': ('fps', {int_or_none}),
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', {str}),
'abr': ('audioBitrate', {int_or_none}),
... | ```suggestion
for thumb_url in traverse_obj(image_info, (('urlDefault', 'urlPre'), {url_or_none})):
thumbnails.append({
'url': thumb_url,
``` | for info in video_info:
format_info = traverse_obj(info, {
'fps': ('fps', {int_or_none}),
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', ... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ int_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.714 | suggestion | 193 | 46 | 44 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', {str}),
'abr': ('audioBitrate', {int_or_none}),
'vbr': ('videoBitrate', {int_or_none}),
... | ```suggestion
**thumbnail_info,
``` | format_info = traverse_obj(info, {
'fps': ('fps', {int_or_none}),
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', {str}),
'abr': (... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ int_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.571 | suggestion | 57 | 45 | 43 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'duration': ('duration', {lambda x: float_or_none(x, scale=1000)})
})
formats.extend(traverse_obj(info, (('mediaUrl', ('backupUrls', ...)), {
lambda url: url_or_none(url) and {'url': url, **format_info}})))
thumbnails = []
for image_info in trave... | or else we could end up with `[{'url': None}]`
```suggestion
'thumbnails': thumbnails,
``` | 'format': ('qualityType', {str}),
'filesize': ('size', {int_or_none}),
'duration': ('duration', {functools.partial(float_or_none, scale=1000)})
})
formats.extend(traverse_obj(info, (('mediaUrl', ('backupUrls', ...)), {
lambda u: ur... | @@ -0,0 +1,85 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ int_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu.com/explore/(?P<id>[a-f0-9]+)'
+ IE... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.786 | suggestion | 105 | 35 | 33 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = tr... | ```suggestion
'duration': ('duration', {functools.partial(float_or_none, scale=1000)})
``` | 'thumbnail': r're:https?://sns-webpic-qc\.xhscdn\.com/\d+/[a-z0-9]+/[\w]+',
}
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE_... | @@ -0,0 +1,81 @@
+from .common import InfoExtractor
+from ..utils import (
+ float_or_none,
+ int_or_none,
+ js_to_json,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class XiaoHongShuIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
+ IE... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.714 | suggestion | 108 | 51 | 51 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
from .common import InfoExtractor
from ..utils import (
float_or_none,
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
IE_DESC = '小红书'
_TESTS = [{
... | ```suggestion
import functools
from .common import InfoExtractor
``` | import functools
from .common import InfoExtractor
from ..utils import (
float_or_none,
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class XiaoHongShuIE(InfoExtractor):
_VALID_URL = r'https?://www\.xiaohongshu\.com/explore/(?P<id>[\da-f]+)'
IE_DESC = '小红书... | @@ -0,0 +1,81 @@
+from .common import InfoExtractor | yt_dlp/extractor/xiaohongshu.py | 3 | Python | 0.643 | refactor | 73 | 28 | 28 | false | [ie/xiaohongshu] Add extractor | 9,646 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
for file_ in playlist.findall('./files/file'):
video_url = xpath_text(file_, './url')
if not video_url:
continue
lang = xpath_text(file_, './lg')
formats.append({
'url': video_url,
'format_id': lang,
... | changing the formatting makes it very difficult to see what the diff is, and now the line is too long and `(?x)` is unnecessary. please revert
also, please add a test for the the new url format | for file_ in playlist.findall('./files/file'):
video_url = xpath_text(file_, './url')
if not video_url:
continue
lang = xpath_text(file_, './lg')
formats.append({
'url': video_url,
'format_id': lang,
... | @@ -93,10 +93,7 @@ def get_item(type_, preference):
class EuroParlWebstreamIE(InfoExtractor):
- _VALID_URL = r'''(?x)
- https?://multimedia\.europarl\.europa\.eu/[^/#?]+/
- (?:(?!video)[^/#?]+/[\w-]+_)(?P<id>[\w-]+)
- '''
+ _VALID_URL = r'''(?x)https?://multimedia\.europarl\.europa\.eu/(?:(?... | yt_dlp/extractor/europa.py | 26 | Python | 0.5 | refactor | 196 | 51 | 51 | false | [ie/EuroParlWebstream] Support new URL format | 9,647 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | voidful |
from .common import InfoExtractor
from ..utils import (
int_or_none,
join_nonempty,
merge_dicts,
parse_count,
url_or_none,
)
from ..utils.traversal import traverse_obj
class NFBBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?(?P<site>nfb|onf)\.ca'
_GEO_COUNTRIES = ['CA']
... | we can simplify this now
```suggestion
r'episodesData\s*:', webpage, 'episode data', video_id, fatal=fatal) or {}
``` | from .common import InfoExtractor
from ..utils import (
int_or_none,
join_nonempty,
merge_dicts,
parse_count,
url_or_none,
)
from ..utils.traversal import traverse_obj
class NFBBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?(?P<site>nfb|onf)\.ca'
_GEO_COUNTRIES = ['CA']
... | @@ -16,8 +15,8 @@ class NFBBaseIE(InfoExtractor):
def _extract_ep_data(self, webpage, video_id, fatal=False):
return self._search_json(
- r'const\s+episodesData\s*=', webpage, 'episode data', video_id,
- contains_pattern=r'\[\s*{(?s:.+)}\s*\]', fatal=fatal) or []
+ r'epi... | yt_dlp/extractor/nfb.py | 19 | Python | 0.786 | refactor | 132 | 44 | 44 | false | Changes to NFB extractor to reflect recent site changes | 9,650 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rrgomes |
'info_dict': {
'id': 'afterlife',
'ext': 'mp4',
'title': 'Afterlife',
'description': 'md5:84951394f594f1fb1e62d9c43242fdf5',
'release_year': 1978,
'duration': 420.0,
'uploader': 'Ishu Patel',
'thumbnail': r're:^https... | we can save ourselves a request now
```suggestion
player_data = self._search_json(
r'window\.PLAYER_OPTIONS\[[^\]]+\]\s*=', webpage, 'player data', slug)
video_id = self._match_id(player_data['overlay']['url']) # overlay url always has unique slug
``` | 'id': 'afterlife',
'ext': 'mp4',
'title': 'Afterlife',
'description': 'md5:84951394f594f1fb1e62d9c43242fdf5',
'release_year': 1978,
'duration': 420.0,
'uploader': 'Ishu Patel',
'thumbnail': r're:^https?://.*\.jpg$',
... | @@ -224,15 +223,15 @@ def _real_extract(self, url):
# type_ can change from film to serie(s) after redirect; new slug may have episode number
type_, slug = self._match_valid_url(urlh.url).group('type', 'id')
- embed_url = urljoin(f'https://www.{site}.ca', self._html_search_regex(
- ... | yt_dlp/extractor/nfb.py | 26 | Python | 0.786 | suggestion | 285 | 51 | 51 | false | Changes to NFB extractor to reflect recent site changes | 9,650 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rrgomes |
'description': 'md5:84951394f594f1fb1e62d9c43242fdf5',
'release_year': 1978,
'duration': 420.0,
'uploader': 'Ishu Patel',
'thumbnail': r're:^https?://.*\.jpg$',
},
'params': {'skip_download': 'm3u8'},
}]
def _real_extract(self, url):
... | ```suggestion
player_data['source'], video_id, 'mp4', m3u8_id='hls')
``` | 'release_year': 1978,
'duration': 420.0,
'uploader': 'Ishu Patel',
'thumbnail': r're:^https?://.*\.jpg$',
},
'params': {'skip_download': 'm3u8'},
}]
def _real_extract(self, url):
site, type_, slug = self._match_valid_url(url).group('site',... | @@ -224,15 +223,15 @@ def _real_extract(self, url):
# type_ can change from film to serie(s) after redirect; new slug may have episode number
type_, slug = self._match_valid_url(urlh.url).group('type', 'id')
- embed_url = urljoin(f'https://www.{site}.ca', self._html_search_regex(
- ... | yt_dlp/extractor/nfb.py | 26 | Python | 0.571 | suggestion | 86 | 51 | 51 | false | Changes to NFB extractor to reflect recent site changes | 9,650 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rrgomes |
'duration': 420.0,
'uploader': 'Ishu Patel',
'thumbnail': r're:^https?://.*\.jpg$',
},
'params': {'skip_download': 'm3u8'},
}]
def _real_extract(self, url):
site, type_, slug = self._match_valid_url(url).group('site', 'type', 'id')
# Need to c... | ```suggestion
if dv_source := url_or_none(player_data.get('dvSource')):
``` | 'uploader': 'Ishu Patel',
'thumbnail': r're:^https?://.*\.jpg$',
},
'params': {'skip_download': 'm3u8'},
}]
def _real_extract(self, url):
site, type_, slug = self._match_valid_url(url).group('site', 'type', 'id')
# Need to construct the URL since we match... | @@ -224,15 +223,15 @@ def _real_extract(self, url):
# type_ can change from film to serie(s) after redirect; new slug may have episode number
type_, slug = self._match_valid_url(urlh.url).group('type', 'id')
- embed_url = urljoin(f'https://www.{site}.ca', self._html_search_regex(
- ... | yt_dlp/extractor/nfb.py | 26 | Python | 0.571 | suggestion | 85 | 51 | 51 | false | Changes to NFB extractor to reflect recent site changes | 9,650 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rrgomes |
player = self._download_webpage(embed_url, video_id, 'Downloading player page')
if 'MESSAGE_GEOBLOCKED' in player:
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
self._html_search_regex(r'["\']?sour... | ```suggestion
'thumbnail': url_or_none(player_data.get('poster')),
``` | formats, subtitles = self._extract_m3u8_formats_and_subtitles(
player_data['source'], video_id, 'mp4', m3u8_id='hls')
if dv_source := url_or_none(player_data.get('dvSource')):
fmts, subs = self._extract_m3u8_formats_and_subtitles(
dv_source, video_id, 'mp4', m3u8... | @@ -246,17 +245,17 @@ def _real_extract(self, url):
info = {
'id': video_id,
'title': self._html_search_regex(
- r'<[^>]+\bid=["\']titleHeader["\'][^>]*>\s*<h1[^>]*>\s*([^<]+?)\s*</h1>',
+ r'["\']nfb_version_title["\']\s*:\s*["\']([^"\']+)',
... | yt_dlp/extractor/nfb.py | 26 | Python | 0.571 | suggestion | 84 | 51 | 51 | false | Changes to NFB extractor to reflect recent site changes | 9,650 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rrgomes |
'screen_width': '1920',
'secUid': sec_uid,
'type': '1', # pagination type: 0 == oldest-to-newest, 1 == newest-to-oldest
'tz_name': 'UTC',
'verifyFp': 'verify_%s' % ''.join(random.choices(string.hexdigits, k=7)),
'webcast_language': 'en',
}... | ```suggestion
response, ('itemList', -1, 'createTime', {lambda x: int_or_none(x, invscale=1E3}))
```
or actually, just
```suggestion
response, ('itemList', -1, 'createTime', {lambda x: int(x * 1E3}))
``` | return self._extract_aweme_app(video_id)
except ExtractorError as e:
e.expected = True
self.report_warning(f'{e}; trying with webpage')
url = self._create_url(user_id, video_id)
video_data, status = self._extract_web_data_and_status(url, video... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.786 | suggestion | 241 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'type': '1', # pagination type: 0 == oldest-to-newest, 1 == newest-to-oldest
'tz_name': 'UTC',
'verifyFp': 'verify_%s' % ''.join(random.choices(string.hexdigits, k=7)),
'webcast_language': 'en',
}
def _entries(self, sec_uid, user_name):
cursor = int(... | ```suggestion
cursor = old_cursor - 7 * 86_400_000 # jump 1 week back in time
```
is more readable imo. As for the comment, it may be more useful to explain "why 1 week" | e.expected = True
self.report_warning(f'{e}; trying with webpage')
url = self._create_url(user_id, video_id)
video_data, status = self._extract_web_data_and_status(url, video_id)
if video_data and status == 0:
return self._parse_aweme_video_web(video... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.786 | suggestion | 189 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
elif sigi_data := self._get_sigi_state(webpage, video_id):
self.write_debug('Found sigi state data')
status = traverse_obj(sigi_data, ('VideoPage', 'statusCode', {int})) or 0
video_data = traverse_obj(sigi_data, ('ItemModule', video_id, {dict}))
elif next_data := se... | We could do something like this if you think it's useful
```suggestion
r'tiktokuser:(?P<id>MS4wLjABAAAA[\w-]{64})(?:@(?P<username>[\w.-]+))?',
``` | 'title': 'md5:1d95c0b96560ca0e8a231af4172b2c0a',
'description': 'md5:1d95c0b96560ca0e8a231af4172b2c0a',
'channel': 'MoxyPatch',
'uploader': 'moxypatch',
'uploader_id': '7039142049363379205',
'uploader_url': 'https://www.tiktok.com/@moxypatch',
... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.786 | suggestion | 157 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
video_data = traverse_obj(universal_data, ('webapp.video-detail', 'itemInfo', 'itemStruct', {dict}))
elif sigi_data := self._get_sigi_state(webpage, video_id):
self.write_debug('Found sigi state data')
status = traverse_obj(sigi_data, ('VideoPage', 'statusCode', {int})) or 0... | ```suggestion
r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w.-]+)/?(?:$|[#?])',
``` | 'ext': 'mp4',
'title': 'md5:1d95c0b96560ca0e8a231af4172b2c0a',
'description': 'md5:1d95c0b96560ca0e8a231af4172b2c0a',
'channel': 'MoxyPatch',
'uploader': 'moxypatch',
'uploader_id': '7039142049363379205',
'uploader_url': 'https://www.ti... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])', | yt_dlp/extractor/tiktok.py | 26 | Python | 0.571 | suggestion | 91 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'referer': '',
'region': 'US',
'screen_height': '1080',
'screen_width': '1920',
'secUid': sec_uid,
'type': '1', # pagination type: 0 == oldest-to-newest, 1 == newest-to-oldest
'tz_name': 'UTC',
'verifyFp': 'verify_%s' % ''.... | As I said on discord, this isn't necessary to get `tiktokuser:` working, but I leave it to your discretion |
if self._KNOWN_APP_INFO:
try:
return self._extract_aweme_app(video_id)
except ExtractorError as e:
e.expected = True
self.report_warning(f'{e}; trying with webpage')
url = self._create_url(user_id, video_id)
video_data, st... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.571 | suggestion | 106 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'browser_name': 'Mozilla',
'browser_online': 'true',
'browser_platform': 'Win32',
'browser_version': '5.0 (Windows)',
'channel': 'tiktok_web',
'cookie_enabled': 'true',
'count': '15',
'cursor': cursor,
'device_id... | ```suggestion
'verifyFp': f'verify_{"".join(random.choices(string.hexdigits, k=7))}',
``` | 'track': 'watching the stars',
'duration': 60,
'upload_date': '20230708',
'timestamp': 1688816612,
'view_count': int,
'like_count': int,
'comment_count': int,
'repost_count': int,
'thumbnail': r're:^https://.+\.(... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.714 | suggestion | 103 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
video_id = video['id']
webpage_url = self._create_url(user_name, video_id)
info = try_call(
lambda: self._parse_aweme_video_web(video, webpage_url, video_id)) or {'id': video_id}
info.pop('formats', None)
yield self.url_... | Personally, I try to avoid this type of indenting where it's not obvious where one traverse_obj ends and next begins. But not a big deal
```suggestion
return (traverse_obj(self._get_universal_data(webpage, user_name),
('webapp.user-detail', 'userInfo', 'user', 'secUid', {str}))
... | IE_NAME = 'tiktok:user'
_VALID_URL = r'(?:tiktokuser:|https?://(?:www\.)?tiktok\.com/@)(?P<id>[\w.-]+)/?(?:$|[#?])'
_TESTS = [{
'url': 'https://tiktok.com/@corgibobaa?lang=en',
'playlist_mincount': 45,
'info_dict': {
'id': 'MS4wLjABAAAAepiJKgwWhulvCpSuUVsp7sgVVsFJbbNaLeQ6... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 1 | suggestion | 578 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
old_cursor = cursor
cursor = traverse_obj(
response, ('itemList', -1, 'createTime', {lambda x: x * 1E3}, {int_or_none}))
if not cursor:
cursor = old_cursor - 604800000 # jump 1 week back in time
if cursor < 1472706000000 or not traverse_ob... | ```suggestion
if url.startswith('tiktokuser:'):
sec_uid, user_name = self._match_id(url), None
else:
sec_uid, user_name = None, self._match_id(url)
``` | 'title': 'corgibobaa',
},
}, {
'url': 'https://www.tiktok.com/@6820838815978423302',
'playlist_mincount': 5,
'info_dict': {
'id': 'MS4wLjABAAAA0tF1nBwQVVMyrGu3CqttkNgM68Do1OXUFuCY0CRQk8fEtSVDj89HqoqvbSTmUP2W',
'title': '6820838815978423302',
... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.786 | suggestion | 196 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
webpage = self._download_webpage(
user_url, user_name, fatal=False, headers={'User-Agent': 'Mozilla/5.0'},
note=f'Downloading {msg} webpage', errnote=f'Unable to download {msg} webpage') or ''
return traverse_obj(
self._get_universal_data(webpage, user_name),
... | ```suggestion
for user_url, msg in (
(self._UPLOADER_URL_FORMAT % user_name, 'user'),
(self._UPLOADER_URL_FORMAT % f'{user_name}/live', 'live'),
):
if sec_uid:
break
sec_uid = self._get_sec_uid(user_url, user_name, msg)
``` | }, {
'url': 'https://www.tiktok.com/@meme',
'playlist_mincount': 593,
'info_dict': {
'id': 'MS4wLjABAAAAiKfaDWeCsT3IHwY77zqWGtVRIy9v4ws1HbVi7auP1Vx7dJysU_hc5yRiGywojRD6',
'title': 'meme',
},
}, {
'url': 'tiktokuser:MS4wLjABAAAAM3R2BtjzVT-uAtstkl2iu... | @@ -793,102 +792,150 @@ def _real_extract(self, url):
class TikTokUserIE(TikTokBaseIE):
IE_NAME = 'tiktok:user'
- _VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
- _WORKING = False
+ _VALID_URL = [
+ r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
+ ... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.857 | suggestion | 311 | 51 | 51 | false | [ie/tiktok:user] Fix extractor | 9,661 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'upload_date': upload_date,
'formats': formats,
})
return self.playlist_result(entries)
class ORFONIE(InfoExtractor):
IE_NAME = 'orf:on'
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d+)(/(?P<slug>[\w-]+))?'
_TESTS = [{
'url': 'https://on.or... | Don't delete the test, but add a new one. | 'thumbnail': thumbnail,
'upload_date': upload_date,
'formats': formats,
})
return self.playlist_result(entries)
class ORFONIE(InfoExtractor):
IE_NAME = 'orf:on'
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d+)'
_TESTS = [{
'... | @@ -569,19 +569,20 @@ def _real_extract(self, url):
class ORFONIE(InfoExtractor):
IE_NAME = 'orf:on'
- _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d+)(/(?P<slug>[\w-]+))?'
_TESTS = [{
- 'url': 'https://on.orf.at/... | yt_dlp/extractor/orf.py | 26 | Python | 0.071 | suggestion | 41 | 51 | 51 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
if manifest_type == 'hls':
fmts, subs = self._extract_m3u8_formats_and_subtitles(
manifest_url, display_id, fatal=False, m3u8_id='hls')
elif manifest_type == 'dash':
fmts, subs = self._extract_mpd_formats_and_subtitles(
... | I cannot replicate this. For me, all subtitle formats on [this](https://on.orf.at/video/14210000/school-of-champions-48) video work. Do you have examples where they don't work? | }
}]
def _extract_video(self, video_id):
encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
api_json = self._download_json(
f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', video_id)
if traverse_obj(api_... | @@ -604,10 +608,33 @@ def _extract_video(self, video_id, display_id):
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
+ for subtitle_type in ['vtt']: # not working formats 'xml', 'srt', 'sami', 'ttml', 'stl' | yt_dlp/extractor/orf.py | 26 | Python | 0.357 | question | 176 | 51 | 51 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
'media_type': 'episode',
'timestamp': 52916400,
'upload_date': '19710905',
}
}]
def _extract_video(self, video_id, display_id):
encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
api_json = self._download_json(
... | ```suggestion
if api_json.get('is_drm_protected'):
``` | 'media_type': 'episode',
'timestamp': 1706472362,
'upload_date': '20240128',
}
}, {
'url': 'https://on.orf.at/video/3220355',
'md5': 'f94d98e667cf9a3851317efb4e136662',
'info_dict': {
'id': '3220355',
'ext': 'mp4',
... | @@ -590,6 +591,9 @@ def _extract_video(self, video_id, display_id):
api_json = self._download_json(
f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', display_id)
+ if traverse_obj(api_json, 'is_drm_protected'): | yt_dlp/extractor/orf.py | 26 | Python | 0.571 | suggestion | 64 | 51 | 51 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
self._merge_subtitles({
'de': [
{
'url': subtitle_url,
'ext': f'{subtitle_type}',
}
],
}, target=subtitles)
age_classification = traverse_obj(api_json, ('age_classific... | I think you can just use `parse_age_limit` from `..utils`
If you can, just inline this in to the `traverse_obj` call below. | fmts, subs = self._extract_m3u8_formats_and_subtitles(
manifest_url, video_id, fatal=False, m3u8_id='hls')
elif manifest_type == 'dash':
fmts, subs = self._extract_mpd_formats_and_subtitles(
manifest_url, video_id, f... | @@ -604,10 +608,33 @@ def _extract_video(self, video_id, display_id):
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
+ for subtitle_type in ['vtt']: # not working formats 'xml', 'srt', 'sami', 'ttml', 'stl'
+ subtitle_url = traverse_obj(api_json... | yt_dlp/extractor/orf.py | 26 | Python | 0.571 | suggestion | 124 | 46 | 41 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
age_classification = traverse_obj(api_json, ('age_classification'), {str})
age_limit = None
if isinstance(age_classification, str) and len(age_classification) != 0:
# age_classification is in the format `<age:int>+`
# example: "6+" or "18+"
age_limit_str = age... | I don't think we should add a display_id if it is not present
```suggestion
```
Edit: Actually I see the problem, the requests below use the `display_id` for the log. Maybe change that to `video_id`? |
for sub_url in traverse_obj(api_json, (
'_embedded', 'subtitle',
('xml_url', 'sami_url', 'stl_url', 'ttml_url', 'srt_url', 'vtt_url'), {url_or_none})):
self._merge_subtitles({'de': [{'url': sub_url}]}, target=subtitles)
return {
'id': video_id,
... | @@ -618,6 +645,8 @@ def _extract_video(self, video_id, display_id):
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).group('id', 'slug')
+ if display_id is None:
+ display_id = video_id | yt_dlp/extractor/orf.py | 26 | Python | 0.857 | question | 202 | 37 | 32 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
continue
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
for subtitle_type in ['vtt']: # not working formats 'xml', 'srt', 'sami', 'ttml', 'stl'
subtitle_url = traverse_obj(api_json, ('_embedded', 'subtitle', f'{subtitle_type}_... | You can just inline this:
```suggestion
**traverse_obj(api_json, {
'age_limit': ('age_classification', {parse_age_limit}),
``` | continue
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
for sub_url in traverse_obj(api_json, (
'_embedded', 'subtitle',
('xml_url', 'sami_url', 'stl_url', 'ttml_url', 'srt_url', 'vtt_url'), {url_or_none})):... | @@ -583,31 +584,65 @@ class ORFONIE(InfoExtractor):
'timestamp': 1706472362,
'upload_date': '20240128',
}
+ }, {
+ 'url': 'https://on.orf.at/video/3220355',
+ 'md5': 'f94d98e667cf9a3851317efb4e136662',
+ 'info_dict': {
+ 'id': '3220355',
+ ... | yt_dlp/extractor/orf.py | 26 | Python | 0.714 | suggestion | 158 | 46 | 35 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
import functools
import re
from .common import InfoExtractor
from ..networking import HEADRequest
from ..utils import (
InAdvancePagedList,
clean_html,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
make_archive_id,
mimetype2ext,
orderedSet,
remove_end,
smuggle_ur... | Oh, and you can add this to the imports from above sorted alphabetically | import functools
import re
from .common import InfoExtractor
from ..networking import HEADRequest
from ..utils import (
InAdvancePagedList,
clean_html,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
make_archive_id,
mimetype2ext,
orderedSet,
parse_age_limit,
remov... | @@ -24,6 +24,7 @@
url_or_none,
)
from ..utils.traversal import traverse_obj
+from ..utils import parse_age_limit | yt_dlp/extractor/orf.py | 26 | Python | 0.214 | suggestion | 72 | 51 | 51 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
self._merge_subtitles(subs, target=subtitles)
for sub_url in traverse_obj(api_json, ('_embedded', 'subtitle', lambda k, _: k.endswith('_url'), {url_or_none})):
subtitle_type = sub_url.split('.')[-1]
self._merge_subtitles({'de': [{'url': sub_url, 'ext': subtitle_type}]}, ... | ```suggestion
video_id = self._match_id(url)
``` | self._merge_subtitles(subs, target=subtitles)
for sub_url in traverse_obj(api_json, (
'_embedded', 'subtitle',
('xml_url', 'sami_url', 'stl_url', 'ttml_url', 'srt_url', 'vtt_url'), {url_or_none})):
self._merge_subtitles({'de': [{'url': sub_url}]}, tar... | @@ -617,14 +645,14 @@ def _extract_video(self, video_id, display_id):
}
def _real_extract(self, url):
- video_id, display_id = self._match_valid_url(url).group('id', 'slug')
- webpage = self._download_webpage(url, display_id)
+ video_id = self._match_valid_url(url).group('id') | yt_dlp/extractor/orf.py | 26 | Python | 0.571 | suggestion | 58 | 37 | 33 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
if api_json.get('is_drm_protected'):
self.report_drm(video_id)
formats, subtitles = [], {}
for manifest_type in traverse_obj(api_json, ('sources', {dict.keys}, ...)):
for manifest_url in traverse_obj(api_json, ('sources', manifest_type, ..., 'src', {url_or_none})):
... | I think this is a bit cleaner:
```suggestion
for sub_url in traverse_obj(api_json, (
'_embedded', 'subtitle',
('xml_url', 'sami_url', 'stl_url', 'ttml_url', 'srt_url', 'vtt_url'), {url_or_none})):
self._merge_subtitles({'de': [{'url': sub_url}]}, target=subtitles... |
if traverse_obj(api_json, 'is_drm_protected'):
self.report_drm(video_id)
formats, subtitles = [], {}
for manifest_type in traverse_obj(api_json, ('sources', {dict.keys}, ...)):
for manifest_url in traverse_obj(api_json, ('sources', manifest_type, ..., 'src', {url_or_non... | @@ -583,32 +584,59 @@ class ORFONIE(InfoExtractor):
'timestamp': 1706472362,
'upload_date': '20240128',
}
+ }, {
+ 'url': 'https://on.orf.at/video/3220355',
+ 'md5': 'f94d98e667cf9a3851317efb4e136662',
+ 'info_dict': {
+ 'id': '3220355',
+ ... | yt_dlp/extractor/orf.py | 26 | Python | 0.786 | suggestion | 436 | 51 | 49 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
'media_type': 'episode',
'timestamp': 1706472362,
'upload_date': '20240128',
}
}, {
'url': 'https://on.orf.at/video/3220355',
'md5': 'f94d98e667cf9a3851317efb4e136662',
'info_dict': {
'id': '3220355',
'ext': 'mp4',
... | Turns out there was a reason to use `traverse_obj` here, to not be fatal during error handling
```suggestion
if traverse_obj(api_json, 'is_drm_protected'):
``` | 'media_type': 'episode',
'timestamp': 1706472362,
'upload_date': '20240128',
}
}, {
'url': 'https://on.orf.at/video/3220355',
'md5': 'f94d98e667cf9a3851317efb4e136662',
'info_dict': {
'id': '3220355',
'ext': 'mp4',
... | @@ -583,32 +584,55 @@ class ORFONIE(InfoExtractor):
'timestamp': 1706472362,
'upload_date': '20240128',
}
+ }, {
+ 'url': 'https://on.orf.at/video/3220355',
+ 'md5': 'f94d98e667cf9a3851317efb4e136662',
+ 'info_dict': {
+ 'id': '3220355',
+ ... | yt_dlp/extractor/orf.py | 26 | Python | 0.929 | suggestion | 170 | 51 | 51 | false | [ie/orf:on] Improve extraction | 9,677 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | TuxCoder |
class TBSIE(TurnerBaseIE):
_VALID_URL = r'https?://(?:www\.)?(?P<site>tbs|tntdrama|trutv)\.com(?P<path>/(?:movies|watchtnt|watchtbs|watchtrutv|shows/[^/]+/(?:clips|season-\d+/episode-\d+))/(?P<id>[^/?#]+))'
_TESTS = [{
'url': 'http://www.tntdrama.com/shows/the-alienist/clips/monster',
'info_dict... | ```suggestion
}, {
'url': 'https://www.trutv.com/shows/impractical-jokers/season-9/episode-1/you-dirty-dog',
'only_matching': True,
}, {
'url': 'https://www.trutv.com/watchtrutv/east',
'only_matching': True,
}]
``` | _SITE_INFO = {
'tbs': ('TBS', 'eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJkZTA0NTYxZS1iMTFhLTRlYTgtYTg5NC01NjI3MGM1NmM2MWIiLCJuYmYiOjE1MzcxODkzOTAsImlzcyI6ImF1dGguYWRvYmUuY29tIiwiaWF0IjoxNTM3MTg5MzkwfQ.Z7ny66kaqNDdCHf9Y9KsV12LrBxrLkGGxlYe2XGm6qsw2T-k1OCKC1TMzeqiZP735292MMRAQkcJDKrMIzNbAuf9nCdIcv4kE1E2nqUnjPMBduC1bHffZ... | @@ -34,6 +34,9 @@ class TBSIE(TurnerBaseIE):
}, {
'url': 'http://www.tntdrama.com/movies/star-wars-a-new-hope',
'only_matching': True,
+ }, {
+ 'url': 'https://www.trutv.com/watchtrutv/east',
+ 'only_matching': True,
}] | yt_dlp/extractor/tbs.py | 26 | Python | 0.786 | suggestion | 266 | 51 | 51 | false | [ie/tbs] Fix truTV support | 9,683 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | ischmidt20 |
'url': 'https://www.trutv.com/watchtrutv/east',
'only_matching': True,
}]
_SOFTWARE_STATEMENT_MAP = {
'tbs': 'eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJkZTA0NTYxZS1iMTFhLTRlYTgtYTg5NC01NjI3MGM1NmM2MWIiLCJuYmYiOjE1MzcxODkzOTAsImlzcyI6ImF1dGguYWRvYmUuY29tIiwiaWF0IjoxNTM3MTg5MzkwfQ.Z7ny66kaqNDdCHf9Y9... | ```suggestion
'site_name': {'tbs': 'TBS', 'tntdrama': 'TNT', 'trutv': 'truTV'}[site],
``` | 'season_number': 6,
'episode': 'Episode 12',
'episode_number': 12,
'timestamp': 1478276239,
'upload_date': '20161104',
},
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.tntdrama.com/shows/the-librarians-the-next-chapt... | @@ -54,7 +60,7 @@ def _real_extract(self, url):
info = self._extract_ngtv_info(
media_id, tokenizer_query, self._SOFTWARE_STATEMENT_MAP[site], {
'url': url,
- 'site_name': site[:3].upper(),
+ 'site_name': {'tbs': 'TBS', 'tnt': 'TNT', 'trutv': 'truTV'}... | yt_dlp/extractor/tbs.py | 26 | Python | 0.714 | suggestion | 107 | 51 | 51 | false | [ie/tbs] Fix truTV support | 9,683 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | ischmidt20 |
'timestamp': item_time,
'description': strip_or_none(item_desc),
})
for resp in (initial_data.get('data') or {}).values():
name = resp.get('name')
if name == 'media-experience':
parse_medi... | just use the `playlist_id` that was already assigned | 'description': clip.get('description'),
'duration': parse_duration(clip.get('duration')),
'formats': formats,
'subtitles': subtitles,
}
bbc3_playlist = try_get(
payload, lambda x: x['content']['bb... | @@ -1255,6 +1266,45 @@ 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)
+ video_id = self._match_i... | yt_dlp/extractor/bbc.py | 26 | Python | 0.429 | suggestion | 52 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
'description': strip_or_none(item_desc),
})
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... | this needs to be non-fatal -- use `traverse_obj`. as-is, this line will throw for UK users before the rest of the extraction code can be reached | 'duration': parse_duration(clip.get('duration')),
'formats': formats,
'subtitles': subtitles,
}
bbc3_playlist = try_get(
payload, lambda x: x['content']['bbcMedia']['playlist'],
dict)
if b... | @@ -1255,6 +1266,45 @@ 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)
+ video_id = self._match_i... | yt_dlp/extractor/bbc.py | 26 | Python | 0.571 | refactor | 144 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
lambda x: x['data']['content']['model']['blocks'],),
list) or []):
if block.get('type') not in ['media', 'video']:
continue
parse_media(block.get('model'))
... | use `traverse_obj` to filter here, and only bother to extract the timestamp if there is actually `video_data`, e.g.
```suggestion
video_data = traverse_obj(next_data, (
..., 'contents', lambda _, v: v['type'] == 'video'), get_all=False)
if video_data:
timestamp = traverse_ob... | thumbnail = bbc3_playlist.get('holdingImageURL')
entries = []
for bbc3_item in bbc3_playlist['items']:
programme_id = bbc3_item.get('versionID')
if not programme_id:
continue
formats, subt... | @@ -1255,6 +1266,45 @@ 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)
+ video_id = self._match_i... | yt_dlp/extractor/bbc.py | 26 | Python | 1 | refactor | 482 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
video_data = item
elif item.get('type') == 'timestamp':
timestamp = item
if video_data:
for item in (try_get(video_data, lambda x: x['model']['blocks'], list) or []):
if item.get('type') == 'media':
for subty... | use traversal here too. currently, many of these variables are unbound `if not model` | return
formats, subtitles = self._download_media_selector(item_id)
return {
'id': item_id,
'formats': formats,
'subtitles': subtitles,
**traverse_obj(model, {
'title': ('title', {str}),
... | @@ -1255,6 +1266,45 @@ 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)
+ video_id = self._match_i... | yt_dlp/extractor/bbc.py | 26 | Python | 0.429 | suggestion | 85 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
continue
parse_media(block.get('model'))
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
def extract_all(pattern):
return list(filter(None, map(
lambda s: self._p... | The extractor should start using t_o instead of try_get, especially as the PR is using it above.
```suggestion
item_id = traverse_obj(model, ('versions', 0, 'versionId'))
```
Maybe also replace dict_get. | programme_id = bbc3_item.get('versionID')
if not programme_id:
continue
formats, subtitles = self._download_media_selector(programme_id)
entries.append({
'id': programme_id,
... | @@ -1255,6 +1266,36 @@ 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 | 225 | 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 |
'thumbnail': r're:https?://.+/.+\.jpg',
'timestamp': 1437785037,
'upload_date': '20150725',
},
}, {
# video with window.__INITIAL_DATA__ and value as JSON string
'url': 'https://www.bbc.com/news/av/world-europe-59468682',
'info_dict': {
... | this is wrong, need to convert milliseconds to seconds | # single video with playlist URL from weather section
'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-environmen... | @@ -791,6 +791,17 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'timestamp': 1638230731,
'upload_date': '20211130',
},
+ }, {
+ # video with script id __NEXT_DATA__ and value as JSON string
+ 'url': 'https://www.bbc.com/news/uk-68546268',
+ ... | yt_dlp/extractor/bbc.py | 26 | Python | 0.214 | bug | 54 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
'info_dict': {
'id': 'p0b71qth',
'ext': 'mp4',
'title': 'Why France is making this woman a national hero',
'description': 'md5:7affdfab80e9c3a1f976230a1ff4d5e4',
'thumbnail': r're:https?://.+/.+\.jpg',
'timestamp': 1638230731,
'... | someone should probably run this test from a UK IP too before merge | 'info_dict': {
'id': 'p02xzws1',
'ext': 'mp4',
'title': "Pluto may have 'nitrogen glaciers'",
'description': 'md5:6a95b593f528d7a5f2605221bc56912f',
'thumbnail': r're:https?://.+/.+\.jpg',
'timestamp': 1437785037,
'upload_date':... | @@ -791,6 +791,17 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'timestamp': 1638230731,
'upload_date': '20211130',
},
+ }, {
+ # video with script id __NEXT_DATA__ and value as JSON string
+ 'url': 'https://www.bbc.com/news/uk-68546268', | yt_dlp/extractor/bbc.py | 26 | Python | 0.286 | suggestion | 67 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
'description': strip_or_none(item_desc),
})
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... | `_search_nextjs_data` is still fatal. needs a `default`. `get_all=False` is unnecessary
```suggestion
next_data = traverse_obj(
self._search_nextjs_data(webpage, playlist_id, default='{}'),
('props', 'pageProps', 'page', {dict}))
``` | 'duration': parse_duration(clip.get('duration')),
'formats': formats,
'subtitles': subtitles,
}
bbc3_playlist = try_get(
payload, lambda x: x['content']['bbcMedia']['playlist'],
dict)
if b... | @@ -1255,6 +1266,38 @@ 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.786 | suggestion | 272 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
continue
parse_media(block.get('model'))
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
def extract_all(pattern):
return list(filter(None, map(
lambda s: self._p... | ~~inline this in the append call~~ | programme_id = bbc3_item.get('versionID')
if not programme_id:
continue
formats, subtitles = self._download_media_selector(programme_id)
entries.append({
'id': programme_id,
... | @@ -1255,6 +1266,38 @@ 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.071 | suggestion | 34 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
if block.get('type') not in ['media', 'video']:
continue
parse_media(block.get('model'))
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
def extract_all(pattern):
... | convert to seconds, and we can inline this in the append call
```suggestion
timestamp = traverse_obj(next_data, (
..., 'contents', lambda _, v: v['type'] == 'timestamp', 'model',
'timestamp', {functools.partial(int_or_none, scale=1000)}, any))
``` | for bbc3_item in bbc3_playlist['items']:
programme_id = bbc3_item.get('versionID')
if not programme_id:
continue
formats, subtitles = self._download_media_selector(programme_id)
entries.append({
... | @@ -1255,6 +1266,38 @@ 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.929 | suggestion | 308 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
(lambda x: x['data']['blocks'],
lambda x: x['data']['content']['model']['blocks'],),
list) or []):
if block.get('type') not in ['media', 'video']:
... | we don't use `video_data` for anything other than the truthy check -- this could be a single traversal for `model` instead | playlist_title = bbc3_playlist.get('title') or playlist_title
thumbnail = bbc3_playlist.get('holdingImageURL')
entries = []
for bbc3_item in bbc3_playlist['items']:
programme_id = bbc3_item.get('versionID')
if not pr... | @@ -1255,6 +1266,38 @@ 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 | 122 | 51 | 51 | false | Issue 9701: NEXT_DATA field video extraction for bbc US website | 9,705 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kylegustavo |
# US accessed article with single embedded video (e.g.
# https://www.bbc.com/news/uk-68546268)
next_data = traverse_obj(self._search_nextjs_data(webpage, playlist_id), (
'props', 'pageProps', 'page'), get_all=False)
video_data = traverse_obj(next_data, (
..., 'co... | As in several places elsewhere in the existing code (eg l.1100):
```suggestion
'thumbnail': ('imageUrl', {lambda u: url_or_none(u.replace('$recipe', 'raw'))}),
```
I can't tell from l.802 if this applies to the US page but it probably does. However the equivalent `imageUrl` in the UK page h... | 'formats': formats,
'subtitles': subtitles,
})
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
def parse_model(model):
"""Extract single video from model ... | @@ -1255,6 +1266,38 @@ 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 | bug | 418 | 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 |
..., 'contents', lambda _, v: v['type'] == 'video'), get_all=False)
if video_data:
model = traverse_obj(video_data, (
'model', 'blocks', lambda _, v: v['type'] == 'media',
'model', 'blocks', lambda _, v: v['type'] == 'mediaMetadata',
'model... | Using the inline function suggested above:
```suggestion
entry = parse_model(model)
if entry:
if entry.get('timestamp') is None:
entry['timestamp'] = traverse_obj(next_data, (
..., 'contents', lambda _, v: v['type'] == 'timestamp'... | def parse_model(model):
"""Extract single video from model structure"""
item_id = traverse_obj(model, ('versions', 0, 'versionId', {str}))
if not item_id:
return
formats, subtitles = self._download_media_selector(item_id)
return {
... | @@ -1255,6 +1266,38 @@ 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.929 | suggestion | 765 | 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': "Pluto may have 'nitrogen glaciers'",
'description': 'md5:6a95b593f528d7a5f2605221bc56912f',
'thumbnail': r're:https?://.+/.+\.jpg',
'timestamp': 1437785037,
'upload_date': '20150725',
},
}, {
# video with window.__INITIAL_DATA__ a... | It's the exact number now:
```suggestion
'description': r're:(?s)Doctor Abu Sabha said he was detained by Israeli forces after .{276} hostages\."$',
``` | 'skip': 'redirects to Young Reporter home page https://www.bbc.co.uk/news/topics/cg41ylwv43pt',
}, {
# single video with playlist URL from weather section
'url': 'http://www.bbc.com/weather/features/33601775',
'only_matching': True,
}, {
# custom redirection to www.bbc.co... | @@ -791,6 +791,19 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'timestamp': 1638230731,
'upload_date': '20211130',
},
+ }, {
+ # video with script id __NEXT_DATA__ and value as JSON string
+ 'url': 'https://www.bbc.com/news/uk-68546268',
+ ... | yt_dlp/extractor/bbc.py | 26 | Python | 0.714 | suggestion | 167 | 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 |
if not item_id:
return
formats, subtitles = self._download_media_selector(item_id)
return {
'id': item_id,
'formats': formats,
'subtitles': subtitles,
**traverse_obj(model, {
'title': ... | Make traversal return first item found:
```suggestion
model = traverse_obj(next_data, (
..., 'contents', lambda _, v: v['type'] == 'video',
'model', 'blocks', lambda _, v: v['type'] == 'media',
'model', 'blocks', lambda _, v: v['type'] == 'mediaMetadata',
'm... | item_id = traverse_obj(model, ('versions', 0, 'versionId', {str}))
if not item_id:
return
formats, subtitles = self._download_media_selector(item_id)
return {
'id': item_id,
'formats': formats,
'subtitles': s... | @@ -1255,6 +1268,48 @@ def extract_all(pattern):
lambda s: self._parse_json(s, playlist_id, fatal=False),
re.findall(pattern, webpage))))
+ def parse_model(model):
+ '''Extract single video from model structure'''
+ if isinstance(model, list):
+ ... | yt_dlp/extractor/bbc.py | 26 | Python | 0.929 | suggestion | 345 | 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 |
'description': strip_or_none(item_desc),
})
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... | I think you're getting a list when you expected a dict because the traversal is branching. If there might be multiple videos, let the calling code handle it, or make the traversal return the first dict found.
```suggestion
``` | 'subtitles': subtitles,
}
bbc3_playlist = try_get(
payload, lambda x: x['content']['bbcMedia']['playlist'],
dict)
if bbc3_playlist:
playlist_title = bbc3_playlist.get('title') or playlist_title
th... | @@ -1255,6 +1268,48 @@ def extract_all(pattern):
lambda s: self._parse_json(s, playlist_id, fatal=False),
re.findall(pattern, webpage))))
+ def parse_model(model):
+ '''Extract single video from model structure'''
+ if isinstance(model, list):
+ ... | yt_dlp/extractor/bbc.py | 26 | Python | 1 | suggestion | 229 | 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': 'business-28299555',
'title': 'Farnborough Airshow: Video highlights',
'description': 'BBC reports and video highlights at the Farnborough Airshow.',
},
'playlist_count': 9,
'skip': 'Save time',
}, {
# article with mult... | ```suggestion
'duration': 47,
```
Let the test fail if extraction is wrong. That's the point of tests | 'id': 'business-28299555',
'title': 'Farnborough Airshow: Video highlights',
'description': 'BBC reports and video highlights at the Farnborough Airshow.',
},
'playlist_count': 9,
'skip': 'Save time',
}, {
# article with multiple videos embedded wi... | @@ -631,14 +633,14 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
'info_dict': {
'id': 'p02mprgb',
'ext': 'mp4',
- 'title': 'Aerial footage showed the site of the crash in the Alps - courtesy BFM TV',
- 'description': 'md5:2868290467291b37fed... | yt_dlp/extractor/bbc.py | 26 | Python | 0.786 | bug | 118 | 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 |
'ext': 'mp4',
'title': "YPG: Tel Abyad'ın tamamı kontrolümüzde",
'description': 'md5:33a4805a855c9baf7115fcbde57e7025',
'timestamp': 1434397334,
'upload_date': '20150615',
},
'params': {
'skip_download': True,
},
'sk... | Don't skip tests that expose extractor bug | 'title': "YPG: Tel Abyad'ın tamamı kontrolümüzde",
'description': 'md5:33a4805a855c9baf7115fcbde57e7025',
'timestamp': 1434397334,
'upload_date': '20150615',
},
'params': {
'skip_download': True,
},
'skip': 'now SIMORGH_DATA wit... | @@ -670,7 +673,9 @@ class BBCIE(BBCCoUkIE): # XXX: Do not subclass from concrete IE
},
'params': {
'skip_download': True,
- }
+ },
+ # TODO: now in .pageData.promo.media of SIMORGH_DATA
+ 'skip': 'video extraction failed', | yt_dlp/extractor/bbc.py | 26 | Python | 0.286 | bug | 42 | 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 |
# single video from video playlist embedded with vxp-playlist-data JSON
'url': 'http://www.bbc.com/news/video_and_audio/must_see/33376376',
'info_dict': {
'id': 'p02w6qjc',
'ext': 'mp4',
'title': '''Judge Mindy Glazer: "I'm sorry to see you here... I always wo... | pls explain the comments. Is current extraction correct? | 'url': 'http://www.bbc.com/news/video_and_audio/must_see/33376376',
'info_dict': {
'id': 'p02w6qjc',
'ext': 'mp4',
'title': '''Judge Mindy Glazer: "I'm sorry to see you here... I always wondered what happened to you"''',
'duration': 56,
'descri... | @@ -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
'url': 'http://www.bbc.com/travel/story/2... | yt_dlp/extractor/bbc.py | 26 | Python | 0.286 | refactor | 56 | 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 |
'url': 'http://www.bbc.com/autos/story/20130513-hyundais-rock-star',
'info_dict': {
'id': 'p018zqqg',
'ext': 'mp4',
'title': 'Hyundai Santa Fe Sport: Rock star',
'description': 'md5:b042a26142c4154a6e472933cf20793d',
'timestamp': 1415867444,
... | ```suggestion
# single video in __INITIAL_DATA__
```
Do we know any URL with `playlist.sxml`? | 'id': 'p018zqqg',
'ext': 'mp4',
'title': 'Hyundai Santa Fe Sport: Rock star',
'description': 'md5:b042a26142c4154a6e472933cf20793d',
'timestamp': 1415867444,
'upload_date': '20141113',
},
'skip': 'redirects to TopGear home page',
... | @@ -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 | question | 106 | 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': 1415867444,
'upload_date': '20141113',
},
'skip': 'redirects to TopGear home page',
}, {
# single video embedded with Morph
# TODO: replacement test page
'url': 'http://www.bbc.co.uk/sport/live/olympics/36895975',
'info_dict': {
... | ```suggestion
'description': r're:(?s)BBC Sport\'s David Ornstein rounds up the latest transfer reports, .{359} here\.$',
``` | },
'skip': 'redirects to TopGear home page',
}, {
# 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': "... | @@ -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 | 139 | 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 |
},
'skip': 'Video no longer in page',
}, {
# single video in __INITIAL_DATA__ (was: playlist.sxml URL in playlist param)
'url': 'http://www.bbc.com/sport/0/football/33653409',
'info_dict': {
'id': 'p02xycnp',
'ext': 'mp4',
'title': 'Ronaldo... | ```suggestion
# Testing noplaylist
``` | }, {
# single video in __INITIAL_DATA__
'url': 'http://www.bbc.com/sport/0/football/33653409',
'info_dict': {
'id': 'p02xycnp',
'ext': 'mp4',
'title': 'Ronaldo to Man Utd, Arsenal to spend?',
'description': r're:(?s)BBC Sport\'s David Ornstein ... | @@ -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.429 | suggestion | 48 | 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 |
'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',
}, {
# single video with playlist URL from weather section
'url': 'http://www.bbc.com... | Do we know why ID changed? Did the video change? | 'playlist_count': 1,
'skip': 'redirects to Young Reporter home page https://www.bbc.co.uk/news/topics/cg41ylwv43pt',
}, {
# single video with playlist URL from weather section
'url': 'http://www.bbc.com/weather/features/33601775',
'only_matching': True,
}, {
# cus... | @@ -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.143 | question | 48 | 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 |
if version_id:
title = smp_data['title']
formats, subtitles = self._download_media_selector(version_id)
image_url = smp_data.get('holdingImageURL')
display_date = init_data.get('displayDate')
topic_title = init_data.get('topicTi... | Note to self: Check if this can be simplified | if version_id:
title = smp_data['title']
formats, subtitles = self._download_media_selector(version_id)
image_url = smp_data.get('holdingImageURL')
display_date = init_data.get('displayDate')
topic_title = init_data.get('topicTi... | @@ -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.071 | 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 | pukkandan | kylegustavo |
'description': smp_data.get('summary') or init_data.get('shortSummary'),
'upload_date': display_date.replace('-', '') if display_date else None,
'subtitles': subtitles,
'duration': int_or_none(clip_data.get('duration')),
... | ```suggestion
'title': lead_media.get('title') or self._og_search_title(webpage),
``` | 'description': smp_data.get('summary') or init_data.get('shortSummary'),
'upload_date': display_date.replace('-', '') if display_date else None,
'subtitles': subtitles,
'duration': int_or_none(clip_data.get('duration')),
... | @@ -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.714 | suggestion | 107 | 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 |
return {
'id': version_id,
'title': title,
'formats': formats,
'alt_title': init_data.get('shortTitle'),
'thumbnail': image_url.replace('$recipe', 'raw') if image_url else None,
'desc... | ```suggestion
for lead_media in traverse_obj(morph_payload, (
'body', 'components', ..., 'props', 'leadMedia', {dict})):
programme_id = traverse_obj(lead_media, ('identifiers', ('vpid', 'playablePid'), {str}, any))
``` |
return {
'id': version_id,
'title': title,
'formats': formats,
'alt_title': init_data.get('shortTitle'),
'thumbnail': image_url.replace('$recipe', 'raw') if image_url else None,
'desc... | @@ -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.786 | suggestion | 270 | 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 |
contains_pattern=r'\{(?:(?!</script>)[\s\S])+?(?:"leadMedia"|\\"videoData\\")\s*:(?:(?!</script>)[\s\S])+\}',
default={})
if morph_payload:
for component in traverse_obj(morph_payload, (
'body', 'components', lambda _, v: v['props']['leadMedia']['identifie... | Why pase_json inside traverse_obj?
```suggestion
body = self._parse_json(traverse_obj(morph_payload, (
'body', 'content', 'article', 'body')), playlist_id, fatal=False)
``` | contains_pattern=r'{(?s:(?:(?!</script>).)+(?:"leadMedia"|\\"videoData\\")\s*:.+)}',
default={})
if morph_payload:
for lead_media in traverse_obj(morph_payload, (
'body', 'components', ..., 'props', 'leadMedia', {dict})):
programme_id = tra... | @@ -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.786 | question | 204 | 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 component in traverse_obj(morph_payload, (
'body', 'components', lambda _, v: v['props']['leadMedia']['identifiers'])):
lead_media = component['props']['leadMedia']
programme_id = traverse_obj(lead_media['identifiers'], 'vpid', 'playablePid', expected_... | ```suggestion
for video_data in traverse_obj(body, (lambda _, v: v['videoData']['pid'], 'videoData')):
if video_data.get('vpid'):
``` | for lead_media in traverse_obj(morph_payload, (
'body', 'components', ..., 'props', 'leadMedia', {dict})):
programme_id = traverse_obj(lead_media, ('identifiers', ('vpid', 'playablePid'), {str}, any))
if not programme_id:
continue
... | @@ -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.714 | suggestion | 164 | 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 |
'description': ('summary', {str}),
'duration': ('duration', ('rawDuration', 'formattedDuration', 'spokenDuration'), {parse_duration}),
'uploader': ('masterBrand', {str}),
'uploader_id': ('mid', {str}),
})... | ```suggestion
entry = self.url_result(
f'https://www.bbc.co.uk/programmes/{video_id}, BBCCoUkIE,
video_id, url_transparent=True)
``` | 'uploader': ('masterBrand', {str}),
'uploader_id': ('mid', {str}),
}),
'formats': formats,
'subtitles': subtitles,
}
body = self._parse_json(traverse_obj(morph_payload, (
... | @@ -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.786 | suggestion | 204 | 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 |
'body', 'content', 'article', 'body',
{lambda s: self._parse_json(s, playlist_id, fatal=False)}))
added = False
for video_data in traverse_obj(body, (Ellipsis, 'videoData', {lambda v: v.get('pid') and v})):
if video_data.get('vpid'):
... | * The indentation is confusing
* traverse_obj don't need merge_dicts. Just use `{**entry, **traverse_obj(` | if video_data.get('vpid'):
video_id = video_data['vpid']
formats, subtitles = self._download_media_selector(video_id)
entry = {
'id': video_id,
'formats': formats,
'subtitl... | @@ -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.571 | style | 107 | 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 |
video_id = video_data['vpid']
formats, subtitles = self._download_media_selector(video_id)
entry = {
'id': video_id,
'formats': formats,
'subtitles': subtitles,
}
... | ```suggestion
if entries:
```
Why do we needed a separate `added`? | 'formats': formats,
'subtitles': subtitles,
}
else:
video_id = video_data['pid']
entry = self.url_result(
f'https://www.bbc.co.uk/programmes/{video_id}', BBCCoUkIE,
... | @@ -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.571 | question | 81 | 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': ('dateTimeInfo', 'dateTime', {parse_iso8601}),
})), traverse_obj(video_data, {
'thumbnail': (('iChefImage', 'image'), {url_or_none}, any),
'title': (('title', 'caption'), {str}, any),
... | ```suggestion
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':
``` | 'duration': ('duration', {parse_duration}),
}),
})
if video_data.get('isLead') and not self._yes_playlist(playlist_id, video_id):
return entry
entries.append(entry)
if entries:
pla... | @@ -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.929 | suggestion | 260 | 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 |
article = traverse_obj(preload_state, (
'entities', 'articles', lambda _, v: v['assetVideo'][0] == asset_id, any))
def image_url(image_id):
return traverse_obj(preload_state, (
'entities', 'images', image_id, 'url',
... | ```suggestion
f'https://www.bbc.co.uk/programmes/{asset_id}', BBCCoUkIE,
``` | {lambda u: url_or_none(u.replace('$recipe', 'raw'))}))
formats, subtitles = self._download_media_selector(video_id)
return {
'id': video_id,
**traverse_obj(preload_state, ('entities', 'videos', asset_id, {
... | @@ -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.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 | pukkandan | kylegustavo |
payload, lambda x: x['content']['bbcMedia']['playlist'],
dict)
if bbc3_playlist:
playlist_title = bbc3_playlist.get('title') or playlist_title
thumbnail = bbc3_playlist.get('holdingImageURL')
entries = []
for bbc... | ```suggestion
"""Extract single video from model structure"""
``` | if not programme_id:
continue
formats, subtitles = self._download_media_selector(programme_id)
entries.append({
'id': programme_id,
'title': playlist_title,
'thumbn... | @@ -1191,6 +1279,28 @@ def _real_extract(self, url):
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
+ k_int_or_none = functools.partial(int_or_none, scale=1000)
+
+ def parse_model(model):
+ '''Extract single vide... | yt_dlp/extractor/bbc.py | 26 | Python | 0.643 | refactor | 79 | 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': timestamp,
'formats': formats,
'subtitles': subtitles,
})
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
k_int_or_none = functoo... | ```suggestion
'timestamp': ('versions', 0, 'availableFrom', {lambda x: int_or_none(x, scale=1000)}),
``` | """Extract single video from model structure"""
item_id = traverse_obj(model, ('versions', 0, 'versionId', {str}))
if not item_id:
return
formats, subtitles = self._download_media_selector(item_id)
return {
'id': item_id,
... | @@ -1191,6 +1279,28 @@ def _real_extract(self, url):
return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)
+ k_int_or_none = functools.partial(int_or_none, scale=1000)
+
+ def parse_model(model):
+ '''Extract single vide... | yt_dlp/extractor/bbc.py | 26 | Python | 0.714 | suggestion | 126 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.