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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
page_id = self._match_id(url)
webpage = self._download_webpage(url, page_id)
json_obj = traverse_obj(
self._search_nextjs_data(webpage, page_id), ('props', 'pageProps'), default={})
info = traverse_obj(json_obj, {
'id': ('recipe', 'id', {str_or_none}),
... | this can be inlined in the return too, e.g.
```py
'thumbnails': traverse_obj(next_data, (
'recipe', 'image', 'crops', 'recipe', lambda _, v: url_or_none(v['url']), {
'url': 'url',
})),
``` | 'playlist_count': 2,
}, {
# single video example
'url': 'https://cooking.nytimes.com/guides/50-how-to-make-mac-and-cheese',
'md5': '64415805fe0b8640fce6b0b9def5989a',
'info_dict': {
'id': '100000005835845',
'ext': 'mp4',
'title': 'How to Ma... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.786 | suggestion | 258 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'title': ('recipe', 'title'),
'description': ('recipe', 'topnote', {clean_html}),
'timestamp': ('recipe', 'publishedAt'),
'creator': ('recipe', 'contentAttribution', 'cardByline'),
'upload_date': ('meta', 'jsonLD', 'video', 'uploadDate', {unified_strdate}),
... | in the future, just unpack instead of doing this ( `**info` )
but we'll be doing the traversal here anyways as per my above comment | 'title': 'How to Make Mac and Cheese',
'description': 'md5:b8f2f33ec1fb7523b21367147c9594f1',
'duration': 9.51,
'creator': 'Alison Roman',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
'url': 'https://cooking.nytimes.com/... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.571 | suggestion | 132 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
for image in traverse_obj(json_obj, ('promotionalMedia', 'crops', ..., 'renditions', ...)):
image_url = image.get('url')
if not url_or_none(image_url):
continue
thumbnails.append({
'name': image.get('name'),
... | the class var could be `_DNS_NAMESPACE = uuid.UUID('36dd619a-56dc-595b-9e09-37f4152c7b5d')` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.429 | suggestion | 91 | 51 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'creator': creators,
'formats': formats,
'subtitles': subtitles,
'thumbnails': thumbnails,
})
return entries
def _json_from_graphql(self, media_id):
# reference: `id-to-uri.js`
namespace = uuid.UUID(self._DNS_UUID)
... | these could be inlined in the `_download_json()` call | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.429 | suggestion | 53 | 51 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
})
return entries
def _json_from_graphql(self, media_id):
# reference: `id-to-uri.js`
namespace = uuid.UUID(self._DNS_UUID)
video_uuid = uuid.uuid5(namespace, 'video')
media_uuid = uuid.uuid5(video_uuid, media_id)
payload = {
'query': self._G... | if this always non-fatal, we could default to `{}` in the return instead after the call
```suggestion
data=json.dumps(payload, separators=(',', ':')).encode(), headers=headers, fatal=False) or {}
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | suggestion | 214 | 51 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
crops {
name
renditions {
name
width
height
url
}
}
}
}
renditions {
type
width
height
url
bitrate
}
summary
}
}
}'''
def _bu... | I'd make this a generator instead of an append loop | 'upload_date': '20190102',
'title': 'Overnight Oats',
'creator': 'Genevieve Ko',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}]
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_webpage(ur... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.286 | suggestion | 51 | 51 | 29 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
def _build_playlist(self, media_items):
entries = []
for media_id in media_items:
json_obj = traverse_obj(self._json_from_graphql(media_id) or {}, ('data', 'video'))
title = json_obj.get('promotionalHeadline') or media_id
description = json_obj.get('summary')
... | I'd use dict key traversal and filtering here as well (demonstrated in a couple other comments) | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.286 | suggestion | 95 | 51 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
get_elements_html_by_class('video-item', webpage), (..., {extract_attributes}, 'data-video-id'))
title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
description = self._html_search_meta(['og:description', 'twitter:description'], webpage)
creator = self._search_rege... | duplicated code from above. make a helper function | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.214 | refactor | 50 | 38 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
}
renditions {
type
width
height
url
bitrate
}
summary
}
}
}'''
def _build_playlist(self, media_items):
entries = []
for media_id in media_items:
json_obj = traverse_obj(self._json_from_graphql(media_id) or {}, ('data... | if applying my `_extract_media_from_json` suggestion
```suggestion
formats, subtitles = self._extract_media_from_json(media_id, json_obj)
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.786 | refactor | 156 | 51 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
return self._download_json(
self._GRAPHQL_API, id, note='Downloading json from GRAPHQL API',
data=json.dumps(payload, separators=(',', ':')).encode(), headers=headers, fatal=False)
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_w... | same
```suggestion
formats, subtitles = self._extract_media_from_json(lead_video_id, json_obj)
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_URL = r'https?://(?:w... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.786 | refactor | 109 | 49 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
from ..utils import (
clean_html,
determine_ext,
extract_attributes,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
str_or_none,
traverse_obj,
unified_strdate,
url_or_none,
)
class NYTimesBaseIE(InfoE... | ```suggestion
for video in traverse_obj(content_media_json, ('renditions', ..., {dict})):
``` | from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
str_or_none,
traverse_obj,
url_or_none,
)
class N... | @@ -1,50 +1,33 @@
-import hmac
-import hashlib
-import base64
+import json
+import uuid
from .common import InfoExtractor
from ..utils import (
+ clean_html,
determine_ext,
- float_or_none,
+ extract_attributes,
+ get_elements_html_by_class,
int_or_none,
- js_to_json,
+ merge_dicts,
... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.714 | suggestion | 103 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'id': 'air-traffic-controllers-safety',
'title': 'Drunk and Asleep on the Job: Air Traffic Controllers Pushed to the Brink',
'description': 'md5:549e5a5e935bf7d048be53ba3d2c863d',
},
'playlist_count': 3,
}, {
'url': 'https://www.nytimes.com/2023/12/02/bus... | core code tries to set `ext` by calling `determine_ext` on format url if the extractor doesn't set the `ext`, so don't need to do it here. If it's an audio-only URL though, we should add `'vcodec': 'none'`
```suggestion
formats.append({'url': url, 'vcodec': 'none'})
``` | 'description': 'md5:93603dada88ddbda9395632fdc5da260',
'timestamp': 1398631707, # FIXME
'upload_date': '20140427', # FIXME
'creator': 'Brett Weiner',
'thumbnail': r're:https?://\w+\.nyt.com/images/.+\.jpg',
'duration': 419,
},
}, {
... | @@ -124,139 +82,408 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 285 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'subtitles': subtitles
}
def _extract_thumbnails(self, thumbs):
return traverse_obj(thumbs, (lambda _, v: url_or_none(v['url']), {
'url': 'url',
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
}))
def _real_extract... | inline `art_upload_date` in the `timestamp` field below -- as I said in another comment, manually calculating `upload_date` from the same value that you are using for `timestamp` is just unnecessary complexity.
Also, `timestamp` is not being added to the entries. Is this intentional? If it was an oversight, then it ... | 'uploader': 'Matthew Williams',
'creator': 'Patricia Cohen',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
'duration': 119.0,
},
}, {
# article with audio and no video
'url': 'https://www.nytimes.com/2023/09/29/health/mosquitoes-gene... | @@ -124,139 +82,408 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.643 | performance | 433 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'id': 'air-traffic-controllers-safety',
'title': 'Drunk and Asleep on the Job: Air Traffic Controllers Pushed to the Brink',
'description': 'md5:549e5a5e935bf7d048be53ba3d2c863d',
},
'playlist_count': 3,
}, {
'url': 'https://www.nytimes.com/2023/12/02/bus... | audio-only formats should have `'vcodec': 'none'`
```suggestion
formats.append({'url': url, 'vcodec': 'none'})
``` | },
}, {
'url': 'http://www.nytimes.com/video/travel/100000003550828/36-hours-in-dubai.html',
'only_matching': True,
}]
def _real_extract(self, url):
video_id = self._match_id(url)
return self._extract_video(video_id)
class NYTimesArticleIE(NYTimesBaseIE):
_VAL... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.786 | suggestion | 129 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'id': media_id,
'title': title,
'description': description,
'duration': duration,
'creator': creators, # TODO: change to 'creators'
'formats': formats,
'subtitles': subtitles,
'thumbnails': s... | is the google Referer necessary? also formatting
```suggestion
'Origin': 'https://cooking.nytimes.com',
}, fatal=False) or {}
``` | 'timestamp': 1701302400,
'upload_date': '20231130',
'creator': 'Sue Li',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
'url': 'https://cooking.nytimes.com/recipes/1019516-overnight-oats',
'md5': '2fe7965a3adc899913b8e25ada360... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.714 | suggestion | 161 | 51 | 42 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
yield {
'id': media_id,
'title': title,
'description': description,
'duration': duration,
'creator': creators, # TODO: change to 'creators'
'formats': formats,
'subtitles': subtitles,
... | formatting
```suggestion
'query': self._GRAPHQL_QUERY,
'variables': {'id': f'nyt://video/{media_uuid}'},
}, separators=(',', ':')).encode(), headers={
'Content-Type': 'application/json',
'Nyt-App-Type': 'vhs',
'Nyt-App-Ve... | 'description': 'md5:ba12394c585ababea951cb6d2fcc6631',
'timestamp': 1701302400,
'upload_date': '20231130',
'creator': 'Sue Li',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
'url': 'https://cooking.nytimes.com/recipes/101... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.929 | suggestion | 445 | 51 | 43 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
video_uuid = uuid.uuid5(self._DNS_NAMESPACE, 'video')
media_uuid = uuid.uuid5(video_uuid, media_id)
return self._download_json(
self._GRAPHQL_API, media_id, note='Downloading json from GRAPHQL API', data=json.dumps({
'query': self._GRAPHQL_QUERY, 'variables': {'id': ... | inline `creator` extraction in return | 'upload_date': '20190102',
'title': 'Overnight Oats',
'creator': 'Genevieve Ko',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}]
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_webpage(ur... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.286 | refactor | 37 | 47 | 29 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'playlist_count': 3,
}, {
'url': 'https://www.nytimes.com/2023/12/02/business/media/netflix-squid-game-challenge.html',
'only_matching': True,
}]
def _extract_content_from_block(self, block):
details = traverse_obj(block, {
'id': ('sourceId', {str}),
... | let's extract the thumbnails per block here
```suggestion
**details,
'thumbnails': self._extract_thumbnails(traverse_obj(
block, ('promotionalMedia', 'crops', ..., 'renditions', ...))),
'formats': formats,
``` | }]
def _real_extract(self, url):
video_id = self._match_id(url)
return self._extract_video(video_id)
class NYTimesArticleIE(NYTimesBaseIE):
_VALID_URL = r'https?://(?:www\.)?nytimes\.com/\d{4}/\d{2}/\d{2}/(?!books|podcasts)[^/?#]+/(?:\w+/)?(?P<id>[^./?#]+)(?:\.html)?'
_TESTS = [{
... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 267 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
url = traverse_obj(block, ('fileUrl', {url_or_none}))
if not formats and url:
formats.append({'url': url})
return {
**details,
'formats': formats,
'subtitles': subtitles
}
def _real_extract(self, url):
page_id = self._match_id... | extract common thumbs here
```suggestion
traverse_obj(art_json, ('bylines', ..., 'creators', ..., 'displayName'))), # TODO: change to 'creators' (list)
'thumbnails': self._extract_thumbnails(traverse_obj(
art_json, ('promotionalMedia', 'assetCrops', ..., 'renditions', ..... | 'upload_date': '20150414',
'uploader': 'Matthew Williams',
'creator': 'Patricia Cohen',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
'duration': 119.0,
},
}, {
# article with audio and no video
'url': 'https://www.nytime... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 341 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
art_json = self._search_json(
r'window\.__preloadedData\s*=', webpage, 'media details', page_id,
transform_source=lambda x: x.replace('undefined', 'null'))['initialData']['data']['article']
common_info = {
'title': remove_end(self._html_extract_title(webpage), ' - Th... | if applying the above 2 suggestions we can simplify like this (and remove below)
```suggestion
entries = []
for block in blocks:
entries.append({
**common_info,
**self._extract_content_from_block(block),
})
if len(entries) > 1:
... | 'title': 'The Gamble: Can Genetically Modified Mosquitoes End Disease?',
'description': 'md5:9ff8b47acbaf7f3ca8c732f5c815be2e',
'timestamp': 1695960700,
'upload_date': '20230929',
'creator': 'Stephanie Nolen, Natalija Gormalova',
'thumbnail': r're:... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 482 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'timestamp': traverse_obj(art_json, ('firstPublished', {parse_iso8601})),
'creator': ', '.join(
traverse_obj(art_json, ('bylines', ..., 'creators', ..., 'displayName'))) # TODO: change to 'creators' (list)
}
blocks = traverse_obj(art_json, (
'sprinkl... | if applying above suggestion we can remove this section
```suggestion
``` | 'url': 'https://www.nytimes.com/2023/11/29/business/dealbook/kamala-harris-biden-voters.html',
'md5': '3eb5ddb1d6f86254fe4f233826778737',
'info_dict': {
'id': '100000009202270',
'ext': 'mp4',
'title': 'Kamala Harris Defends Biden Policies, but Says ‘More Work’... | @@ -124,139 +88,347 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.643 | refactor | 75 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
determine_ext,
extract_attributes,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
str_or_none,
traverse_obj,
url_or_none,
)
class NYTimesBaseIE(InfoExtractor):
_GRAPHQL_API = 'https://samizdat-graphql.nyt... | imo we should be more direct/obvious with the name of this method: `_extract_formats_and_subtitles` | clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
str_or_none,
traverse_obj,
url_or_none,
)
class NYTimesBaseIE(InfoExtractor):
_DNS_NAME... | @@ -1,50 +1,39 @@
-import hmac
-import hashlib
-import base64
+import json
+import uuid
from .common import InfoExtractor
from ..utils import (
+ clean_html,
determine_ext,
- float_or_none,
+ extract_attributes,
+ get_elements_html_by_class,
int_or_none,
- js_to_json,
+ merge_dicts,
... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.429 | refactor | 99 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
def _extract_thumbnails(self, thumbs):
return traverse_obj(thumbs, (lambda _, v: url_or_none(v['url']), {
'url': 'url',
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
}), default=None)
def _extract_media_from_json(self, video_id, cont... | do you know why the old code was skipping dash manifest extraction? is it problematic in some way? should we do this?
```suggestion
self.report_warning('Skipping DASH formats', video_id)
``` | _DNS_NAMESPACE = uuid.UUID('36dd619a-56dc-595b-9e09-37f4152c7b5d')
_TOKEN = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuNIzKBOFB77aT/jN/FQ+/QVKWq5V1ka1AYmCR9hstz1pGNPH5ajOU9gAqta0T89iPnhjwla+3oec/Z3kGjxbpv6miQXufHFq3u2RC6HyU458cLat5kVPSOQCe3VVB5NRpOlRuwKHqn0txfxnwSSj8mqzstR997d3gKB//RO9zE16y3PoWlDQXkASngNJEWv... | @@ -59,51 +48,26 @@ def get_file_size(file_size):
subtitles = self._merge_subtitles(subtitles, m3u8_subs)
elif ext == 'mpd':
continue | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 209 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'title': 'The Gamble: Can Genetically Modified Mosquitoes End Disease?',
'description': 'md5:9ff8b47acbaf7f3ca8c732f5c815be2e',
'timestamp': 1695960700,
'upload_date': '20230929',
'creator': 'Stephanie Nolen, Natalija Gormalova',
'thumbnail': r're:... | this is enough
```suggestion
'skip_download': 'm3u8',
``` |
return {
'id': media_id,
'title': data.get('promotionalHeadline'),
'description': data.get('summary'),
'duration': float_or_none(data.get('duration'), scale=1000),
'creator': ', '.join(traverse_obj(data, ( # TODO: change to 'creators'
... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.571 | suggestion | 72 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
block, ('promotionalMedia', 'crops', ..., 'renditions', ...))),
'subtitles': subtitles
}
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_webpage(url, page_id)
art_json = self._search_json(
r'window\.__prelo... | I think we should raise here if we don't find anything. Better than an IndexError later imo
```suggestion
blocks = traverse_obj(art_json, (
'sprinkledBody', 'content', ..., ('ledeMedia', None),
lambda _, v: v['__typename'] in ('Video', 'Audio')))
if not blocks:
... | 'id': '100000009110381',
'ext': 'mp3',
'title': 'The Gamble: Can Genetically Modified Mosquitoes End Disease?',
'description': 'md5:9ff8b47acbaf7f3ca8c732f5c815be2e',
'timestamp': 1695960700,
'upload_date': '20230929',
'creator': 'Steph... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 1 | refactor | 396 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
}, {
'url': 'https://www.nytimes.com/2023/12/02/business/media/netflix-squid-game-challenge.html',
'only_matching': True,
}]
def _extract_content_from_block(self, block):
details = traverse_obj(block, {
'id': ('sourceId', {str}),
'uploader': ('bylines', ..., ... | nitpick: it's weird having thumbnails sandwiched between formats and subtitles
```suggestion
'thumbnails': self._extract_thumbnails(traverse_obj(
block, ('promotionalMedia', 'crops', ..., 'renditions', ...))),
'formats': formats,
``` | return self._extract_video(video_id)
class NYTimesArticleIE(NYTimesBaseIE):
_VALID_URL = r'https?://(?:www\.)?nytimes\.com/\d{4}/\d{2}/\d{2}/(?!books|podcasts)[^/?#]+/(?:\w+/)?(?P<id>[^./?#]+)(?:\.html)?'
_TESTS = [{
'url': 'http://www.nytimes.com/2015/04/14/business/owner-of-gravity-payments-... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 278 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
def _build_playlist(self, media_items):
for media_id in media_items:
json_obj = traverse_obj(self._json_from_graphql(media_id) or {}, ('data', 'video'))
title = json_obj.get('promotionalHeadline') or media_id
description = json_obj.get('summary')
creators = ... | `_call_api` is the convention
```suggestion
def _call_api(self, media_id):
``` | 'timestamp': 1447804800,
'upload_date': '20151118',
'creator': 'David Tanis',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
'url': 'https://cooking.nytimes.com/recipes/1024781-neapolitan-checkerboard-cookies',
'md5': '58df359... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.571 | suggestion | 85 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'title': title,
'description': description,
'duration': duration,
'creator': creators, # TODO: change to 'creators'
'formats': formats,
'subtitles': subtitles,
'thumbnails': self._extract_thumbnails(
... | instead of performing the same traversal outside of this method both times we call it, let's handle the traversal inside the method:
```suggestion
return traverse_obj(self._download_json(
self._GRAPHQL_API, media_id, 'Downloading JSON from GraphQL API', data=json.dumps({
'query':... | 'creator': 'Sue Li',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
'url': 'https://cooking.nytimes.com/recipes/1019516-overnight-oats',
'md5': '2fe7965a3adc899913b8e25ada360823',
'info_dict': {
'id': '1019516',
'ext':... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 1 | suggestion | 777 | 51 | 40 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'query': self._GRAPHQL_QUERY,
'variables': {'id': f'nyt://video/{media_uuid}'},
}, separators=(',', ':')).encode(), headers={
'Content-Type': 'application/json',
'Nyt-App-Type': 'vhs',
'Nyt-App-Version': 'v3.52.21',
... | ```suggestion
json_obj = self._call_api(lead_video_id)
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.571 | suggestion | 68 | 42 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
crops {
name
renditions {
name
width
height
url
}
}
}
}
renditions {
type
width
height
url
bitrate
}
summary
}
}
}'''
def _bu... | ```suggestion
json_obj = self._call_api(media_id)
``` | return self.playlist_result(
[self._extract_video(media_id) for media_id in media_ids], page_id, title, description)
return {
**self._extract_video(lead_video_id),
'title': title,
'description': description,
'creator': self._search_reg... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.571 | suggestion | 67 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
... on Image {
crops {
name
renditions {
name
width
height
url
}
}
}
}
renditions {
type
width
height
url
bitrate
}
summary
... | imo it's more clear to just call them `media_ids`
```suggestion
def _build_playlist(self, media_ids):
for media_id in media_ids:
``` | media_ids.append(lead_video_id)
return self.playlist_result(
[self._extract_video(media_id) for media_id in media_ids], page_id, title, description)
return {
**self._extract_video(lead_video_id),
'title': title,
'description': descript... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.714 | suggestion | 148 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
return self._download_json(
self._GRAPHQL_API, media_id, note='Downloading json from GRAPHQL API', data=json.dumps({
'query': self._GRAPHQL_QUERY,
'variables': {'id': f'nyt://video/{media_uuid}'},
}, separators=(',', ':')).encode(), headers={
... | ```suggestion
if media_ids:
media_ids.append(lead_video_id)
return self.playlist_result(self._build_playlist(media_ids), page_id, title, description)
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.714 | suggestion | 189 | 44 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
}
}'''
def _build_playlist(self, media_items):
for media_id in media_items:
json_obj = traverse_obj(self._json_from_graphql(media_id) or {}, ('data', 'video'))
title = json_obj.get('promotionalHeadline') or media_id
description = json_obj.get('summary')
cr... | ```suggestion
formats, subtitles = self._extract_formats_and_subtitles(media_id, json_obj)
yield {
'id': media_id,
'title': json_obj.get('promotionalHeadline'),
'description': json_obj.get('summary'),
'duration': int_or_none... | 'title': 'Cranberry Curd Tart',
'description': 'md5:ad77a3fc321db636256d4343c5742152',
'timestamp': 1447804800,
'upload_date': '20151118',
'creator': 'David Tanis',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 798 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
# reference: `id-to-uri.js`
video_uuid = uuid.uuid5(self._DNS_NAMESPACE, 'video')
media_uuid = uuid.uuid5(video_uuid, media_id)
return self._download_json(
self._GRAPHQL_API, media_id, note='Downloading json from GRAPHQL API', data=json.dumps({
'query': self.... | I don't think `lead_video_id` should be non-fatal? Or else we need to check before appending it to `media_ids` and we should raise after the playlist_result code path
```suggestion
title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
description = self._html_search_meta(['og:descrip... | 'upload_date': '20190102',
'title': 'Overnight Oats',
'creator': 'Genevieve Ko',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}]
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_webpage(ur... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 632 | 48 | 29 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_webpage(url, page_id)
lead_video_id = self._search_regex(
r'data-video-player-id="(\d+)"></div>', webpage, 'lead video', default=None)
media_items = traverse_obj(
get_element... | just cuz line too long
```suggestion
'creator': self._search_regex( # TODO: change to 'creators'
r'<span itemprop="author">([^<]+)</span></p>', webpage, 'author', default=None),
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
determine_ext,
extract_attributes,
float_or_none,
get_elements_html_by_class,
int_or_none,
merge_dicts,
mimetype2ext,
parse_iso8601,
remove_end,
remove_start,
... | @@ -124,139 +88,348 @@ class NYTimesIE(NYTimesBaseIE):
def _real_extract(self, url):
video_id = self._match_id(url)
+ # FIXME
- return self._extract_video_from_id(video_id)
+ return {
+ 'id': video_id
+ }
class NYTimesArticleIE(NYTimesBaseIE):
- _VALID_UR... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | security | 214 | 32 | 417 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
def _extract_thumbnails(self, thumbs):
return traverse_obj(thumbs, (lambda _, v: url_or_none(v['url']), {
'url': 'url',
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
}), default=None)
def _extract_formats_and_subtitles(self, video_id... | if we make it non-fatal I don't see how it could hurt
```suggestion
dash_fmts, dash_subs = self._extract_mpd_formats_and_subtitles(
video_url, video_id, fatal=False, mpd_id='dash')
formats.extend(dash_fmts)
self._merge_subtitles(dash_subs, target=... | _TOKEN = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuNIzKBOFB77aT/jN/FQ+/QVKWq5V1ka1AYmCR9hstz1pGNPH5ajOU9gAqta0T89iPnhjwla+3oec/Z3kGjxbpv6miQXufHFq3u2RC6HyU458cLat5kVPSOQCe3VVB5NRpOlRuwKHqn0txfxnwSSj8mqzstR997d3gKB//RO9zE16y3PoWlDQXkASngNJEWvL19iob/xwAkfEWCjyRILWFY0JYX3AvLMSbq7wsqOCE5srJpo7rRU32zsByhsp1D5W9OYqqw... | @@ -58,52 +48,27 @@ def get_file_size(file_size):
formats.extend(m3u8_fmts)
subtitles = self._merge_subtitles(subtitles, m3u8_subs)
elif ext == 'mpd':
- continue
- # formats.extend(self._extract_mpd_formats(
- # video_url, v... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.857 | refactor | 335 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
_DNS_UUID = '36dd619a-56dc-595b-9e09-37f4152c7b5d' # uuid -v5 ns:DNS scoop.nyt.net
_GRAPHQL_QUERY = '''query VideoQuery($id: String!) {
video(id: $id) {
... on Video {
advertisingProperties {
sensitivity
sponsored
}
bylines {
renderedRepresentation
}
... | note: these may be useful in the future | 'title': 'Cranberry Curd Tart',
'description': 'md5:ad77a3fc321db636256d4343c5742152',
'timestamp': 1447804800,
'upload_date': '20151118',
'creator': 'David Tanis',
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
},
}, {
... | @@ -59,204 +51,549 @@ def get_file_size(file_size):
subtitles = self._merge_subtitles(subtitles, m3u8_subs)
elif ext == 'mpd':
continue
- # formats.extend(self._extract_mpd_formats(
- # video_url, video_id, format_id or 'dash', fatal=False... | yt_dlp/extractor/nytimes.py | 26 | Python | 0.143 | suggestion | 39 | 51 | 51 | false | [ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides | 9,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
url
}
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...I... | `_perform_login` won't be called if the user does not provide credentials. This check needs to be done in `_real_extract` or `_real_initialize`. But does passing cookies (instead of user/pass) work for this site? Ideally we would check if an auth cookie is in the cookiejar (use `self._get_cookies()`) instead of checkin... | name
description
duration
episodeNumber
seasonNumber
seriesName
medias {
type
url
}
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
... | @@ -135,11 +138,29 @@ class PlaySuisseIE(InfoExtractor):
url
}'''
+ def _perform_login(self, username, password):
+ if username is None or password is None:
+ self.raise_login_required('Your Play Suisse account\'s details must be provided with --username and --password.') | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.643 | security | 335 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
... | - line too long
- use the `query` param of `_download_webpage()`
- single quotes | duration
episodeNumber
seasonNumber
seriesName
medias {
type
url
}
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
... | @@ -135,11 +138,29 @@ class PlaySuisseIE(InfoExtractor):
url
}'''
+ def _perform_login(self, username, password):
+ if username is None or password is None:
+ self.raise_login_required('Your Play Suisse account\'s details must be provided with --username and --password.')
+
... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.429 | refactor | 82 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
... | use `_search_json()`
```suggestion
settings = self._search_json(r'var\s+SETTINGS\s*=', login_page, 'settings', None)
``` | seasonNumber
seriesName
medias {
type
url
}
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
... | @@ -135,11 +138,29 @@ class PlaySuisseIE(InfoExtractor):
url
}'''
+ def _perform_login(self, username, password):
+ if username is None or password is None:
+ self.raise_login_required('Your Play Suisse account\'s details must be provided with --username and --password.')
+
... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.786 | suggestion | 131 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
def _get_media_data(self, media_id):
# NOTE In the web app, the "locale" header is used to switch between langu... | - review the contributing guide for code formatting
- inline `login_endpoint` in the `_download_webpage_handle` call, and use its `query` param
- single quotes | thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
... | @@ -135,11 +138,29 @@ class PlaySuisseIE(InfoExtractor):
url
}'''
+ def _perform_login(self, username, password):
+ if username is None or password is None:
+ self.raise_login_required('Your Play Suisse account\'s details must be provided with --username and --password.')
+
... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.714 | style | 161 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
def _get_media_data(self, media_id):
# NOTE In the web app, the "locale" header is used to switch between languages,
# However this doesn't seem to take effect when passing the header h... | the above comment applies here too | thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
... | @@ -135,11 +138,29 @@ class PlaySuisseIE(InfoExtractor):
url
}'''
+ def _perform_login(self, username, password):
+ if username is None or password is None:
+ self.raise_login_required('Your Play Suisse account\'s details must be provided with --username and --password.')
+
... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.071 | suggestion | 34 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
}
fragment ImageDetails on AssetImage {
id
url
}'''
def _get_media_data(self, media_id):
# NOTE In the web app, the "locale" header is used to switch between languages,
# However this doesn't seem to take effect when passing the header here.
r... | use `yt_dlp.utils.parse_qs` instead, then you won't need to `urlsplit`
we should probably error gracefully here (`raise ExtractorError`) if an `id_token` value is not present in the query instead of KeyErroring
also you need to set `_id_token` as a class variable outside of this method | ...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_LOGI... | @@ -135,11 +138,29 @@ class PlaySuisseIE(InfoExtractor):
url
}'''
+ def _perform_login(self, username, password):
+ if username is None or password is None:
+ self.raise_login_required('Your Play Suisse account\'s details must be provided with --username and --password.')
+
... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.786 | refactor | 292 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
import json
from .common import InfoExtractor
from ..utils import int_or_none, traverse_obj
class PlaySuisseIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?playsuisse\.ch/(?:watch|detail)/(?:[^#]*[?&]episodeId=)?(?P<id>[0-9]+)'
_TESTS = [
{
# Old URL
'url': 'https://www.p... | use `update_url_query` (import from utils) and inline below | raise ExtractorError('Invalid username or password', expected=True)
urlh = self._request_webpage(
f'{self._LOGIN_BASE_URL}/{self._LOGIN_PATH}/api/CombinedSigninAndSignup/confirmed',
None, 'Downloading ID token', query={
'rememberMe': 'false',
... | @@ -167,6 +188,7 @@ def _extract_single(self, media_data):
for media in traverse_obj(media_data, 'medias', default=[]):
if not media.get('url') or media.get('type') != 'HLS':
continue
+ media['url'] = media['url'] + "&id_token=" + self._id_token | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.429 | suggestion | 59 | 188 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
import json
from .common import InfoExtractor
from ..utils import int_or_none, traverse_obj, urlencode_postdata, parse_qs, ExtractorError, update_url_query
class PlaySuisseIE(InfoExtractor):
_NETRC_MACHINE = 'playsuisse'
_VALID_URL = r'https?://(?:www\.)?playsuisse\.ch/(?:watch|detail)/(?:[^#]*[?&]episodeId=... | use `isort`
```suggestion
from ..utils import (
ExtractorError,
int_or_none,
parse_qs,
traverse_obj,
update_url_query,
urlencode_postdata,
)
``` | import json
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
parse_qs,
traverse_obj,
update_url_query,
urlencode_postdata,
)
class PlaySuisseIE(InfoExtractor):
_NETRC_MACHINE = 'playsuisse'
_VALID_URL = r'https?://(?:www\.)?playsuisse\.ch/(?:watch|d... | @@ -1,10 +1,11 @@
import json
from .common import InfoExtractor
-from ..utils import int_or_none, traverse_obj
+from ..utils import int_or_none, traverse_obj, urlencode_postdata, parse_qs, ExtractorError, update_url_query | yt_dlp/extractor/playsuisse.py | 4 | Python | 0.929 | refactor | 178 | 29 | 29 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDeta... | since we reuse these values multiple times it will be more readable/maintainable to have them as class vars
```suggestion
_LOGIN_BASE_URL = 'https://login.srgssr.ch/srgssrlogin.onmicrosoft.com'
_LOGIN_PATH = 'B2C_1A__SignInV2'
_ID_TOKEN = None
``` | seasonNumber
seriesName
medias {
type
url
}
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
... | @@ -134,12 +135,35 @@ class PlaySuisseIE(InfoExtractor):
id
url
}'''
+ _ID_TOKEN = None | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.857 | suggestion | 264 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_ID_TOKEN = None
def _perform_login(self, username, password):
login_page =... | let's extract out the useful bits
```suggestion
settings = self._search_json(r'var\s+SETTINGS\s*=', login_page, 'settings', None)
csrf_token = settings['csrf']
query = {'tx': settings['transId'], 'p': self._LOGIN_PATH}
``` | thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
... | @@ -134,12 +135,35 @@ class PlaySuisseIE(InfoExtractor):
id
url
}'''
+ _ID_TOKEN = None
+
+ def _perform_login(self, username, password):
+ login_page = self._download_webpage(
+ 'https://www.playsuisse.ch/api/sso/login', None, note='Downloading login page',
+ ... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.857 | security | 253 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_ID_T... | we should expect an error if the user passes the wrong credentials
```suggestion
status = traverse_obj(self._download_json(
f'{self._LOGIN_BASE_URL}/{self._LOGIN_PATH}/SelfAsserted', None, 'Logging in'
query=query, headers={'X-CSRF-TOKEN': csrf_token}, data=urlencode_postdata({
... | type
url
}
thumbnail16x9 {
...ImageDetails
}
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {... | @@ -134,12 +135,35 @@ class PlaySuisseIE(InfoExtractor):
id
url
}'''
+ _ID_TOKEN = None
+
+ def _perform_login(self, username, password):
+ login_page = self._download_webpage(
+ 'https://www.playsuisse.ch/api/sso/login', None, note='Downloading login page',
+ ... | yt_dlp/extractor/playsuisse.py | 26 | Python | 1 | bug | 617 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_ID_TOKEN = None
def _perform_login(self, username, password):
login_page = self._download_webpage(
'https://... | we're not using `webpage` for anything, so `_request_webpage()` will suffice
```suggestion
urlh = self._request_webpage(
f'{self._LOGIN_BASE_URL}/{self._LOGIN_PATH}/api/CombinedSigninAndSignup/confirmed',
None, 'Downloading ID token', query={
'rememberMe': 'false',
... | }
thumbnail2x3 {
...ImageDetails
}
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
... | @@ -134,12 +135,35 @@ class PlaySuisseIE(InfoExtractor):
id
url
}'''
+ _ID_TOKEN = None
+
+ def _perform_login(self, username, password):
+ login_page = self._download_webpage(
+ 'https://www.playsuisse.ch/api/sso/login', None, note='Downloading login page',
+ ... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.786 | security | 438 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
id
url
}'''
_ID_TOKEN = None
def _perform_login(self, username, password):
login_page = self._download_webpage(
'https://www.playsuisse.ch/api/sso/login', None, note='Downloading login page',
query={'x': 'x', 'locale': 'de', 'redirectUrl': 'https:... | ```suggestion
self._ID_TOKEN = traverse_obj(parse_qs(urlh.url), ('id_token', 0))
if not self._ID_TOKEN:
raise ExtractorError('Login failed')
``` | ...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_LOGIN_BASE_URL = 'https://login.srgssr.ch/srgssrlogin.onmicrosoft.com'
_LOGIN_PATH ... | @@ -134,12 +135,35 @@ class PlaySuisseIE(InfoExtractor):
id
url
}'''
+ _ID_TOKEN = None
+
+ def _perform_login(self, username, password):
+ login_page = self._download_webpage(
+ 'https://www.playsuisse.ch/api/sso/login', None, note='Downloading login page',
+ ... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.929 | bug | 176 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
'https://login.srgssr.ch/srgssrlogin.onmicrosoft.com/B2C_1A__SignInV2/api/CombinedSigninAndSignup/confirmed',
None, note='Downloading ID token',
query={'rememberMe': 'false', 'csrf_token': settings['csrf'], 'tx': settings['transId'], 'p': 'B2C_1A__SignInV2', 'diags': ''})
qu... | ```suggestion
self.raise_login_required(method='password')
```
or else the error message will tell the user they can pass cookies too | settings = self._search_json(r'var\s+SETTINGS\s*=', login_page, 'settings', None)
csrf_token = settings['csrf']
query = {'tx': settings['transId'], 'p': self._LOGIN_PATH}
status = traverse_obj(self._download_json(
f'{self._LOGIN_BASE_URL}/{self._LOGIN_PATH}/SelfAsserted', N... | @@ -150,6 +174,9 @@ def _get_media_data(self, media_id):
return response['data']['assetV2']
def _real_extract(self, url):
+ if not self._ID_TOKEN:
+ self.raise_login_required() | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.929 | suggestion | 148 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_LOGIN_BASE_URL = 'https://login.srgssr.ch/srgssrlo... | ```suggestion
f'{self._LOGIN_BASE_URL}/{self._LOGIN_PATH}/SelfAsserted', None, 'Logging in',
``` | thumbnail16x9WithTitle {
...ImageDetails
}
thumbnail2x3WithTitle {
...ImageDetails
}
}
fragment ImageDetails on AssetImage {
id
url
}'''
_LOGIN_BASE_URL = 'https://login.srgssr.ch/srgssrlo... | @@ -134,12 +142,47 @@ class PlaySuisseIE(InfoExtractor):
id
url
}'''
+ _LOGIN_BASE_URL = 'https://login.srgssr.ch/srgssrlogin.onmicrosoft.com'
+ _LOGIN_PATH = 'B2C_1A__SignInV2'
+ _ID_TOKEN = None
+
+ def _perform_login(self, username, password):
+ login_page = self... | yt_dlp/extractor/playsuisse.py | 26 | Python | 0.714 | suggestion | 110 | 51 | 51 | false | [extractor/playsuisse] fix #7974 with login | 9,077 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | chkuendig |
import base64
import collections
import contextlib
import http.cookiejar
import http.cookies
import io
import json
import os
import re
import shutil
import struct
import subprocess
import sys
import tempfile
import time
import urllib.request
from datetime import datetime, timedelta, timezone
from enum import Enum, auto... | ```suggestion
from .compat import functools # isort: split
from .compat import compat_os_name
``` | import base64
import collections
import contextlib
import http.cookiejar
import http.cookies
import io
import json
import os
import re
import shutil
import struct
import subprocess
import sys
import tempfile
import time
import urllib.request
from datetime import datetime, timedelta, timezone
from enum import Enum, auto... | @@ -23,14 +23,15 @@
aes_gcm_decrypt_and_verify_bytes,
unpad_pkcs7,
)
-from .compat import functools
+from .compat import functools, compat_os_name | yt_dlp/cookies.py | 26 | Python | 0.714 | suggestion | 101 | 51 | 51 | false | [cookies] Improve error message for Windows `--cookies-from-browser chrome` issue | 9,080 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
require_js_player = self._get_default_ytcfg(client).get('REQUIRE_JS_PLAYER')
if 'js' in self._configuration_arg('player_skip'):
require_js_player = False
player_url = None
if not player_url and not tried_iframe_fallback and require_js_player:
... | IMO we shouldn't raise like this; we should instead fix #7715, the format selection bug that is causing `best` to select storyboards as a fallback, and then we will properly raise for no formats.
we could add the IP block note to the warning though, something like this?
```suggestion
f'Skip... | if 'configs' not in self._configuration_arg('player_skip') and client != 'web':
player_ytcfg = self._download_ytcfg(client, video_id) or player_ytcfg
player_url = player_url or self._extract_player_url(master_ytcfg, player_ytcfg, webpage=webpage)
require_js_player = ... | @@ -3703,7 +3703,8 @@ def append_client(*client_names):
pr_video_id = traverse_obj(pr, ('videoDetails', 'videoId'))
if pr_video_id and pr_video_id != video_id:
self.report_warning(
- f'Skipping player response from {client} client (got player... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | bug | 512 | 51 | 51 | false | [ie/youtube] Add helpful info if all responses are skipped | 9,083 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Grub4K |
'description': 'Medal,https://medal.tv/desktop/',
'uploader': 'Mimicc',
'timestamp': 1605580939,
'upload_date': '20201117',
'uploader_id': '5156321',
'uploader_url': 'https://medal.tv/users/5156321',
'comment_count': int,
'v... | ```suggestion
webpage = self._download_webpage(update_url_query(url, {'mobilebypass': 'true'}), video_id)
```
Import `update_url_query` from `..utils`. | 'ext': 'mp4',
'title': 'u tk me i tk u bigger',
'description': 'Medal,https://medal.tv/desktop/',
'uploader': 'Mimicc',
'timestamp': 1605580939,
'upload_date': '20201117',
'uploader_id': '5156321',
'thumbnail': 'https://cdn.... | @@ -81,6 +79,9 @@ class MedalTVIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
+ if '?mobilebypass=true' not in url:
+ url += ('&' if '?' in url else '?') + 'mobilebypass=true'
+
webpage = self._download_webpage(url, video_id) | yt_dlp/extractor/medaltv.py | 26 | Python | 0.714 | suggestion | 162 | 51 | 51 | false | Fix MedalTV extractor | 9,098 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | Danish-H |
'id': 'jTBFnLKdLy15K',
'ext': 'mp4',
'title': "Mornu's clutch",
'description': '',
'uploader': 'Aciel',
'timestamp': 1651628243,
'upload_date': '20220504',
'uploader_id': '19335460',
'uploader_url': 'https://meda... | Add the thumbnail line back, even if it makes the test fail. Thumbnail extraction is failing and will need to be fixed (in a separate PR -- not your responsibility) | 'id': 'jTBFnLKdLy15K',
'ext': 'mp4',
'title': "Mornu's clutch",
'description': '',
'uploader': 'Aciel',
'timestamp': 1651628243,
'upload_date': '20220504',
'uploader_id': '19335460',
'uploader_url': 'https://meda... | @@ -44,15 +45,14 @@ class MedalTVIE(InfoExtractor):
'timestamp': 1603165266,
'upload_date': '20201020',
'uploader_id': '10619174',
- 'thumbnail': 'https://cdn.medal.tv/10619174/thumbnail-34934644-720p.jpg?t=1080p&c=202042&missing', | yt_dlp/extractor/medaltv.py | 26 | Python | 0.429 | bug | 164 | 51 | 51 | false | Fix MedalTV extractor | 9,098 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Danish-H |
import re
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class Art19IE(InfoExtractor):
_UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
_VALID_URL = [
rf'https?://(?:ww... | I think a UUID without dashes is not valid. Unless you have examples of this site using invalid UUIDs, I would simplify the pattern by enforcing dashes
```suggestion
_UUID_REGEX = r'[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}'
```
could do this to make it shorter, although arguably harder to... | import re
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class Art19IE(InfoExtractor):
_UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
_VALID_URL = [
rf'https?://(?:ww... | @@ -0,0 +1,304 @@
+import re
+
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class Art19IE(InfoExtractor):
+ _UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}' | yt_dlp/extractor/art19.py | 9 | Python | 0.857 | refactor | 450 | 34 | 34 | false | [ie/art19] Add extractors | 9,099 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
import re
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class Art19IE(InfoExtractor):
_UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
_VALID_URL = [
rf'https?://(?:ww... | not needed
```suggestion
_EMBED_REGEX = [rf'<iframe[^>]+\bsrc=[\'"](?P<url>{_VALID_URL[0]})']
``` | import re
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj
class Art19IE(InfoExtractor):
_UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
_VALID_URL = [
rf'https?://(?:ww... | @@ -0,0 +1,304 @@
+import re
+
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class Art19IE(InfoExtractor):
+ _UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
+ _VALID_URL =... | yt_dlp/extractor/art19.py | 14 | Python | 0.714 | suggestion | 104 | 39 | 39 | false | [ie/art19] Add extractors | 9,099 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'release_timestamp': ('released_at', {parse_iso8601}),
'modified_timestamp': ('updated_at', {parse_iso8601})
})),
**traverse_obj(rss_metadata, ('content', {
'title': ('episode_title', {str}),
'description': ('episode_description_pla... | ```suggestion
_EMBED_REGEX = [rf'<iframe[^>]+\bsrc=[\'"](?P<url>{_VALID_URL_BASE}[^\'"])']
``` | 'modified_timestamp': ('updated_at', {parse_iso8601})
})),
**traverse_obj(rss_metadata, ('content', {
'title': ('episode_title', {str}),
'description': ('episode_description_plain', {str}),
'episode_id': ('episode_id', {str}),
... | @@ -0,0 +1,304 @@
+import re
+
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class Art19IE(InfoExtractor):
+ _UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
+ _VALID_URL =... | yt_dlp/extractor/art19.py | 26 | Python | 0.714 | suggestion | 100 | 51 | 51 | false | [ie/art19] Add extractors | 9,099 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
note='Downloading player metadata', fatal=False,
headers={'Accept': 'application/vnd.art19.v0+json'})
rss_metadata = self._download_json(
f'https://rss.art19.com/episodes/{episode_id}.json', episode_id, fatal=False,
note='Downloading RSS metadata')
format... | ```suggestion
formats = [{
'format_id': 'direct',
'url': f'https://rss.art19.com/episodes/{episode_id}.mp3',
'vcodec': 'none',
'acodec': 'mp3',
}]
for fmt_id, fmt_data in traverse_obj(rss_metadata, ('content', 'media', {dict.items}, ...)):
... | note='Downloading player metadata', fatal=False,
headers={'Accept': 'application/vnd.art19.v0+json'})
rss_metadata = self._download_json(
f'https://rss.art19.com/episodes/{episode_id}.json', episode_id, fatal=False,
note='Downloading RSS metadata')
format... | @@ -0,0 +1,304 @@
+import re
+
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class Art19IE(InfoExtractor):
+ _UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
+ _VALID_URL =... | yt_dlp/extractor/art19.py | 26 | Python | 0.786 | suggestion | 762 | 51 | 51 | false | [ie/art19] Add extractors | 9,099 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'timestamp': 1360215023,
'thumbnail': 'https://i49.vbox7.com/design/iconci/png/noimg6.png',
'description': 'Смях! Чудо - чист за секунди - Скрита камера',
'upload_date': '20130207',
'duration': 83,
},
'expected_warnings': ['Failed to download m... | what do some `data['src']` values look like? | 'timestamp': 1360215023,
'thumbnail': 'https://i49.vbox7.com/design/iconci/png/noimg6.png',
'description': 'Смях! Чудо - чист за секунди - Скрита камера',
'upload_date': '20130207',
'duration': 83,
},
'expected_warnings': ['Failed to download m... | @@ -53,41 +60,33 @@ class Vbox7IE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
- response = self._download_json(
- 'https://www.vbox7.com/ajax/video/nextvideo.php?vid=%s' % video_id,
- video_id)
-
- if 'error' in response:
- ... | yt_dlp/extractor/vbox7.py | 26 | Python | 0.214 | question | 44 | 49 | 51 | false | [ie/Vbox7] Fix extractor | 9,100 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'url': 'http://vbox7.com/play:0946fff23c',
'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf',
'info_dict': {
'id': '0946fff23c',
'ext': 'mp4',
'title': 'Борисов: Притеснен съм за бъдещето на България',
'description': 'По думите му е опасно страната ни да б... | Really? `noimg6.png` isn't a likely name for a useful image (and the image isn't). Should it be filtered out?
I get:
```
'thumbnail': 'https://i49.vbox7.com/o/249/249bb972c20.jpg',
```
and that is an image that looks like a frame of the video. | _TESTS = [{
'url': 'http://vbox7.com/play:0946fff23c',
'md5': '50ca1f78345a9c15391af47d8062d074',
'info_dict': {
'id': '0946fff23c',
'ext': 'mp4',
'title': 'Борисов: Притеснен съм за бъдещето на България',
'description': 'По думите му е опасно ... | @@ -29,19 +30,25 @@ class Vbox7IE(InfoExtractor):
'timestamp': 1470982814,
'upload_date': '20160812',
'uploader': 'zdraveibulgaria',
- },
- 'params': {
- 'proxy': '127.0.0.1:8118',
+ 'view_count': int,
+ 'duration': 2640,
},
... | yt_dlp/extractor/vbox7.py | 26 | Python | 0.857 | suggestion | 260 | 51 | 51 | false | [ie/Vbox7] Fix extractor | 9,100 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | seproDev |
class ORFONIE(InfoExtractor):
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
_TESTS = [{
'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duration': 2651.08,
... | I think the safest way to do this would be
```suggestion
for manifest_type in traverse_obj(api_json, ('sources', {dict.keys}, ...)):
``` |
class ORFONIE(InfoExtractor):
IE_NAME = 'orf:on'
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
_TESTS = [{
'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'durati... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.857 | suggestion | 147 | 51 | 51 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duration': 2651.08,
'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
'title': 'School of Champions (4/8)',
'description': 'md5:d0... | We could traverse for the url itself, and hls should be non-fatal too since there are multiple m3u8 urls
```suggestion
for manifest_url in traverse_obj(api_json, ('sources', manifest_type, ..., 'src', {url_or_none})):
fmts, subs = [], {}
if manifest_type == 'hls':
... | 'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duration': 2651.08,
'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
'title': 'School of Champions (4/8)',
'description': 'md5:d0... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 1 | refactor | 591 | 51 | 51 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'media_type': 'episode',
}
}]
def _call_api(self, video_id, display_id):
# NOTE: the prefix `3dSlfek03nsLKdj4Jsd` is only based on my observation on several
# api call. This string may change in future
encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.... | We are always passing `video_id` so the fallback is never used
```suggestion
'id': video_id,
``` | 'media_type': 'episode',
'timestamp': 1706472362,
'upload_date': '20240128',
}
}]
def _extract_video(self, video_id, display_id):
encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
api_json = self._download_json(
... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.786 | suggestion | 111 | 51 | 50 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
api_json = self._download_json(
f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', display_id)
formats, subtitles = [], {}
for manifest_type in api_json.get('sources') or [{}]:
for manifest_info in traverse_obj(api_json, ('sources', manifest_t... | if you want to branch and try `title` before `headline` etc, do it like this:
```suggestion
'title': (('title', 'headline'), {str}),
'description': (('description', 'teaser_text'), {str}),
'media_type': ('video_type', {str}),
}, get_all=False)
``` | api_json = self._download_json(
f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', display_id)
formats, subtitles = [], {}
for manifest_type in traverse_obj(api_json, ('sources', {dict.keys}, ...)):
for manifest_url in traverse_obj(api_json, (... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.929 | suggestion | 313 | 48 | 42 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
fmt, subs = [], {}
if manifest_type == 'hls':
fmt, subs = self._extract_m3u8_formats_and_subtitles(manifest_info.get('src'), display_id)
elif manifest_type == 'dash':
fmt, subs = self._extract_mpd_formats_and_subtitles(manifest_info... | json ld should be non-fatal since it's only metadata and mostly fallback metadata | if manifest_type == 'hls':
fmts, subs = self._extract_m3u8_formats_and_subtitles(
manifest_url, display_id, fatal=False, m3u8_id='hls')
elif manifest_type == 'dash':
fmts, subs = self._extract_mpd_formats_and_subtitles(
... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.286 | suggestion | 81 | 42 | 36 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
fmt, subs = self._extract_mpd_formats_and_subtitles(manifest_info.get('src'), display_id, fatal=False)
else:
continue
formats.extend(fmt)
self._merge_subtitles(subs, target=subtitles)
return {
'id': video_id or ... | ```suggestion
return merge_dicts(self._call_api(video_id, display_id), {
```
but we don't even really need `merge_dicts` here, since `traverse_obj` will not return keys paired with `None` values. We could just unpack `**self._call_api(video_id, display_id)` after the unpacked json ld traversal | fmts, subs = self._extract_mpd_formats_and_subtitles(
manifest_url, display_id, fatal=False, mpd_id='dash')
else:
continue
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
return {
... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.857 | suggestion | 307 | 38 | 32 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'formats': formats,
'subtitles': subtitles,
**traverse_obj(api_json, {
'duration': ('duration_second', float_or_none),
'title': (('title'), ('headline')),
'description': (('description'), ('teaser_text')),
'media_type': ... | ```suggestion
'timestamp': ('timestamp', {int_or_none}),
```
not really necessary to transform though since `_search_json_ld()` should return the proper types | import base64
import functools
import re
from .common import InfoExtractor
from ..networking import HEADRequest
from ..utils import (
InAdvancePagedList,
clean_html,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
make_archive_id,
mimetype2ext,
orderedSet,
remove_end,
... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.929 | suggestion | 177 | 30 | 632 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'thumbnail': thumbnail,
'upload_date': upload_date,
'formats': formats,
})
return self.playlist_result(entries)
class ORFONIE(InfoExtractor):
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
_TESTS = [{
'url'... | The comment is not necessary imo.
Also, this method does quite a bit more than just call the api, it could be renamed, e.g. `_extract_video` | 'upload_date': upload_date,
'formats': formats,
})
return self.playlist_result(entries)
class ORFONIE(InfoExtractor):
IE_NAME = 'orf:on'
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
_TESTS = [{
'url': 'https://on.orf... | @@ -565,3 +567,71 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.571 | refactor | 142 | 51 | 51 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
}]
def _extract_video(self, video_id, display_id):
encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
api_json = self._download_json(
f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', display_id)
formats, subtitl... | transformations in traversal paths need to be in curly braces (`set` syntax)
```suggestion
'duration': ('duration_second', {float_or_none}),
``` | }
}]
def _extract_video(self, video_id, display_id):
encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
api_json = self._download_json(
f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', display_id)
format... | @@ -565,3 +566,66 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.714 | suggestion | 163 | 47 | 47 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duration': 2651.08,
'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
'title': 'School of Champions (4/8)',
'description': 'md5:d0... | it would be good to set the format_id prefixes so users can easily distinguish hls from dash
```suggestion
fmts, subs = self._extract_m3u8_formats_and_subtitles(
manifest_url, display_id, fatal=False, m3u8_id='hls')
elif manifest_type == 'dash':
... | 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duration': 2651.08,
'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
... | @@ -565,3 +566,66 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 1 | refactor | 468 | 51 | 51 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
class ORFONIE(InfoExtractor):
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
_TESTS = [{
'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duration': 2651.08,
... | don't have to worry about these being unbound because of `else: continue`
```suggestion
``` | class ORFONIE(InfoExtractor):
IE_NAME = 'orf:on'
_VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
_TESTS = [{
'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
'info_dict': {
'id': '14210000',
'ext': 'mp4',
'duratio... | @@ -565,3 +566,66 @@ def _real_extract(self, url):
})
return self.playlist_result(entries)
+
+
+class ORFONIE(InfoExtractor):
+ _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
+ _TESTS = [{
+ 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',... | yt_dlp/extractor/orf.py | 26 | Python | 0.643 | suggestion | 93 | 51 | 51 | false | [ie/orf] Add ORFON extractor | 9,113 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'only_matching': True,
}, {
# FMT (TOKYO FM) station does not provide <desc>
'url': 'https://radiko.jp/#!/ts/FMT/20210810150000',
'only_matching': True,
}, {
'url': 'https://radiko.jp/#!/ts/JOAK-FM/20210509090000',
'only_matching': True,
}]
def _real_extr... | this is fatal, `unified_timestamp` can return `None`. wrap in `try_call` |
class RadikoIE(RadikoBaseIE):
_VALID_URL = r'https?://(?:www\.)?radiko\.jp/#!/ts/(?P<station>[A-Z0-9-]+)/(?P<id>\d+)'
_TESTS = [{
# QRR (文化放送) station provides <desc>
'url': 'https://radiko.jp/#!/ts/QRR/20210425101300',
'only_matching': True,
}, {
# FMT (TOKYO FM) station ... | @@ -186,10 +186,12 @@ def _real_extract(self, url):
return {
'id': video_id,
'title': try_call(lambda: prog.find('title').text),
+ 'artist': try_call(lambda: prog.find('pfm').text),
'description': clean_html(try_call(lambda: prog.find('info').text)),
... | yt_dlp/extractor/radiko.py | 26 | Python | 0.357 | suggestion | 72 | 51 | 51 | false | [ie/radiko]add Metadata info (performer, duration) | 9,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | YoshichikaAAA |
# QRR (文化放送) station provides <desc>
'url': 'https://radiko.jp/#!/live/QRR',
'only_matching': True,
}, {
# FMT (TOKYO FM) station does not provide <desc>
'url': 'https://radiko.jp/#!/live/FMT',
'only_matching': True,
}, {
'url': 'https://radiko.jp/#!/live/... | wrap in `try_call` and inline in return | ),
}
class RadikoRadioIE(RadikoBaseIE):
_VALID_URL = r'https?://(?:www\.)?radiko\.jp/#!/live/(?P<id>[A-Z0-9-]+)'
_TESTS = [{
# QRR (文化放送) station provides <desc>
'url': 'https://radiko.jp/#!/live/QRR',
'only_matching': True,
}, {
# FMT (TOKYO FM) statio... | @@ -234,6 +236,7 @@ def _real_extract(self, url):
title = prog.find('title').text
description = clean_html(prog.find('info').text)
station_name = station_program.find('.//name').text
+ performer = prog.find('pfm').text | yt_dlp/extractor/radiko.py | 26 | Python | 0.214 | suggestion | 39 | 44 | 51 | false | [ie/radiko]add Metadata info (performer, duration) | 9,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | YoshichikaAAA |
update_url_query,
)
class RadikoBaseIE(InfoExtractor):
_GEO_BYPASS = False
_FULL_KEY = None
_HOSTS_FOR_TIME_FREE_FFMPEG_UNSUPPORTED = (
'https://c-rpaa.smartstream.ne.jp',
'https://si-c-radiko.smartstream.ne.jp',
'https://tf-f-rpaa-radiko.smartstream.ne.jp',
'https://tf... | the separator character class is a good idea, but we can inline this in the method
```suggestion
``` | update_url_query,
)
from ..utils.traversal import traverse_obj
class RadikoBaseIE(InfoExtractor):
_GEO_BYPASS = False
_FULL_KEY = None
_HOSTS_FOR_TIME_FREE_FFMPEG_UNSUPPORTED = (
'https://c-rpaa.smartstream.ne.jp',
'https://si-c-radiko.smartstream.ne.jp',
'https://tf-f-rpaa-rad... | @@ -33,6 +34,8 @@ class RadikoBaseIE(InfoExtractor):
_HOSTS_FOR_LIVE = (
'https://c-radiko.smartstream.ne.jp',
)
+ # performer separtor character (include Japanese charset)
+ _PERFORMER_SPLIT_RE = "[//、 ,,]" | yt_dlp/extractor/radiko.py | 26 | Python | 0.714 | suggestion | 102 | 51 | 51 | false | [ie/radiko]add Metadata info (performer, duration) | 9,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | YoshichikaAAA |
})
time_to_skip = None if is_onair else cursor - ft
domain = urllib.parse.urlparse(playlist_url).netloc
subformats = self._extract_m3u8_formats(
playlist_url, video_id, ext='m4a',
live=True, fatal=False, m3u8_id=domain,
no... | This is still fatal (`try_call` returns `None` when it fails, which is not iterable), and the `artists` PR has not been merged yet, so we'll still need a string for now:
```suggestion
def _extract_performers(self, prog):
performers = traverse_obj(prog, (
'pfm/text()', ..., {lambda x: re.spli... |
time_to_skip = None if is_onair else cursor - ft
domain = urllib.parse.urlparse(playlist_url).netloc
subformats = self._extract_m3u8_formats(
playlist_url, video_id, ext='m4a',
live=True, fatal=False, m3u8_id=domain,
note=f'Downloadin... | @@ -159,6 +162,9 @@ def _extract_formats(self, video_id, station, is_onair, ft, cursor, auth_token,
return formats
+ def _extract_performers(self, prog):
+ return [x.strip() for x in try_call(lambda: re.split(self._PERFORMER_SPLIT_RE, prog.find('pfm').text))] | yt_dlp/extractor/radiko.py | 26 | Python | 0.857 | bug | 503 | 51 | 51 | false | [ie/radiko]add Metadata info (performer, duration) | 9,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | YoshichikaAAA |
_VALID_URL = r'https?://(?:www\.)?radiko\.jp/#!/ts/(?P<station>[A-Z0-9-]+)/(?P<id>\d+)'
_TESTS = [{
# QRR (文化放送) station provides <desc>
'url': 'https://radiko.jp/#!/ts/QRR/20210425101300',
'only_matching': True,
}, {
# FMT (TOKYO FM) station does not provide <desc>
... | ```suggestion
'artist': self._extract_performers(prog),
``` |
class RadikoIE(RadikoBaseIE):
_VALID_URL = r'https?://(?:www\.)?radiko\.jp/#!/ts/(?P<station>[A-Z0-9-]+)/(?P<id>\d+)'
_TESTS = [{
# QRR (文化放送) station provides <desc>
'url': 'https://radiko.jp/#!/ts/QRR/20210425101300',
'only_matching': True,
}, {
# FMT (TOKYO FM) station d... | @@ -186,10 +192,12 @@ def _real_extract(self, url):
return {
'id': video_id,
'title': try_call(lambda: prog.find('title').text),
+ 'artists': self._extract_performers(prog), | yt_dlp/extractor/radiko.py | 26 | Python | 0.643 | refactor | 73 | 51 | 51 | false | [ie/radiko]add Metadata info (performer, duration) | 9,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | YoshichikaAAA |
}]
def _real_extract(self, url):
station = self._match_id(url)
self.report_warning('Downloader will not stop at the end of the program! Press Ctrl+C to stop')
auth_token, area_id = self._auth_client()
# get current time in JST (GMT+9:00 w/o DST)
vid_now = time_seconds(h... | ```suggestion
'artist': self._extract_performers(prog),
``` | 'url': 'https://radiko.jp/#!/live/JOAK-FM',
'only_matching': True,
}]
def _real_extract(self, url):
station = self._match_id(url)
self.report_warning('Downloader will not stop at the end of the program! Press Ctrl+C to stop')
auth_token, area_id = self._auth_client()
... | @@ -243,6 +252,7 @@ def _real_extract(self, url):
return {
'id': station,
'title': title,
+ 'artists': performers, | yt_dlp/extractor/radiko.py | 26 | Python | 0.643 | refactor | 73 | 34 | 35 | false | [ie/radiko]add Metadata info (performer, duration) | 9,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | YoshichikaAAA |
'modified_date': '20240118',
'title': 'Afsnit 1: “Det føltes som en kidnapning.” ',
'upload_date': '20240116',
'uploader_id': 'a81VP3BY',
'modified_timestamp': 1705568739,
'release_timestamp': 1705377592,
'uploader_url': 'https://www.ze... | would be best to ensure URLs with a `url_or_none` transformation
```suggestion
for audio_url in traverse_obj(story_data, ('story_content', 'meta', 'audioFiles', ..., {url_or_none})):
``` | 'modified_date': '20240118',
'title': 'Afsnit 1: “Det føltes som en kidnapning.” ',
'upload_date': '20240116',
'uploader_id': 'a81VP3BY',
'modified_timestamp': 1705568739,
'release_timestamp': 1705377592,
'uploader_url': 'https://www.ze... | @@ -0,0 +1,73 @@
+from .common import InfoExtractor
+from ..utils import determine_ext, merge_dicts, unified_timestamp
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 26 | Python | 0.714 | suggestion | 197 | 51 | 51 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'modified_timestamp': 1705568739,
'release_timestamp': 1705377592,
'uploader_url': 'https://www.zetland.dk/skribent/a81VP3BY',
'uploader': 'Helle Fuusager',
'release_date': '20240116',
'thumbnail': 'https://zetland.imgix.net/2aafe500-b14e-11ee-bf83... | core code will set `ext` from `determine_ext(url)` if the extractor doesn't set it, so it's better to keep it simple imo
```suggestion
'url': audio_url,
'vcodec': 'none',
``` | 'modified_timestamp': 1705568739,
'release_timestamp': 1705377592,
'uploader_url': 'https://www.zetland.dk/skribent/a81VP3BY',
'uploader': 'Helle Fuusager',
'release_date': '20240116',
'thumbnail': r're:https://zetland\.imgix\.net/2aafe500-b14e-11e... | @@ -0,0 +1,73 @@
+from .common import InfoExtractor
+from ..utils import determine_ext, merge_dicts, unified_timestamp
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 26 | Python | 0.857 | refactor | 210 | 51 | 51 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
webpage = self._download_webpage(url, display_id)
next_js_data = self._search_nextjs_data(webpage, display_id)['props']['pageProps']
story_data = traverse_obj(next_js_data, ('initialState', 'consume', 'story', 'story'))
formats = []
for audio_url in traverse_obj(story_data, ('s... | `or` won't work as you want it to within a traversal path, you need to use branching instead, with `get_all=False` so it doesn't return a list
```suggestion
}, traverse_obj(story_data, {
'title': ((('story_content', 'content', 'title'), 'title'), {str}),
'uploader': ('sharer', 'name'... | webpage = self._download_webpage(url, display_id)
next_js_data = self._search_nextjs_data(webpage, display_id)['props']['pageProps']
story_data = traverse_obj(next_js_data, ('initialState', 'consume', 'story', 'story'))
formats = []
for audio_url in traverse_obj(story_data, ('s... | @@ -0,0 +1,73 @@
+from .common import InfoExtractor
+from ..utils import determine_ext, merge_dicts, unified_timestamp
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 26 | Python | 0.857 | suggestion | 739 | 43 | 41 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'ext': determine_ext(audio_url)
})
return merge_dicts({
'id': display_id,
'formats': formats,
'uploader_id': uploader_id
}, traverse_obj(story_data, {
'title': ('story_content', 'content', 'title') or 'title',
'uplo... | same as above
```suggestion
'title': ((('meta', 'title'), ('ld', 'headline'), ('og', 'og:title'), ('og', 'twitter:title')), {str}),
'description': ((('meta', 'description'), ('ld', 'description'), ('og', 'og:description'), ('og', 'twitter:description')), {str}),
'uploader': ((('m... | })
return merge_dicts({
'id': display_id,
'formats': formats,
'uploader_id': uploader_id
}, traverse_obj(story_data, {
'title': ((('story_content', 'content', 'title'), 'title'), {str}),
'uploader': ('sharer', 'name'),
... | @@ -0,0 +1,73 @@
+from .common import InfoExtractor
+from ..utils import determine_ext, merge_dicts, unified_timestamp
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 26 | Python | 0.786 | security | 813 | 33 | 31 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
'uploader_id': uploader_id
}, traverse_obj(story_data, {
'title': ('story_content', 'content', 'title') or 'title',
'uploader': ('sharer', 'name'),
'uploader_id': ('sharer', 'sharer_id'),
'description': ('story_content', 'content', 'sosialDescription')... | json ld should be non-fatal since it is metadata-only and a fallback to a fallback | from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https?://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'... | @@ -0,0 +1,73 @@
+from .common import InfoExtractor
+from ..utils import determine_ext, merge_dicts, unified_timestamp
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 26 | Python | 0.286 | suggestion | 82 | 27 | 72 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
}]
def _real_extract(self, url):
display_id, uploader_id = self._match_valid_url(url).group('id', 'uploader_id')
webpage = self._download_webpage(url, display_id)
next_js_data = self._search_nextjs_data(webpage, display_id)['props']['pageProps']
story_data = traverse_obj(next_... | typo?
```suggestion
'description': ('story_content', 'content', 'socialDescription'),
``` |
}]
def _real_extract(self, url):
display_id, uploader_id = self._match_valid_url(url).group('id', 'uploader_id')
webpage = self._download_webpage(url, display_id)
next_js_data = self._search_nextjs_data(webpage, display_id)['props']['pageProps']
story_data = traverse_obj(next_... | @@ -0,0 +1,71 @@
+from .common import InfoExtractor
+from ..utils import merge_dicts, unified_timestamp, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 26 | Python | 0.714 | suggestion | 104 | 46 | 46 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'url... | use regex here imo
```suggestion
'thumbnail': r're:https://zetland\.imgix\.net/2aafe500-b14e-11ee-bf83-65d5e1283a57/Zetland_Image_1\.jpg',
``` | from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https?://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'... | @@ -0,0 +1,71 @@
+from .common import InfoExtractor
+from ..utils import merge_dicts, unified_timestamp, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
+ ... | yt_dlp/extractor/zetland.py | 22 | Python | 0.786 | suggestion | 157 | 47 | 47 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'url... | ```suggestion
_VALID_URL = r'https://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
``` | from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https?://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'... | @@ -0,0 +1,71 @@
+from .common import InfoExtractor
+from ..utils import merge_dicts, unified_timestamp, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www.zetland.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))' | yt_dlp/extractor/zetland.py | 7 | Python | 0.714 | suggestion | 129 | 32 | 32 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | HobbyistDev |
from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'u... | ```suggestion
_VALID_URL = r'https?://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
``` | from .common import InfoExtractor
from ..utils import merge_dicts, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class ZetlandDKArticleIE(InfoExtractor):
_VALID_URL = r'https?://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))'
_TESTS = [{
'... | @@ -0,0 +1,71 @@
+from .common import InfoExtractor
+from ..utils import merge_dicts, unified_timestamp, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class ZetlandDKArticleIE(InfoExtractor):
+ _VALID_URL = r'https://www\.zetland\.dk/\w+/(?P<id>(?P<story_id>\w{8})-(?P<uploader_id>\w{8})-(?:\w{5}))' | yt_dlp/extractor/zetland.py | 7 | Python | 0.714 | suggestion | 130 | 32 | 32 | false | [ie/zetland] Add ZetlandDKArticle Extractor | 9,116 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | HobbyistDev |
'tbr': float_or_none(video.get('bandwidth'), scale=1000),
'filesize': int_or_none(video.get('size')),
'quality': int_or_none(video.get('id')),
'format_id': traverse_obj(
video, (('baseUrl', 'base_url'), {self._FORMAT_ID_RE.search}, 1),
('id... | The patch by GD_Slime tried using `http_dash_segments` to handle segmented multi-video flv, which #6438 previously tried to address.
It appears that `http_dash_segments` downloader is not meant for this and will cause timestamp problems, and later converting this to a `multi_video` playlist (and discarding other forma... | 'acodec': traverse_obj(audio, ('codecs', {str.lower})),
'vcodec': 'none',
'tbr': float_or_none(audio.get('bandwidth'), scale=1000),
'filesize': int_or_none(audio.get('size')),
'format_id': str_or_none(audio.get('id')),
} for audio in audios]
f... | @@ -86,10 +88,30 @@ def extract_formats(self, play_info):
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
+ if formats and missing_formats:
self.to_sc... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | style | 439 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | c-basalt | c-basalt |
}, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_old_archive_ids': [make_archive_id(self, old_video_id)] if old_video_id else None,
'title': title,
'http_headers': headers,
}
is_interactive = traverse_obj(video_da... | It seems that even for those with flv format, a single-file mp4 format is still available.
```suggestion
if traverse_obj(formats, lambda _, v: v['fragments']):
# choose best quality for multi_video
formats = traverse_obj(formats, lambda _, v: not v.get('fragme... |
if is_anthology:
part_id = part_id or 1
title += f' p{part_id:02d} {traverse_obj(page_list_json, (part_id - 1, "part")) or ""}'
aid = video_data.get('aid')
old_video_id = format_field(aid, None, f'%s_part{part_id or 1}')
cid = traverse_obj(video_data, ('pages', ... | @@ -589,14 +690,40 @@ def _real_extract(self, url):
'__post_extractor': self.extract_comments(aid),
})
else:
- return {
- **metainfo,
- 'duration': float_or_none(play_info.get('timelength'), scale=1000),
- 'chapters':... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.857 | question | 511 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | c-basalt | c-basalt |
formats.extend({
'url': traverse_obj(video, 'baseUrl', 'base_url', 'url'),
'ext': mimetype2ext(traverse_obj(video, 'mimeType', 'mime_type')),
'fps': float_or_none(traverse_obj(video, 'frameRate', 'frame_rate')),
'width': int_or_none(video.get('width')),
... | This can be flv (possibly multiple) or mp4 (single file) here, when dash is not available. | 'acodec': traverse_obj(audio, ('codecs', {str.lower})),
'vcodec': 'none',
'tbr': float_or_none(audio.get('bandwidth'), scale=1000),
'filesize': int_or_none(audio.get('size')),
'format_id': str_or_none(audio.get('id')),
} for audio in audios]
f... | @@ -85,19 +96,32 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.214 | suggestion | 90 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | c-basalt | c-basalt |
{lambda x: x.rpartition('/')[2].partition('.')[0]})))
mixin_key_enc_tab = [
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
61, 26, 17, 0, 1, 60, 51, 30, 4, 22, ... | Why not keep the name `_download_playinfo()`? We're interested in what is returned more than where it came from. | return traverse_obj(chapters, ('data', 'view_points', ..., {
'title': 'content',
'start_time': 'from',
'end_time': 'to',
})) or None
def _get_comments(self, aid):
for idx in itertools.count(1):
replies = traverse_obj(
self._dow... | @@ -175,6 +199,49 @@ def _get_episodes_from_season(self, ss_id, url):
lambda _, v: url_or_none(v['share_url']) and v['id'])):
yield self.url_result(entry['share_url'], BiliBiliBangumiIE, str_or_none(entry.get('id')))
+ def _get_wbi_key(self, video_id):
+ if time.time() < self._... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.5 | question | 112 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | c-basalt |
61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11,
36, 20, 34, 44, 52
]
self._wbi_key_cache.update({
'key': ''.join(lookup[i] for i in mixin_key_enc_tab)[:32],
'ts': time.time(),
})
return self._wbi_key_cache['key'... | Hey, I want to get to reviewing this soon, but something I just discovered is that passing `'try_look': 1` here (and calling the api always instead of using the js playinfo data) it is possible to get 1080p videos without an account.
Would you be interested in exploring this further and possibly incorporating it int... | # from getMixinKey() in the vendor js
mixin_key_enc_tab = [
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6... | @@ -86,18 +100,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.643 | question | 352 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
list_id = self._match_id(url)
bvid = traverse_obj(parse_qs(url), ('bvid', 0))
if not self._yes_playlist(list_id, bvid):
return self.url_result(f'https://www.bilibili.com/video/{bvid}', BiliBiliIE)
webpage = self._download_webpage(url, list_id)
initial_state = self._... | Just making sure, the server sometimes returns 0 as the timestamp? | if error_code == -400 and list_id == 'watchlater':
self.raise_login_required('You need to login to access your watchlater playlist')
elif error_code == -403:
self.raise_login_required('This is a private playlist. You need to login as its owner')
elif e... | @@ -1414,7 +1593,7 @@ def _real_extract(self, url):
'title': ('title', {str}),
'uploader': ('upper', 'name', {str}),
'uploader_id': ('upper', 'mid', {str_or_none}),
- 'timestamp': ('ctime', {int_or_none}),
+ 'timestamp': ('ctime', {int_or_... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.214 | question | 66 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
edges.setdefault(edge_id, {}).update(
traverse_obj(division_data, ('data', 'story_list', lambda _, v: v['edge_id'] == edge_id, {
'title': ('title', {str}),
'cid': ('cid', {int_or_none}),
}), get_all=False))
edges[edge_id].update(traverse_obj(divis... | Is this just for future expansion? The headers are currently not passed when calling this function in `BiliBiliIE` | 'https://api.bilibili.com/x/stein/edgeinfo_v2', video_id,
query={'graph_version': graph_version, 'edge_id': edge_id, 'bvid': video_id},
note=f'Extracting divisions from edge {edge_id}')
edges.setdefault(edge_id, {}).update(
traverse_obj(division_data, ('data', 'st... | @@ -203,15 +274,15 @@ def _get_divisions(self, video_id, graph_version, edges, edge_id, cid_edges=None
self._get_divisions(video_id, graph_version, edges, choice['edge_id'], cid_edges=cid_edges)
return cid_edges
- def _get_interactive_entries(self, video_id, cid, metainfo):
+ def _get_... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.5 | question | 114 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'format_id': traverse_obj(
video, (('baseUrl', 'base_url'), {self._FORMAT_ID_RE.search}, 1),
('id', {str_or_none}), get_all=False),
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
if for... | I think having this in the `format_note` would be better to show it in the `-F` table
```suggestion
'format_note': ('quality', {lambda x: format_names.get(x)}),
``` | 'tbr': float_or_none(video.get('bandwidth'), scale=1000),
'filesize': int_or_none(video.get('size')),
'quality': int_or_none(video.get('id')),
'format_id': traverse_obj(
video, (('baseUrl', 'base_url'), {self._FORMAT_ID_RE.search}, 1),
('id... | @@ -86,18 +100,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.786 | suggestion | 187 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
if formats:
self.check_missing_formats(play_info, formats)
fragments = traverse_obj(play_info, ('durl', lambda _, v: url_or_none(v['url']), {
'url': ... | To set a proper height, we can use `parse_resolution` from `..utils`:
```suggestion
'duration': ('timelength', {lambda x: float_or_none(x, scale=1000)}),
}),
**parse_resolution(format_names.get(play_info.get('quality'))),
``` | 'format_id': traverse_obj(
video, (('baseUrl', 'base_url'), {self._FORMAT_ID_RE.search}, 1),
('id', {str_or_none}), get_all=False),
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
if for... | @@ -86,18 +100,74 @@ def extract_formats(self, play_info):
'format': format_names.get(video.get('id')),
} for video in traverse_obj(play_info, ('dash', 'video', ...)))
- missing_formats = format_names.keys() - set(traverse_obj(formats, (..., 'quality')))
- if missing_formats:
- ... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.857 | suggestion | 282 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
}
is_interactive = traverse_obj(video_data, ('rights', 'is_stein_gate'))
if is_interactive:
return self.playlist_result(
self._get_interactive_entries(video_id, cid, metainfo), **metainfo,
duration=traverse_obj(initial_state, ('videoData', 'duration',... | Are we only dropping when mp4 formats exist? Maybe I am missing something here, but I don't see a check for that. | lambda _, v: not has_qn(v['quality'])))
self._check_missing_formats(play_info, formats)
flv_formats = traverse_obj(formats, lambda _, v: v['fragments'])
if flv_formats and len(flv_formats) < len(formats):
# Flv and mp4 are incom... | @@ -590,14 +740,54 @@ def _real_extract(self, url):
duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
- return {
- **metainfo,
- 'duration': float_or_none(... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.357 | question | 113 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
'comment_count': ('stat', 'reply', {int_or_none}),
}, get_all=False),
'id': f'{video_id}{format_field(part_id, None, "_p%d")}',
'_old_archive_ids': [make_archive_id(self, old_video_id)] if old_video_id else None,
'title': title,
'http_headers':... | I think we should still document it in the readme. | if not traverse_obj(play_info, ('dash')):
# we only have legacy formats and need additional work
has_qn = lambda x: x in traverse_obj(formats, (..., 'quality'))
for qn in traverse_obj(play_info, ('accept_quality', lambda _, v: not has_qn(v), {int})):
... | @@ -590,14 +740,54 @@ def _real_extract(self, url):
duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
- return {
- **metainfo,
- 'duration': float_or_none(... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.286 | suggestion | 50 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
formats = self.extract_formats(play_info)
if not traverse_obj(play_info, ('dash')): # for legacy-only formats
... | I'd add a comment saying that this was done since concatenation of flv files corrupts them.
I spent quite a while looking into the existing F4mFD code/flv parser, but couldn't get it to work. Since these are only legacy formats, I'd say the workaround of using multi video is fine. | dropped_fmts = ', '.join(
f'{f.get("format_note")} ({f.get("format_id")})' for f in flv_formats)
formats = traverse_obj(formats, lambda _, v: not v.get('fragments'))
if dropped_fmts:
self.to_s... | @@ -590,14 +740,54 @@ def _real_extract(self, url):
duration=traverse_obj(initial_state, ('videoData', 'duration', {int_or_none})),
__post_extractor=self.extract_comments(aid))
else:
- return {
- **metainfo,
- 'duration': float_or_none(... | yt_dlp/extractor/bilibili.py | 26 | Python | 0.5 | style | 282 | 51 | 51 | false | [ie/bilibili] Add support for legacy formats | 9,117 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | c-basalt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.