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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
raise ExtractorError('Could not find asset_id nor program playlist nor podcast episodes')
return self.playlist_result([
self.url_result(episode['file'], url_transparent=True, **traverse_obj(episode, {
'title': 'title',
... | `traverse_obj(..., {})` always returns a dict
```suggestion
entries = [
self.url_result(
urljoin(url, episode['slug']), url_transparent=True,
**traverse_obj(season, {
'season': 'title',
'season_num... | raise ExtractorError('Could not find asset_id nor program playlist nor podcast episodes')
return self.playlist_result([
self.url_result(episode['file'], url_transparent=True, **traverse_obj(episode, {
'title': 'title',
... | @@ -0,0 +1,291 @@
+import re
+
+from .common import InfoExtractor, ExtractorError
+from ..utils import (
+ clean_html,
+ determine_ext,
+ int_or_none,
+ float_or_none,
+ js_to_json,
+ mimetype2ext,
+ traverse_obj,
+ urljoin,
+ url_or_none,
+)
+
+
+class RTVCPlayBaseIE(InfoExtractor):
+ _BA... | yt_dlp/extractor/rtvcplay.py | 26 | Python | 0.786 | suggestion | 746 | 51 | 51 | false | [extractors/rtvc] Add extractors | 6,578 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | elyse0 |
if not podcast_episodes:
raise ExtractorError('Could not find asset_id nor program playlist nor podcast episodes')
return self.playlist_result([
self.url_result(episode['file'], url_transparent=True, **traverse_obj(episode, {
... | ```suggestion
entries = [self.url_result(
urljoin(url, episode['slug']), url_transparent=True,
**traverse_obj(season, {
'season': 'title',
'season_number': ('season', {int_or_none}),
}), **traverse_obj(episode, {
... | if not podcast_episodes:
raise ExtractorError('Could not find asset_id nor program playlist nor podcast episodes')
return self.playlist_result([
self.url_result(episode['file'], url_transparent=True, **traverse_obj(episode, {
... | @@ -0,0 +1,290 @@
+import re
+
+from .common import InfoExtractor, ExtractorError
+from ..utils import (
+ clean_html,
+ determine_ext,
+ int_or_none,
+ float_or_none,
+ js_to_json,
+ mimetype2ext,
+ traverse_obj,
+ urljoin,
+ url_or_none,
+)
+
+
+class RTVCPlayBaseIE(InfoExtractor):
+ _BA... | yt_dlp/extractor/rtvcplay.py | 26 | Python | 0.786 | suggestion | 597 | 51 | 51 | false | [extractors/rtvc] Add extractors | 6,578 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | elyse0 |
from .common import InfoExtractor
from ..utils import traverse_obj, unified_timestamp
class EttuTvIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?ettu\.tv/[^?#]+/playerpage/(?P<id>[0-9]+)'
_TESTS = [{
'url': 'https://www.ettu.tv/en-int/playerpage/1573849',
'md5': '5874b7639a2aa866d1f6c3a... | if the other suggestions are applied:
```suggestion
from ..utils import bool_or_none, traverse_obj, unified_timestamp, url_or_none
``` | from .common import InfoExtractor
from ..utils import bool_or_none, traverse_obj, unified_timestamp, url_or_none
class EttuTvIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?ettu\.tv/[^?#]+/playerpage/(?P<id>[0-9]+)'
_TESTS = [{
'url': 'https://www.ettu.tv/en-int/playerpage/1573849',
'md5... | @@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import traverse_obj, unified_timestamp | yt_dlp/extractor/ettutv.py | 2 | Python | 0.714 | suggestion | 137 | 27 | 27 | false | [extractor/ettutv] Add extractor | 6,579 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | elyse0 |
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
player_settings = self._download_json(
f'https://www.ettu.tv/api/v3/contents/{video_id}/player-settings', video_id, query={
'language': 'en',
'showTitle': 'true',
... | ```suggestion
'thumbnail': ('image', {url_or_none}),
``` | },
}]
def _real_extract(self, url):
video_id = self._match_id(url)
player_settings = self._download_json(
f'https://www.ettu.tv/api/v3/contents/{video_id}/player-settings', video_id, query={
'language': 'en',
'showTitle': 'true',
... | @@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import traverse_obj, unified_timestamp
+
+
+class EttuTvIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?ettu\.tv/[^?#]+/playerpage/(?P<id>[0-9]+)'
+
+ _TESTS = [{
+ 'url': 'https://www.ettu.tv/en-int/playerpage/1573849',
+ 'md5... | yt_dlp/extractor/ettutv.py | 26 | Python | 0.571 | suggestion | 74 | 31 | 31 | false | [extractor/ettutv] Add extractor | 6,579 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | elyse0 |
def _real_extract(self, url):
video_id = self._match_id(url)
player_settings = self._download_json(
f'https://www.ettu.tv/api/v3/contents/{video_id}/player-settings', video_id, query={
'language': 'en',
'showTitle': 'true',
'device': 'des... | maybe we wanna do this to prevent false positives in case of strange input? what do you think
```suggestion
'is_live': ('isLivestream', {bool_or_none}),
``` |
def _real_extract(self, url):
video_id = self._match_id(url)
player_settings = self._download_json(
f'https://www.ettu.tv/api/v3/contents/{video_id}/player-settings', video_id, query={
'language': 'en',
'showTitle': 'true',
'device': 'des... | @@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import traverse_obj, unified_timestamp
+
+
+class EttuTvIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?ettu\.tv/[^?#]+/playerpage/(?P<id>[0-9]+)'
+
+ _TESTS = [{
+ 'url': 'https://www.ettu.tv/en-int/playerpage/1573849',
+ 'md5... | yt_dlp/extractor/ettutv.py | 26 | Python | 0.714 | suggestion | 175 | 29 | 29 | false | [extractor/ettutv] Add extractor | 6,579 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | elyse0 |
'info_dict': {
'id': '8946969',
'title': 'Karel Šiktanc: Černý jezdec, bílý kůň. Napínavá pohádka o tajemném přízraku',
},
'playlist_count': 1,
'playlist': [{
'info_dict': {
'id': '10631121',
'ext': 'm4a',
... | ```suggestion
audio_id = entry['meta']['ga']['contentId']
for audio in traverse_obj(entry, ('audioLinks', lambda _, v: url_or_none(v['url']))):
``` | 'info_dict': {
'id': '8946969',
'title': 'Karel Šiktanc: Černý jezdec, bílý kůň. Napínavá pohádka o tajemném přízraku',
},
'playlist_count': 1,
'playlist': [{
'info_dict': {
'id': '10631121',
'ext': 'm4a',
... | @@ -139,27 +146,65 @@ class RozhlasVltavaIE(InfoExtractor):
'chapter_number': 5,
},
}]
+ }, {
+ 'url': 'https://dvojka.rozhlas.cz/karel-siktanc-cerny-jezdec-bily-kun-napinava-pohadka-o-tajemnem-prizraku-8946969',
+ 'info_dict': {
+ 'id': '8946969',
+ ... | yt_dlp/extractor/rozhlas.py | 26 | Python | 0.714 | suggestion | 166 | 51 | 51 | false | [extractor/rozhlas] Extract manifest formats | 6,590 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'uploader_id': '@TEDEd',
'uploader_url': 'http://www.youtube.com/@TEDEd',
'duration': 344,
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb1... | instead of parsing JSON LD with regex, we could do this:
```suggestion
embed_url = traverse_obj(list(self._yield_json_ld(webpage, video_id)), (
lambda _, v: v['@type'] == 'VideoObject', 'embedUrl', {url_or_none}), get_all=False)
if not embed_url:
self.raise_no_formats('No em... | 'uploader_id': '@TEDEd',
'uploader_url': 'https://www.youtube.com/@TEDEd',
'duration': 344,
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb... | @@ -30,11 +31,41 @@ class AeonCoIE(InfoExtractor):
'uploader_url': 'https://vimeo.com/user140352216',
'duration': 1344
}
+ }, {
+ 'url': 'https://aeon.co/videos/chew-over-the-prisoners-dilemma-and-see-if-you-can-find-the-rational-path-out',
+ 'md5': '1cfda0bf3ae24df17... | yt_dlp/extractor/aeonco.py | 26 | Python | 1 | suggestion | 394 | 30 | 33 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alexklapheke |
'duration': 344,
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
'categories': ['Education'],
'like_count': int,
'channel... | `get_domain` won't work with `player.vimeo.com` embed URLs
```py
def get_domain(url):
"""
This implementation is inconsistent, but is kept for compatibility.
Use this only for "webpage_url_domain"
"""
return remove_start(urllib.parse.urlparse(url).netloc, 'www.') or None
```
instead we coul... | 'duration': 344,
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
'categories': ['Education'],
'like_count': int,
'channel... | @@ -30,11 +31,41 @@ class AeonCoIE(InfoExtractor):
'uploader_url': 'https://vimeo.com/user140352216',
'duration': 1344
}
+ }, {
+ 'url': 'https://aeon.co/videos/chew-over-the-prisoners-dilemma-and-see-if-you-can-find-the-rational-path-out',
+ 'md5': '1cfda0bf3ae24df17... | yt_dlp/extractor/aeonco.py | 26 | Python | 0.857 | suggestion | 513 | 28 | 31 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alexklapheke |
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
'categories': ['Education'],
'like_count': int,
'channel': 'TED-Ed',
'cha... | on second thought this should raise ExtractorError
```suggestion
raise ExtractorError('No embed URL found in webpage')
``` | 'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
'categories': ['Education'],
'like_count': int,
'channel': 'TED-Ed',
'cha... | @@ -19,22 +20,55 @@ class AeonCoIE(InfoExtractor):
}
}, {
'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
- 'md5': '4e5f3dad9dbda0dbfa2da41a851e631e',
+ 'md5': '03582d795382e49f2fd0b427b55de409',
'info_dict': {
-... | yt_dlp/extractor/aeonco.py | 26 | Python | 0.929 | refactor | 137 | 30 | 30 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alexklapheke |
from .common import InfoExtractor
from .vimeo import VimeoIE
from ..utils import traverse_obj, url_or_none
class AeonCoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?aeon\.co/videos/(?P<id>[^/?]+)'
_TESTS = [{
'url': 'https://aeon.co/videos/raw-solar-storm-footage-is-the-punk-rock-antidote-to-sl... | ```suggestion
from ..utils import ExtractorError, traverse_obj, url_or_none
``` | from .common import InfoExtractor
from .vimeo import VimeoIE
from ..utils import ExtractorError, traverse_obj, url_or_none
class AeonCoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?aeon\.co/videos/(?P<id>[^/?]+)'
_TESTS = [{
'url': 'https://aeon.co/videos/raw-solar-storm-footage-is-the-punk-roc... | @@ -1,5 +1,6 @@
from .common import InfoExtractor
from .vimeo import VimeoIE
+from ..utils import traverse_obj, url_or_none | yt_dlp/extractor/aeonco.py | 3 | Python | 0.786 | refactor | 81 | 28 | 28 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alexklapheke |
'thumbnail': 'https://i.vimeocdn.com/video/1525599692-84614af88e446612f49ca966cf8f80eab2c73376bedd80555741c521c26f9a3e-d_1280',
'uploader': 'Aeon Video',
'uploader_id': 'aeonvideo',
'uploader_url': 'https://vimeo.com/aeonvideo',
'duration': 1344
}
... | ```suggestion
'chapters': 'count:7',
``` | 'thumbnail': 'https://i.vimeocdn.com/video/1525599692-84614af88e446612f49ca966cf8f80eab2c73376bedd80555741c521c26f9a3e-d_1280',
'uploader': 'Aeon Video',
'uploader_id': 'aeonvideo',
'uploader_url': 'https://vimeo.com/aeonvideo',
'duration': 1344
}
... | @@ -19,22 +20,55 @@ class AeonCoIE(InfoExtractor):
}
}, {
'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
- 'md5': '4e5f3dad9dbda0dbfa2da41a851e631e',
+ 'md5': '03582d795382e49f2fd0b427b55de409',
'info_dict': {
-... | yt_dlp/extractor/aeonco.py | 26 | Python | 0.571 | suggestion | 54 | 48 | 48 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alexklapheke |
'uploader_id': '@TEDEd',
'uploader_url': 'http://www.youtube.com/@TEDEd',
'duration': 344,
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb1... | ```suggestion
embed_url = traverse_obj(self._yield_json_ld(webpage, video_id), (
``` | 'uploader_id': '@TEDEd',
'uploader_url': 'https://www.youtube.com/@TEDEd',
'duration': 344,
'upload_date': '20200827',
'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
'playable_in_embed': True,
'description': 'md5:c0959524f08cb60f96fd010f3dfb... | @@ -19,22 +20,55 @@ class AeonCoIE(InfoExtractor):
}
}, {
'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
- 'md5': '4e5f3dad9dbda0dbfa2da41a851e631e',
+ 'md5': '03582d795382e49f2fd0b427b55de409',
'info_dict': {
-... | yt_dlp/extractor/aeonco.py | 26 | Python | 0.571 | suggestion | 94 | 33 | 33 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alexklapheke |
'duration': 348
}
}, {
'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
'md5': '03582d795382e49f2fd0b427b55de409',
'info_dict': {
'id': '759576926',
'ext': 'mp4',
'title': 'Wr... | fix test
```suggestion
'uploader_url': 'https://www.youtube.com/@TEDEd',
``` | 'duration': 348
}
}, {
'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
'md5': '03582d795382e49f2fd0b427b55de409',
'info_dict': {
'id': '759576926',
'ext': 'mp4',
'title': 'Wr... | @@ -19,22 +20,55 @@ class AeonCoIE(InfoExtractor):
}
}, {
'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
- 'md5': '4e5f3dad9dbda0dbfa2da41a851e631e',
+ 'md5': '03582d795382e49f2fd0b427b55de409',
'info_dict': {
-... | yt_dlp/extractor/aeonco.py | 26 | Python | 0.571 | suggestion | 91 | 51 | 51 | false | [AeonCo] Add support for YouTube embeds | 6,591 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alexklapheke |
'ext': 'mp4',
'title': 'Just Out Of The Shower JOI - Shooshtime',
'thumbnail': 'https://i.shoosh.co/contents/videos_screenshots/284000/284002/preview.mp4.jpg',
'height': 720,
'age_limit': 18,
},
},
]
def report_... | ```py
fragment_query = self._configuration_arg('fragment_query', [None], casesense=True)[0]
if fragment_query is not None:
``` | 'ext': 'mp4',
'title': 'Just Out Of The Shower JOI - Shooshtime',
'thumbnail': 'https://i.shoosh.co/contents/videos_screenshots/284000/284002/preview.mp4.jpg',
'height': 720,
'age_limit': 18,
},
},
]
def report_... | @@ -2188,17 +2187,21 @@ def report_detected(self, name, num=1, note=None):
def _extra_manifest_info(self, info, manifest_url):
if self._configuration_arg('fragment_query'):
- query_string = urllib.parse.urlparse(manifest_url).query
- if query_string:
- info['extra_pa... | yt_dlp/extractor/generic.py | 26 | Python | 0.714 | suggestion | 145 | 51 | 51 | false | [extractor/generic] Accept values for `fragment_query`, `variant_query` | 6,600 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'uploader': 'SHOWTIME',
'uploader_id': '@Showtime',
'uploader_url': 'http://www.youtube.com/@Showtime',
'channel': 'SHOWTIME',
'channel_id': 'UCtwMWJr2BFPkuJTnSvCESSQ',
'channel_url': 'https://www.youtube.com/channel/UCtwMWJr2BFPkuJTnSvCESSQ',
... | ```suggestion
return self.url_result(display_id, YoutubeIE)
```
same for brightcove | 'title': 'Lavell Crawford: THEE Lavell Crawford Comedy Special Official Trailer | SHOWTIME',
'description': 'md5:39581bcc3fd810209b642609f448af70',
'uploader': 'SHOWTIME',
'uploader_id': '@Showtime',
'uploader_url': 'http://www.youtube.com/@Showtime',
... | @@ -162,3 +166,110 @@ def _extract_video_info(self, content_id, site='cbs', mpx_acc=2198311517):
'duration': int_or_none(xpath_text(video_data, 'videoLength'), 1000),
'thumbnail': url_or_none(xpath_text(video_data, 'previewImageURL')),
})
+
+
+class ParamountPressExpressIE(InfoExtract... | yt_dlp/extractor/cbs.py | 26 | Python | 0.571 | suggestion | 98 | 41 | 43 | false | [extractor/cbs] Add `ParamountPressExpress` extractor | 6,604 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
webpage = self._download_webpage(url, display_id)
data = extract_attributes(get_element_html_by_class('vlanding-video-card__link', webpage) or '')
video_id = data['data-video-showcase-trigger']
showcase_type = data['data-video-showcase-type']
if showcase_type == 'jwplayer':
... | Does each page have a fixed amount of videos? If so, this can be a pagedlist. Otherwise, looks good to merge. | display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
data = extract_attributes(get_element_html_by_class('vlanding-video-card__link', webpage) or '')
video_id = data['data-video-showcase-trigger']
showcase_type = data['data-video-showcase-type']
... | @@ -0,0 +1,74 @@
+import itertools
+import re
+
+from .common import InfoExtractor
+from .jwplatform import JWPlatformIE
+from ..utils import (
+ ExtractorError,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+)
+
+
+class HollywoodReporterIE(InfoExtractor):
+ _VALID_URL = r'h... | yt_dlp/extractor/hollywoodreporter.py | 26 | Python | 0.357 | suggestion | 109 | 43 | 41 | false | [extractor/hollywoodreporter] Add extractors | 6,614 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
known_resolutions = {}
def extract_addr(addr, add_meta={}):
parsed_meta, res = parse_url_key(addr.get('url_key', ''))
if res:
known_resolutions.setdefault(res, {}).setdefault('height', add_meta.get('height'))
known_resolutions[res].setdefault('wid... | Looks ugly inline imo. Maybe it should be a function. But feel free to ignore if u disagree | known_resolutions = {}
def mp3_meta(url):
return {
'format_note': 'Music track',
'ext': 'mp3',
'acodec': 'mp3',
'vcodec': 'none',
'width': None,
'height': None,
} if determine_ext(url... | @@ -219,7 +220,15 @@ def extract_addr(addr, add_meta={}):
'source_preference': -2 if 'aweme/v1' in url else -1, # Downloads from API might get blocked
**add_meta, **parsed_meta,
'format_note': join_nonempty(
- add_meta.get('format_note'), '(API)' if... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.286 | suggestion | 91 | 51 | 51 | false | [extractor/tiktok] Fix slideshow mp3 formats | 6,615 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
self.assertEqual(json.loads(on), {'42': 42.0})
on = js_to_json('{ "0x40": "0x40" }')
self.assertEqual(json.loads(on), {'0x40': '0x40'})
on = js_to_json('{ "040": "040" }')
self.assertEqual(json.loads(on), {'040': '040'})
on = js_to_json('[1,//{},\n2]')
self.ass... | Add a test like this too
```py
self.assertEqual(js_to_json('`${name}`', {}), '${name}')
``` | self.assertEqual(json.loads(on), {'42': 42.0})
on = js_to_json('{ "0x40": "0x40" }')
self.assertEqual(json.loads(on), {'0x40': '0x40'})
on = js_to_json('{ "040": "040" }')
self.assertEqual(json.loads(on), {'040': '040'})
on = js_to_json('[1,//{},\n2]')
self.ass... | @@ -1190,6 +1190,12 @@ def test_js_to_json_malformed(self):
self.assertEqual(js_to_json('42a1'), '42"a1"')
self.assertEqual(js_to_json('42a-1'), '42"a"-1')
+ def test_js_to_json_template_literal(self):
+ self.assertEqual(js_to_json('`Hello ${name}`', {'name': '"world"'}), '"Hello world"')
... | test/test_utils.py | 26 | Python | 0.714 | suggestion | 104 | 51 | 51 | false | [utils] `js_to_json`: Implement template strings | 6,623 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
from .common import InfoExtractor
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': {
'id': 'release1',
... | ```suggestion
playlist_id, playlist_type = self._match_valid_url(url).group('id', 'type')
``` | from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import traverse_obj
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stoc... | @@ -0,0 +1,36 @@
+from .common import InfoExtractor
+
+
+class DiscogsReleasePlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
+ 'info_dict': {
+ ... | yt_dlp/extractor/discogs.py | 24 | Python | 0.857 | suggestion | 103 | 37 | 36 | false | [extractor/discogs] Add extractor | 6,624 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rjy |
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': {
'id': 'release1',
'title': 'Stockholm',
... | ```suggestion
display_id = f'{playlist_type}{playlist_id}'
response = self._download_json(
f'https://api.discogs.com/{playlist_type}s/{playlist_id}', display_id)
``` | from ..utils import traverse_obj
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': {
'id': 'release1',
... | @@ -0,0 +1,36 @@
+from .common import InfoExtractor
+
+
+class DiscogsReleasePlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
+ 'info_dict': {
+ ... | yt_dlp/extractor/discogs.py | 26 | Python | 0.857 | suggestion | 197 | 35 | 34 | false | [extractor/discogs] Add extractor | 6,624 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rjy |
},
'playlist_mincount': 7,
}, {
'url': 'https://www.discogs.com/master/113-Vince-Watson-Moments-In-Time',
'info_dict': {
'id': 'master113',
'title': 'Moments In Time',
},
'playlist_mincount': 53,
}]
def _real_extract(self, url):
... | This traversal filter would ensure we only try to loop through a list, and if the list is not empty, `video` will always be a dict with a `uri` key.
(you'll need to import `traverse_obj`)
```suggestion
entries = [
self.url_result(video['uri'], video_title=video.get('title'))
for v... | 'id': 'release1',
'title': 'Stockholm',
},
'playlist_mincount': 7,
}, {
'url': 'https://www.discogs.com/master/113-Vince-Watson-Moments-In-Time',
'info_dict': {
'id': 'master113',
'title': 'Moments In Time',
},
'playlist... | @@ -0,0 +1,36 @@
+from .common import InfoExtractor
+
+
+class DiscogsReleasePlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
+ 'info_dict': {
+ ... | yt_dlp/extractor/discogs.py | 26 | Python | 0.786 | suggestion | 474 | 27 | 26 | false | [extractor/discogs] Add extractor | 6,624 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rjy |
from .common import InfoExtractor
from ..utils import traverse_obj
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': ... | ```suggestion
from .common import InfoExtractor
from .youtube import YoutubeIE
``` | from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import traverse_obj
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stoc... | @@ -0,0 +1,34 @@
+from .common import InfoExtractor | yt_dlp/extractor/discogs.py | 1 | Python | 0.643 | refactor | 85 | 26 | 26 | false | [extractor/discogs] Add extractor | 6,624 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rjy |
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': {
'id': 'release1',
'title': 'Stockholm',
},
'playlist_mincount': 7,
}, {
'url': 'https://www.discogs.com/master/113-Vince-Watson-Moments-In-Time',
... | ```suggestion
entries = [
self.url_result(video['uri'], YoutubeIE, video_title=video.get('title'))
for video in traverse_obj(response, ('videos', lambda _, v: YoutubeIE.suitable(v['uri'])))]
``` | _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm',
'info_dict': {
'id': 'release1',
'title': 'Stockholm',
},
'playlist_mincount': 7,
}, {
... | @@ -0,0 +1,34 @@
+from .common import InfoExtractor
+from ..utils import traverse_obj
+
+
+class DiscogsReleasePlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.discogs.com/release/1-The-Persuader-Stockhol... | yt_dlp/extractor/discogs.py | 26 | Python | 0.786 | suggestion | 230 | 29 | 30 | false | [extractor/discogs] Add extractor | 6,624 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rjy |
from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import traverse_obj
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-St... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
``` | from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import traverse_obj
class DiscogsReleasePlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.discogs.com/release/1-The-Persuader-Stoc... | @@ -0,0 +1,35 @@
+from .common import InfoExtractor
+from .youtube import YoutubeIE
+from ..utils import traverse_obj
+
+
+class DiscogsReleasePlaylistIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>(release|master))/(?P<id>\d+)' | yt_dlp/extractor/discogs.py | 7 | Python | 0.857 | suggestion | 108 | 32 | 32 | false | [extractor/discogs] Add extractor | 6,624 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | rjy |
import re
import json
import base64
import time
from .common import InfoExtractor
from ..compat import (
compat_str,
)
from ..utils import (
int_or_none,
join_nonempty,
js_to_json,
orderedSet,
smuggle_url,
strip_or_none,
try_get,
ExtractorError,
get_element_by_id,
parse_iso8... | these could be sorted after adding/removing what we need/don't | import re
import json
import base64
import time
from .common import InfoExtractor
from ..compat import (
compat_str,
)
from ..utils import (
ExtractorError,
int_or_none,
join_nonempty,
js_to_json,
orderedSet,
parse_iso8601,
smuggle_url,
strip_or_none,
traverse_obj,
try_get,
... | @@ -16,6 +16,8 @@
strip_or_none,
try_get,
ExtractorError,
+ get_element_by_id,
+ parse_iso8601
) | yt_dlp/extractor/cbc.py | 21 | Python | 0.286 | suggestion | 62 | 46 | 46 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
}
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
_VALID_URL = r'https?://gem\.cbc\.ca/live(?:-event)?/(?P<id>\d+)'
_TEST = {
'url': 'https://gem.cbc.ca/live/920604739687',
'info_dict': {
'title': 'Ottawa',
'description': 'The live TV channel ... | ```suggestion
video_info = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['data']
``` | 'series': show_info.get('title'),
'season_number': season_info.get('season'),
'season': season_info['title'],
}
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
_VALID_URL = r'https?://gem\.cbc\.ca/live(?:-event)?/(?P<id>\d+)'
_TESTS = [
{
... | @@ -490,32 +492,32 @@ class CBCGemLiveIE(InfoExtractor):
'skip': 'Live might have ended',
}
- # It's unclear where the chars at the end come from, but they appear to be
- # constant. Might need updating in the future.
- # There are two URLs, some livestreams are in one, and some
- # in the o... | yt_dlp/extractor/cbc.py | 26 | Python | 0.714 | suggestion | 114 | 51 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
import re
import json
import base64
import time
from .common import InfoExtractor
from ..compat import (
compat_str,
)
from ..utils import (
int_or_none,
join_nonempty,
js_to_json,
orderedSet,
smuggle_url,
strip_or_none,
try_get,
ExtractorError,
get_element_by_id,
parse_iso8... | import `traverse_obj`
```py
if not video_info.get('formattedIdMedia'):
video_info = traverse_obj(
video_info, ('freeTv', 'items', lambda _, v: v['key'] == video_id, {dict}),
get_all=False, default={})
``` | },
{
'url': 'https://gem.cbc.ca/live-event/10835',
'info_dict': {
'id': '10835',
'ext': 'mp4',
'is_live': True,
'title': r're:^The National \| Biden’s trip wraps up, Paltrow testifies, Bird flu [0-9\-: ]+',
... | @@ -490,32 +492,32 @@ class CBCGemLiveIE(InfoExtractor):
'skip': 'Live might have ended',
}
- # It's unclear where the chars at the end come from, but they appear to be
- # constant. Might need updating in the future.
- # There are two URLs, some livestreams are in one, and some
- # in the o... | yt_dlp/extractor/cbc.py | 26 | Python | 0.786 | style | 258 | 524 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
'ext': 'mp4',
'timestamp': 1492106160,
'upload_date': '20170413',
'uploader': 'CBCC-NEW',
},
'skip': 'Live might have ended',
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, vide... | ```suggestion
stream_data = self._download_json(
'https://services.radio-canada.ca/media/validation/v2/', video_id, query={
'appCode': 'mpx',
'connectionType': 'hd',
'deviceType': 'ipad',
'idMedia': video_stream_id,
... | 'description': 'The live TV channel and local programming from Ottawa',
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/CBC_OTT_VMS/Live_Channel_Static_Images/Ottawa_2880x1620.jpg',
'is_live': True,
'id': 'AyqZwxRqh8EH',
'ex... | @@ -490,32 +492,32 @@ class CBCGemLiveIE(InfoExtractor):
'skip': 'Live might have ended',
}
- # It's unclear where the chars at the end come from, but they appear to be
- # constant. Might need updating in the future.
- # There are two URLs, some livestreams are in one, and some
- # in the o... | yt_dlp/extractor/cbc.py | 26 | Python | 0.929 | suggestion | 478 | 38 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
'skip': 'Live might have ended',
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
video_info = json.loads(get_element_by_id('__NEXT_DATA__', webpage))['props']['pageProps']['data']
# Two types of metadata JSO... | why return a `url_transparent` info_dict to `Generic`?
we can extract m3u8 formats in this extractor, yeah?
`traverse_obj` can also be used to make this cleaner:
```py
return {
'id': video_id,
'formats': self._extract_m3u8_formats(stream_data['url'], video_id, 'mp4', live=True),
... | 'timestamp': 1492106160,
'upload_date': '20170413',
'uploader': 'CBCC-NEW',
},
'skip': 'Live might have ended',
},
{
'url': 'https://gem.cbc.ca/live/44',
'info_dict': {
'id': '44',
... | @@ -490,32 +492,32 @@ class CBCGemLiveIE(InfoExtractor):
'skip': 'Live might have ended',
}
- # It's unclear where the chars at the end come from, but they appear to be
- # constant. Might need updating in the future.
- # There are two URLs, some livestreams are in one, and some
- # in the o... | yt_dlp/extractor/cbc.py | 26 | Python | 0.857 | refactor | 623 | 33 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
if not video_info.get('formattedIdMedia'):
video_info = traverse_obj(
video_info, ('freeTv', 'items', lambda _, v: v['key'] == video_id, {dict}),
get_all=False, default={})
video_stream_id = video_info.get('formattedIdMedia')
if not video_stream_id:
... | an `id` needs to be returned, use the video_id. traversal is non-fatal and may not return a value for `id`
```suggestion
'id': video_id,
'formats': self._extract_m3u8_formats(stream_data['url'], video_id, 'mp4', live=True),
'is_live': True,
**traverse_obj(video_info,... | video_info = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['data']
# Two types of metadata JSON
if not video_info.get('formattedIdMedia'):
video_info = traverse_obj(
video_info, (('freeTv', ('streams', ...)), 'items', lambda _, v: v['key'] == vide... | @@ -473,49 +475,90 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.857 | refactor | 327 | 33 | 36 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
},
'params': {'skip_download': True},
'skip': 'Live might have ended',
},
{
'url': 'https://gem.cbc.ca/live-event/10835',
'info_dict': {
'id': 'live-event/10835',
'ext': 'mp4',
'is_live': True,
... | ```suggestion
video_id, video_key = self._match_valid_url(url).group('id', 'key')
``` | 'description': 'The live TV channel and local programming from Ottawa',
'live_status': 'is_live',
'thumbnail': r're:https://images.gem.cbc.ca/v1/cbc-gem/live/.*'
},
'params': {'skip_download': True},
'skip': 'Live might have ended',
... | @@ -473,49 +475,92 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.571 | suggestion | 95 | 51 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
'skip': 'Live might have ended',
},
{
'url': 'https://gem.cbc.ca/live-event/10835',
'info_dict': {
'id': 'live-event/10835',
'ext': 'mp4',
'is_live': True,
'title': r're:^The National \| Biden’s trip wrap... | these were better with video_id imo, then output will show the actual video id
```suggestion
webpage = self._download_webpage(url, video_id)
video_info = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['data']
``` | 'thumbnail': r're:https://images.gem.cbc.ca/v1/cbc-gem/live/.*'
},
'params': {'skip_download': True},
'skip': 'Live might have ended',
},
{
'url': 'https://gem.cbc.ca/live-event/10835',
'info_dict': {
'id': '1083... | @@ -473,49 +475,92 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.857 | suggestion | 251 | 51 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
'upload_date': '20230325',
},
'params': {'skip_download': True},
'skip': 'Live might have ended',
}
]
def _real_extract(self, url):
match = self._match_valid_url(url)
video_id = match.group('id')
video_key = match.group('key')
... | same as above
```suggestion
'https://services.radio-canada.ca/media/validation/v2/', video_id, query={
``` | 'live_status': 'is_live',
'thumbnail': r're:https://images.gem.cbc.ca/v1/cbc-gem/live/.*',
'timestamp': 1679706000,
'upload_date': '20230325',
},
'params': {'skip_download': True},
'skip': 'Live might have ended',
... | @@ -473,49 +475,92 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.714 | suggestion | 121 | 48 | 49 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
# Two types of metadata JSON
if not video_info.get('formattedIdMedia'):
video_info = traverse_obj(
video_info, ('freeTv', 'items', lambda _, v: v['key'] == video_key, {dict}),
get_all=False, default={})
video_stream_id = video_info.get('formattedIdMe... | ```suggestion
'formats': self._extract_m3u8_formats(stream_data['url'], video_id, 'mp4', live=True),
``` | video_info = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['data']
# Two types of metadata JSON
if not video_info.get('formattedIdMedia'):
video_info = traverse_obj(
video_info, (('freeTv', ('streams', ...)), 'items', lambda _, v: v['key'] == vide... | @@ -473,49 +475,92 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.786 | refactor | 118 | 35 | 36 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
})
thumbnail = None
tn_uri = season_info.get('image')
# the-national was observed to use a "data:image/png;base64"
# URI for their 'image' value. The image was 1x1, and is
# probably just a placeholder, so it is ignored.
if tn_uri is not None and not tn_uri.s... | 1. Why do you need to change id? Are there live and event with same id? Even then, id of `live/` doesn't need changing.
1. When changing `video_id` of an existing extractor, `_old_archive_ids` must be implemented.
1. id must not contain `/` | 'episode_id': episode['id'],
'duration': episode.get('duration'),
'categories': [episode.get('category')],
})
thumbnail = None
tn_uri = season_info.get('image')
# the-national was observed to use a "data:image/png;base64"
# URI... | @@ -473,49 +475,92 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.643 | refactor | 243 | 51 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | makew0rld |
'title': r're:^The National \| Biden’s trip wraps up, Paltrow testifies, Bird flu [0-9\-: ]+',
'description': 'March 24, 2023 | President Biden’s Ottawa visit ends with big pledges from both countries. Plus, Gwyneth Paltrow testifies in her ski collision trial.',
'live_st... | ```suggestion
video_info = traverse_obj(
video_info, (('freeTv', ('streams', ...)), 'items', lambda _, v: v['key'] == video_id, {dict}),
get_all=False, default={})
``` | 'id': '10835',
'ext': 'mp4',
'is_live': True,
'title': r're:^The National \| Biden’s trip wraps up, Paltrow testifies, Bird flu [0-9\-: ]+',
'description': 'March 24, 2023 | President Biden’s Ottawa visit ends with big pledges from both cou... | @@ -473,49 +475,94 @@ def _real_extract(self, url):
class CBCGemLiveIE(InfoExtractor):
IE_NAME = 'gem.cbc.ca:live'
- _VALID_URL = r'https?://gem\.cbc\.ca/live/(?P<id>\d+)'
- _TEST = {
- 'url': 'https://gem.cbc.ca/live/920604739687',
- 'info_dict': {
- 'title': 'Ottawa',
- ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.786 | suggestion | 215 | 51 | 51 | false | [extractor/cbc] Fix livestream downloading and playlist URL regex | 6,625 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | makew0rld |
if start_time is None or duration is None:
self.report_warning(f'Important chapter information missing for chapter {name}', item_id)
continue
yield {
'start_time': start_time,
'end_time': start_time + duration,
'tit... | This is not what I had meant. I was asking only to return 0x0 along with whatever we extract. But this is fine too, assuming all these thumbs are available for all the videos. is it? | if game:
yield {'title': game}
return
for moment in info['moments']:
start_time = int_or_none(moment.get('positionMilliseconds'), 1000)
duration = int_or_none(moment.get('durationMilliseconds'), 1000)
name = str_or_none(moment.get('des... | @@ -455,20 +455,28 @@ def _extract_info_gql(self, info, item_id):
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailURL'))
is_live = None
+ thumbnails = None
if thumbnail:
if re.findall(r'/404_processing_[^.?#]+\.png', thumbnail):
- ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.429 | refactor | 182 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | JC-Chung |
if game:
yield {'title': game}
return
for moment in info['moments']:
start_time = int_or_none(moment.get('positionMilliseconds'), 1000)
duration = int_or_none(moment.get('durationMilliseconds'), 1000)
name = str_or_none(moment.get('des... | we can revert most of the changes in this class and then inline the new method in the return
```suggestion
``` | if game:
yield {'title': game}
return
for moment in info['moments']:
start_time = int_or_none(moment.get('positionMilliseconds'), 1000)
duration = int_or_none(moment.get('durationMilliseconds'), 1000)
name = str_or_none(moment.get('des... | @@ -455,20 +463,22 @@ def _extract_info_gql(self, info, item_id):
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailURL'))
is_live = None
+ thumbnails = None | yt_dlp/extractor/twitch.py | 26 | Python | 0.786 | suggestion | 112 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
for moment in info['moments']:
start_time = int_or_none(moment.get('positionMilliseconds'), 1000)
duration = int_or_none(moment.get('durationMilliseconds'), 1000)
name = str_or_none(moment.get('description'))
if start_time is None or duration is None:
... | ```suggestion
is_live, thumbnail = True, None
``` |
for moment in info['moments']:
start_time = int_or_none(moment.get('positionMilliseconds'), 1000)
duration = int_or_none(moment.get('durationMilliseconds'), 1000)
name = str_or_none(moment.get('description'))
if start_time is None or duration is None:
... | @@ -455,20 +463,22 @@ def _extract_info_gql(self, info, item_id):
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailURL'))
is_live = None
+ thumbnails = None
if thumbnail:
if re.findall(r'/404_processing_[^.?#]+\.png', thumbnail):
- ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.571 | suggestion | 67 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
if start_time is None or duration is None:
self.report_warning(f'Important chapter information missing for chapter {name}', item_id)
continue
yield {
'start_time': start_time,
'end_time': start_time + duration,
'tit... | not reverting here; we just want to get rid of this. the commented code is very old and no longer applicable
```suggestion
``` |
if start_time is None or duration is None:
self.report_warning(f'Important chapter information missing for chapter {name}', item_id)
continue
yield {
'start_time': start_time,
'end_time': start_time + duration,
'tit... | @@ -455,20 +463,22 @@ def _extract_info_gql(self, info, item_id):
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailURL'))
is_live = None
+ thumbnails = None
if thumbnail:
if re.findall(r'/404_processing_[^.?#]+\.png', thumbnail):
- ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.714 | suggestion | 128 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
'title': name,
}
def _extract_info_gql(self, info, item_id):
vod_id = info.get('id') or item_id
# id backward compatibility for download archives
if vod_id[0] != 'v':
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailUR... | ```suggestion
'thumbnails': self._get_thumbnails(thumbnail),
``` | 'title': name,
}
def _extract_info_gql(self, info, item_id):
vod_id = info.get('id') or item_id
# id backward compatibility for download archives
if vod_id[0] != 'v':
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailUR... | @@ -455,20 +463,22 @@ def _extract_info_gql(self, info, item_id):
vod_id = 'v%s' % vod_id
thumbnail = url_or_none(info.get('previewThumbnailURL'))
is_live = None
+ thumbnails = None
if thumbnail:
if re.findall(r'/404_processing_[^.?#]+\.png', thumbnail):
- ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.571 | suggestion | 78 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
'allow_audio_only': 'true',
'allow_spectre': 'true',
'p': random.randint(1000000, 10000000),
'player': 'twitchweb',
'playlist_include_framerate': 'true',
'segment_preference': '4',
'sig': access_token['signature'].encode('utf-8'),
... | same as the other class, we can inline in the return
```suggestion
``` | 'playlist_include_framerate': 'true',
'segment_preference': '4',
'sig': access_token['signature'].encode('utf-8'),
'token': token.encode('utf-8'),
}
formats = self._extract_m3u8_formats(
'%s/api/channel/hls/%s.m3u8' % (self._USHER_BASE, channel... | @@ -1042,6 +1052,7 @@ def _real_extract(self, url):
thumbnail = url_or_none(try_get(
gql, lambda x: x[2]['data']['user']['stream']['previewImageURL'],
compat_str))
+ thumbnails = self._get_thumbnails(thumbnail) | yt_dlp/extractor/twitch.py | 26 | Python | 0.571 | suggestion | 72 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
self._prefer_source(formats)
view_count = stream.get('viewers')
timestamp = unified_timestamp(stream.get('createdAt'))
sq_user = try_get(gql, lambda x: x[1]['data']['user'], dict) or {}
uploader = sq_user.get('displayName')
description = try_get(
sq_user, la... | ```suggestion
'thumbnails': self._get_thumbnails(thumbnail),
``` |
sq_user = try_get(gql, lambda x: x[1]['data']['user'], dict) or {}
uploader = sq_user.get('displayName')
description = try_get(
sq_user, lambda x: x['broadcastSettings']['title'], compat_str)
thumbnail = url_or_none(try_get(
gql, lambda x: x[2]['data']['user']['... | @@ -1053,7 +1064,7 @@ def _real_extract(self, url):
'display_id': channel_name,
'title': title,
'description': description,
- 'thumbnail': thumbnail,
+ 'thumbnails': thumbnails, | yt_dlp/extractor/twitch.py | 26 | Python | 0.571 | suggestion | 78 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
def _download_access_token(self, video_id, token_kind, param_name):
method = '%sPlaybackAccessToken' % token_kind
ops = {
'query': '''{
%s(
%s: "%s",
params: {
platform: "web",
playerBackend: "mediaplayer"... | This causes problems with custom VOD thumbnails, since they do not have to be JPEGs, as such a more flexible RegEx should be used.
**Example:**
```py
'url': re.sub(r'\d+x\d+\.(jpg|jpeg|png|gif|webp)', '0x0.\g<1>', thumbnail),
```
> This would also be more future-proof in-case Twitch changes their thumbnail ext... |
def _download_access_token(self, video_id, token_kind, param_name):
method = '%sPlaybackAccessToken' % token_kind
ops = {
'query': '''{
%s(
%s: "%s",
params: {
platform: "web",
playerBackend: "mediaplayer"... | @@ -179,6 +179,14 @@ def _download_access_token(self, video_id, token_kind, param_name):
video_id, ops,
'Downloading %s access token GraphQL' % token_kind)['data'][method]
+ def _get_thumbnails(self, thumbnail):
+ return [{
+ 'url': re.sub(r'\d+x\d+\.jpg', '0x0.jpg', thu... | yt_dlp/extractor/twitch.py | 26 | Python | 0.857 | suggestion | 327 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | mauritzn | JC-Chung |
def _download_access_token(self, video_id, token_kind, param_name):
method = '%sPlaybackAccessToken' % token_kind
ops = {
'query': '''{
%s(
%s: "%s",
params: {
platform: "web",
playerBackend: "mediaplayer"... | ```suggestion
'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', r'0x0\g<1>', thumbnail),
``` |
def _download_access_token(self, video_id, token_kind, param_name):
method = '%sPlaybackAccessToken' % token_kind
ops = {
'query': '''{
%s(
%s: "%s",
params: {
platform: "web",
playerBackend: "mediaplayer"... | @@ -179,6 +179,14 @@ def _download_access_token(self, video_id, token_kind, param_name):
video_id, ops,
'Downloading %s access token GraphQL' % token_kind)['data'][method]
+ def _get_thumbnails(self, thumbnail):
+ return [{
+ 'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', ... | yt_dlp/extractor/twitch.py | 26 | Python | 0.714 | suggestion | 101 | 51 | 51 | false | [extractor/twitch] Update thumbnail size | 6,629 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JC-Chung |
from ..utils import (
ExtractorError,
HEADRequest,
UnsupportedError,
determine_ext,
int_or_none,
parse_resolution,
str_or_none,
traverse_obj,
unified_timestamp,
url_basename,
urljoin,
url_or_none,
)
class TrillerBaseIE(InfoExtractor):
_NETRC_MACHINE = 'triller'
... | I don't like how this mutates and then resets the var. I'd rather do:
```suggestion
headers = {**self._API_HEADERS, 'Content-Type': 'application/json'}
``` | from ..utils import (
ExtractorError,
HEADRequest,
UnsupportedError,
determine_ext,
int_or_none,
parse_resolution,
str_or_none,
traverse_obj,
unified_timestamp,
url_basename,
urljoin,
url_or_none,
)
class TrillerBaseIE(InfoExtractor):
_NETRC_MACHINE = 'triller'
... | @@ -22,30 +28,28 @@ def _perform_login(self, username, password):
if self._API_HEADERS.get('Authorization'):
return
- user_check = self._download_json(
+ self._API_HEADERS['Content-Type'] = 'application/json' | yt_dlp/extractor/triller.py | 26 | Python | 0.857 | suggestion | 166 | 51 | 51 | false | [extractor/triller] Support short URLs, detect removed videos | 6,636 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
if traverse_obj(video_info, (
None, ('transcoded_url', 'video_url', 'stream_url', 'audio_url'),
{lambda x: re.search(r'/copyright/', x)}), get_all=False):
self.raise_no_formats('This video has been removed due to licensing restrictions', expected=True)
def fo... | ```suggestion
'vcodec': video.get('codec'),
'vbr': int_or_none(video.get('bitrate'), 1000),
```
is just simpler here | None, ('transcoded_url', 'video_url', 'stream_url', 'audio_url'),
{lambda x: re.search(r'/copyright/', x)}), get_all=False):
self.raise_no_formats('This video has been removed due to licensing restrictions', expected=True)
def format_info(url):
return {
... | @@ -55,100 +59,102 @@ def _get_comments(self, video_id, limit=15):
headers=self._API_HEADERS, query={'limit': limit}) or {}
if not comment_info.get('comments'):
return
- for comment_dict in comment_info['comments']:
- yield {
- 'author': traverse_obj(c... | yt_dlp/extractor/triller.py | 26 | Python | 0.714 | suggestion | 152 | 51 | 51 | false | [extractor/triller] Support short URLs, detect removed videos | 6,636 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
},
}, {
'url': 'https://triller.co/@theestallion/video/07f35f38-1f51-48e2-8c5f-f7a8e829988f',
'md5': 'af7b3553e4b8bfca507636471ee2eb41',
'info_dict': {
'id': '71837829',
'ext': 'mp4',
'title': 'UNGRATEFUL VIDEO OUT NOW 👏🏾👏🏾👏🏾 💙💙 link my bio... | Revert. The thumbnail is still on the webpage and if we are not extracting it, just Let the test fail | 'md5': 'af7b3553e4b8bfca507636471ee2eb41',
'info_dict': {
'id': '71837829',
'ext': 'mp4',
'title': 'UNGRATEFUL VIDEO OUT NOW 👏🏾👏🏾👏🏾 💙💙 link my bio #womeninhiphop',
'display_id': '07f35f38-1f51-48e2-8c5f-f7a8e829988f',
'thumbnail': r're... | @@ -190,59 +195,73 @@ class TrillerIE(TrillerBaseIE):
'timestamp': 1660773354,
'upload_date': '20220817',
'duration': 16,
- 'height': 1920,
- 'width': 1080,
'view_count': int,
'like_count': int,
'artist': 'Dixie',
... | yt_dlp/extractor/triller.py | 26 | Python | 0.429 | bug | 101 | 51 | 51 | false | [extractor/triller] Support short URLs, detect removed videos | 6,636 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
up = urllib.parse.urlparse(fileurl)
q = urllib.parse.parse_qs(up.query)
paths = up.path.rstrip('/').split('/')
# https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047
x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).... | any suggestions to make this message better? (or which error type is more on point?) | up = urllib.parse.urlparse(fileurl)
q = urllib.parse.parse_qs(up.query)
paths = up.path.rstrip('/').split('/')
# https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047
x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).... | @@ -63,20 +65,27 @@ def _extract_formats(self, video_id, fileurl):
# https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047
x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).hexdigest()
+ preference = qualities([
+ 'prev... | yt_dlp/extractor/iwara.py | 26 | Python | 0.429 | suggestion | 84 | 51 | 51 | false | Fix iwara quality selection | 6,651 | yt-dlp/yt-dlp | 132,642 | Python | hasezoey | hasezoey |
'age_limit': 18,
'title': 'Aponia 阿波尼亚SEX Party Tonight 手动脱衣 大奶 裸腿',
'description': 'md5:0c4c310f2e0592d68b9f771d348329ca',
'uploader': '龙也zZZ',
'uploader_id': 'user792540',
'tags': [
'uncategorized'
],
'lik... | ```suggestion
preference = qualities(['preview', '360', '540', 'Source'])
```
Are you sure these are the only options? | 'age_limit': 18,
'title': 'Aponia 阿波尼亚SEX Party Tonight 手动脱衣 大奶 裸腿',
'description': 'md5:0c4c310f2e0592d68b9f771d348329ca',
'uploader': '龙也zZZ',
'uploader_id': 'user792540',
'tags': [
'uncategorized'
],
'lik... | @@ -63,20 +65,27 @@ def _extract_formats(self, video_id, fileurl):
# https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047
x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).hexdigest()
+ preference = qualities([
+ 'prev... | yt_dlp/extractor/iwara.py | 26 | Python | 0.786 | question | 131 | 51 | 51 | false | Fix iwara quality selection | 6,651 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hasezoey |
'like_count': 1809,
'view_count': 25156,
'comment_count': 1,
'timestamp': 1678732213,
'modified_timestamp': 1679110271,
},
}]
def _extract_formats(self, video_id, fileurl):
up = urllib.parse.urlparse(fileurl)
q = urllib.parse.p... | ```suggestion
'quality': ('name', {preference}),
``` | 'like_count': 1809,
'view_count': 25156,
'comment_count': 1,
'timestamp': 1678732213,
'modified_timestamp': 1679110271,
},
}]
def _extract_formats(self, video_id, fileurl):
up = urllib.parse.urlparse(fileurl)
q = urllib.parse.p... | @@ -63,20 +65,27 @@ def _extract_formats(self, video_id, fileurl):
# https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047
x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).hexdigest()
+ preference = qualities([
+ 'prev... | yt_dlp/extractor/iwara.py | 26 | Python | 0.643 | suggestion | 70 | 51 | 51 | false | Fix iwara quality selection | 6,651 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hasezoey |
extract_Initialization(segment_list)
segment_urls_e = segment_list.findall(_add_ns('SegmentURL'))
if segment_urls_e:
ms_info['segment_urls'] = [segment.attrib['media'] for segment in segment_urls_e]
else:
segment_template = ... | ```suggestion
'subtitles': collections.defaultdict(list)
``` | stream_numbers = collections.defaultdict(int)
for period_idx, period in enumerate(mpd_doc.findall(_add_ns('Period'))):
period_entry = {
'id': period.get('id', f'period-{period_idx}'),
'formats': [],
'subtitles': collections.defaultdict(list),
... | @@ -2634,9 +2696,14 @@ def extract_Initialization(source):
return ms_info
mpd_duration = parse_duration(mpd_doc.get('mediaPresentationDuration'))
- formats, subtitles = [], {}
stream_numbers = collections.defaultdict(int)
- for period in mpd_doc.findall(_add_ns('Period')):... | yt_dlp/extractor/common.py | 26 | Python | 0.571 | suggestion | 78 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
'url': mpd_url or base_url,
'fragment_base_url': base_url,
'fragments': [],
'protocol': 'http_dash_segments' if mime_type != 'image/jpeg' else 'mhtml',
})
if 'i... | ```suggestion
period_entry['subtitles'][lang or 'und'].append(f)
``` | stream_numbers[f['url']] += 1
period_entry['formats'].append(f)
elif content_type == 'text':
period_entry['subtitles'][lang or 'und'].append(f)
yield period_entry
def _extract_ism_formats(self, *args, **kwargs):... | @@ -2885,12 +2952,16 @@ def add_segment_url():
f['url'] = base_url
if content_type in ('video', 'audio', 'image/jpeg'):
f['manifest_stream_number'] = stream_numbers[f['url']]
+ f['dash_period_id'] = period_entry['id']
+ ... | yt_dlp/extractor/common.py | 26 | Python | 0.571 | suggestion | 94 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
})
if 'initialization_url' in representation_ms_info:
initialization_url = representation_ms_info['initialization_url']
if not f.get('url'):
f['url'] = initialization_url
... | ```suggestion
yield period_entry
```
no need to make list | yield period_entry
def _extract_ism_formats(self, *args, **kwargs):
fmts, subs = self._extract_ism_formats_and_subtitles(*args, **kwargs)
if subs:
self._report_ignoring_subs('ISM')
return fmts
def _extract_ism_formats_and_subtitles(self, ism_url, video_id, ism_i... | @@ -2885,12 +2952,16 @@ def add_segment_url():
f['url'] = base_url
if content_type in ('video', 'audio', 'image/jpeg'):
f['manifest_stream_number'] = stream_numbers[f['url']]
+ f['dash_period_id'] = period_entry['id']
+ ... | yt_dlp/extractor/common.py | 26 | Python | 0.571 | suggestion | 72 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
return fmts
def _parse_mpd_formats_and_subtitles(self, *args, **kwargs):
periods = self._parse_mpd_periods(*args, **kwargs)
return self._merge_mpd_periods(periods)
def _merge_mpd_periods(self, periods):
"""
Combine all formats and subtitles from an MPD manifest into a s... | ```suggestion
format_key = tuple(v for k, v in f.values() if k not in (
'format_id', 'fragments', 'manifest_stream_number'))
``` |
def _parse_mpd_formats_and_subtitles(self, *args, **kwargs):
periods = self._parse_mpd_periods(*args, **kwargs)
return self._merge_mpd_periods(periods)
def _merge_mpd_periods(self, periods):
"""
Combine all formats and subtitles from an MPD manifest into a single list,
... | @@ -2536,26 +2545,79 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.714 | suggestion | 167 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
# require almost all parameters to be the same
shared_keys = [k for k in periods[0]['formats'][0].keys()
if k not in ('format_id', 'fragments', 'manifest_stream_number',
'dash_period_id', 'dash_period_idx')]
# create merged formats
... | Simplified
```suggestion
assert 'is_dash_periods' not in f, 'format already processed'
f['is_dash_periods'] = True
if format_key not in groups:
groups[format_key] = f
elif 'fragments' in f:
groups[format_key].... | f['is_dash_periods'] = True
format_key = tuple(v for k, v in f.items() if k not in (
('format_id', 'fragments', 'manifest_stream_number')))
if format_key not in formats:
formats[format_key] = f
elif 'fragments' in f:... | @@ -2536,26 +2545,79 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.786 | suggestion | 390 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
'dash_period_id', 'dash_period_idx')]
# create merged formats
stream_numbers = collections.defaultdict(int)
groups = {}
formats = []
for period in periods:
for f in period['formats']:
format_key = tuple(f[k] for k i... | This overwrites each other. The lists inside should be appended to instead | if format_key not in formats:
formats[format_key] = f
elif 'fragments' in f:
formats[format_key].setdefault('fragments', []).extend(f['fragments'])
if subtitles and period['subtitles']:
self.report_warning(bug_reports_m... | @@ -2536,26 +2545,79 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.286 | suggestion | 74 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
format_key = tuple(f[k] for k in shared_keys)
if 'fragments' not in f or format_key not in groups:
# unmergeable format, or first period of this format
mf = {}
mf.update(f)
mf['manifest_stream_number'] = stre... | ```suggestion
return list(groups.values()), subtitles
``` | 'if part of the subtitles are missing,'
), only_once=True)
for sub_lang, sub_info in period['subtitles'].items():
subtitles.setdefault(sub_lang, []).extend(sub_info)
return list(formats.values()), subtitles
def _parse_mpd_periods(self, mpd_d... | @@ -2536,26 +2545,79 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.571 | suggestion | 67 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
if k not in ('format_id', 'fragments', 'manifest_stream_number',
'dash_period_id', 'dash_period_idx')]
# create merged formats
stream_numbers = collections.defaultdict(int)
groups = {}
formats = []
for period in periods:... | ```suggestion
subtitles = {}
for period in periods:
``` | ('format_id', 'fragments', 'manifest_stream_number')))
if format_key not in formats:
formats[format_key] = f
elif 'fragments' in f:
formats[format_key].setdefault('fragments', []).extend(f['fragments'])
if subtitles... | @@ -2536,26 +2545,79 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.571 | suggestion | 74 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
video_id, headers={
'Authorization': 'Bearer %s' % self._id_token,
**self.geo_verification_headers(),
})
if 'manifestUrls' in api:
formats, subs = self._extract_m3u8_formats_and_subtitles(
api['manifestUrls']['hls'], video_id, ... | ```suggestion
periods = [p for p in periods if '-ad-' not in p['id'])) # skip ads
``` | video_id, headers={
'Authorization': 'Bearer %s' % self._id_token,
**self.geo_verification_headers(),
})
if 'manifestUrls' in api:
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
api['manifestUrls']['hls'], video... | @@ -77,16 +93,38 @@ def _real_extract(self, url):
api = self._download_json(
f'https://api.goplay.be/web/v1/videos/long-form/{video_id}',
- video_id, headers={'Authorization': 'Bearer %s' % self._id_token})
+ video_id, headers={
+ 'Authorization': 'Bearer %s'... | yt_dlp/extractor/goplay.py | 26 | Python | 0.714 | suggestion | 100 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
movie = video_data.get('movie')
if movie:
video_id = movie['videoUuid']
info_dict = {
'title': movie.get('title')
}
else:
episode = traverse_obj(video_data, ('playlists', ..., 'episodes', lambda _, v: v['pageInfo']['url'] == url), ... | ```suggestion
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
```
name is different below |
movie = video_data.get('movie')
if movie:
video_id = movie['videoUuid']
info_dict = {
'title': movie.get('title')
}
else:
episode = traverse_obj(video_data, ('playlists', ..., 'episodes', lambda _, v: v['pageInfo']['url'] == url), ... | @@ -77,16 +93,38 @@ def _real_extract(self, url):
api = self._download_json(
f'https://api.goplay.be/web/v1/videos/long-form/{video_id}',
- video_id, headers={'Authorization': 'Bearer %s' % self._id_token})
+ video_id, headers={
+ 'Authorization': 'Bearer %s'... | yt_dlp/extractor/goplay.py | 26 | Python | 0.786 | refactor | 119 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
if 'manifestUrls' in api:
formats, subs = self._extract_m3u8_formats_and_subtitles(
api['manifestUrls']['hls'], video_id, ext='mp4', m3u8_id='HLS')
else:
assert 'ssai' in api, 'expecting Google SSAI stream'
ssai_content_source_id = api['ssai']['conte... | ```suggestion
'formats': formats,
'subtitles': subtitles,
```
Why are you discarding subs? | if 'manifestUrls' in api:
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
api['manifestUrls']['hls'], video_id, ext='mp4', m3u8_id='HLS')
else:
if 'ssai' not in api:
raise ExtractorError('expecting Google SSAI stream')
... | @@ -77,16 +93,38 @@ def _real_extract(self, url):
api = self._download_json(
f'https://api.goplay.be/web/v1/videos/long-form/{video_id}',
- video_id, headers={'Authorization': 'Bearer %s' % self._id_token})
+ video_id, headers={
+ 'Authorization': 'Bearer %s'... | yt_dlp/extractor/goplay.py | 26 | Python | 0.714 | question | 118 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
res = self._download_xml_handle(
mpd_url, video_id,
note='Downloading MPD manifest' if note is None else note,
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:... | Pls explain. Leftover from old impl? |
if self.get_param('ignore_no_formats_error'):
fatal = False
res = self._download_xml_handle(
mpd_url, video_id,
note='Downloading MPD manifest' if note is None else note,
errnote='Failed to download MPD manifest' if errnote is None else errnote,
... | @@ -2536,26 +2545,79 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.071 | question | 36 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
to add to the request.
* stretched_ratio If given and not 1, indicates that the
video's pixels are not square.
width : height ratio as float.
* no_resume The server does not suppo... | ```suggestion
* is_dash_periods Whether the format is a result of merging
multiple DASH periods.
``` | to add to the request.
* stretched_ratio If given and not 1, indicates that the
video's pixels are not square.
width : height ratio as float.
* no_resume The server does not suppo... | @@ -247,6 +247,9 @@ class InfoExtractor:
(For internal use only)
* http_chunk_size Chunk size for HTTP downloads
* ffmpeg_args Extra arguments for ffmpeg downloader
+ MPD formats can have the add... | yt_dlp/extractor/common.py | 26 | Python | 0.714 | suggestion | 157 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
def _merge_mpd_periods(self, periods):
"""
Combine all formats and subtitles from an MPD manifest into a single list,
by concatenate streams with similar formats.
"""
# create merged formats
formats = {}
subtitles = {}
for period in periods:
... | ```suggestion
formats, subtitles = {}, {}
for period in periods:
for f in period['formats']:
assert 'is_dash_periods' not in f, 'format already processed'
f['is_dash_periods'] = True
format_key = tuple(v for k, v in f.items() if k not in ... | """
Combine all formats and subtitles from an MPD manifest into a single list,
by concatenate streams with similar formats.
"""
formats, subtitles = {}, {}
for period in periods:
for f in period['formats']:
assert 'is_dash_periods' not in f, 'f... | @@ -2543,26 +2550,55 @@ def _extract_mpd_formats_and_subtitles(
errnote='Failed to download MPD manifest' if errnote is None else errnote,
fatal=fatal, data=data, headers=headers, query=query)
if res is False:
- return [], {}
+ return []
mpd_doc, urlh = ... | yt_dlp/extractor/common.py | 26 | Python | 0.786 | suggestion | 817 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
'url': mpd_url or base_url,
'fragment_base_url': base_url,
'fragments': [],
'protocol': 'http_dash_segments' if mime_type != 'image/jpeg' else 'mhtml',
})
if 'i... | Is the if condition necessary? This should work just as well
```suggestion
yield period_entry
``` | 'url': mpd_url or base_url,
'fragment_base_url': base_url,
'fragments': [],
'protocol': 'http_dash_segments' if mime_type != 'image/jpeg' else 'mhtml',
})
if 'i... | @@ -2893,11 +2933,11 @@ def add_segment_url():
if content_type in ('video', 'audio', 'image/jpeg'):
f['manifest_stream_number'] = stream_numbers[f['url']]
stream_numbers[f['url']] += 1
- formats.append(f)
+ ... | yt_dlp/extractor/common.py | 26 | Python | 0.786 | suggestion | 112 | 51 | 51 | false | [extractor/goplay] Fix GoPlay downloads | 6,654 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alard |
import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
dict_get,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
s... | ~~simpler as class vars~~
```suggestion
_HOMEPAGE = f'https://{_DOMAIN}'
_LOGIN_API = f'{_HOMEPAGE}/login/'
_LOGOUT_DEVICES_API = f'{_HOMEPAGE}/logout_devices/?next=/'
_CONTENT_API = f'{_HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
_HLS_AES_URI = f'{_HOMEPAGE}/api/v2.5/video_contents/{{content... | import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaBaseIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEP... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 20 | Python | 0.786 | suggestion | 336 | 45 | 45 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
dict_get,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
s... | I think it would be safer to check the actual url. This goes together with the first suggestion in `BrilliantpalaIE._real_extract()`
```suggestion
def _get_logged_in_username(self, url, video_id):
webpage, urlh = self._download_webpage_handle(url, video_id)
if self._LOGIN_API == urlh.url:
``` | import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaBaseIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEP... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 24 | Python | 1 | refactor | 318 | 49 | 49 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
from .common import InfoExtractor
from ..utils import (
ExtractorError,
dict_get,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEPAGE =... | ```suggestion
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')
``` |
from .common import InfoExtractor
from ..utils import (
ExtractorError,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaBaseIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEPAGE = f'https:/... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.786 | suggestion | 115 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
self._LOGOUT_DEVICES_API = f'{self._HOMEPAGE}/logout_devices/?next=/'
self._CONTENT_API = f'{self._HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
self._HLS_AES_URI = f'{self._HOMEPAGE}/api/v2.5/video_contents/{{content_id}}/key/'
def _get_logged_in_username(self, webpage):
if self._LO... | Can be simplified; `fatal=False` is redundant if there is a `default`, and `name` arg doesn't matter if it will never throw/warn
```suggestion
r'(Your username / email and password)', logged_page, 'auth fail', default=None):
``` | self._CONTENT_API = f'{self._HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
self._HLS_AES_URI = f'{self._HOMEPAGE}/api/v2.5/video_contents/{{content_id}}/key/'
def _get_logged_in_username(self, url, video_id):
webpage, urlh = self._download_webpage_handle(url, video_id)
if self._LOGIN... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.857 | bug | 243 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
if self._LOGIN_API == self._og_search_property('url', webpage):
self.raise_login_required()
return self._html_search_regex(
r'"username":\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')
def _perform_login(self, username, password):
login_form = sel... | same as above
```suggestion
if self._html_search_regex(
r'(Logout Other Devices)', logged_page, 'logout devices button', default=None):
``` | if self._LOGIN_API == urlh.url:
self.raise_login_required()
return self._html_search_regex(
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')
def _perform_login(self, username, password):
login_form = self._hidden_inputs(self._downlo... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.714 | suggestion | 163 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
'password': password,
})
self._set_cookie(self._DOMAIN, 'csrftoken', login_form['csrfmiddlewaretoken'])
logged_page = self._download_webpage(
self._LOGIN_API, None, note='Logging in', headers={'Referer': self._LOGIN_API},
data=urlencode_postdata(login_form))
... | To go with above suggestion in `_get_logged_in_username()`
```suggestion
username = self._get_logged_in_username(url, video_id)
``` | 'password': password,
})
self._set_cookie(self._DOMAIN, 'csrftoken', login_form['csrfmiddlewaretoken'])
logged_page = self._download_webpage(
self._LOGIN_API, None, note='Logging in', headers={'Referer': self._LOGIN_API},
data=urlencode_postdata(login_form))
... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.786 | suggestion | 142 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
if self._html_search_regex(
r'(?P<warning>Your username / email and password)', logged_page,
'authentication failure warning', group='warning', fatal=False, default=''):
raise ExtractorError('wrong username or password', expected=True)
if self._html_search_regex... | Branching will guarantee a list, and filtering can guarantee dicts with useful values
```suggestion
for stream in traverse_obj(content_json, ('video', 'streams', lambda _, v: v['id'] and v['url'])):
``` |
if self._html_search_regex(
r'(Your username / email and password)', logged_page, 'auth fail', default=None):
raise ExtractorError('wrong username or password', expected=True)
# the maximum number of logins is one
if self._html_search_regex(
r'(Logou... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.857 | suggestion | 213 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
r'(?P<warning>Your username / email and password)', logged_page,
'authentication failure warning', group='warning', fatal=False, default=''):
raise ExtractorError('wrong username or password', expected=True)
if self._html_search_regex(
r'(?P<button_text>Logou... | Do we want this to be non-fatal?
```suggestion
formats = self._extract_m3u8_formats(stream['url'], video_id, fatal=False)
if not formats:
continue
``` | r'(Your username / email and password)', logged_page, 'auth fail', default=None):
raise ExtractorError('wrong username or password', expected=True)
# the maximum number of logins is one
if self._html_search_regex(
r'(Logout Other Devices)', logged_page, 'logo... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.786 | refactor | 195 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
def _real_extract(self, url):
course_id, content_id = self._match_valid_url(url).group('course_id', 'content_id')
video_id = f'{course_id}-{content_id}'
username = self._get_logged_in_username(self._download_webpage(url, video_id))
content_json = self._download_json(
se... | ```suggestion
entries.append({
'id': str(stream['id']),
'title': content_json.get('title'),
'formats': formats,
'hls_aes': {'uri': self._HLS_AES_URI.format(content_id=content_id)},
'http_headers': {'X-Key': hashlib.sha256(... | course_id, content_id = self._match_valid_url(url).group('course_id', 'content_id')
video_id = f'{course_id}-{content_id}'
username = self._get_logged_in_username(url, video_id)
content_json = self._download_json(
self._CONTENT_API.format(content_id=content_id), video_id,
... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.857 | suggestion | 443 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
note='Fetching content info', errnote='Unable to fetch content info')
entries = []
for stream in traverse_obj(content_json, ('video', 'streams')):
formats = self._extract_m3u8_formats(
m3u8_url=stream['url'], video_id=video_id)
for format in formats:
... | ~~Do not subclass from concrete IE. Create a baseclass and move all common code into it, and subclass all 3 concrete IEs from the baseclass~~ |
entries = []
for stream in traverse_obj(content_json, ('video', 'streams', lambda _, v: v['id'] and v['url'])):
formats = self._extract_m3u8_formats(stream['url'], video_id, fatal=False)
if not formats:
continue
entries.append({
'id': ... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.429 | suggestion | 141 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
class BrilliantpalaElearnIE(BrilliantpalaIE):
IE_NAME = 'Brilliantpala:Elearn'
IE_DESC = 'VoD on elearn.brilliantpala.org'
_VALID_URL = r'https?://elearn\.brilliantpala\.org/courses/(?P<course_id>\d+)/contents/(?P<content_id>\d+)/?'
_TESTS = [{
'url': 'https://elearn.brilliantpala.org/courses/42... | this can be simplified using a single `_DOMAIN` class var | _TESTS = [{
'url': 'https://elearn.brilliantpala.org/courses/42/contents/12345/',
'only_matching': True,
}, {
'url': 'https://elearn.brilliantpala.org/courses/98/contents/36683/',
'info_dict': {
'id': '23577',
'ext': 'mp4',
'title': 'Physical W... | @@ -0,0 +1,139 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ dict_get,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _ini... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.357 | suggestion | 57 | 51 | 43 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEPAGE ... | ```suggestion
class BrilliantpalaBaseIE(InfoExtractor):
``` | import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
traverse_obj,
urlencode_postdata,
)
class BrilliantpalaBaseIE(InfoExtractor):
_NETRC_MACHINE = 'brilliantpala'
_DOMAIN = '{subdomain}.brilliantpala.org'
def _initialize_pre_login(self):
self._HOMEP... | @@ -0,0 +1,126 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor): | yt_dlp/extractor/brilliantpala.py | 11 | Python | 0.643 | refactor | 61 | 36 | 36 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
username = self._get_logged_in_username(url, video_id)
content_json = self._download_json(
self._CONTENT_API.format(content_id=content_id), video_id,
note='Fetching content info', errnote='Unable to fetch content info')
entries = []
for stream in traverse_obj(c... | ```suggestion
class BrilliantpalaElearnIE(BrilliantpalaBaseIE):
``` | video_id = f'{course_id}-{content_id}'
username = self._get_logged_in_username(url, video_id)
content_json = self._download_json(
self._CONTENT_API.format(content_id=content_id), video_id,
note='Fetching content info', errnote='Unable to fetch content info')
en... | @@ -0,0 +1,126 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _initialize_pre_log... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.571 | suggestion | 69 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
class BrilliantpalaElearnIE(BrilliantpalaIE):
IE_NAME = 'Brilliantpala:Elearn'
IE_DESC = 'VoD on elearn.brilliantpala.org'
_VALID_URL = r'https?://elearn\.brilliantpala\.org/courses/(?P<course_id>\d+)/contents/(?P<content_id>\d+)/?'
_TESTS = [{
'url': 'https://elearn.brilliantpala.org/courses/4... | ```suggestion
class BrilliantpalaClassesIE(BrilliantpalaBaseIE):
``` |
class BrilliantpalaElearnIE(BrilliantpalaBaseIE):
IE_NAME = 'Brilliantpala:Elearn'
IE_DESC = 'VoD on elearn.brilliantpala.org'
_VALID_URL = r'https?://elearn\.brilliantpala\.org/courses/(?P<course_id>\d+)/contents/(?P<content_id>\d+)/?'
_TESTS = [{
'url': 'https://elearn.brilliantpala.org/cour... | @@ -0,0 +1,126 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _initialize_pre_log... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.571 | suggestion | 70 | 48 | 49 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
def _get_logged_in_username(self, url, video_id):
webpage, urlh = self._download_webpage_handle(url, video_id)
if self._LOGIN_API == urlh.url:
self.raise_login_required()
return self._html_search_regex(
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'stream page ... | Why do you need to logout of other devices? Might be worth dropping a quick comment in the code. | def _get_logged_in_username(self, url, video_id):
webpage, urlh = self._download_webpage_handle(url, video_id)
if self._LOGIN_API == urlh.url:
self.raise_login_required()
return self._html_search_regex(
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'stream page ... | @@ -0,0 +1,126 @@
+import hashlib
+
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ traverse_obj,
+ urlencode_postdata,
+)
+
+
+class BrilliantpalaBaseIE(InfoExtractor):
+ _NETRC_MACHINE = 'brilliantpala'
+ _DOMAIN = '{subdomain}.brilliantpala.org'
+
+ def _initialize_pre... | yt_dlp/extractor/brilliantpala.py | 26 | Python | 0.214 | question | 96 | 51 | 51 | false | [brilliantpala] Add extractor | 6,680 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | pzhlkj6612 |
'only_matching': True,
}, {
'url': 'https://www.pornhubpremium.com/view_video.php?viewkey=ph5f75b0f4b18e3',
'only_matching': True,
}, {
# geo restricted
'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5a9813bfa7156',
'only_matching': True,
}, {
... | Why do you set a cookie for a third party site? This shouldn't be required. | 'only_matching': True,
}, {
# Some videos are available with the same id on both premium
# and non-premium sites (e.g. this and the following test)
'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5f75b0f4b18e3',
'only_matching': True,
}, {
'url': 'https:/... | @@ -269,6 +269,8 @@ def _real_extract(self, url):
self._login(host)
self._set_cookie(host, 'age_verified', '1')
+ self._set_cookie(host, 'accessAgeDisclaimerPH', '1')
+ self._set_cookie('thumbzilla.com', 'accessAgeDisclaimerTZ', '1') | yt_dlp/extractor/pornhub.py | 26 | Python | 0.286 | question | 75 | 51 | 51 | false | [extractor/pornhub][fix] fix changed ageverification cookie | 6,685 | yt-dlp/yt-dlp | 132,642 | Python | tinyoverflow | schmoaaaaah |
if not ret:
return ret
webpage, urlh = ret
if any(re.search(p, webpage) for p in (
r'<body\b[^>]+\bonload=["\']go\(\)',
r'document\.cookie\s*=\s*["\']RNKEY=',
r'document\.location\.reload\(true\)')):
url_or_request = args... | ```suggestion
self._set_cookie(host, 'accessAgeDisclaimerPH', '1')
self._set_cookie(host, 'accessPH', '1')
``` |
if not ret:
return ret
webpage, urlh = ret
if any(re.search(p, webpage) for p in (
r'<body\b[^>]+\bonload=["\']go\(\)',
r'document\.cookie\s*=\s*["\']RNKEY=',
r'document\.location\.reload\(true\)')):
url_or_request = args... | @@ -58,6 +58,10 @@ def dl(*args, **kwargs):
def _real_initialize(self):
self._logged_in = False
+ def _set_age_cookies(self, host):
+ self._set_cookie(host, 'age_verified', '1')
+ self._set_cookie(host, 'accessAgeDisclaimerPH', '1') | yt_dlp/extractor/pornhub.py | 26 | Python | 0.714 | suggestion | 129 | 51 | 51 | false | [extractor/pornhub][fix] fix changed ageverification cookie | 6,685 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | schmoaaaaah |
'url': 'https://v.youku.com/v_show/id_XNTA2NTA0MjA1Mg==.html',
'info_dict': {
'id': 'XNTA2NTA0MjA1Mg',
'ext': 'mp4',
'title': 'Minecraft我的世界:建造超大巨型航空飞机,菜鸟vs高手vs黑客',
'duration': 542.13,
'thumbnail': r're:^https?://.*',
'uploader': '波... | Don't delete this one since there is no replacement test and just add something like `'skip': '404'` | 'params': {
'videopassword': '100600',
},
}, {
# /play/get.json contains streams with "channel_type":"tail"
'url': 'http://v.youku.com/v_show/id_XOTUxMzg4NDMy.html',
'info_dict': {
'id': 'XOTUxMzg4NDMy',
'ext': 'mp4',
'title': '... | @@ -26,66 +27,6 @@ class YoukuIE(InfoExtractor):
'''
_TESTS = [{
- # MD5 is unstable
- 'url': 'http://v.youku.com/v_show/id_XMTc1ODE5Njcy.html',
- 'info_dict': {
- 'id': 'XMTc1ODE5Njcy',
- 'title': '★Smile﹗♡ Git Fresh -Booty Music舞蹈.',
- 'ext': 'mp4',
- ... | yt_dlp/extractor/youku.py | 26 | Python | 0.571 | suggestion | 100 | 51 | 51 | false | Fix youku extractor | 6,690 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | carusocr |
import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data-audio-diraid[^>]*>... | Avoid using names of built-ins (`id`)
You can rename the var to whatever you want, but for the sake of this review I will be using `id_` throughout
```suggestion
def _parse_button_attrs(self, button, id_=None):
attrs = extract_attributes(button)
id_ = id_ or attrs['data-audio-diraid']
``` | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 17 | Python | 0.857 | refactor | 315 | 42 | 42 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data-audio-diraid[^>]*>... | Unless the comment is relevant to how we need to extract/download the formats, it can be removed.
`traverse_obj` can make this easier (and it's ok if not fatal). Import it from utils
```suggestion
url = traverse_obj(
attrs, 'data-audio-download-src', 'data-audio', 'data-audioreference',
... | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 1 | refactor | 376 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data-audio-diraid[^>]*>... | imo we can use an `ext` var to make things easier below
```suggestion
ext = determine_ext(url)
``` | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 25 | Python | 0.786 | suggestion | 111 | 50 | 50 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
determine_ext,
extract_attributes,
int_or_none,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data-audio-diraid[^>]*>)'
def _parse_button_attrs(self, button, id=None):
at... | I think we should add `extractor_key` and `extractor` to the info_dict here so that the individual media will be recorded in download archives under the `DFL` extractor (instead of `DFLCorpus`) and duplicate downloads can be detected properly
```suggestion
'id': id_,
'extractor_key': DLFIE.ie... | from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data-audio-diraid[^>]*>)'
def _parse_button_... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.857 | refactor | 373 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
# Note: DLF's mp3 recordings are in two distinct locations on the web:
# A direct download location, https://download.deutschlandfunk.de/ ... .mp3
# A stream with playback controls, https://ondemand-mp3.dradio.de/ ... .mp3
url = url_or_none(
attrs.get('data-audio-download-src... | - We need to add `'vcodec': 'none'` if it's audio-only.
- Using `formats` for both m3u8 and mp3 formats seems simpler to me
- `traverse_obj` makes this less grueling to read/write
- Like how I suggested to add `extractor` and `extractor_key` above, we want to extract the `webpage_url` for individual media here t... | audio_id = audio_id or attrs['data-audio-diraid']
url = traverse_obj(
attrs, 'data-audio-download-src', 'data-audio', 'data-audioreference',
'data-audio-src', expected_type=url_or_none)
ext = determine_ext(url)
return {
'id': audio_id,
'e... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.857 | refactor | 1,081 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'series': 'On Stage',
'channel': 'deutschlandfunk'
},
'params': {
'skip_download': 'm3u8'
},
'skip': 'This webpage no longer exists'
}, {
'url': 'https://www.deutschlandfunk.de/russische-athleten-kehren-z... | ```suggestion
id_ = self._match_id(url)
webpage = self._download_webpage(url, id_)
``` | 'skip': 'This webpage no longer exists'
}, {
'url': 'https://www.deutschlandfunk.de/russische-athleten-kehren-zurueck-auf-die-sportbuehne-ein-gefaehrlicher-tueroeffner-dlf-d9cc1856-100.html',
'info_dict': {
'id': 'd9cc1856',
'title': 'Russische... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.714 | suggestion | 105 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'params': {
'skip_download': 'm3u8'
},
'skip': 'This webpage no longer exists'
}, {
'url': 'https://www.deutschlandfunk.de/russische-athleten-kehren-zurueck-auf-die-sportbuehne-ein-gefaehrlicher-tueroeffner-dlf-d9cc1856-100.html',
'info... | ```suggestion
self._search_regex(self._BUTTON_REGEX, webpage, 'button'), id_)
``` | 'info_dict': {
'id': 'd9cc1856',
'title': 'Russische Athleten kehren zurück auf die Sportbühne: Ein gefährlicher Türöffner',
'ext': 'mp3',
'duration': 291,
'thumbnail': 'https://assets.deutschlandfunk.de/FALLBACK-IMAGE-AUDIO/512... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.571 | suggestion | 95 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
id = self._match_id(url)
webpage = self._download_webpage(url, id)
return self._parse_button_attrs(
self._search_regex(DLFBaseIE._BUTTON_REGEX, webpage, 'button'), id)
class DLFCorpusIE(DLFBaseIE):
_VALID_URL = DLFBaseIE._VALID_URL_BASE + r'(?:[a-z]+-)+\d+\.html'
IE_NAME ... | format URLs are not required by the tests, can be removed | class DLFCorpusIE(DLFBaseIE):
IE_NAME = 'dlf:corpus'
IE_DESC = 'DLF Multi-feed Archives'
_VALID_URL = DLFBaseIE._VALID_URL_BASE + r'(?P<id>(?![\w-]+-dlf-[\da-f]{8})[\w-]+-\d+)\.html'
_TESTS = [
# Recorded news broadcast with referrals to related broadcasts
{
'url': 'https://w... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.286 | style | 57 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'thumbnail': 'https://assets.deutschlandfunk.de/a595989d-1ed1-4a2e-8370-b64d7f11d757/512x512.jpg?t=1679173825412',
'uploader': 'Deutschlandfunk',
'series': 'Sport am Samstag',
'channel': 'deutschlandfunk'
}
}],
... | Keys with `None` values can be omitted from tests
Let the test_download script generate the info_dicts for you by only manually entering `url` and `id`, and then `ext` (if single media) or `playlist_count`/`playlist_mincount` (if playlist). The test will fail and output the rest of the dict for you to copy/paste | 'title': 'Meinung - Kommentare und Themen der Woche',
'description': 'md5:2901bbd65cd2d45e116d399a099ce5d5',
},
'playlist_mincount': 10,
},
# Podcast feed with no description
{
'url': 'https://www.deutschlandfunk.de/podcast-toll... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.571 | bug | 316 | 47 | 30 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'title': r're:Kunst & Pop [-/] Corso',
'description': 'md5:ba0f80303683591bff4b7459077bef58'
},
'playlist_mincount': 34,
'params': {'skip_download': True}
},
# Podcast feed with no description
{
'url': 'https://www.d... | Is the URL slug unique? Can't we match that for the playlist `id`? | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.357 | question | 66 | 34 | 193 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'params': {'skip_download': True}
},
# Podcast feed with no description
{
'url': 'https://www.deutschlandfunk.de/podcast-tolle-idee-100.html',
'info_dict': {
'id': False,
'title': 'Wissenschaftspodcast - Tolle Idee! - Was wurde ... | playlist title should be non-fatal
```suggestion
['og:title', 'twitter:title'], webpage, default=None),
``` | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,209 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<button[^>]+alt="Anhör... | yt_dlp/extractor/dlf.py | 26 | Python | 0.786 | suggestion | 126 | 30 | 193 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
url = traverse_obj(
attrs, 'data-audio-download-src', 'data-audio', 'data-audioreference',
'data-audio-src', expected_type=url_or_none)
ext = determine_ext(url)
return {
'id': audio_id,
'extractor_key': DLFIE.ie_key(),
'extractor': DL... | ```suggestion
_VALID_URL = DLFBaseIE._VALID_URL_BASE + r'[\w-]+-dlf-(?P<id>[\da-f]{8})-100\.html'
``` |
url = traverse_obj(
attrs, 'data-audio-download-src', 'data-audio', 'data-audioreference',
'data-audio-src', expected_type=url_or_none)
ext = determine_ext(url)
return {
'id': audio_id,
'extractor_key': DLFIE.ie_key(),
'extractor': DL... | @@ -0,0 +1,197 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<bu... | yt_dlp/extractor/dlf.py | 26 | Python | 0.714 | suggestion | 107 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'skip': 'This webpage no longer exists'
}, {
'url': 'https://www.deutschlandfunk.de/russische-athleten-kehren-zurueck-auf-die-sportbuehne-ein-gefaehrlicher-tueroeffner-dlf-d9cc1856-100.html',
'info_dict': {
'id': 'd9cc1856',
'title': 'Russische... | ```suggestion
_VALID_URL = DLFBaseIE._VALID_URL_BASE + r'(?P<id>(?![\w-]+-dlf-[\da-f]{8})[\w-]+-\d+)\.html'
``` | }, {
'url': 'https://www.deutschlandfunk.de/russische-athleten-kehren-zurueck-auf-die-sportbuehne-ein-gefaehrlicher-tueroeffner-dlf-d9cc1856-100.html',
'info_dict': {
'id': 'd9cc1856',
'title': 'Russische Athleten kehren zurück auf die Sportbühne: Ein gefä... | @@ -0,0 +1,197 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<bu... | yt_dlp/extractor/dlf.py | 26 | Python | 0.714 | suggestion | 117 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data-... | just minor formatting nitpick
```suggestion
'data-audio-src', expected_type=url_or_none)
ext = determine_ext(url)
``` | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,197 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<bu... | yt_dlp/extractor/dlf.py | 24 | Python | 0.857 | suggestion | 141 | 49 | 49 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
'channel': 'deutschlandfunk'
}
}, {
'info_dict': {
'id': '47e1a096',
'title': r're:Rückkehr Russlands im Fechten [-/] "Fassungslos, dass es einfach so passiert ist"',
'ext': 'mp3',
... | `skip_download` isn't needed for playlist tests
```suggestion
'params': {'skip_download': 'm3u8'}
``` | }
}, {
'info_dict': {
'id': '47e1a096',
'title': r're:Rückkehr Russlands im Fechten [-/] "Fassungslos, dass es einfach so passiert ist"',
'ext': 'mp3',
'duration': 602,
'thumbn... | @@ -0,0 +1,197 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<bu... | yt_dlp/extractor/dlf.py | 26 | Python | 0.714 | suggestion | 116 | 51 | 51 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | nick-cd |
# Podcast feed with no description
{
'url': 'https://www.deutschlandfunk.de/podcast-tolle-idee-100.html',
'info_dict': {
'id': 'podcast-tolle-idee-100',
'title': 'Wissenschaftspodcast - Tolle Idee! - Was wurde daraus?',
},
'... | ```suggestion
'entries': map(self._parse_button_attrs, re.findall(self._BUTTON_REGEX, webpage)),
}
``` | import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
extract_attributes,
int_or_none,
traverse_obj,
url_or_none,
)
class DLFBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
_BUTTON_REGEX = r'(<button[^>]+alt="Anhören"[^>]+data... | @@ -0,0 +1,197 @@
+import re
+from .common import InfoExtractor
+from ..utils import (
+ determine_ext,
+ extract_attributes,
+ int_or_none,
+ traverse_obj,
+ url_or_none,
+)
+
+
+class DLFBaseIE(InfoExtractor):
+ _VALID_URL_BASE = r'https?://(?:www\.)?deutschlandfunk\.de/'
+ _BUTTON_REGEX = r'(<bu... | yt_dlp/extractor/dlf.py | 26 | Python | 0.714 | suggestion | 125 | 27 | 193 | false | [extractor/dlf] Add support for Deutschlandfunk | 6,697 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | nick-cd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.