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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
if image.get('type') not in ('episode_image', 'bonus_feature_image'):
continue
thumbnails.extend([{
'id': name,
'url': url,
} for name, url in (image.get('attributes') or {}).items() if url_or_none(url)])
attributes = data.get(... | If it's always a UUID, `str_or_none` is not necessary here. But it probably doesn't hurt, either | if image.get('type') not in ('episode_image', 'bonus_feature_image'):
continue
thumbnails.extend([{
'id': name,
'url': url,
} for name, url in (image.get('attributes') or {}).items() if url_or_none(url)])
attributes = data.get(... | @@ -63,9 +62,9 @@ def _extract_video_info(self, data):
'display_id': attributes.get('slug'),
'title': title,
'description': traverse_obj(attributes, 'description', 'caption'),
- 'series': attributes.get('show_title'),
+ 'series': traverse_obj(attributes, 'sho... | yt_dlp/extractor/roosterteeth.py | 26 | Python | 0.357 | suggestion | 96 | 51 | 51 | false | [ie/roosterteeth] support bonus features | 9,406 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Bl4Cc4t |
'info_dict': {
'id': '40432',
'display_id': 'rwby-bonus-25',
'title': 'Grimm',
'description': 'md5:f30ff570741213418a8d2c19868b93ab',
'episode': 'Grimm',
'channel_id': '92f780eb-ebfe-4bf5-a3b5-c6ad5460a5f1',
'thumbnail': r're:^h... | are we sure this `id` value is unique for the bonus features? | 'duration': 145,
'release_timestamp': 1462982400,
'release_date': '20160511',
},
'params': {'skip_download': True},
}, {
'url': 'https://roosterteeth.com/watch/rwby-bonus-25',
'info_dict': {
'id': '40432',
'display_id': 'rwb... | @@ -130,6 +129,30 @@ class RoosterTeethIE(RoosterTeethBaseIE):
'release_date': '20141016',
},
'params': {'skip_download': True},
+ }, {
+ 'url': 'https://roosterteeth.com/watch/rwby-bonus-21',
+ 'info_dict': {
+ 'id': '33', | yt_dlp/extractor/roosterteeth.py | 26 | Python | 0.357 | question | 61 | 51 | 51 | false | [ie/roosterteeth] support bonus features | 9,406 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Bl4Cc4t |
'series': 'RWBY: World of Remnant',
'season_number': 1,
'duration': 216,
'release_timestamp': 1413489600,
'release_date': '20141016',
},
'params': {'skip_download': True},
}, {
'url': 'https://roosterteeth.com/watch/rwby-bonus-21',
... | fields with `None` values can be excluded from the test dict
```suggestion
'series': 'RWBY',
``` | 'ext': 'mp4',
'availability': 'public',
'episode_id': 'f8117b13-f068-499e-803e-eec9ea2dec8c',
'episode_number': 3,
'tags': ['Animation'],
'season_id': '4b8f0a9e-12c4-41ed-8caa-fed15a85bab8',
'season': 'Season 1',
'series': '... | @@ -130,6 +129,30 @@ class RoosterTeethIE(RoosterTeethBaseIE):
'release_date': '20141016',
},
'params': {'skip_download': True},
+ }, {
+ 'url': 'https://roosterteeth.com/watch/rwby-bonus-21',
+ 'info_dict': {
+ 'id': '33',
+ 'display_id': 'rwby-bonu... | yt_dlp/extractor/roosterteeth.py | 26 | Python | 0.714 | suggestion | 111 | 51 | 51 | false | [ie/roosterteeth] support bonus features | 9,406 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Bl4Cc4t |
if channel_banners:
uncropped_banner = _get_uncropped(channel_banners[0]['url'])
if uncropped_banner:
channel_banners.append({
'url': uncropped_banner,
'id': 'banner_uncropped',
'preference': -5
}... | ```suggestion
'tags': (traverse_obj(data, ('microformat', 'microformatDataRenderer', 'tags', ..., {str}))
``` | if channel_banners:
uncropped_banner = _get_uncropped(channel_banners[0]['url'])
if uncropped_banner:
channel_banners.append({
'url': uncropped_banner,
'id': 'banner_uncropped',
'preference': -5
}... | @@ -5087,7 +5088,8 @@ def _get_uncropped(url):
'availability': self._extract_availability(data),
'channel_follower_count': self._get_count(data, ('header', ..., 'subscriberCountText')),
'description': try_get(metadata_renderer, lambda x: x.get('description', '')),
- 'ta... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 123 | 51 | 51 | false | [ie/youtube:tab] Fix incorrect splitting of tags with whitespace | 9,413 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | x11x |
import hashlib
import requests
import json
from .common import InfoExtractor
from ..utils import (
ExtractorError,
try_get
)
class GofileIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
_TESTS = [{
'url': 'https://gofile.io/d/AMZyDw',
'info_dict': {
... | not needed, we should be using the helper methods instead
```suggestion
``` | import hashlib
from .common import InfoExtractor
from ..utils import (
ExtractorError,
try_get
)
class GofileIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
_TESTS = [{
'url': 'https://gofile.io/d/AMZyDw',
'info_dict': {
'id': 'AMZyDw',
... | @@ -1,4 +1,6 @@
import hashlib
+import requests
+import json | yt_dlp/extractor/gofile.py | 3 | Python | 0.643 | refactor | 77 | 28 | 28 | false | Fix download gofile.py | 9,446 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | ghost |
'info_dict': {
'id': 'TMjXd9',
},
'playlist_count': 1,
}, {
'url': 'https://gofile.io/d/gqOtRf',
'info_dict': {
'id': 'gqOtRf',
},
'playlist_mincount': 1,
'params': {
'videopassword': 'password',
},
}]
... | ```suggestion
account_data = self._download_json(
'https://api.gofile.io/accounts', None, 'Getting a new guest account', data=b'{}')
``` | },
'playlist_count': 1,
}, {
'url': 'https://gofile.io/d/gqOtRf',
'info_dict': {
'id': 'gqOtRf',
},
'playlist_mincount': 1,
'params': {
'videopassword': 'password',
},
}]
_TOKEN = None
def _real_initialize(self):
... | @@ -57,23 +59,32 @@ def _real_initialize(self):
self._TOKEN = token.value
return
- account_data = self._download_json(
- 'https://api.gofile.io/createAccount', None, note='Getting a new guest account')
+ print('Getting a new guest account')
+ get_account_data ... | yt_dlp/extractor/gofile.py | 26 | Python | 0.714 | suggestion | 159 | 51 | 51 | false | Fix download gofile.py | 9,446 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | ghost |
}, {
'url': 'https://gofile.io/d/gqOtRf',
'info_dict': {
'id': 'gqOtRf',
},
'playlist_mincount': 1,
'params': {
'videopassword': 'password',
},
}]
_TOKEN = None
def _real_initialize(self):
token = self._get_cookies('https:/... | do you know if video passwords still work the same way? the pw-protected extractor test is dead | 'info_dict': {
'id': 'gqOtRf',
},
'playlist_mincount': 1,
'params': {
'videopassword': 'password',
},
}]
_TOKEN = None
def _real_initialize(self):
token = self._get_cookies('https://gofile.io/').get('accountToken')
if token:
... | @@ -57,23 +59,32 @@ def _real_initialize(self):
self._TOKEN = token.value
return
- account_data = self._download_json(
- 'https://api.gofile.io/createAccount', None, note='Getting a new guest account')
+ print('Getting a new guest account')
+ get_account_data ... | yt_dlp/extractor/gofile.py | 26 | Python | 0.286 | refactor | 95 | 51 | 51 | false | Fix download gofile.py | 9,446 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | ghost |
print('Getting a new guest account')
get_account_data = requests.post('https://api.gofile.io/accounts', '{}')
account_data = get_account_data.json()
# account_data = self._download_json(get_account_data, None, note='Getting a new guest account')
self._TOKEN = account_data['data']... | ```suggestion
files = self._download_json(
f'https://api.gofile.io/contents/{file_id}', file_id, 'Getting filelist',
query=query_params, headers={'Authorization': f'Bearer {self._TOKEN}'})
``` | self._TOKEN = account_data['data']['token']
self._set_cookie('.gofile.io', 'accountToken', self._TOKEN)
def _entries(self, file_id):
query_params = {'wt': '4fd6sg89d7s6'} # From https://gofile.io/dist/js/alljs.js
password = self.get_param('videopassword')
if password:
... | @@ -57,23 +59,32 @@ def _real_initialize(self):
self._TOKEN = token.value
return
- account_data = self._download_json(
- 'https://api.gofile.io/createAccount', None, note='Getting a new guest account')
+ print('Getting a new guest account')
+ get_account_data ... | yt_dlp/extractor/gofile.py | 26 | Python | 0.786 | security | 228 | 51 | 43 | false | Fix download gofile.py | 9,446 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | ghost |
if not continuation_list[0]:
break
def _real_extract(self, url):
display_id = 'notifications'
ytcfg = self._download_ytcfg('web', display_id) if not self.skip_webpage else {}
self._report_playlist_authcheck(ytcfg)
return self.playlist_result(self._notific... | ```suggestion
'url': 'ytsearch1:i hate myself and i wanna die',
'playlist_count': 1,
'info_dict': {
``` | if not continuation_list[0]:
break
def _real_extract(self, url):
display_id = 'notifications'
ytcfg = self._download_ytcfg('web', display_id) if not self.skip_webpage else {}
self._report_playlist_authcheck(ytcfg)
return self.playlist_result(self._notific... | @@ -6965,22 +6965,29 @@ class YoutubeSearchIE(YoutubeTabBaseInfoExtractor, SearchInfoExtractor):
IE_DESC = 'YouTube search'
IE_NAME = 'youtube:search'
_SEARCH_KEY = 'ytsearch'
- _SEARCH_PARAMS = 'EgIQAQ%3D%3D' # Videos only
+ _SEARCH_PARAMS = 'EgIIAfABAQ==' # Videos only
_TESTS = [{
... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 131 | 51 | 51 | false | [ie/YoutubeSearchDate] Fix search parameters | 9,456 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alb |
def _notification_menu_entries(self, ytcfg):
continuation_list = [None]
response = None
for page in itertools.count(1):
ctoken = traverse_obj(
continuation_list, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
r... | Are you sure this is correct? The previous params were % encoded. If it works, ignore | def _notification_menu_entries(self, ytcfg):
continuation_list = [None]
response = None
for page in itertools.count(1):
ctoken = traverse_obj(
continuation_list, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
r... | @@ -6965,22 +6965,29 @@ class YoutubeSearchIE(YoutubeTabBaseInfoExtractor, SearchInfoExtractor):
IE_DESC = 'YouTube search'
IE_NAME = 'youtube:search'
_SEARCH_KEY = 'ytsearch'
- _SEARCH_PARAMS = 'EgIQAQ%3D%3D' # Videos only
+ _SEARCH_PARAMS = 'EgIIAfABAQ==' # Videos only | yt_dlp/extractor/youtube.py | 26 | Python | 0.214 | suggestion | 85 | 51 | 51 | false | [ie/YoutubeSearchDate] Fix search parameters | 9,456 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alb |
for page in itertools.count(1):
ctoken = traverse_obj(
continuation_list, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
response = self._extract_response(
item_id=f'page {page}', query={'ctoken': ctoken} if ctoken... | the new params yield only 2 results, while the old params still yield 5 (it makes no difference if the new params' `=`s are percent encoded) | for page in itertools.count(1):
ctoken = traverse_obj(
continuation_list, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
response = self._extract_response(
item_id=f'page {page}', query={'ctoken': ctoken} if ctoken... | @@ -6965,22 +6965,30 @@ class YoutubeSearchIE(YoutubeTabBaseInfoExtractor, SearchInfoExtractor):
IE_DESC = 'YouTube search'
IE_NAME = 'youtube:search'
_SEARCH_KEY = 'ytsearch'
- _SEARCH_PARAMS = 'EgIQAQ%3D%3D' # Videos only
+ _SEARCH_PARAMS = 'EgIIAfABAQ==' # Videos only
_TESTS = [{
... | yt_dlp/extractor/youtube.py | 26 | Python | 0.5 | suggestion | 140 | 51 | 51 | false | [ie/YoutubeSearchDate] Fix search parameters | 9,456 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | alb |
def _notification_menu_entries(self, ytcfg):
continuation_list = [None]
response = None
for page in itertools.count(1):
ctoken = traverse_obj(
continuation_list, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
r... | ```suggestion
_SEARCH_PARAMS = 'EgIQAfABAQ==' # Videos only
``` | def _notification_menu_entries(self, ytcfg):
continuation_list = [None]
response = None
for page in itertools.count(1):
ctoken = traverse_obj(
continuation_list, (0, 'continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
r... | @@ -6965,22 +6965,30 @@ class YoutubeSearchIE(YoutubeTabBaseInfoExtractor, SearchInfoExtractor):
IE_DESC = 'YouTube search'
IE_NAME = 'youtube:search'
_SEARCH_KEY = 'ytsearch'
- _SEARCH_PARAMS = 'EgIQAQ%3D%3D' # Videos only
+ _SEARCH_PARAMS = 'EgIIAfABAQ==' # Videos only | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 70 | 51 | 51 | false | [ie/YoutubeSearchDate] Fix search parameters | 9,456 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | alb |
MTLS_CERT_DIR = os.path.join(TEST_DIR, 'testdata', 'certificate')
def create_mtls_wss_websocket_server():
certfn = os.path.join(TEST_DIR, 'testcert.pem')
cacertfn = os.path.join(MTLS_CERT_DIR, 'ca.crt')
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
sslctx.verify_mode = ssl.CERT_REQUIRED
sslct... | would be good to raise when retry loop is exhausted
```suggestion
max_tries = 3
for i in range(max_tries):
try:
return rh.send(req)
except TransportError as e:
if i < (max_tries - 1) and 'connection closed during handshake' in str(e):
# websockets ... | return create_websocket_server(ssl_context=sslctx)
MTLS_CERT_DIR = os.path.join(TEST_DIR, 'testdata', 'certificate')
def create_mtls_wss_websocket_server():
certfn = os.path.join(TEST_DIR, 'testcert.pem')
cacertfn = os.path.join(MTLS_CERT_DIR, 'ca.crt')
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERV... | @@ -100,6 +98,18 @@ def create_mtls_wss_websocket_server():
return create_websocket_server(ssl_context=sslctx)
+def ws_validate_and_send(rh, req):
+ rh.validate(req)
+ for i in range(0, 3):
+ try:
+ return rh.send(req)
+ except TransportError as e:
+ if 'connection clo... | test/test_websockets.py | 26 | Python | 0.929 | suggestion | 411 | 51 | 51 | false | [test] Handle websockets server hanging | 9,467 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'url': 'https://i.imgur.com/A61SaA1.gifv',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/crGpqCV.mp4',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/jxBXAMC.gifv',
'info_dict': {
'id': 'jxBXAMC',
'ext': 'mp4',
... | don't need `add_ies`, but can you add `md5` field please? | 'url': 'https://i.imgur.com/A61SaA1.gifv',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/crGpqCV.mp4',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/jxBXAMC.gifv',
'info_dict': {
'id': 'jxBXAMC',
'ext': 'mp4',
... | @@ -76,6 +76,24 @@ class ImgurIE(ImgurBaseIE):
'thumbnail': 'https://i.imgur.com/jxBXAMCh.jpg',
'dislike_count': int,
},
+ },
+ # from https://github.com/yt-dlp/yt-dlp/issues/9458
+ {
+ 'url': 'https://imgur.com/zV03bd5',
+ 'add_ies': ['Imgur'], | yt_dlp/extractor/imgur.py | 26 | Python | 0.357 | question | 57 | 51 | 51 | false | [extractor/imgur] Fix Imgur Extractor | 9,471 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | trwstin |
'ext': 'mp4',
'title': 'Fahaka puffer feeding',
'timestamp': 1533835503,
'upload_date': '20180809',
'release_date': '20180809',
'like_count': int,
'duration': 30.0,
'comment_count': int,
'release_timestamp': 1533... | use [`devscripts/run_tests.py`](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#adding-support-for-a-new-site) and let it output the correct test data for you
```suggestion
'duration': 56.92,
``` | 'ext': 'mp4',
'title': 'Fahaka puffer feeding',
'timestamp': 1533835503,
'upload_date': '20180809',
'release_date': '20180809',
'like_count': int,
'duration': 30.0,
'comment_count': int,
'release_timestamp': 1533... | @@ -76,6 +76,24 @@ class ImgurIE(ImgurBaseIE):
'thumbnail': 'https://i.imgur.com/jxBXAMCh.jpg',
'dislike_count': int,
},
+ },
+ # from https://github.com/yt-dlp/yt-dlp/issues/9458
+ {
+ 'url': 'https://imgur.com/zV03bd5',
+ 'md5': '4CB52A2B62E3C21EFF561D... | yt_dlp/extractor/imgur.py | 26 | Python | 0.857 | suggestion | 223 | 51 | 51 | false | [extractor/imgur] Fix Imgur Extractor | 9,471 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | trwstin |
'url': 'https://i.imgur.com/A61SaA1.gifv',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/crGpqCV.mp4',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/jxBXAMC.gifv',
'info_dict': {
'id': 'jxBXAMC',
'ext': 'mp4',
... | ```suggestion
'md5': '59df97884e8ba76143ff6b640a0e2904',
``` | 'url': 'https://i.imgur.com/A61SaA1.gifv',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/crGpqCV.mp4',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/jxBXAMC.gifv',
'info_dict': {
'id': 'jxBXAMC',
'ext': 'mp4',
... | @@ -76,6 +76,24 @@ class ImgurIE(ImgurBaseIE):
'thumbnail': 'https://i.imgur.com/jxBXAMCh.jpg',
'dislike_count': int,
},
+ },
+ # from https://github.com/yt-dlp/yt-dlp/issues/9458
+ {
+ 'url': 'https://imgur.com/zV03bd5',
+ 'md5': '4CB52A2B62E3C21EFF561D... | yt_dlp/extractor/imgur.py | 26 | Python | 0.571 | suggestion | 70 | 51 | 51 | false | [extractor/imgur] Fix Imgur Extractor | 9,471 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | trwstin |
},
}, {
'url': 'https://i.imgur.com/A61SaA1.gifv',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/crGpqCV.mp4',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/jxBXAMC.gifv',
'info_dict': {
'id': 'jxBXAMC',
'ext... | just formatting
```suggestion
}, {
# needs Accept header, ref: https://github.com/yt-dlp/yt-dlp/issues/9458
``` | },
}, {
'url': 'https://i.imgur.com/A61SaA1.gifv',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/crGpqCV.mp4',
'only_matching': True,
}, {
'url': 'https://i.imgur.com/jxBXAMC.gifv',
'info_dict': {
'id': 'jxBXAMC',
'ext... | @@ -76,6 +76,24 @@ class ImgurIE(ImgurBaseIE):
'thumbnail': 'https://i.imgur.com/jxBXAMCh.jpg',
'dislike_count': int,
},
+ },
+ # from https://github.com/yt-dlp/yt-dlp/issues/9458
+ { | yt_dlp/extractor/imgur.py | 26 | Python | 0.714 | suggestion | 127 | 51 | 51 | false | [extractor/imgur] Fix Imgur Extractor | 9,471 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | trwstin |
time.sleep(sleep_interval)
else:
self._downloader._first_webpage_request = False
if note is None:
self.report_download_webpage(video_id)
elif note is not False:
if video_id is None:
self.to_screen(str(note))
else:
... | > Something else we could consider is allowing a preferred order of multiple impersonate targets for a particular request, though I don't know of any sites where that would be necessary.
This is trivial to support if needed
```suggestion
impersonate = tuple(map(ImpersonateTarget.from_str,
... | time.sleep(sleep_interval)
else:
self._downloader._first_webpage_request = False
if note is None:
self.report_download_webpage(video_id)
elif note is not False:
if video_id is None:
self.to_screen(str(note))
else:
... | @@ -860,8 +862,14 @@ def _request_webpage(self, url_or_request, video_id, note=None, errnote=None, fa
headers = (headers or {}).copy()
headers.setdefault('X-Forwarded-For', self._x_forwarded_for_ip)
+ extensions = None
+ if impersonate is not None:
+ target = Imperso... | yt_dlp/extractor/common.py | 26 | Python | 1 | bug | 731 | 51 | 51 | false | [ie] Add extractor impersonate API | 9,474 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
Keyword arguments:
note -- note printed before downloading (string)
errnote -- note printed in case of an error (string)
fatal -- flag denoting whether error should be considered fatal,
i.e. whether it should cause ExtractionError to be raised,
otherwise a warning... | Do you have a example use case for `force_impersonate=False`? Wouldn't this be better pattern?
```py
try:
page = self._request(..., impersonate=True)
except ...:
# Do stuff for bypass
page = self._request(...)
```
as opposed to:
```py
page = self._request(..., force_impersonate=False)
if 'captcha... | if fatal:
raise ExtractorError(errmsg, cause=err)
else:
self.report_warning(errmsg)
return False
def _download_webpage_handle(self, url_or_request, video_id, note=None, errnote=None, fatal=True,
encoding=None, ... | @@ -911,13 +920,19 @@ def _download_webpage_handle(self, url_or_request, video_id, note=None, errnote=
returning True if it should be accepted
Note that this argument does not affect success status codes (2xx)
which are always accepted.
+ impersonate -- the impersonat... | yt_dlp/extractor/common.py | 26 | Python | 0.857 | suggestion | 476 | 51 | 51 | false | [ie] Add extractor impersonate API | 9,474 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
if sleep_interval > 0:
self.to_screen('Sleeping %s seconds ...' % sleep_interval)
time.sleep(sleep_interval)
else:
self._downloader._first_webpage_request = False
if note is None:
self.report_download_webpage(video_id)
elif not... | ```suggestion
target = ImpersonateTarget.from_str('' if impersonate is True else impersonate)
```
is more standard/consistent I would think | if sleep_interval > 0:
self.to_screen('Sleeping %s seconds ...' % sleep_interval)
time.sleep(sleep_interval)
else:
self._downloader._first_webpage_request = False
if note is None:
self.report_download_webpage(video_id)
elif not... | @@ -860,8 +862,14 @@ def _request_webpage(self, url_or_request, video_id, note=None, errnote=None, fa
headers = (headers or {}).copy()
headers.setdefault('X-Forwarded-For', self._x_forwarded_for_ip)
+ extensions = None
+ if impersonate is not None:
+ target = Imperso... | yt_dlp/extractor/common.py | 26 | Python | 0.714 | suggestion | 156 | 51 | 51 | false | [ie] Add extractor impersonate API | 9,474 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | bashonly |
def IE_NAME(cls):
return cls.__name__[:-2]
@staticmethod
def __can_accept_status_code(err, expected_status):
assert isinstance(err, HTTPError)
if expected_status is None:
return False
elif callable(expected_status):
return expected_status(err.status) ... | perhaps could accept an ImpersonateTarget too, if needing to generate it programmatically.. though, could add that later if need be. | def IE_NAME(cls):
return cls.__name__[:-2]
@staticmethod
def __can_accept_status_code(err, expected_status):
assert isinstance(err, HTTPError)
if expected_status is None:
return False
elif callable(expected_status):
return expected_status(err.status) ... | @@ -826,10 +827,11 @@ def _create_request(self, url_or_request, data=None, headers=None, query=None):
elif not isinstance(url_or_request, Request):
url_or_request = Request(url_or_request)
- url_or_request.update(data=data, headers=headers, query=query)
+ url_or_request.update(data... | yt_dlp/extractor/common.py | 26 | Python | 0.429 | suggestion | 132 | 51 | 51 | false | [ie] Add extractor impersonate API | 9,474 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | bashonly |
self._downloader._first_webpage_request = False
if note is None:
self.report_download_webpage(video_id)
elif note is not False:
if video_id is None:
self.to_screen(str(note))
else:
self.to_screen(f'{video_id}: {note}')
... | * If none of these match, the argument is silently ignored? We should error instead imo.
* Shouldn't it also support `list[ImpersonateTarget]` for consistency?
```suggestion
if impersonate is True:
impersonate = ['']
requested_targets = [
x if isinstance(x, ImpersonateTar... | self._downloader._first_webpage_request = False
if note is None:
self.report_download_webpage(video_id)
elif note is not False:
if video_id is None:
self.to_screen(str(note))
else:
self.to_screen(f'{video_id}: {note}')
... | @@ -860,8 +862,30 @@ def _request_webpage(self, url_or_request, video_id, note=None, errnote=None, fa
headers = (headers or {}).copy()
headers.setdefault('X-Forwarded-For', self._x_forwarded_for_ip)
+ extensions, requested_targets = {}, []
+ if impersonate is True:
+ ... | yt_dlp/extractor/common.py | 26 | Python | 1 | suggestion | 536 | 51 | 51 | false | [ie] Add extractor impersonate API | 9,474 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'url': 'https://fathom.video/share/G9mkjkspnohVVZ_L5nrsoPycyWcB8y7s',
'md5': '0decd5343b8f30ae268625e79a02b60f',
'info_dict': {
'id': '47200596',
'ext': 'mp4',
'title': 'eCom Inucbator - Coaching Session',
'duration': 8125.380507,
'time... | instead of redefining `video_id` later, we could use `display_id` here (and we could return it in the info dict too)
```suggestion
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
``` | _TESTS = [{
'url': 'https://fathom.video/share/G9mkjkspnohVVZ_L5nrsoPycyWcB8y7s',
'md5': '0decd5343b8f30ae268625e79a02b60f',
'info_dict': {
'id': '47200596',
'ext': 'mp4',
'title': 'eCom Inucbator - Coaching Session',
'duration': 8125.380507,
... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+)
+
+
+class FathomIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
+ _TESTS = [... | yt_dlp/extractor/fathom.py | 26 | Python | 0.857 | suggestion | 237 | 50 | 41 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
'ext': 'mp4',
'title': 'eCom Inucbator - Coaching Session',
'duration': 8125.380507,
'timestamp': 1699036314.0,
'upload_date': '20231103',
},
}, {
'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
'md5': '4f5cb38... | we could do this and get rid of the 2 single-use vars (import `traverse_obj` from utils)
```suggestion
props = traverse_obj(
get_element_html_by_id('app', webpage), ({extract_attributes}, 'data-page', {json.loads}, 'props'))
``` | 'id': '47200596',
'ext': 'mp4',
'title': 'eCom Inucbator - Coaching Session',
'duration': 8125.380507,
'timestamp': 1699048914,
'upload_date': '20231103',
},
}, {
'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxG... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+)
+
+
+class FathomIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
+ _TESTS = [... | yt_dlp/extractor/fathom.py | 26 | Python | 0.857 | refactor | 252 | 46 | 37 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
'duration': 8125.380507,
'timestamp': 1699036314.0,
'upload_date': '20231103',
},
}, {
'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
'md5': '4f5cb382126c22d1aba8a939f9c49690',
'info_dict': {
'id': '46812957',
... | adjusting per my above suggestion
```suggestion
video_id = str(props['call']['id'])
``` | 'title': 'eCom Inucbator - Coaching Session',
'duration': 8125.380507,
'timestamp': 1699048914,
'upload_date': '20231103',
},
}, {
'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
'md5': '4f5cb382126c22d1aba8a939f9c49690',
... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+)
+
+
+class FathomIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
+ _TESTS = [... | yt_dlp/extractor/fathom.py | 26 | Python | 0.571 | suggestion | 98 | 44 | 35 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
'md5': '4f5cb382126c22d1aba8a939f9c49690',
'info_dict': {
'id': '46812957',
'ext': 'mp4',
'title': 'Jon, Lawrence, Neman chat about practice',
'duration': 3571.517847,
... | this metadata extraction should be completely non-fatal and can be inlined in the return
```suggestion
``` | }, {
'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
'md5': '4f5cb382126c22d1aba8a939f9c49690',
'info_dict': {
'id': '46812957',
'ext': 'mp4',
'title': 'Jon, Lawrence, Neman chat about practice',
'duration': 3571.517847,
... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+)
+
+
+class FathomIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
+ _TESTS = [... | yt_dlp/extractor/fathom.py | 26 | Python | 0.786 | refactor | 108 | 39 | 30 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
div_app = get_element_html_by_id('app', webpage)
attrs = extract_attributes(div_app)
data = json.loads(attrs["data-page"])
video_id = str(data['props']['cal... | traversal and helper funcs let us extract the metadata concisely and non-fatally
import `parse_iso8601` and `float_or_none` from utils
`entry_protocol='m3u8_native'` is the default, other extractors do it because they were written before it was the default
IMO m3u8 extraction can be fatal
```suggestion
... | import json
from .common import InfoExtractor
from ..utils import (
extract_attributes,
float_or_none,
get_element_html_by_id,
parse_iso8601,
)
from ..utils.traversal import traverse_obj
class FathomIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+)'
_TE... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+)
+
+
+class FathomIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
+ _TESTS = [... | yt_dlp/extractor/fathom.py | 26 | Python | 0.857 | refactor | 698 | 28 | 55 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
from datetime import datetime
import time
import json
from .common import InfoExtractor
from ..utils import (
get_element_html_by_id,
extract_attributes,
)
class FathomIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
_TESTS = [{
'url': 'https://fatho... | you can easily keep these sorted with `isort` (though we may be moving to hatch/ruff in the near future)
```suggestion
import json
from .common import InfoExtractor
from ..utils import (
extract_attributes,
float_or_none,
get_element_html_by_id,
parse_iso8601,
)
from ..utils.traversal import... | import json
from .common import InfoExtractor
from ..utils import (
extract_attributes,
float_or_none,
get_element_html_by_id,
parse_iso8601,
)
from ..utils.traversal import traverse_obj
class FathomIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+)'
_TE... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+) | yt_dlp/extractor/fathom.py | 9 | Python | 0.857 | refactor | 338 | 34 | 34 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
from datetime import datetime
import time
import json
from .common import InfoExtractor
from ..utils import (
get_element_html_by_id,
extract_attributes,
)
class FathomIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
_TESTS = [{
'url': 'https://fatho... | after applying suggestions, please run the tests and update as necessary. thanks! | import json
from .common import InfoExtractor
from ..utils import (
extract_attributes,
float_or_none,
get_element_html_by_id,
parse_iso8601,
)
from ..utils.traversal import traverse_obj
class FathomIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+)'
_TE... | @@ -0,0 +1,63 @@
+from datetime import datetime
+import time
+import json
+
+from .common import InfoExtractor
+from ..utils import (
+ get_element_html_by_id,
+ extract_attributes,
+)
+
+
+class FathomIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?fathom\.video/share/(?P<id>[^/?#&]+?)'
+ _TESTS = [... | yt_dlp/extractor/fathom.py | 15 | Python | 0.214 | suggestion | 81 | 40 | 40 | false | [ie/fathom] Add extractor | 9,495 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | src-tinkerer |
'only_matching': True
}, {
'url': 'https://it.xvideos.com/video4588838/biker_takes_his_girl',
'only_matching': True
}, {
'url': 'http://de.xvideos.com/video4588838/biker_takes_his_girl',
'only_matching': True
}, {
'url': 'https://de.xvideos.com/video4588838/bi... | these 2 are dupes, can remove both | 'only_matching': True
}, {
'url': 'https://it.xvideos.com/video4588838/biker_takes_his_girl',
'only_matching': True
}, {
'url': 'http://de.xvideos.com/video4588838/biker_takes_his_girl',
'only_matching': True
}, {
'url': 'https://de.xvideos.com/video4588838/bi... | @@ -90,6 +90,51 @@ class XVideosIE(InfoExtractor):
}, {
'url': 'https://de.xvideos.com/video4588838/biker_takes_his_girl',
'only_matching': True
+ }, {
+ 'url': 'https://flashservice.xvideos.com/embedframe/ucuvbkfda4e',
+ 'only_matching': True,
+ }, {
+ 'url': 'https://... | yt_dlp/extractor/xvideos.py | 26 | Python | 0.143 | suggestion | 34 | 51 | 51 | false | [ie/xvideos] Fix regex (#9493) | 9,502 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | sta1us |
'url': 'https://www.xvideos.es/video.ucuvbkfda4e/a_beautiful_red-haired_stranger_was_refused_but_still_came_to_my_room_for_sex',
'only_matching': True
}, {
'url': 'http://xvideos.es/video.ucuvbkfda4e/a_beautiful_red-haired_stranger_was_refused_but_still_came_to_my_room_for_sex',
'onl... | we really only need an .es test out of these | if mobj:
raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
title = self._html_search_regex(
(r'<title>(?P<title>.+?)\s+-\s+XVID',
r'setVideoTitle\s*\(\s*(["\'])(?P<title>(?:(?!\1).)+)\1'),
webpage, 'title', de... | @@ -90,6 +90,51 @@ class XVideosIE(InfoExtractor):
}, {
'url': 'https://de.xvideos.com/video4588838/biker_takes_his_girl',
'only_matching': True
+ }, {
+ 'url': 'https://flashservice.xvideos.com/embedframe/ucuvbkfda4e',
+ 'only_matching': True,
+ }, {
+ 'url': 'https://... | yt_dlp/extractor/xvideos.py | 26 | Python | 0.071 | suggestion | 44 | 51 | 51 | false | [ie/xvideos] Fix regex (#9493) | 9,502 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | sta1us |
'upload_date': '20190820',
'uploader_id': '235196876',
},
'params': {'skip_download': 'dash fragment too small'},
}, {
'url': 'https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e',
'info_dict': {
'id': '787379022466',
'ext': '... | use `_search_json` here (you could update the old code below to also use it, if you want)
also use `shared_name` as the id here or else we are passing `None` to the function
```suggestion
if not file_id:
post_stream_data = self._search_json(
r'Box\.postStreamData\s*=', webpage... | 'upload_date': '20190820',
'uploader_id': '235196876',
},
'params': {'skip_download': 'dash fragment too small'},
}, {
'url': 'https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e',
'info_dict': {
'id': '787379022466',
'ext': '... | @@ -25,11 +26,34 @@ class BoxIE(InfoExtractor):
'uploader_id': '235196876',
},
'params': {'skip_download': 'dash fragment too small'},
- }
+ }, {
+ 'url': 'https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e',
+ 'info_dict': {
+ 'id': '787379022466... | yt_dlp/extractor/box.py | 26 | Python | 0.857 | suggestion | 363 | 51 | 51 | false | [ie/box] Add support for implicit file ID | 9,504 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | shreyasminocha |
'url': 'https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e',
'info_dict': {
'id': '787379022466',
'ext': 'mp4',
'title': 'Webinar recording: Take the Leap!.mp4',
'uploader': 'Patricia Mosele',
'timestamp': 1615824864,
'up... | use `traverse_obj` so we don't throw during error handling (which should be `expected=True`, right?)
then let's intentionally KeyError if there's no `itemID`, since we need it for the next request
```suggestion
shared_item = traverse_obj(post_stream_data, ('/app-api/enduserapp/shared-item', {dict}) or ... | 'url': 'https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e',
'info_dict': {
'id': '787379022466',
'ext': 'mp4',
'title': 'Webinar recording: Take the Leap!.mp4',
'uploader': 'Patricia Mosele',
'timestamp': 1615824864,
'up... | @@ -25,11 +26,34 @@ class BoxIE(InfoExtractor):
'uploader_id': '235196876',
},
'params': {'skip_download': 'dash fragment too small'},
- }
+ }, {
+ 'url': 'https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e',
+ 'info_dict': {
+ 'id': '787379022466... | yt_dlp/extractor/box.py | 26 | Python | 1 | refactor | 527 | 51 | 51 | false | [ie/box] Add support for implicit file ID | 9,504 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | shreyasminocha |
def _real_initialize(self):
session_info = self._download_json(
'https://platform-api.tver.jp/v2/api/platform_users/browser/create',
None, 'Creating session', data=b'device_type=pc')
self._PLATFORM_QUERY = traverse_obj(session_info, ('result', {
'platform_uid': '... | ```suggestion
episodes_info = self._call_platform_api(
f'v1/callSeasonEpisodes/{season_id}', series_id, f'Downloading season {season_id} episodes info')
``` |
def _real_initialize(self):
session_info = self._download_json(
'https://platform-api.tver.jp/v2/api/platform_users/browser/create',
None, 'Creating session', data=b'device_type=pc')
self._PLATFORM_QUERY = traverse_obj(session_info, ('result', {
'platform_uid': '... | @@ -21,80 +22,115 @@ class TVerIE(InfoExtractor):
'episode': '売り場席巻のチーズSP&財前直見×森泉親子の脱東京暮らし密着!',
'alt_title': '売り場席巻のチーズSP&財前直見×森泉親子の脱東京暮らし密着!',
'channel': 'テレビ朝日',
- },
- 'add_ie': ['BrightcoveNew'],
- }, {
- 'url': 'https://tver.jp/olympic/paris2024/video/... | yt_dlp/extractor/tver.py | 26 | Python | 0.714 | suggestion | 187 | 51 | 51 | false | [ie/TVer] Fix extractor | 9,507 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | vvto33 |
from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
bool_or_none,
str_or_none,
traverse_obj,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:medici|edu\.medici)\.tv/(?:(?:[a-zA-Z0-9-_\.]+)/)*(?:#!/)?(?P<id>[^?#&]+)'
_T... | this project prefers to import the whole module for code readability/uniformity
```suggestion
import urllib.parse
``` | import urllib.parse
from .common import InfoExtractor
from ..utils import (
filter_dict,
parse_iso8601,
traverse_obj,
try_call,
url_or_none,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/[a-z]{2}/[\w.-]+/(?P<id>[^/?#&]+)'
_TESTS = [{
'u... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote | yt_dlp/extractor/medici.py | 1 | Python | 0.786 | suggestion | 122 | 26 | 26 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
bool_or_none,
str_or_none,
traverse_obj,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:medici|edu\.medici)\.tv/(?:(?:[a-zA-Z0-9-_\.]+)/)*(?:#!/)?(?P<id>[^?#&]+)'
_T... | we don't want to match `www.edu.medici.tv`, right? or do you have a working URL from that hostname?
can we add a test for a `/#!/` URL?
I would write it like this, to be more precise and so that we can match `edu` for later use:
```suggestion
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/(?:#!|[... | import urllib.parse
from .common import InfoExtractor
from ..utils import (
filter_dict,
parse_iso8601,
traverse_obj,
try_call,
url_or_none,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/[a-z]{2}/[\w.-]+/(?P<id>[^/?#&]+)'
_TESTS = [{
'u... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 12 | Python | 0.857 | suggestion | 359 | 37 | 37 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
'info_dict': {
'id': '3024',
'ext': 'mp4',
'title': 'Olivier Messiaen and Yvonne Loriod, pianists and teachers',
'thumbnail': r're:^https?://medicitv-[abc]\.imgix\.net/movie/[^?]+\.jpg(?:\?[^?]+)?',
'description': 'md5:aab948e2f... | ```suggestion
video_id, subdomain = self._match_valid_url(url).group('id', 'sub')
``` | },
'expected_warnings': [r'preview'],
}, {
'url': 'https://edu.medici.tv/en/masterclasses/yvonne-loriod-olivier-messiaen',
'md5': 'fb5dcec46d76ad20fbdbaabb01da191d',
'info_dict': {
'id': '3024',
'ext': 'mp4',
'title': 'Olivier Messiaen and ... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.571 | suggestion | 95 | 51 | 51 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
from .common import InfoExtractor
from ..utils import (
unified_strdate,
bool_or_none,
str_or_none,
traverse_obj,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:medici|edu\.medici)\.tv/(?:(?:[a-zA-Z0-9-_\.]+)/)*(?:#!/)?(?P<id>[^?#&]+)'
_TESTS = [
{
'u... | is the csrftoken cookie no longer needed? |
from .common import InfoExtractor
from ..utils import (
filter_dict,
parse_iso8601,
traverse_obj,
try_call,
url_or_none,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/[a-z]{2}/[\w.-]+/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.me... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.071 | security | 41 | 51 | 51 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
'url': 'https://www.medici.tv/en/jazz/makaya-mccraven-la-rochelle',
'md5': '4cc279a8b06609782747c8f50beea2b3',
'expected_warnings': [r'preview'],
'info_dict': {
'id': '7922',
'ext': 'mp4',
'title': 'NEW: Makaya McCraven in L... | ```suggestion
origin = f'https://{urllib.parse.urlparse(url).hostname}'
subdomain = 'edu-' if subdomain == 'edu' else ''
api_url = f'https://api.medici.tv/{subdomain}satie/edito/movie-file/{video_id}/'
```
though I would also move this block below the cookie code block and inline the `api_u... | 'description': 'md5:aab948e2f7690214b5c28896c83f1fc1',
'upload_date': '20150223',
'timestamp': 1424706608,
'display_id': 'yvonne-loriod-olivier-messiaen',
},
'skip': 'Requires authentication; preview starts in the middle',
}, {
'url': 'https://... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.857 | refactor | 356 | 51 | 51 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
'title': 'Olivier Messiaen and Yvonne Loriod, pianists and teachers',
'thumbnail': r're:^https?://medicitv-[abc]\.imgix\.net/movie/[^?]+\.jpg(?:\?[^?]+)?',
'description': 'md5:aab948e2f7690214b5c28896c83f1fc1',
'upload_date': '20150223',
},
... | should be with the rest of the cookie code
```suggestion
``` | 'url': 'https://edu.medici.tv/en/masterclasses/yvonne-loriod-olivier-messiaen',
'md5': 'fb5dcec46d76ad20fbdbaabb01da191d',
'info_dict': {
'id': '3024',
'ext': 'mp4',
'title': 'Olivier Messiaen and Yvonne Loriod, pianists and teachers',
'thumbnail':... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.643 | suggestion | 62 | 51 | 51 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
'title': 'NEW: Makaya McCraven in La Rochelle',
'thumbnail': r're:^https?://medicitv-[abc]\.imgix\.net/movie/[^?]+\.jpg(?:\?[^?]+)?',
'description': 'md5:b5a8aaeb6993d8ccb18bde8abb8aa8d2',
'upload_date': '20231228',
},
},
]
def... | import `try_call` from utils
```suggestion
token = try_call(lambda: urllib.parse.unquote(self._get_cookies(url)['auth._token.mAuth'].value))
``` | }, {
'url': 'https://www.medici.tv/en/jazz/makaya-mccraven-la-rochelle',
'md5': '4cc279a8b06609782747c8f50beea2b3',
'info_dict': {
'id': '7922',
'ext': 'mp4',
'title': 'NEW: Makaya McCraven in La Rochelle',
'thumbnail': r're:https://.+/.+\.jpg'... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.714 | security | 155 | 51 | 51 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
def _real_extract(self, url):
video_id = self._match_id(url)
self._download_webpage(url, video_id)
cookies = self._get_cookies(url)
if 'edu' in url:
request_url = f'https://api.medici.tv/edu-satie/edito/movie-file/{video_id}/'
source_url = 'https://edu.medic... | if applying my suggestion above
```suggestion
'Origin': origin,
'Referer': f'{origin}/',
``` | 'description': 'md5:b5a8aaeb6993d8ccb18bde8abb8aa8d2',
'upload_date': '20231228',
'timestamp': 1703754863,
'display_id': 'makaya-mccraven-la-rochelle',
},
'expected_warnings': [r'preview'],
}]
def _real_extract(self, url):
display_id, subd... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.714 | suggestion | 128 | 51 | 48 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
self._download_webpage(url, video_id)
cookies = self._get_cookies(url)
if 'edu' in url:
request_url = f'https://api.medici.tv/edu-satie/edito/movie-file/{video_id}/'
source_url = 'https://edu.medici.tv'
else:
request_url = f'https://api.medici.tv/sat... | shouldn't be needed
```suggestion
``` | 'timestamp': 1703754863,
'display_id': 'makaya-mccraven-la-rochelle',
},
'expected_warnings': [r'preview'],
}]
def _real_extract(self, url):
display_id, subdomain = self._match_valid_url(url).group('id', 'sub')
self._request_webpage(url, display_id, 'Requ... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.5 | suggestion | 39 | 51 | 46 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
if 'edu' in url:
request_url = f'https://api.medici.tv/edu-satie/edito/movie-file/{video_id}/'
source_url = 'https://edu.medici.tv'
else:
request_url = f'https://api.medici.tv/satie/edito/movie-file/{video_id}/'
source_url = 'https://www.medici.tv'
... | use a diff var name; avoid redefining built-ins like `id`. IMO I would use `display_id` for the slug matched from the URL and use `video_id` for this var
| }]
def _real_extract(self, url):
display_id, subdomain = self._match_valid_url(url).group('id', 'sub')
self._request_webpage(url, display_id, 'Requesting CSRF token cookie')
subdomain = 'edu-' if subdomain == 'edu' else ''
origin = f'https://{urllib.parse.urlparse(url).hostname... | @@ -1,67 +1,164 @@
+from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
unified_strdate,
- update_url_query,
- urlencode_postdata,
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?medic... | yt_dlp/extractor/medici.py | 26 | Python | 0.571 | suggestion | 157 | 51 | 42 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
import urllib.parse
from .common import InfoExtractor
from ..utils import (
bool_or_none,
str_or_none,
traverse_obj,
try_call,
unified_strdate,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/(?:[a-z]{2}/[\w.-]+)/(?P<id>[^/?#&]+)'
_TESTS = [
... | ```suggestion
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/[a-z]{2}/[\w.-]+/(?P<id>[^/?#&]+)'
``` | import urllib.parse
from .common import InfoExtractor
from ..utils import (
filter_dict,
parse_iso8601,
traverse_obj,
try_call,
url_or_none,
)
class MediciIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/[a-z]{2}/[\w.-]+/(?P<id>[^/?#&]+)'
_TESTS = [{
'u... | @@ -1,67 +1,152 @@
+import urllib.parse
+
from .common import InfoExtractor
from ..utils import (
+ bool_or_none,
+ str_or_none,
+ traverse_obj,
+ try_call,
unified_strdate,
- update_url_query,
- urlencode_postdata,
)
class MediciIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?m... | yt_dlp/extractor/medici.py | 14 | Python | 0.714 | suggestion | 116 | 39 | 39 | false | [ie/medici] Fix extractor | 9,518 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Offert4324 |
url = player_url['url']
format_type = player_url.get('type')
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
formats.extend(self._extract_m3u8_formats(url, video_id, m3u8_id='hls', fatal=False))
elif format_type in ('dash',... | This should probably be `auth_data["accessToken"]` since we catch `KeyError` below. | for player_url in traverse_obj(player_urls, lambda _, v: url_or_none(v['url'])):
url = player_url['url']
format_type = player_url.get('type')
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
formats.extend(self._extract_m3u8_for... | @@ -162,9 +165,22 @@ def _extract_formats(self, player_urls, video_id):
def _real_extract(self, url):
user, post_id = self._match_valid_url(url).group('user', 'post_id')
+
+ auth_cookie = self._get_cookies('https://api.boosty.to/').get('auth')
+ auth_headers = {}
+ if auth_cookie is... | yt_dlp/extractor/boosty.py | 26 | Python | 0.571 | security | 83 | 51 | 51 | false | [ie/Boosty] include auth token in API call if available | 9,522 | yt-dlp/yt-dlp | 132,642 | Python | un-def | RasmusAntons |
'ext': 'mp4',
'format_id': format_type,
'quality': quality(format_type),
})
else:
self.report_warning(f'Unknown format type: {format_type!r}')
return formats
def _real_extract(self, url):
user, p... | `raise_login_required` and move this to L222 | 'url': url,
'ext': 'mp4',
'format_id': format_type,
'quality': quality(format_type),
})
else:
self.report_warning(f'Unknown format type: {format_type!r}')
return formats
def _real_ext... | @@ -162,9 +165,22 @@ def _extract_formats(self, player_urls, video_id):
def _real_extract(self, url):
user, post_id = self._match_valid_url(url).group('user', 'post_id')
+
+ auth_cookie = self._get_cookies('https://api.boosty.to/').get('auth')
+ auth_headers = {}
+ if auth_cookie is... | yt_dlp/extractor/boosty.py | 26 | Python | 0.286 | refactor | 44 | 51 | 51 | false | [ie/Boosty] include auth token in API call if available | 9,522 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | RasmusAntons |
for player_url in traverse_obj(player_urls, lambda _, v: url_or_none(v['url'])):
url = player_url['url']
format_type = player_url.get('type')
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
formats.extend(self._extract_m3u8_for... | ```suggestion
auth_data = json.loads(urllib.parse.unquote(auth_cookie.value))
```
change import as well | quality = qualities(self._MP4_TYPES)
for player_url in traverse_obj(player_urls, lambda _, v: url_or_none(v['url'])):
url = player_url['url']
format_type = player_url.get('type')
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
... | @@ -162,9 +165,19 @@ def _extract_formats(self, player_urls, video_id):
def _real_extract(self, url):
user, post_id = self._match_valid_url(url).group('user', 'post_id')
+
+ auth_cookie = self._get_cookies('https://boosty.to/').get('auth')
+ auth_headers = {}
+ if auth_cookie is not... | yt_dlp/extractor/boosty.py | 26 | Python | 0.786 | security | 124 | 51 | 51 | false | [ie/Boosty] include auth token in API call if available | 9,522 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | RasmusAntons |
import json
import urllib
from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
int_or_none,
qualities,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class BoostyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?boos... | ```suggestion
import urllib.parse
```
The fact that import `urllib` works here is due to a weird quirk of python and should not be relied on | import json
import urllib.parse
from .common import InfoExtractor
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
bug_reports_message,
int_or_none,
qualities,
str_or_none,
url_or_none,
)
from ..utils.traversal import traverse_obj
class BoostyIE(InfoExtractor):
_VALID_... | @@ -1,3 +1,6 @@
+import json
+import urllib | yt_dlp/extractor/boosty.py | 2 | Python | 0.786 | suggestion | 143 | 27 | 27 | false | [ie/Boosty] include auth token in API call if available | 9,522 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | RasmusAntons |
'modified_timestamp': ('updatedAt', {int_or_none}),
'tags': ('tags', ..., 'title', {str}),
'like_count': ('count', 'likes', {int_or_none}),
}),
}
entries = []
for item in traverse_obj(post, ('data', ..., {dict})):
item_type ... | I'd also check for entries here in case the site stops using the `hasAccess` key. Also, the `if / if` logic here would break `--ignore-no-formats` even though we are doing `metadata_available=True`. We can remove `method='cookies'`, since that's the default for extractors that don't set `_NETRC_MACHINE`
```suggestion... | 'release_timestamp': ('publishTime', {int_or_none}),
'modified_timestamp': ('updatedAt', {int_or_none}),
'tags': ('tags', ..., 'title', {str}),
'like_count': ('count', 'likes', {int_or_none}),
}),
}
entries = []
for item... | @@ -202,6 +215,8 @@ def _real_extract(self, url):
'thumbnail': (('previewUrl', 'defaultPreview'), {url_or_none}),
}, get_all=False)})
+ if not post.get('hasAccess'):
+ self.raise_login_required('This post requires a subscription', True, method='cookies')... | yt_dlp/extractor/boosty.py | 26 | Python | 0.857 | refactor | 508 | 31 | 32 | false | [ie/Boosty] include auth token in API call if available | 9,522 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | RasmusAntons |
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
formats.extend(self._extract_m3u8_formats(url, video_id, m3u8_id='hls', fatal=False))
elif format_type in ('dash', 'dash_live', 'live_playback_dash'):
formats.extend(self._extract_mpd... | Maybe include a bug report msg? You'd need to import `bug_reports_message` from utils
```suggestion
self.report_warning(f'Failed to extract token from auth cookie{bug_reports_message()}')
``` | format_type = player_url.get('type')
if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
formats.extend(self._extract_m3u8_formats(url, video_id, m3u8_id='hls', fatal=False))
elif format_type in ('dash', 'dash_live', 'live_playback_dash'):... | @@ -162,9 +165,19 @@ def _extract_formats(self, player_urls, video_id):
def _real_extract(self, url):
user, post_id = self._match_valid_url(url).group('user', 'post_id')
+
+ auth_cookie = self._get_cookies('https://boosty.to/').get('auth')
+ auth_headers = {}
+ if auth_cookie is not... | yt_dlp/extractor/boosty.py | 26 | Python | 1 | bug | 210 | 51 | 51 | false | [ie/Boosty] include auth token in API call if available | 9,522 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | RasmusAntons |
'clientVersion': '0.1',
},
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 95
},
}
def _split_innertube_client(client_name):
variant, *base = client_name.rsplit('.', 1)
if base:
return variant, base[0], variant
base, *variant = client_name.split('_', 1)
retu... | ```suggestion
BASE_CLIENTS = ('ios', 'android', 'web', 'tv', 'mweb')
``` | 'client': {
'clientName': 'MEDIA_CONNECT_FRONTEND',
'clientVersion': '0.1',
},
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 95
},
}
def _split_innertube_client(client_name):
variant, *base = client_name.rsplit('.', 1)
if base:
return v... | @@ -258,7 +268,7 @@ def build_innertube_clients():
THIRD_PARTY = {
'embedUrl': 'https://www.youtube.com/', # Can be any valid URL
}
- BASE_CLIENTS = ('ios', 'android', 'web', 'tv', 'mweb')
+ BASE_CLIENTS = ('ios', 'android', 'web', 'tv', 'mweb', 'media_connect_frontend') | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 78 | 51 | 51 | false | Add YouTube client for 1080p muxed videos | 9,546 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | clienthax |
syncid = self._extract_account_syncid(player_ytcfg, master_ytcfg, initial_pr)
sts = self._extract_signature_timestamp(video_id, player_url, master_ytcfg, fatal=False) if player_url else None
headers = self.generate_api_headers(
ytcfg=player_ytcfg, account_syncid=syncid, session_index... | ```suggestion
default = ['ios', 'android', 'web']
``` |
session_index = self._extract_session_index(player_ytcfg, master_ytcfg)
syncid = self._extract_account_syncid(player_ytcfg, master_ytcfg, initial_pr)
sts = self._extract_signature_timestamp(video_id, player_url, master_ytcfg, fatal=False) if player_url else None
headers = self.generate_... | @@ -3619,7 +3629,7 @@ def _extract_player_response(self, client, video_id, master_ytcfg, player_ytcfg,
def _get_requested_clients(self, url, smuggled_data):
requested_clients = []
- default = ['ios', 'android', 'web']
+ default = ['ios', 'android', 'web', 'media_connect_frontend'] | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 63 | 51 | 51 | false | Add YouTube client for 1080p muxed videos | 9,546 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | clienthax |
# mweb has 'ultralow' formats
# See: https://github.com/yt-dlp/yt-dlp/pull/557
'mweb': {
'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'MWEB',
'clientVersion': '2.20220801.00.00',
... | as pukkandan mentioned on discord, `_` has special meaning in client names, so we need to change this to something like `mediaconnect` | 'REQUIRE_JS_PLAYER': False
},
# mweb has 'ultralow' formats
# See: https://github.com/yt-dlp/yt-dlp/pull/557
'mweb': {
'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'MWEB',
... | @@ -238,6 +238,16 @@
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 85
},
+ # This client has 1080p non split stream videos
+ 'media_connect_frontend': { | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 134 | 51 | 51 | false | Add YouTube client for 1080p muxed videos | 9,546 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | clienthax |
'is_pad': '0',
'current_region': 'US',
'app_type': 'normal',
'sys_region': 'US',
'last_install_time': int(time.time()) - random.randint(86400, 1123200),
'timezone_name': 'America/New_York',
'residence': 'US',
'app_language':... | Why not let user pass multiple ids and rotate like our hardcoded ones. It'll simplify code too | **query,
'device_platform': 'android',
'os': 'android',
'ssmix': 'a',
'_rticket': int(time.time() * 1000),
'cdid': str(uuid.uuid4()),
'channel': 'googleplay',
'aid': self._APP_INFO['aid'],
'app_name': self._APP_I... | @@ -67,80 +92,87 @@ def _call_api_impl(self, ep, query, manifest_app_version, video_id, fatal=True,
return self._download_json(
'https://%s/aweme/v1/%s/' % (self._API_HOSTNAME, ep), video_id=video_id,
fatal=fatal, note=note, errnote=errnote, headers={
- 'User-Agent': f'... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.286 | refactor | 94 | 51 | 51 | false | [ie/tiktok] Fix API extraction | 9,548 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
from .common import InfoExtractor
from ..compat import compat_urllib_parse_urlparse
from ..networking import HEADRequest
from ..utils import (
ExtractorError,
LazyList,
UnsupportedError,
UserNotLive,
determine_ext,
format_field,
int_or_none,
join_nonempty,
merge_dicts,
qualities,... | I assume we know the owner of these ids? We don't wanna use random people's id without their permission. | from ..compat import compat_urllib_parse_urlparse
from ..networking import HEADRequest
from ..utils import (
ExtractorError,
LazyList,
UnsupportedError,
UserNotLive,
determine_ext,
format_field,
int_or_none,
join_nonempty,
merge_dicts,
qualities,
remove_start,
srt_subtitl... | @@ -30,14 +32,37 @@
class TikTokBaseIE(InfoExtractor):
- _APP_VERSIONS = [('26.1.3', '260103'), ('26.1.2', '260102'), ('26.1.1', '260101'), ('25.6.2', '250602')]
- _WORKING_APP_VERSION = None
- _APP_NAME = 'trill'
- _AID = 1180
+ _APP_INSTALL_IDS = [ | yt_dlp/extractor/tiktok.py | 26 | Python | 0.429 | security | 105 | 51 | 51 | false | [ie/tiktok] Fix API extraction | 9,548 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'host_abi': 'armeabi-v7a',
'locale': 'en',
'ac2': 'wifi5g',
'uoo': '1',
'op_region': 'US',
'build_number': self._APP_VERSION,
'region': 'US',
'ts': int(time.time()),
'iid': iid,
'device_id': random.ra... | https://github.com/yt-dlp/yt-dlp/pull/9548#discussion_r1543188731 would simplify this to:
```suggestion
iids = self._configuration_arg('iid', self._APP_INSTALL_IDS, ie_key=TikTokIE):
max_tries = len(iids)
for count, iid in enumerate(random.sample(iids, max_tries), start=1):
``` | 'version_code': ''.join((f'{int(v):02d}' for v in self._APP_INFO['app_version'].split('.'))),
'version_name': self._APP_INFO['app_version'],
'manifest_version_code': self._APP_INFO['manifest_app_version'],
'update_version_code': self._APP_INFO['manifest_app_version'],
... | @@ -67,80 +92,87 @@ def _call_api_impl(self, ep, query, manifest_app_version, video_id, fatal=True,
return self._download_json(
'https://%s/aweme/v1/%s/' % (self._API_HOSTNAME, ep), video_id=video_id,
fatal=fatal, note=note, errnote=errnote, headers={
- 'User-Agent': f'... | yt_dlp/extractor/tiktok.py | 26 | Python | 0.857 | refactor | 309 | 51 | 51 | false | [ie/tiktok] Fix API extraction | 9,548 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
class CBCPlayerIE(InfoExtractor):
IE_NAME = 'cbc.ca:player'
_VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/|i/caffeine/syndicate/\?mediaId=))(?P<id>(?:\d\.)?\d+)'
_TESTS = [{
'url': 'http://www.cbc.ca/player/play/2683190193',
'md5': '64d25f841ddf4ddb28a235338af32e2c... | ```suggestion
'title': 'CBC Montreal is organizing its first ever community hackathon!',
'description': 'md5:dd3b692f0a139b0369943150bd1c46a9',
``` |
class CBCPlayerIE(InfoExtractor):
IE_NAME = 'cbc.ca:player'
_VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/|i/caffeine/syndicate/\?mediaId=))(?P<id>(?:\d\.)?\d+)'
_TESTS = [{
'url': 'http://www.cbc.ca/player/play/2683190193',
'md5': '64d25f841ddf4ddb28a235338af32e2c... | @@ -165,9 +165,52 @@ class CBCPlayerIE(InfoExtractor):
'uploader': 'CBCC-NEW',
},
'skip': 'Geo-restricted to Canada and no longer available',
+ }, {
+ 'url': 'http://www.cbc.ca/i/caffeine/syndicate/?mediaId=2657631896',
+ 'md5': 'e5e708c34ae6fca156aafe17c43e8b75',
+ ... | yt_dlp/extractor/cbc.py | 26 | Python | 0.714 | suggestion | 174 | 51 | 51 | false | [ie/cbc.ca:player] Support new URL format | 9,561 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | trainman261 |
'description': 'md5:cb6f660850dc5eb7d1ab776ea094959d',
'duration': 2581.0,
'timestamp': 1675160100,
'upload_date': '20230131',
'thumbnail': 'https://epg-image.zdf.de/fotobase-webdelivery/images/e2d7e55a-09f0-424e-ac73-6cac4dd65f35?layout=2400x1350',
... | somehow this video changed completely. it also no longer matches what is visible on the webpage. But it also says "Video no longer available" on the page, so that might explain the discrepancy. Still let me verify that it matches the player2 behaviour.
:
'timestamp': 1675160100,
'upload_date': '20230131',
'thumbnail': 'https://epg-image.zdf.de/fotobase-webdelivery/images/e2d7e55a-09f0-424e-ac73-6cac4dd65f35?layout=2400x1350',
+ 'series': 'SOKO Stuttgart',
+ 'serie... | yt_dlp/extractor/zdf.py | 26 | Python | 0.5 | suggestion | 353 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | StefanLobbenmeier | StefanLobbenmeier |
}
mobj = re.search(r'(?P<width>\d+)x(?P<height>\d+)', layout_key)
if mobj:
thumbnail.update({
'width': int(mobj.group('width')),
'height': int(mobj.group('height')),
})
... | ```suggestion
'series_id': traverse_obj(target_info, ('http://zdf.de/rels/cmdm/series', 'seriesUuid')),
``` | continue
thumbnail = {
'url': layout_url,
'format_id': layout_key,
}
mobj = re.search(r'(?P<width>\d+)x(?P<height>\d+)', layout_key)
if mobj:
thumbnail.update({
... | @@ -305,23 +344,38 @@ def _extract_entry(self, url, player, content, video_id):
'title': chap.get('anchorLabel'),
} for chap, next_chap in zip(chapter_marks, chapter_marks[1:])]
+ target_info = traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/target'))
return merge_... | yt_dlp/extractor/zdf.py | 26 | Python | 0.714 | suggestion | 121 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | StefanLobbenmeier |
thumbnails.append(thumbnail)
chapter_marks = t.get('streamAnchorTag') or []
chapter_marks.append({'anchorOffset': int_or_none(t.get('duration'))})
chapters = [{
'start_time': chap.get('anchorOffset'),
'end_time': next_chap.get('anchorOffset'),
... | You could do
```py
'episode': title,
**traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/target', {
'series_id': ('http://zdf.de/rels/cmdm/series', 'seriesUuid'),
'series': ('http://zdf.de/rels/cmdm/series', 'seriesTitle'),
...... | thumbnail.update({
'width': int(mobj.group('width')),
'height': int(mobj.group('height')),
})
thumbnails.append(thumbnail)
chapter_marks = t.get('streamAnchorTag') or []
chapter_marks.append({'anchor... | @@ -305,23 +344,38 @@ def _extract_entry(self, url, player, content, video_id):
'title': chap.get('anchorLabel'),
} for chap, next_chap in zip(chapter_marks, chapter_marks[1:])]
+ target_info = traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/target'))
return merge_... | yt_dlp/extractor/zdf.py | 26 | Python | 0.857 | suggestion | 367 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | StefanLobbenmeier |
'info_dict': {
'id': 'aktenzeichen-xy-ungeloest',
'title': 'Aktenzeichen XY... ungelöst',
'entries': "lambda x: not any('xy580-fall1-kindermoerder-gesucht-100' in e['url'] for e in x)",
},
'playlist_mincount': 2,
}, {
'url': 'https://www.zdf.de/fil... | ```suggestion
rf'''<div\b[^>]*?\sdata-plusbar-id\s*=\s*(["'])(?P<p_id>[\w-]+)\1[^>]*?\sdata-plusbar-url=\1(?P<url>{ZDFIE._VALID_URL})\1''',
``` | 'title': 'planet e.',
'description': 'md5:87e3b9c66a63cf1407ee443d2c4eb88e',
},
'playlist_mincount': 50,
}, {
'url': 'https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest',
'info_dict': {
'id': 'aktenzeichen-xy-ungeloest',
'title':... | @@ -416,7 +471,7 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, channel_id)
matches = re.finditer(
- rf'''<div\b[^>]*?\sdata-plusbar-id\s*=\s*(["'])(?P<p_id>[\w-]+)\1[^>]*?\sdata-plusbar-url=\1(?P<url>{ZDFIE._VALID_URL})\1''',
+ fr'''<div\b[^>]*?\sdata-p... | yt_dlp/extractor/zdf.py | 26 | Python | 0.714 | suggestion | 157 | 49 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | StefanLobbenmeier |
def _og_search_title(self, webpage, fatal=False):
title = super()._og_search_title(webpage, fatal=fatal)
return re.split(r'\s+[-|]\s+ZDF(?:mediathek)?$', title or '')[0] or None
def _real_extract(self, url):
channel_id = self._match_id(url)
webpage = self._download_webpage(url,... | ```suggestion
rf'''(<a\b[^>]*?\shref\s*=[^>]+?\sdata-target-id\s*=\s*(["']){m.group("p_id")}\2[^>]*>)''',
``` | }]
@classmethod
def suitable(cls, url):
return False if ZDFIE.suitable(url) else super().suitable(url)
def _extract_entry(self, entry):
return self.url_result(
entry['sharingUrl'], ZDFIE, **traverse_obj(entry, {
'id': ('basename', {str}),
'ti... | @@ -431,7 +486,7 @@ def _real_extract(self, url):
def check_video(m):
v_ref = self._search_regex(
- r'''(<a\b[^>]*?\shref\s*=[^>]+?\sdata-target-id\s*=\s*(["']){}\2[^>]*>)'''.format(m.group('p_id')),
+ fr'''(<a\b[^>]*?\shref\s*=[^>]+?\sdata-target-id\s*=\s*(["']){m.... | yt_dlp/extractor/zdf.py | 26 | Python | 0.714 | suggestion | 127 | 34 | 45 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | StefanLobbenmeier |
duration = float_or_none(try_get(
ptmd, lambda x: x['attributes']['duration']['value']), scale=1000)
return {
'extractor_key': ZDFIE.ie_key(),
'id': content_id,
'duration': duration,
'formats': formats,
'subtitles': self._extract_... | ```suggestion
_VALID_URL = r'https?://www\.zdf\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)\.html'
_TESTS = [{
``` | duration = float_or_none(try_get(
ptmd, lambda x: x['attributes']['duration']['value']), scale=1000)
return {
'extractor_key': ZDFIE.ie_key(),
'id': content_id,
'duration': duration,
'formats': formats,
'subtitles': self._extract_s... | @@ -140,6 +141,7 @@ def _extract_player(self, webpage, video_id, fatal=True):
class ZDFIE(ZDFBaseIE):
_VALID_URL = r'https?://www\.zdf\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)\.html'
+
_TESTS = [{ | yt_dlp/extractor/zdf.py | 26 | Python | 0.714 | suggestion | 112 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | StefanLobbenmeier |
'duration': int_or_none(t.get('duration')),
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
'chapters': chapters or None,
'episode': title,
**traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/tar... | I don't understand the `try_call` usage. It doesn't suppress `ExtractorError`, so the fallback will never be used. I would do this:
```suggestion
player_url = player['content']
for query in ({'profile': 'player-3'}, None):
try:
content = self._call_api(
... | 'thumbnails': thumbnails,
'chapters': chapters or None,
'episode': title,
**traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/target', {
'series_id': ('http://zdf.de/rels/cmdm/series', 'seriesUuid', {str}),
'series': ('http://z... | @@ -316,12 +357,28 @@ def _extract_entry(self, url, player, content, video_id):
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
'chapters': chapters or None,
+ 'episode': title,
+ **traverse_obj(content, ('programmeItem... | yt_dlp/extractor/zdf.py | 26 | Python | 1 | refactor | 708 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | StefanLobbenmeier |
thumbnails.append(thumbnail)
chapter_marks = t.get('streamAnchorTag') or []
chapter_marks.append({'anchorOffset': int_or_none(t.get('duration'))})
chapters = [{
'start_time': chap.get('anchorOffset'),
'end_time': next_chap.get('anchorOffset'),
... | We should type check/transform
```suggestion
'series_id': ('http://zdf.de/rels/cmdm/series', 'seriesUuid', {str}),
'series': ('http://zdf.de/rels/cmdm/series', 'seriesTitle', {str}),
'season': ('http://zdf.de/rels/cmdm/season', 'seasonTitle', {str}),
... | chapter_marks = t.get('streamAnchorTag') or []
chapter_marks.append({'anchorOffset': int_or_none(t.get('duration'))})
chapters = [{
'start_time': chap.get('anchorOffset'),
'end_time': next_chap.get('anchorOffset'),
'title': chap.get('anchorLabel'),
} f... | @@ -316,12 +357,28 @@ def _extract_entry(self, url, player, content, video_id):
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
'chapters': chapters or None,
+ 'episode': title,
+ **traverse_obj(content, ('programmeItem... | yt_dlp/extractor/zdf.py | 26 | Python | 1 | suggestion | 617 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | StefanLobbenmeier |
chapter_marks = t.get('streamAnchorTag') or []
chapter_marks.append({'anchorOffset': int_or_none(t.get('duration'))})
chapters = [{
'start_time': chap.get('anchorOffset'),
'end_time': next_chap.get('anchorOffset'),
'title': chap.get('anchorLabel'),
} ... | ~~Currently, the usage of `merge_dicts` will overwrite these metadata fields if they already exist in the `info` dict. Do we want that? or do we want to priotize the new data? Or doesn't it matter?~~ |
chapter_marks = t.get('streamAnchorTag') or []
chapter_marks.append({'anchorOffset': int_or_none(t.get('duration'))})
chapters = [{
'start_time': chap.get('anchorOffset'),
'end_time': next_chap.get('anchorOffset'),
'title': chap.get('anchorLabel'),
} ... | @@ -316,12 +355,32 @@ def _extract_entry(self, url, player, content, video_id):
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
'chapters': chapters or None,
+ 'episode': title,
+ **traverse_obj(content, ('programmeItem... | yt_dlp/extractor/zdf.py | 26 | Python | 0.5 | suggestion | 199 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | StefanLobbenmeier |
return merge_dicts(info, {
'title': title,
'description': content.get('leadParagraph') or content.get('teasertext'),
'duration': int_or_none(t.get('duration')),
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
... | revert this please, we don't need a single-use temp var |
return merge_dicts(info, {
'title': title,
'description': content.get('leadParagraph') or content.get('teasertext'),
'duration': int_or_none(t.get('duration')),
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
... | @@ -316,12 +355,29 @@ def _extract_entry(self, url, player, content, video_id):
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
'chapters': chapters or None,
+ 'episode': title,
+ **traverse_obj(content, ('programmeItem... | yt_dlp/extractor/zdf.py | 26 | Python | 0.286 | suggestion | 55 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | StefanLobbenmeier |
'thumbnails': thumbnails,
'chapters': chapters or None,
'episode': title,
**traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/target', {
'series_id': ('http://zdf.de/rels/cmdm/series', 'seriesUuid', {str}),
'series': ('http://z... | ```suggestion
player_url, video_id, 'content', player['apiToken'], url)
``` | 'thumbnails': thumbnails,
'chapters': chapters or None,
'episode': title,
**traverse_obj(content, ('programmeItem', 0, 'http://zdf.de/rels/target', {
'series_id': ('http://zdf.de/rels/cmdm/series', 'seriesUuid', {str}),
'series': ('http://z... | @@ -316,12 +355,32 @@ def _extract_entry(self, url, player, content, video_id):
'timestamp': unified_timestamp(content.get('editorialDate')),
'thumbnails': thumbnails,
'chapters': chapters or None,
+ 'episode': title,
+ **traverse_obj(content, ('programmeItem... | yt_dlp/extractor/zdf.py | 26 | Python | 0.571 | suggestion | 93 | 51 | 51 | false | [ie/zdf] Extract more metadata | 9,565 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | StefanLobbenmeier |
'Unable to login: %s said: %s' % (self.IE_NAME, error),
expected=True)
def _real_extract(self, url):
video_id = self._match_id(url)
partial_view = False
adult_view = False
for _ in range(2):
data = self._download_json(
'ht... | all of this `query` business here and above is dead code, should be removed afaict | 'url': 'https://vod.afreecatv.com/player/104647403',
'only_matching': True,
}, {
# private
'url': 'https://vod.afreecatv.com/player/81669846',
'only_matching': True,
}]
def _real_extract(self, url):
video_id = self._match_id(url)
data = self._download... | @@ -199,15 +198,8 @@ def _real_extract(self, url):
query['partialView'] = 'SKIP_ADULT'
if adult_view:
query['adultView'] = 'ADULT_VIEW' | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.429 | suggestion | 82 | 51 | 51 | false | [ie/afreecatv] Fix extractor | 9,566 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Tomoka1 |
break
if flag == 'PARTIAL_ADULT':
self.report_warning(
'In accordance with local laws and regulations, underage users are restricted from watching adult content. '
'Only content suitable for all ages will be downloaded. '
... | this code is strange. stringifying JSON to check its truthiness? It seems like this section of code needs a rewrite instead of trying to fit JSON data into this old XML code | })
entries = []
for file_num, file_element in enumerate(
traverse_obj(data, ('files', lambda _, v: url_or_none(v['file']))), start=1):
file_url = file_element['file']
if determine_ext(file_url) == 'm3u8':
formats = self._extract_m3u8_forma... | @@ -229,20 +221,19 @@ def _real_extract(self, url):
else:
raise ExtractorError('Unable to download video info')
- video_element = video_xml.findall('./track/video')[-1]
- if video_element is None or video_element.text is None:
+ video_element = data['files'][-1]
+ if ... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.429 | suggestion | 173 | 51 | 51 | false | [ie/afreecatv] Fix extractor | 9,566 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Tomoka1 |
self.assertEqual(traverse_obj(_TEST_DATA, [(100, 1.2), all]), [100, 1.2],
msg='`all` should give all results as list')
self.assertEqual(traverse_obj(_TEST_DATA, [(100, 1.2), any]), 100,
msg='`any` should give the first result')
self.assertEqual(t... | Not a good test imo. Using a case that can actually branch like `urls`/`data` would be better. | #!/usr/bin/env python3
# Allow direct execution
import os
import sys
import unittest
import warnings
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import contextlib
import io
import itertools
import json
import subprocess
import xml.etree.ElementTree
from yt_dlp.compat import (
... | @@ -2392,6 +2392,33 @@ def test_traverse_obj(self):
self.assertEqual(traverse_obj(etree, ('country', 0, ..., 'text()', {int_or_none})), [1, 2008, 141100],
msg='special transformations should act on current element')
+ self.assertEqual(traverse_obj(_TEST_DATA, [(100, 1.2), all... | test/test_utils.py | 26 | Python | 0.429 | suggestion | 94 | 51 | 2,079 | false | [utils] `traverse_obj`: Allow unbranching using `all` and `any` | 9,571 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
msg='full Python xpath features should be supported')
self.assertEqual(traverse_obj(etree, (0, '@name')), 'Liechtenstein',
msg='special transformations should act on current element')
self.assertEqual(traverse_obj(etree, ('country', 0, ..., 'text()', {in... | I see how this logically follows from impl, but is there any use-case? | #!/usr/bin/env python3
# Allow direct execution
import os
import sys
import unittest
import warnings
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import contextlib
import io
import itertools
import json
import subprocess
import xml.etree.ElementTree
from yt_dlp.compat import (
... | @@ -2392,6 +2392,33 @@ def test_traverse_obj(self):
self.assertEqual(traverse_obj(etree, ('country', 0, ..., 'text()', {int_or_none})), [1, 2008, 141100],
msg='special transformations should act on current element')
+ self.assertEqual(traverse_obj(_TEST_DATA, [(100, 1.2), all... | test/test_utils.py | 26 | Python | 0.286 | question | 70 | 51 | 2,079 | false | [utils] `traverse_obj`: Allow unbranching using `all` and `any` | 9,571 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
msg='special transformations should act on current element')
self.assertEqual(traverse_obj(etree, ('country', 0, ..., 'text()', {int_or_none})), [1, 2008, 141100],
msg='special transformations should act on current element')
self.assertEqual(traverse_ob... | ~~I don't understand this. Could you explain?~~
Shouldn't it be:
```
('dict', 'None', 100, 1.2) => [100, 1.2]
any => 100
{float} => 100
``` | #!/usr/bin/env python3
# Allow direct execution
import os
import sys
import unittest
import warnings
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import contextlib
import io
import itertools
import json
import subprocess
import xml.etree.ElementTree
from yt_dlp.compat import (
... | @@ -2392,6 +2392,33 @@ def test_traverse_obj(self):
self.assertEqual(traverse_obj(etree, ('country', 0, ..., 'text()', {int_or_none})), [1, 2008, 141100],
msg='special transformations should act on current element')
+ self.assertEqual(traverse_obj(_TEST_DATA, [(100, 1.2), all... | test/test_utils.py | 26 | Python | 0.786 | suggestion | 149 | 51 | 2,079 | false | [utils] `traverse_obj`: Allow unbranching using `all` and `any` | 9,571 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
def lazy_last(iterable):
iterator = iter(iterable)
prev = next(iterator, NO_DEFAULT)
if prev is NO_DEFAULT:
return
for item in iterator:
yield False, prev
prev = item
yield True, prev
def apply_path(start_obj, path, test_type):
... | ```suggestion
objs = (next(filtered_objs, None) if key is any else list(filtered_objs), )
```
readablity |
def lazy_last(iterable):
iterator = iter(iterable)
prev = next(iterator, NO_DEFAULT)
if prev is NO_DEFAULT:
return
for item in iterator:
yield False, prev
prev = item
yield True, prev
def apply_path(start_obj, path, test_type):
... | @@ -228,6 +228,12 @@ def apply_path(start_obj, path, test_type):
if not casesense and isinstance(key, str):
key = key.casefold()
+ if key in (any, all):
+ has_branched = False
+ filtered_objs = (obj for obj in objs if obj not in (None, {}))
+ ... | yt_dlp/utils/traversal.py | 26 | Python | 0.714 | suggestion | 123 | 51 | 51 | false | [utils] `traverse_obj`: Allow unbranching using `all` and `any` | 9,571 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Grub4K |
})
for k in ('ext', 'abr'):
v = str_or_none(f.get(k))
if v:
format_id_list.append(v)
preview = is_preview or re.search(r'/(?:preview|playlist)/0/30/', f['url'])
if preview:
format_id_list.append('prev... | ```suggestion
break
``` | })
for k in ('ext', 'abr'):
v = str_or_none(f.get(k))
if v:
format_id_list.append(v)
preview = is_preview or re.search(r'/(?:preview|playlist)/0/30/', f['url'])
if preview:
format_id_list.append('prev... | @@ -261,16 +261,22 @@ def add_format(f, protocol, is_preview=False):
formats.append(f)
# New API
- transcodings = try_get(
- info, lambda x: x['media']['transcodings'], list) or []
- for t in transcodings:
- if not isinstance(t, dict):
+ for t in traver... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.429 | suggestion | 41 | 51 | 51 | false | [ie/soundcloud] Enable retries for rate-limiting | 9,585 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bashonly |
f['abr'] = int(abr)
if protocol == 'hls':
protocol = 'm3u8' if ext == 'aac' else 'm3u8_native'
else:
protocol = 'http'
f.update({
'format_id': '_'.join(format_id_list),
'protocol': protocol,
... | Should we suggest sleep args to user? | f['abr'] = int(abr)
if protocol == 'hls':
protocol = 'm3u8' if ext == 'aac' else 'm3u8_native'
else:
protocol = 'http'
f.update({
'format_id': '_'.join(format_id_list),
'protocol': protocol,
... | @@ -261,16 +261,22 @@ def add_format(f, protocol, is_preview=False):
formats.append(f)
# New API
- transcodings = try_get(
- info, lambda x: x['media']['transcodings'], list) or []
- for t in transcodings:
- if not isinstance(t, dict):
- continu... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.143 | question | 37 | 51 | 51 | false | [ie/soundcloud] Enable retries for rate-limiting | 9,585 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
def _initialize_pre_login(self):
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
def _verify_oauth_token(self, token):
if self._request_webpage(
self._API_VERIFY_AUTH_TOKEN % (self._API_AUTH_QUERY_TEMPLATE % self._CLIENT_ID),
... | ```suggestion
'Use "--username oauth --password <oauth_token>" to login using an oauth token, '
f'or else {self._login_hint(method="cookies")}', expected=True)
``` |
def _verify_oauth_token(self, token):
if self._request_webpage(
self._API_VERIFY_AUTH_TOKEN % (self._API_AUTH_QUERY_TEMPLATE % self._CLIENT_ID),
None, note='Verifying login token...', fatal=False,
data=json.dumps({'session': {'access_token': token}}).encode()... | @@ -112,21 +111,29 @@ def _download_json(self, *args, **kwargs):
def _initialize_pre_login(self):
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
+ def _verify_oauth_token(self, token):
+ if self._request_webpage(
+ self._API_VE... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.786 | security | 198 | 51 | 51 | false | [ie/soundcloud] Support cookies | 9,586 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
query['client_id'] = self._CLIENT_ID
kwargs['query'] = query
try:
return super()._download_json(*args, **kwargs)
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
self._store... | ```suggestion
self.report_warning('Provided authorization token is invalid. Continuing as guest')
``` | return super()._download_json(*args, **kwargs)
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
self._store_client_id(None)
self._update_client_id()
continue
... | @@ -112,21 +111,29 @@ def _download_json(self, *args, **kwargs):
def _initialize_pre_login(self):
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
+ def _verify_oauth_token(self, token):
+ if self._request_webpage(
+ self._API_VE... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.714 | security | 115 | 51 | 51 | false | [ie/soundcloud] Support cookies | 9,586 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
del kwargs['fatal']
query = kwargs.get('query', {}).copy()
for _ in range(2):
query['client_id'] = self._CLIENT_ID
kwargs['query'] = query
try:
return super()._download_json(*args, **kwargs)
except ExtractorError as e:
... | This will re-trigger verification for each subclass. Is that the intention? Otherwise, making `_HEADERS` a class variable and `self._HEADERS['Authorization'] = f'OAuth {token}'` will share it. | query['client_id'] = self._CLIENT_ID
kwargs['query'] = query
try:
return super()._download_json(*args, **kwargs)
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
self._store... | @@ -112,21 +111,29 @@ def _download_json(self, *args, **kwargs):
def _initialize_pre_login(self):
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
+ def _verify_oauth_token(self, token):
+ if self._request_webpage(
+ self._API_VE... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.5 | security | 192 | 51 | 51 | false | [ie/soundcloud] Support cookies | 9,586 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
kwargs['query'] = query
try:
return super()._download_json(*args, **kwargs)
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
self._store_client_id(None)
self._update... | In current impl, this is unreachable, no? | except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
self._store_client_id(None)
self._update_client_id()
continue
elif non_fatal:
self.report_warning(er... | @@ -112,21 +111,29 @@ def _download_json(self, *args, **kwargs):
def _initialize_pre_login(self):
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
+ def _verify_oauth_token(self, token):
+ if self._request_webpage(
+ self._API_VE... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.071 | question | 41 | 51 | 51 | false | [ie/soundcloud] Support cookies | 9,586 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
operator = None
while offset_key:
item = re.match(
MATH_FIELD_RE if operator else MATH_OPERATORS_RE,
offset_key).group(0)
offset_key = offset_key[len(item):]
if operator is None:
... | How about
```suggestion
return value.translate(str.maketrans('/', '\u29F8', '\0'))
```
| operator = None
# Datetime formatting
if mdict['strf_format']:
value = strftime_or_none(value, mdict['strf_format'].replace('\\,', ','))
# XXX: Workaround for https://github.com/yt-dlp/yt-dlp/issues/4485
if sanitize and value == '':
... | @@ -1292,14 +1293,23 @@ def get_value(mdict):
na = self.params.get('outtmpl_na_placeholder', 'NA')
- def filename_sanitizer(key, value, restricted=self.params.get('restrictfilenames')):
+ def filename_sanitizer(key, value, restricted):
return sanitize_filename(str(value), restric... | yt_dlp/YoutubeDL.py | 26 | Python | 0.714 | suggestion | 103 | 51 | 51 | false | Don't sanitize filename on Unix when `--no-windows-filenames` | 9,591 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | pukkandan |
info.setdefault('tags', []).append(traverse_obj(i, ('attributes', 'value')))
elif i_type == 'campaign':
info.update({
'channel': traverse_obj(i, ('attributes', 'title')),
'channel_id': str_or_none(i.get('id')),
'cha... | ```suggestion
v_url = VimeoIE._smuggle_referrer(v_url, 'https://patreon.com')
if self._request_webpage(v_url, video_id, 'Checking Vimeo embed URL', fatal=False, errnote=False):
return {
**info,
'_type': 'url_transpa... | ext = mimetype2ext(media_attributes.get('mimetype'))
# if size_bytes is None, this media file is likely unavailable
# See: https://github.com/yt-dlp/yt-dlp/issues/4608
size_bytes = int_or_none(media_attributes.get('size_bytes'))
if downloa... | @@ -250,20 +250,27 @@ def _real_extract(self, url):
v_url = url_or_none(compat_urllib_parse_unquote(
self._search_regex(r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)', embed_html, 'vimeo url', fatal=False)))
if v_url:
- return {
- ... | yt_dlp/extractor/patreon.py | 26 | Python | 0.929 | suggestion | 447 | 51 | 51 | false | [patreon] fix some vimeo embed downloads | 9,613 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | johnvictorfs |
'channel_url': traverse_obj(i, ('attributes', 'url')),
'channel_follower_count': int_or_none(traverse_obj(i, ('attributes', 'patron_count'))),
})
# handle Vimeo embeds
if try_get(attributes, lambda x: x['embed']['provider']) == 'Vimeo':
... | ```suggestion
if self._request_webpage(embed_url, video_id, 'Checking embed URL', fatal=False, errnote=False):
``` | # XXX: what happens if there are multiple attachments?
return {
**info,
'ext': ext,
'filesize': size_bytes,
'url': download_url,
}
elif i_type == 'user'... | @@ -250,20 +250,27 @@ def _real_extract(self, url):
v_url = url_or_none(compat_urllib_parse_unquote(
self._search_regex(r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)', embed_html, 'vimeo url', fatal=False)))
if v_url:
- return {
- ... | yt_dlp/extractor/patreon.py | 26 | Python | 0.714 | suggestion | 128 | 51 | 51 | false | [patreon] fix some vimeo embed downloads | 9,613 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | johnvictorfs |
elif i_type == 'post_tag':
info.setdefault('tags', []).append(traverse_obj(i, ('attributes', 'value')))
elif i_type == 'campaign':
info.update({
'channel': traverse_obj(i, ('attributes', 'title')),
'channel_id': str_or_none... | maybe this should be
```suggestion
return self.url_result(v_url, 'Vimeo', **info, url_transparent=True)
``` | download_url = media_attributes.get('download_url')
ext = mimetype2ext(media_attributes.get('mimetype'))
# if size_bytes is None, this media file is likely unavailable
# See: https://github.com/yt-dlp/yt-dlp/issues/4608
size_bytes = int_or... | @@ -250,20 +250,24 @@ def _real_extract(self, url):
v_url = url_or_none(compat_urllib_parse_unquote(
self._search_regex(r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)', embed_html, 'vimeo url', fatal=False)))
if v_url:
- return {
- ... | yt_dlp/extractor/patreon.py | 26 | Python | 0.786 | suggestion | 130 | 51 | 51 | false | [patreon] fix some vimeo embed downloads | 9,613 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | johnvictorfs |
})
# handle Vimeo embeds
if try_get(attributes, lambda x: x['embed']['provider']) == 'Vimeo':
embed_html = try_get(attributes, lambda x: x['embed']['html'])
v_url = url_or_none(compat_urllib_parse_unquote(
self._search_regex(r'(https(?:%3A%2F%2F|:... | same
```suggestion
return self.url_result(embed_url, **info)
``` | **info,
'ext': ext,
'filesize': size_bytes,
'url': download_url,
}
elif i_type == 'user':
user_attributes = i.get('attributes')
if user_attributes:
... | @@ -250,20 +250,24 @@ def _real_extract(self, url):
v_url = url_or_none(compat_urllib_parse_unquote(
self._search_regex(r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)', embed_html, 'vimeo url', fatal=False)))
if v_url:
- return {
- ... | yt_dlp/extractor/patreon.py | 26 | Python | 0.571 | suggestion | 83 | 51 | 51 | false | [patreon] fix some vimeo embed downloads | 9,613 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | johnvictorfs |
if not path.startswith(f'/content/v2/{self._API_ENDPOINT}/'):
path = f'/content/v2/{self._API_ENDPOINT}/{path}'
try:
result = self._call_base_api(
path, internal_id, lang, f'Downloading {note} JSON ({self._API_ENDPOINT})', query=query)
except ExtractorErr... | This function should be merged with `_extract_formats`. Remove the `is_music` parameter and just download the json first part in the function:
```suggestion
def _extract_formats(self, identifier, display_id=None):
if not display_id:
display_id = identifier
stream_response = self._do... | try:
result = self._call_base_api(
path, internal_id, lang, f'Downloading {note} JSON ({self._API_ENDPOINT})', query=query)
except ExtractorError as error:
if isinstance(error.cause, HTTPError) and error.cause.status == 404:
return None
... | @@ -135,47 +145,30 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
+ def _extract_stream(self, internal_id, is_music):
+ if is_music:
+ object_type = 'music/'
+ ... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.857 | security | 721 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bytedream |
object_type = response.get('type')
if object_type == 'episode':
result = self._transform_episode_response(response)
elif object_type == 'movie':
result = self._transform_movie_response(response)
elif object_type == 'movie_listing':
first_movie_id = ... | `is_premium`, setting `_ACCESS_TOKEN`, and this is not needed if we keep using the old check. I remember the premium state not properly lining up sometimes, is there a reason you changed this? | 'skip': 'no longer exists',
}, {
'url': 'https://www.crunchyroll.com/watch/G62PEZ2E6',
'info_dict': {
'id': 'G62PEZ2E6',
'description': 'md5:8d2f8b6b9dd77d87810882e7d2ee5608',
'age_limit': 13,
'duration': 65.138,
'title': 'Garakowa ... | @@ -359,18 +352,12 @@ def entries():
else:
raise ExtractorError(f'Unknown object type {object_type}')
- # There might be multiple audio languages for one object (`<object>_metadata.versions`),
- # so we need to get the id from `streams_link` instead or we dont know which language t... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.571 | question | 192 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bytedream |
if object_type == 'episode':
result = self._transform_episode_response(response)
elif object_type == 'movie':
result = self._transform_movie_response(response)
elif object_type == 'movie_listing':
first_movie_id = traverse_obj(response, ('movie_listing_metad... | Why was this removed? If the user is logged in they should not be prompted to login again.
Same below | 'url': 'https://www.crunchyroll.com/watch/G62PEZ2E6',
'info_dict': {
'id': 'G62PEZ2E6',
'description': 'md5:8d2f8b6b9dd77d87810882e7d2ee5608',
'age_limit': 13,
'duration': 65.138,
'title': 'Garakowa -Restore the World-',
},
'pla... | @@ -359,18 +352,12 @@ def entries():
else:
raise ExtractorError(f'Unknown object type {object_type}')
- # There might be multiple audio languages for one object (`<object>_metadata.versions`),
- # so we need to get the id from `streams_link` instead or we dont know which language t... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.429 | question | 104 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bytedream |
return result
def _extract_stream(self, internal_id, is_music):
if is_music:
object_type = 'music/'
else:
object_type = ''
return self._download_json(
f'https://cr-play-service.prd.crunchyrollsvc.com/v1/{object_type}{internal_id}/console/switch/p... | This should employ the same lazy evaluation that hls had before. see [`_m3u8_meta_format` in `ie/common.py:`](<https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/extractor/common.py#L1985-L1995>) for how to implement the dash version using `http_dash_segments`. For this the above removed block has to be restored.
I... | # if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
f'https://static.crunchyroll.com/skip-events/production/{internal_id}.json',
internal_id, note='Downloading chapter info', fatal=False, errnote=False)
if not skip_events:
... | @@ -135,47 +145,30 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
+ def _extract_stream(self, internal_id, is_music):
+ if is_music:
+ object_type = 'music/'
+ ... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.857 | security | 917 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bytedream |
login_response = self._download_json(
f'{self._API_BASE}/login.1.json', None, 'Logging in',
data=urlencode_postdata({
'account': username,
'password': password,
'session_id': session_id
}))
if login_response['code'] != '... | This should probably be outside the `try`. Perhaps
```suggestion
auth_headers = {'Authorization': CrunchyrollBaseIE._BASIC_AUTH}
if self.is_logged_in:
grant_type = 'etp_rt_cookie'
else:
grant_type = 'client_id'
auth_headers['ETP-Anonymous-ID'] = uuid.uu... | 'password': password,
'session_id': session_id
}))
if login_response['code'] != 'ok':
raise ExtractorError('Login failed. Server message: %s' % login_response['message'], expected=True)
if not self.is_logged_in:
raise ExtractorError('Lo... | @@ -86,9 +91,13 @@ def _update_auth(self):
grant_type = 'etp_rt_cookie' if self.is_logged_in else 'client_id'
try:
+ auth_headers = {'Authorization': CrunchyrollBaseIE._BASIC_AUTH}
+ if not self.is_logged_in:
+ auth_headers['ETP-Anonymous-ID'] = uuid.uuid4() | yt_dlp/extractor/crunchyroll.py | 26 | Python | 1 | security | 371 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bytedream |
if CrunchyrollBaseIE._AUTH_HEADERS and CrunchyrollBaseIE._AUTH_REFRESH > time_seconds():
return
if not CrunchyrollBaseIE._BASIC_AUTH:
cx_api_param = self._CLIENT_ID[self.is_logged_in]
self.write_debug(f'Using cxApiParam={cx_api_param}')
CrunchyrollBaseIE.... | Why save the access token and not decode the token and set `self.is_premium` here immediately? | cx_api_param = self._CLIENT_ID[self.is_logged_in]
self.write_debug(f'Using cxApiParam={cx_api_param}')
CrunchyrollBaseIE._BASIC_AUTH = 'Basic ' + base64.b64encode(f'{cx_api_param}:'.encode()).decode()
auth_headers = {'Authorization': CrunchyrollBaseIE._BASIC_AUTH}
if... | @@ -97,6 +106,7 @@ def _update_auth(self):
'and your browser\'s User-Agent (with --user-agent)', expected=True)
raise
+ CrunchyrollBaseIE._ACCESS_TOKEN = auth_response['access_token'] | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.357 | question | 94 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bytedream |
if isinstance(error.cause, HTTPError) and error.cause.status == 404:
return None
raise
if not result:
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
def _extract_chapters(self, internal_id):
# if n... | metadata extraction needs to be completely non-fatal... avoid `.get()` chains, don't call `.get()` unless you know it's a dict, and only return int/float for chapter times:
```py
def _extract_chapters(self, internal_id):
# if no skip events are available, a 403 xml error is returned
skip_events... | if isinstance(error.cause, HTTPError) and error.cause.status == 404:
return None
raise
if not result:
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
def _extract_chapters(self, internal_id):
# if n... | @@ -135,17 +142,35 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
- def _extract_formats(self, stream_response, display_id=None):
- requested_formats = self._configuration_ar... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 1 | refactor | 1,114 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
return
if not CrunchyrollBaseIE._BASIC_AUTH:
cx_api_param = self._CLIENT_ID[self.is_logged_in]
self.write_debug(f'Using cxApiParam={cx_api_param}')
CrunchyrollBaseIE._BASIC_AUTH = 'Basic ' + base64.b64encode(f'{cx_api_param}:'.encode()).decode()
auth_hea... | assuming `benefits` is a list/array, I would do this
```suggestion
CrunchyrollBaseIE._IS_PREMIUM = 'cr_premium' in traverse_obj(auth_response, ('access_token', {jwt_decode_hs256}, 'benefits', ...))
``` | return
if not CrunchyrollBaseIE._BASIC_AUTH:
cx_api_param = self._CLIENT_ID[self.is_logged_in]
self.write_debug(f'Using cxApiParam={cx_api_param}')
CrunchyrollBaseIE._BASIC_AUTH = 'Basic ' + base64.b64encode(f'{cx_api_param}:'.encode()).decode()
auth_hea... | @@ -97,6 +103,7 @@ def _update_auth(self):
'and your browser\'s User-Agent (with --user-agent)', expected=True)
raise
+ CrunchyrollBaseIE._IS_PREMIUM = 'cr_premium' in jwt_decode_hs256(auth_response['access_token']).get('benefits', []) | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.786 | security | 220 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
raise
if not result:
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
def _extract_chapters(self, internal_id):
# if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
... | I would name this either `_extract_stream()` as you originally had it and Grub suggested, or else rename it to `_extract_formats_and_subtitles()` | raise
if not result:
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
def _extract_chapters(self, internal_id):
# if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
... | @@ -135,17 +142,35 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
- def _extract_formats(self, stream_response, display_id=None):
- requested_formats = self._configuration_ar... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.571 | refactor | 145 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
def _extract_chapters(self, internal_id):
# if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
f'https://static.crunchyroll.com/skip-events/production/{internal_id}.json',
internal_id, note='Downloading chapter info', fatal=False,... | should we call `_update_auth()` before this request? the old code did. |
def _extract_chapters(self, internal_id):
# if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
f'https://static.crunchyroll.com/skip-events/production/{internal_id}.json',
internal_id, note='Downloading chapter info', fatal=False,... | @@ -135,17 +142,35 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
- def _extract_formats(self, stream_response, display_id=None):
- requested_formats = self._configuration_ar... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.429 | security | 70 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
object_type = response.get('type')
if object_type == 'episode':
result = self._transform_episode_response(response)
elif object_type == 'movie':
result = self._transform_movie_response(response)
elif object_type == 'movie_listing':
first_movie_id = ... | I'd maybe flip this so we don't even bother with the traversal if the user's account is premium
```suggestion
if not self._IS_PREMIUM and traverse_obj(response, (f'{object_type}_metadata', 'is_premium_only')):
``` |
object_type = response.get('type')
if object_type == 'episode':
result = self._transform_episode_response(response)
elif object_type == 'movie':
result = self._transform_movie_response(response)
elif object_type == 'movie_listing':
first_movie_id = ... | @@ -359,31 +381,15 @@ def entries():
else:
raise ExtractorError(f'Unknown object type {object_type}')
- # There might be multiple audio languages for one object (`<object>_metadata.versions`),
- # so we need to get the id from `streams_link` instead or we dont know which language t... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 1 | suggestion | 224 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
if not skip_events:
return None
chapters = []
for event in ('recap', 'intro', 'credits', 'preview'):
start = traverse_obj(skip_events, (event, 'start', {float_or_none}))
end = traverse_obj(skip_events, (event, 'start', {float_or_none}))
# some cha... | not sure if we want this to be fatal with `stream['url']`. the old code filtered for dicts with a `url` key (`for stream in traverse_obj(streams, lambda _, v: v['url']):`) | if not skip_events:
return None
chapters = []
for event in ('recap', 'intro', 'credits', 'preview'):
start = traverse_obj(skip_events, (event, 'start', {float_or_none}))
end = traverse_obj(skip_events, (event, 'end', {float_or_none}))
# some chapt... | @@ -135,17 +142,37 @@ def _call_api(self, path, internal_id, lang, note='api', query={}):
raise ExtractorError(f'Unexpected response when downloading {note} JSON')
return result
- def _extract_formats(self, stream_response, display_id=None):
- requested_formats = self._configuration_ar... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.5 | suggestion | 171 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
def _extract_stream(self, identifier, display_id=None):
if not display_id:
display_id = identifier
self._update_auth()
stream_response = self._download_json(
f'https://cr-play-service.prd.crunchyrollsvc.com/v1/{identifier}/console/switch/play',
display_i... | maybe not necessary, but with how unpredictable the crunchy api can be, safe traversal and expected types can't hurt
```suggestion
audio_locale = traverse_obj(stream_response, ('audioLocale', {str}))
``` |
def _extract_stream(self, identifier, display_id=None):
if not display_id:
display_id = identifier
self._update_auth()
stream_response = self._download_json(
f'https://cr-play-service.prd.crunchyrollsvc.com/v1/{identifier}/console/switch/play',
display_i... | @@ -158,39 +185,36 @@ def _extract_formats(self, stream_response, display_id=None):
else:
full_format_langs = set(map(str.lower, available_formats))
- audio_locale = traverse_obj(stream_response, ((None, 'meta'), 'audio_locale'), get_all=False)
+ audio_locale = stream_response.get(... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.929 | suggestion | 214 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bytedream |
path = f'/content/v2/{self._API_ENDPOINT}/{path}'
try:
result = self._call_base_api(
path, internal_id, lang, f'Downloading {note} JSON ({self._API_ENDPOINT})', query=query)
except ExtractorError as error:
if isinstance(error.cause, HTTPError) and err... | Should be ` end = traverse_obj(skip_events, (event, 'end', {float_or_none}))` - 'start' is wrong here. | path = f'/content/v2/{self._API_ENDPOINT}/{path}'
try:
result = self._call_base_api(
path, internal_id, lang, f'Downloading {note} JSON ({self._API_ENDPOINT})', query=query)
except ExtractorError as error:
if isinstance(error.cause, HTTPError) and err... | @@ -146,24 +146,26 @@ def _extract_chapters(self, internal_id):
# if no skip events are available, a 403 xml error is returned
skip_events = self._download_json(
f'https://static.crunchyroll.com/skip-events/production/{internal_id}.json',
- internal_id, note='Downloading chapte... | yt_dlp/extractor/crunchyroll.py | 26 | Python | 0.571 | bug | 102 | 51 | 51 | false | [ie/crunchyroll] Fix extractor | 9,615 | yt-dlp/yt-dlp | 132,642 | Python | rdamas | bytedream |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.