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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
return self.playlist_result(
entries, program_id, programs['program_info']['title'])
raw_id = base64.b64decode(query['c'] + '=' * (-len(query['c']) & 3)).decode()
p_keys = ('contents', lambda _, v: v['id'] == int(raw_id))
program = traverse_obj(programs, (*p_keys, ... | `strftime_or_none` is safe/non-fatal so we can simplify
```suggestion
'upload_date': strftime_or_none(f'20{date_str}'),
``` | if 'c' not in query:
entries = [
self.url_result(update_url_query(url, {'c': self._get_encoded_id(program)}), OnsenIE)
for program in traverse_obj(programs, ('contents', lambda _, v: v['id']))
]
return self.playlist_result(
ent... | @@ -0,0 +1,146 @@
+import base64
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ strftime_or_none,
+ update_url,
+ url_or_none,
+)
+from ..utils.tra... | yt_dlp/extractor/onsen.py | 26 | Python | 0.786 | refactor | 138 | 44 | 49 | false | [ie/onsen] Add extractor | 10,971 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | doe1080 |
raw_id = base64.b64decode(query['c'] + '=' * (-len(query['c']) & 3)).decode()
p_keys = ('contents', lambda _, v: v['id'] == int(raw_id))
program = traverse_obj(programs, (*p_keys, any))
if not program:
raise ExtractorError(
'This program is no longer availab... | maybe?
```suggestion
'id': ('id', {int}, {str_or_none}),
``` | for program in traverse_obj(programs, ('contents', lambda _, v: v['id']))
]
return self.playlist_result(
entries, program_id, traverse_obj(programs, ('program_info', 'title', {clean_html})))
raw_id = base64.urlsafe_b64decode(f'{query["c"]}===').decode()
... | @@ -0,0 +1,146 @@
+import base64
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ strftime_or_none,
+ update_url,
+ url_or_none,
+)
+from ..utils.tra... | yt_dlp/extractor/onsen.py | 26 | Python | 0.571 | suggestion | 79 | 41 | 46 | false | [ie/onsen] Add extractor | 10,971 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | doe1080 |
raise ExtractorError(
'This program is no longer available', expected=True)
m3u8_url = traverse_obj(program, ('streaming_url', {url_or_none}))
if not m3u8_url:
self.raise_login_required(
'This program is only available for premium supporters')
... | since we're branching, we don't need `all`
```suggestion
'cast': (('performers', (*p_keys, 'guests')), ..., 'name', {str}, filter),
``` | raw_id = base64.urlsafe_b64decode(f'{query["c"]}===').decode()
p_keys = ('contents', lambda _, v: v['id'] == int(raw_id))
program = traverse_obj(programs, (*p_keys, any))
if not program:
raise ExtractorError(
'This program is no longer available', expected=Tr... | @@ -0,0 +1,146 @@
+import base64
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ strftime_or_none,
+ update_url,
+ url_or_none,
+)
+from ..utils.tra... | yt_dlp/extractor/onsen.py | 26 | Python | 0.857 | suggestion | 154 | 35 | 40 | false | [ie/onsen] Add extractor | 10,971 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | doe1080 |
display_id = enc_id(program)
date_str = self._search_regex(
rf'{program_id}0?(\d{{6}})', m3u8_url, 'date string', default=None)
return {
'display_id': display_id,
'formats': self._extract_m3u8_formats(m3u8_url, raw_id, headers=self._HEADERS),
'ht... | same
```suggestion
'tags': ('hashtag_list', ..., {str}, filter),
``` | 'This program is no longer available', expected=True)
m3u8_url = traverse_obj(program, ('streaming_url', {url_or_none}))
if not m3u8_url:
self.raise_login_required(
'This program is only available for premium supporters')
display_id = self._get_encode... | @@ -0,0 +1,146 @@
+import base64
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ parse_qs,
+ str_or_none,
+ strftime_or_none,
+ update_url,
+ url_or_none,
+)
+from ..utils.tra... | yt_dlp/extractor/onsen.py | 26 | Python | 0.571 | suggestion | 87 | 29 | 34 | false | [ie/onsen] Add extractor | 10,971 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | doe1080 |
cookies = self._get_cookies('https://www.youtube.com/')
pref_cookie = cookies.get('PREF')
pref = {}
if pref_cookie:
try:
pref = dict(urllib.parse.parse_qsl(pref_cookie.value))
except ValueError:
self.report_warning('Failed to parse ... | This suggestion might be problematic for windows since `''` will be a literal. How about something like this instead:
```suggestion
'Use --username oauth[+USER] --password "" to login using an oauth, '
``` | pref_cookie = cookies.get('PREF')
pref = {}
if pref_cookie:
try:
pref = dict(urllib.parse.parse_qsl(pref_cookie.value))
except ValueError:
self.report_warning('Failed to parse user PREF cookie' + bug_reports_message())
pref.update({... | @@ -584,8 +588,144 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if user and sep != '+':
+ raise ExtractorError('Invalid u... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 226 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | coletdjnz |
auth = self._generate_sapisidhash_header(origin)
if auth is not None:
headers['Authorization'] = auth
headers['X-Origin'] = origin
return headers
def generate_api_headers(
self, *, ytcfg=None, account_syncid=None, session_index=None,
visitor... | This function should not be public imo? |
def _extract_account_syncid(self, *args):
"""
Extract current session ID required to download private playlists of secondary channels
@params response and/or ytcfg
"""
# ytcfg includes channel_syncid if on secondary channel
if delegated_sid := traverse_obj(args, (...... | @@ -752,32 +881,55 @@ def extract_ytcfg(self, video_id, webpage):
r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;', webpage, 'ytcfg',
default='{}'), video_id, fatal=False) or {}
+ def _generate_oauth_headers(self):
+ self._update_oauth()
+ oauth_token = YoutubeBaseInfoExtractor... | yt_dlp/extractor/youtube.py | 26 | Python | 0.143 | question | 39 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | coletdjnz |
auth = self._generate_sapisidhash_header(origin)
if auth is not None:
headers['Authorization'] = auth
headers['X-Origin'] = origin
return headers
def generate_api_headers(
self, *, ytcfg=None, account_syncid=None, session_index=None,
visitor_... | Are there cases where this is `False`? | def _extract_account_syncid(self, *args):
"""
Extract current session ID required to download private playlists of secondary channels
@params response and/or ytcfg
"""
# ytcfg includes channel_syncid if on secondary channel
if delegated_sid := traverse_obj(args, (...,... | @@ -752,32 +881,55 @@ def extract_ytcfg(self, video_id, webpage):
r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;', webpage, 'ytcfg',
default='{}'), video_id, fatal=False) or {}
+ def _generate_oauth_headers(self):
+ self._update_oauth()
+ oauth_token = YoutubeBaseInfoExtractor... | yt_dlp/extractor/youtube.py | 26 | Python | 0.214 | question | 38 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | coletdjnz |
raise ExtractorError(f'Failed to refresh access token: {error}', expected=True)
return token_response
def _oauth_authorize(self):
code_response = self._download_json(
'https://www.youtube.com/o/oauth2/device/code',
video_id='oauth',
note='Initializin... | If you wanted to do that:
```py
for retry in self.RetryManager():
while True:
```
and then later
```py
try:
token_response = self._download_json(...)
except ExtractorError as e:
if isinstance(e.... | except ExtractorError as e:
error_msg = str(e.orig_msg).replace('Failed to refresh access token: ', '')
self.report_warning(f'{self._OAUTH_DISPLAY_ID}: Failed to refresh access token: {error_msg}')
token_response = self._oauth_authorize
else:
... | @@ -584,8 +588,144 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if user and sep != '+':
+ raise ExtractorError('Invalid u... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | refactor | 456 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | coletdjnz |
if cookies.get('__Secure-3PSID'):
return
socs = cookies.get('SOCS')
if socs and not socs.value.startswith('CAA'): # not consented
return
self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True) # accept all (required for mixes)
def _initialize_pref(self... | ```suggestion
auth_type, _, user = (username or '').partition('+')
``` | if cookies.get('__Secure-3PSID'):
return
socs = cookies.get('SOCS')
if socs and not socs.value.startswith('CAA'): # not consented
return
self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True) # accept all (required for mixes)
def _initialize_pref(self... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+') | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | security | 80 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
def _initialize_pref(self):
cookies = self._get_cookies('https://www.youtube.com/')
pref_cookie = cookies.get('PREF')
pref = {}
if pref_cookie:
try:
pref = dict(urllib.parse.parse_qsl(pref_cookie.value))
except ValueError:
self... | not necessary but it would look less jank
```suggestion
f'or else u{self._login_hint(method="cookies")[1:]}', expected=True)
``` |
def _initialize_pref(self):
cookies = self._get_cookies('https://www.youtube.com/')
pref_cookie = cookies.get('PREF')
pref = {}
if pref_cookie:
try:
pref = dict(urllib.parse.parse_qsl(pref_cookie.value))
except ValueError:
self... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 147 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
self._initialize_pref()
self._initialize_consent()
self._check_login_required()
def _perform_login(self, username, password):
auth_type, sep, user = (username or '').partition('+')
if auth_type != 'oauth':
raise ExtractorError(
'Login using usern... | do we wanna do this instead of huge comment block?
```suggestion
'''
OAuth 2.0 Device Authorization Grant flow, used by the YouTube TV client (youtube.com/tv).
For more information regarding OAuth 2.0 and the Device Authorization Grant flow in general, see:
- https://developers.google.com/identit... | self._initialize_pref()
self._initialize_consent()
self._check_login_required()
def _perform_login(self, username, password):
auth_type, _, user = (username or '').partition('+')
if auth_type != 'oauth':
raise ExtractorError(self._youtube_login_hint, expected=Tr... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | security | 834 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
if auth_type != 'oauth':
raise ExtractorError(
'Login using username and password is not supported. '
'Use --username=oauth[+PROFILE] --password="" to log in using oauth, '
f'or else {self._login_hint(method="cookies")}', expected=True)
sel... | ```suggestion
# YouTube TV (TVHTML5) client. You can find these at youtube.com/tv
``` |
if auth_type != 'oauth':
raise ExtractorError(self._youtube_login_hint, expected=True)
self._initialize_oauth(user, password)
'''
OAuth 2.0 Device Authorization Grant flow, used by the YouTube TV client (youtube.com/tv).
For more information regarding OAuth 2.0 and the Device... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 91 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
# OAuth 2.0 Device Authorization Grant flow, used by the YouTube TV client (youtube.com/tv).
#
# For more information regarding OAuth 2.0 and the Device Authorization Grant flow in general, see:
# - https://developers.google.com/identity/protocols/oauth2/limited-input-device
# - https://accounts.goo... | the comments are the same as the var names
```suggestion
_OAUTH_DEVICE_AUTHORIZATION_ENDPOINT = 'https://oauth2.googleapis.com/device/code'
_OAUTH_TOKEN_ENDPOINT = 'https://oauth2.googleapis.com/token'
``` | For more information regarding OAuth 2.0 and the Device Authorization Grant flow in general, see:
- https://developers.google.com/identity/protocols/oauth2/limited-input-device
- https://accounts.google.com/.well-known/openid-configuration
- https://www.rfc-editor.org/rfc/rfc8628
- https://www.rfc-e... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | security | 217 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
auth = self._generate_sapisidhash_header(origin)
if auth is not None:
headers['Authorization'] = auth
headers['X-Origin'] = origin
return headers
def generate_api_headers(
self, *, ytcfg=None, account_syncid=None, session_index=None,
visitor_... | is this for override purposes or futureproofing or something? why does it take a `url` param and not doing anything with it? | }
def _generate_cookie_auth_headers(self, *, ytcfg=None, account_syncid=None, session_index=None, origin=None, **kwargs):
headers = {}
account_syncid = account_syncid or self._extract_account_syncid(ytcfg)
if account_syncid:
headers['X-Goog-PageId'] = account_syncid
... | @@ -752,32 +936,53 @@ def extract_ytcfg(self, video_id, webpage):
r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;', webpage, 'ytcfg',
default='{}'), video_id, fatal=False) or {}
+ def _generate_oauth_headers(self):
+ self._update_oauth()
+ oauth_token = YoutubeBaseInfoExtractor... | yt_dlp/extractor/youtube.py | 26 | Python | 0.5 | question | 124 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
_OAUTH_TOKEN_ENDPOINT = 'https://oauth2.googleapis.com/token' # token_endpoint
@staticmethod
def _get_oauth_cache_key(profile):
return f'oauth_refresh_token_{profile}'
def _set_oauth_info(self, token_response, profile):
YoutubeBaseInfoExtractor._OAUTH_ACCESS_TOKEN... | for consistency?
```suggestion
YoutubeBaseInfoExtractor._OAUTH_PROFILE = user or 'default'
if YoutubeBaseInfoExtractor._OAUTH_PROFILE in YoutubeBaseInfoExtractor._OAUTH_ACCESS_TOKEN_CACHE:
``` |
@property
def _oauth_cache_key(self):
return f'oauth_refresh_token_{self._OAUTH_PROFILE}'
def _read_oauth_error_response(self, response):
return traverse_obj(
self._webpage_read_content(response, self._OAUTH_TOKEN_ENDPOINT, self._OAUTH_DISPLAY_ID, fatal=False),
({js... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 214 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
# - https://accounts.google.com/.well-known/openid-configuration
# - https://www.rfc-editor.org/rfc/rfc8628
# - https://www.rfc-editor.org/rfc/rfc6749
#
# Note: The official client appears to use a proxied version of the oauth2 endpoints on youtube.com/o/oauth2,
# which applies some modification... | maybe this would be nicer? `self._oauth_cache_key` vs `self._get_oauth_cache_key(profile)`
```suggestion
@property
def _oauth_cache_key(self):
return f'oauth_refresh_token_{YoutubeBaseInfoExtractor._OAUTH_PROFILE}'
``` | - https://www.rfc-editor.org/rfc/rfc6749
Note: The official client appears to use a proxied version of the oauth2 endpoints on youtube.com/o/oauth2,
which applies some modifications to the response (such as returning errors as 200 OK).
Since the client works with the standard API, we will use that as i... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 239 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
def _set_oauth_info(self, token_response, profile):
YoutubeBaseInfoExtractor._OAUTH_ACCESS_TOKEN_CACHE.setdefault(profile, {}).update({
'access_token': token_response['access_token'],
'token_type': token_response['token_type'],
'expiry': time_seconds(
seco... | I like the cmd.exe error correction here for sanity reasons, maybe we could condense though
```suggestion
# Allow refresh token passed to initialize cache
if refresh_token and refresh_token.strip('\''):
``` | return traverse_obj(
self._webpage_read_content(response, self._OAUTH_TOKEN_ENDPOINT, self._OAUTH_DISPLAY_ID, fatal=False),
({json.loads}, 'error', {str}))
def _set_oauth_info(self, token_response):
YoutubeBaseInfoExtractor._OAUTH_ACCESS_TOKEN_CACHE.setdefault(self._OAUTH_PR... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | performance | 226 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
try:
token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
video_id=self._OAUTH_DISPLAY_ID,
note='Refreshing access token',
data=json.dumps({
'client_id': self._OAUTH_CLIENT_ID,
'clien... | ```suggestion
raise
``` |
self._set_oauth_info(token_response)
self.write_debug(f'{self._OAUTH_DISPLAY_ID}: Logged in using profile "{self._OAUTH_PROFILE}"')
def _refresh_token(self, refresh_token):
try:
token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
vi... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.429 | suggestion | 37 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
token_response = self._oauth_authorize
else:
token_response = self._oauth_authorize
self._set_oauth_info(token_response, self._OAUTH_PROFILE)
self.write_debug(f'{self._OAUTH_DISPLAY_ID}: Logged in using profile "{self._OAUTH_PROFILE}"')
def _refresh_token(self, ... | passing the url might be nice for `--write-pages` purposes, and we can use traversal and `fatal=False` to make it totally non-fatal
```suggestion
error = traverse_obj(
self._webpage_read_content(e.cause.response, self._OAUTH_TOKEN_ENDPOINT, self._OAUTH_DISPLAY_ID, fatal=False),
... | try:
token_response = self._refresh_token(refresh_token)
except ExtractorError as e:
error_msg = str(e.orig_msg).replace('Failed to refresh access token: ', '')
self.report_warning(f'{self._OAUTH_DISPLAY_ID}: Failed to refresh access token: {error_... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | security | 375 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
poll_interval = traverse_obj(code_response, 'interval', {int}, default=5)
for retry in self.RetryManager():
while True:
try:
token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
video_id=self._O... | I don't like using variables from assignment expressions later / outside of their code path. I'd reuse my suggestion from above (maybe it makes sense as a helper method? `_read_oauth_error` or something)
```suggestion
error = traverse_obj(
self._webpage_read_cont... | self.to_screen(
f'{self._OAUTH_DISPLAY_ID}: To give yt-dlp access to your account, '
f'go to {verification_url} and enter code {user_code}')
# RFC8628 § 3.5: default poll interval is 5 seconds if not provided
poll_interval = traverse_obj(code_response, ('interval', {i... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | security | 512 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
data=json.dumps({
'client_id': self._OAUTH_CLIENT_ID,
'client_secret': self._OAUTH_CLIENT_SECRET,
'device_code': code_response['device_code'],
'grant_type': 'urn:ietf:params:oauth:gran... | ```suggestion
raise ExtractorError(
'You have been denied access to this account', expected=True, video_id=self._OAUTH_DISPLAY_ID)
``` | token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
video_id=self._OAUTH_DISPLAY_ID,
note=False,
errnote='Failed to request access token',
data=json.dumps({
... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.929 | security | 197 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
elif isinstance(e.cause, HTTPError):
token_response = self._parse_json(
self._webpage_read_content(e.cause.response, None, self._OAUTH_DISPLAY_ID, fatal=False) or '{}',
video_id=self._OAUTH_DISPLAY_ID, fatal=False)
... | all code paths before this either raise, continue or break
```suggestion
raise
``` | headers={'Content-Type': 'application/json'})
except ExtractorError as e:
if isinstance(e.cause, TransportError):
retry.error = e
break
elif isinstance(e.cause, HTTPError):
... | @@ -584,8 +587,200 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, sep, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 105 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
elif error == 'access_denied':
raise ExtractorError('User denied access to account', expected=True, video_id=self._OAUTH_DISPLAY_ID)
elif error == 'slow_down':
# RFC8628 § 3.5: add 5 seconds to the poll interval
... | We should update the message to reflect that oauth login is possible | raise ExtractorError(
'Authorization timed out', expected=True, video_id=self._OAUTH_DISPLAY_ID)
elif error == 'access_denied':
raise ExtractorError(
'You denied access to an a... | @@ -584,8 +587,202 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(
+ ... | yt_dlp/extractor/youtube.py | 26 | Python | 0.286 | security | 68 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | coletdjnz |
_OAUTH_CLIENT_SECRET = 'SboVhoG9s0rNafixCSGGKXAT'
_OAUTH_SCOPE = 'http://gdata.youtube.com https://www.googleapis.com/auth/youtube-paid-content'
# From https://accounts.google.com/.well-known/openid-configuration
# Technically, these should be fetched dynamically and not hard-coded.
# However, as t... | ```suggestion
refresh_token = traverse_obj(token_response, ('refresh_token', {str}))
``` | _OAUTH_CLIENT_SECRET = 'SboVhoG9s0rNafixCSGGKXAT'
_OAUTH_SCOPE = 'http://gdata.youtube.com https://www.googleapis.com/auth/youtube-paid-content'
# From https://accounts.google.com/.well-known/openid-configuration
# Technically, these should be fetched dynamically and not hard-coded.
# However, as t... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 98 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
self._set_oauth_info(token_response)
self.write_debug(f'{self._OAUTH_DISPLAY_ID}: Logged in using profile "{self._OAUTH_PROFILE}"')
def _refresh_token(self, refresh_token):
try:
token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
vid... | just a long line
```suggestion
f'Failed to refresh access token: Authorization server returned error {error}',
video_id=self._OAUTH_DISPLAY_ID)
``` | self._set_oauth_info(token_response)
self.write_debug(f'{self._OAUTH_DISPLAY_ID}: Logged in using profile "{self._OAUTH_PROFILE}"')
def _refresh_token(self, refresh_token):
try:
token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
vid... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | bug | 191 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
if isinstance(e.cause, HTTPError):
error = self._read_oauth_error_response(e.cause.response)
if error == 'invalid_grant':
# RFC6749 § 5.2
raise ExtractorError(
'Failed to refresh access token: Refresh token is in... | ```suggestion
verification_url = traverse_obj(code_response, ('verification_url', {str}))
user_code = traverse_obj(code_response, ('user_code', {str}))
``` | if isinstance(e.cause, HTTPError):
error = self._read_oauth_error_response(e.cause.response)
if error == 'invalid_grant':
# RFC6749 § 5.2
raise ExtractorError(
'Failed to refresh access token: Refresh token is in... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 174 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
expected=True, video_id=self._OAUTH_DISPLAY_ID)
raise ExtractorError(
f'Failed to refresh access token: Authorization server returned error {error}', video_id=self._OAUTH_DISPLAY_ID)
raise
return token_response
@property
def _oauth... | long line
```suggestion
self.to_screen(
f'{self._OAUTH_DISPLAY_ID}: To give yt-dlp access to your account, '
f'go to {verification_url} and enter code {user_code}')
``` | expected=True, video_id=self._OAUTH_DISPLAY_ID)
raise ExtractorError(
f'Failed to refresh access token: Authorization server returned error {error}',
video_id=self._OAUTH_DISPLAY_ID)
raise
return token_response
@pro... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 208 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
raise
return token_response
@property
def _oauth_authorize(self):
code_response = self._download_json(
self._OAUTH_DEVICE_AUTHORIZATION_ENDPOINT,
video_id=self._OAUTH_DISPLAY_ID,
note='Initializing authorization flow',
data=json.dumps(... | ```suggestion
poll_interval = traverse_obj(code_response, ('interval', {int}), default=5)
``` | video_id=self._OAUTH_DISPLAY_ID)
raise
return token_response
@property
def _oauth_authorize(self):
code_response = self._download_json(
self._OAUTH_DEVICE_AUTHORIZATION_ENDPOINT,
video_id=self._OAUTH_DISPLAY_ID,
note='Initializ... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 103 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
note=False,
errnote='Failed to request access token',
data=json.dumps({
'client_id': self._OAUTH_CLIENT_ID,
'client_secret': self._OAUTH_CLIENT_SECRET,
'device_code... | line length only
```suggestion
elif error == 'expired_token':
raise ExtractorError(
'Authorization timed out', expected=True, video_id=self._OAUTH_DISPLAY_ID)
elif error == 'access_denied':
... | token_response = self._download_json(
self._OAUTH_TOKEN_ENDPOINT,
video_id=self._OAUTH_DISPLAY_ID,
note=False,
errnote='Failed to request access token',
data=json.dumps({
... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | security | 474 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
raise ExtractorError('You denied access to an account', expected=True, video_id=self._OAUTH_DISPLAY_ID)
elif error == 'slow_down':
# RFC8628 § 3.5: add 5 seconds to the poll interval
poll_interval += 5
... | ```suggestion
return ('Use --username=oauth[+PROFILE] --password="" to log in using oauth, '
f'or else u{self._login_hint(method="cookies")[1:]}. '
'See https://github.com/yt-dlp/yt-dlp/wiki/Extractors#logging-in-with-oauth for more on how to use oauth. '
... | elif error == 'expired_token':
raise ExtractorError(
'Authorization timed out', expected=True, video_id=self._OAUTH_DISPLAY_ID)
elif error == 'access_denied':
raise ExtractorError(
... | @@ -584,9 +587,207 @@ def _real_initialize(self):
self._initialize_consent()
self._check_login_required()
+ def _perform_login(self, username, password):
+ auth_type, _, user = (username or '').partition('+')
+
+ if auth_type != 'oauth':
+ raise ExtractorError(self._youtu... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | security | 430 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
headers = {
'X-YouTube-Client-Name': str(
self._ytcfg_get_safe(ytcfg, lambda x: x['INNERTUBE_CONTEXT_CLIENT_NAME'], default_client=default_client)),
'X-YouTube-Client-Version': self._extract_client_version(ytcfg, default_client),
'Origin': origin,
... | ```suggestion
headers=self._webpage_headers)
``` | headers = {
'X-YouTube-Client-Name': str(
self._ytcfg_get_safe(ytcfg, lambda x: x['INNERTUBE_CONTEXT_CLIENT_NAME'], default_client=default_client)),
'X-YouTube-Client-Version': self._extract_client_version(ytcfg, default_client),
'Origin': origin,
... | @@ -787,7 +1004,8 @@ def _download_ytcfg(self, client, video_id):
if not url:
return {}
webpage = self._download_webpage(
- url, video_id, fatal=False, note=f'Downloading {client.replace("_", " ").strip()} client config')
+ url, video_id, fatal=False, note=f'Download... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 62 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
r'player\\?/([0-9a-fA-F]{8})\\?/', res, 'player version', fatal=fatal)
if player_version:
return f'https://www.youtube.com/s/player/{player_version}/player_ias.vflset/en_US/base.js'
def _signature_cache_id(self, example_sig):
""" Return a string representation of... | ```suggestion
headers=self._webpage_headers)
``` | r'player\\?/([0-9a-fA-F]{8})\\?/', res, 'player version', fatal=fatal)
if player_version:
return f'https://www.youtube.com/s/player/{player_version}/player_ias.vflset/en_US/base.js'
def _signature_cache_id(self, example_sig):
""" Return a string representation of... | @@ -3047,7 +3265,8 @@ def _load_player(self, video_id, player_url, fatal=True):
code = self._download_webpage(
player_url, video_id, fatal=fatal,
note='Downloading player ' + player_id,
- errnote=f'Download of {player_url} failed')
+ errnote=f... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 66 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
# # more consistent results setting it to right before the end
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
qs.update({
'ver': ['2'],
'cpn': [cpn],
'cmt': video_length,
'el': 'detailpage', # otherwis... | ```suggestion
headers=self._webpage_headers)
``` |
# # more consistent results setting it to right before the end
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
qs.update({
'ver': ['2'],
'cpn': [cpn],
'cmt': video_length,
'el': 'detailpage', # otherwis... | @@ -3330,7 +3549,8 @@ def _mark_watched(self, video_id, player_responses):
self._download_webpage(
url, video_id, f'Marking {label}watched',
- 'Unable to mark watched', fatal=False)
+ 'Unable to mark watched', fatal=False,
+ headers=self._gene... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 66 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'format_note': 'storyboard',
'ext': 'mhtml',
'protocol': 'mhtml',
'acodec': 'none',
'vcodec': 'none',
'url': url,
'width': width,
'height': height,
'fps': frame_count / duratio... | ```suggestion
webpage_url, video_id, fatal=False, query=query, headers=self._webpage_headers)
``` | 'format_note': 'storyboard',
'ext': 'mhtml',
'protocol': 'mhtml',
'acodec': 'none',
'vcodec': 'none',
'url': url,
'width': width,
'height': height,
'fps': frame_count / duratio... | @@ -4322,7 +4542,7 @@ def _download_player_responses(self, url, smuggled_data, video_id, webpage_url):
if pp:
query['pp'] = pp
webpage = self._download_webpage(
- webpage_url, video_id, fatal=False, query=query)
+ webpage_url, video_id, fatal=Fals... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 115 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
"""
is_playlist = bool(traverse_obj(
data, ('metadata', 'playlistMetadataRenderer'), ('header', 'playlistHeaderRenderer')))
if not is_playlist:
return
headers = self.generate_api_headers(
ytcfg=ytcfg, account_syncid=self._extract_account_syncid(ytcfg, ... | ```suggestion
webpage = self._download_webpage(url, item_id, note='Downloading webpage', headers=self._webpage_headers)
``` | """
is_playlist = bool(traverse_obj(
data, ('metadata', 'playlistMetadataRenderer'), ('header', 'playlistHeaderRenderer')))
if not is_playlist:
return
headers = self.generate_api_headers(
ytcfg=ytcfg, account_syncid=self._extract_account_syncid(ytcfg, ... | @@ -5609,7 +5829,7 @@ def _extract_webpage(self, url, item_id, fatal=True):
webpage, data = None, None
for retry in self.RetryManager(fatal=fatal):
try:
- webpage = self._download_webpage(url, item_id, note='Downloading webpage')
+ webpage = self._download_we... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 141 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
auth = self._generate_sapisidhash_header(origin)
if auth is not None:
headers['Authorization'] = auth
headers['X-Origin'] = origin
return headers
def generate_api_headers(
self, *, ytcfg=None, account_syncid=None, session_index=None,
visitor_... | on 2nd thought, better to stick with the existing convention
```suggestion
def _generate_webpage_headers(self):
``` | auth = self._generate_sapisidhash_header(origin)
if auth is not None:
headers['Authorization'] = auth
headers['X-Origin'] = origin
return headers
def generate_api_headers(
self, *, ytcfg=None, account_syncid=None, session_index=None,
visitor_... | @@ -752,32 +948,54 @@ def extract_ytcfg(self, video_id, webpage):
r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;', webpage, 'ytcfg',
default='{}'), video_id, fatal=False) or {}
+ def _generate_oauth_headers(self):
+ self._update_oauth()
+ oauth_token = YoutubeBaseInfoExtractor... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 122 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'X-YouTube-Client-Name': str(
self._ytcfg_get_safe(ytcfg, lambda x: x['INNERTUBE_CONTEXT_CLIENT_NAME'], default_client=default_client)),
'X-YouTube-Client-Version': self._extract_client_version(ytcfg, default_client),
'Origin': origin,
'X-Goog-Visitor-Id':... | ```suggestion
headers=self._generate_webpage_headers())
``` | 'X-YouTube-Client-Name': str(
self._ytcfg_get_safe(ytcfg, lambda x: x['INNERTUBE_CONTEXT_CLIENT_NAME'], default_client=default_client)),
'X-YouTube-Client-Version': self._extract_client_version(ytcfg, default_client),
'Origin': origin,
'X-Goog-Visitor-Id':... | @@ -787,7 +1005,8 @@ def _download_ytcfg(self, client, video_id):
if not url:
return {}
webpage = self._download_webpage(
- url, video_id, fatal=False, note=f'Downloading {client.replace("_", " ").strip()} client config')
+ url, video_id, fatal=False, note=f'Download... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 73 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
r'player\\?/([0-9a-fA-F]{8})\\?/', res, 'player version', fatal=fatal)
if player_version:
return f'https://www.youtube.com/s/player/{player_version}/player_ias.vflset/en_US/base.js'
def _signature_cache_id(self, example_sig):
""" Return a string representation of... | ```suggestion
headers=self._generate_webpage_headers())
``` | if player_version:
return f'https://www.youtube.com/s/player/{player_version}/player_ias.vflset/en_US/base.js'
def _signature_cache_id(self, example_sig):
""" Return a string representation of a signature """
return '.'.join(str(len(part)) for part in example_sig.split('... | @@ -3047,7 +3266,8 @@ def _load_player(self, video_id, player_url, fatal=True):
code = self._download_webpage(
player_url, video_id, fatal=fatal,
note='Downloading player ' + player_id,
- errnote=f'Download of {player_url} failed')
+ errnote=f... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 77 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
# # more consistent results setting it to right before the end
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
qs.update({
'ver': ['2'],
'cpn': [cpn],
'cmt': video_length,
'el': 'detailpage', # otherwis... | ```suggestion
headers=self._generate_webpage_headers())
``` | # # more consistent results setting it to right before the end
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
qs.update({
'ver': ['2'],
'cpn': [cpn],
'cmt': video_length,
'el': 'detailpage', # otherwise... | @@ -3330,7 +3550,8 @@ def _mark_watched(self, video_id, player_responses):
self._download_webpage(
url, video_id, f'Marking {label}watched',
- 'Unable to mark watched', fatal=False)
+ 'Unable to mark watched', fatal=False,
+ headers=self._webp... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 77 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'format_note': 'storyboard',
'ext': 'mhtml',
'protocol': 'mhtml',
'acodec': 'none',
'vcodec': 'none',
'url': url,
'width': width,
'height': height,
'fps': frame_count / duratio... | ```suggestion
webpage_url, video_id, fatal=False, query=query, headers=self._generate_webpage_headers())
``` | 'ext': 'mhtml',
'protocol': 'mhtml',
'acodec': 'none',
'vcodec': 'none',
'url': url,
'width': width,
'height': height,
'fps': frame_count / duration,
'rows': rows,
... | @@ -4322,7 +4543,7 @@ def _download_player_responses(self, url, smuggled_data, video_id, webpage_url):
if pp:
query['pp'] = pp
webpage = self._download_webpage(
- webpage_url, video_id, fatal=False, query=query)
+ webpage_url, video_id, fatal=Fals... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 126 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
"""
is_playlist = bool(traverse_obj(
data, ('metadata', 'playlistMetadataRenderer'), ('header', 'playlistHeaderRenderer')))
if not is_playlist:
return
headers = self.generate_api_headers(
ytcfg=ytcfg, account_syncid=self._extract_account_syncid(ytcfg, ... | ```suggestion
webpage = self._download_webpage(url, item_id, note='Downloading webpage', headers=self._generate_webpage_headers())
``` | is_playlist = bool(traverse_obj(
data, ('metadata', 'playlistMetadataRenderer'), ('header', 'playlistHeaderRenderer')))
if not is_playlist:
return
headers = self.generate_api_headers(
ytcfg=ytcfg, account_syncid=self._extract_account_syncid(ytcfg, data),
... | @@ -5609,7 +5830,7 @@ def _extract_webpage(self, url, item_id, fatal=True):
webpage, data = None, None
for retry in self.RetryManager(fatal=fatal):
try:
- webpage = self._download_webpage(url, item_id, note='Downloading webpage')
+ webpage = self._download_we... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 152 | 51 | 51 | false | [ie/youtube] Add support for logging in with OAuth2 | 11,001 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'title': 'Chlapci dobetónovali sme, máme hotovo!',
'display_id': 'chlapci_dobetonovali_sme_mame_hotovo',
'description': 'md5:a0822126044050d304a9ef58c92ddb34',
'thumbnail': 'https://fs5.mojevideo.sk/imgfb/250236.jpg',
'duration': 21.0,
'upload_date... | Can you add support for multiple resolutions?
Here a HD example https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html
Seemingly higher qualities also exist. The logic for constructing the url is as follows:
```
vPa = ['', '_lq', '_hd', '_fhd', '_2k']
v.src = vU + vId + vPa[q] + '.mp4?md... | 'title': 'Chlapci dobetónovali sme, máme hotovo!',
'display_id': 'chlapci_dobetonovali_sme_mame_hotovo',
'description': 'md5:a0822126044050d304a9ef58c92ddb34',
'thumbnail': 'https://fs5.mojevideo.sk/imgfb/250236.jpg',
'duration': 21.0,
'upload_date... | @@ -0,0 +1,50 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>\w+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.mojevide... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.786 | suggestion | 362 | 37 | 51 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
'view_count': int,
'comment_count': int,
},
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_... | This is the same as the page_id in decimal. I would use the ID in the URL as the video_id and then use this one only for the request, probably with a fallback to `str(int(video_id, 16))` | 'view_count': int,
'comment_count': int,
},
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_... | @@ -0,0 +1,115 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.571 | suggestion | 186 | 51 | 51 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_session_nova_sportova_vodotesna_kamera.html',
'only_matching': True,... | Not necessary
```suggestion
r'\bvHash\s*=', webpage, 'video hashes', video_id,
``` | }, {
# 720p
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_session_nova_sportova_vodotesna_kamera.html',
'only_matching': True,... | @@ -0,0 +1,115 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.571 | suggestion | 97 | 51 | 51 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
'url': 'https://www.mojevideo.sk/video/352ee/amd_rx_6800_xt_vs_nvidia_rtx_3080_(test_v_9_hrach).html',
'only_matching': True,
}, {
# 1080p
'url': 'https://www.mojevideo.sk/video/2cbeb/trailer_z_avengers_infinity_war.html',
'only_matching': True,
}]
def _real_extract(... | Maybe like so?
```suggestion
for video_hash, (suffix, quality, format_note) in zip(video_hashes, [
('', 1, 'normálna kvalita'),
('_lq', 0, 'nízka kvalita'),
('_hd', 2, 'HD-720p'),
('_fhd', 3, 'FULL HD-1080p'),
('_2k', 4, '2K-1440p'),
])... | 'url': 'https://www.mojevideo.sk/video/352ee/amd_rx_6800_xt_vs_nvidia_rtx_3080_(test_v_9_hrach).html',
'only_matching': True,
}, {
# 1080p
'url': 'https://www.mojevideo.sk/video/2cbeb/trailer_z_avengers_infinity_war.html',
'only_matching': True,
}]
def _real_extract(... | @@ -0,0 +1,115 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.786 | suggestion | 326 | 42 | 48 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
}, {
# 1080p
'url': 'https://www.mojevideo.sk/video/2cbeb/trailer_z_avengers_infinity_war.html',
'only_matching': True,
}]
def _real_extract(self, url):
page_id, display_id = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, page_id)
... | We should add a quality parameter so the formats are correctly ordered:
```suggestion
'format_id': f'mp4-{quality}',
'quality': quality,
``` | }, {
# 1080p
'url': 'https://www.mojevideo.sk/video/2cbeb/trailer_z_avengers_infinity_war.html',
'only_matching': True,
}]
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, video_id)
... | @@ -0,0 +1,115 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.786 | suggestion | 176 | 40 | 46 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
'url': 'https://www.mojevideo.sk/video/2cbeb/trailer_z_avengers_infinity_war.html',
'only_matching': True,
}]
def _real_extract(self, url):
page_id, display_id = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, page_id)
video_id = self._search_r... | ```suggestion
'url': f'https://cache01.mojevideo.sk/securevideos69/{video_id}{suffix}.mp4?md5={video_hash}&expires={video_exp}',
``` | 'url': 'https://www.mojevideo.sk/video/2cbeb/trailer_z_avengers_infinity_war.html',
'only_matching': True,
}]
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, video_id)
video_id_dec = self._se... | @@ -0,0 +1,115 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.714 | performance | 150 | 38 | 44 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
video_id = self._search_regex(r'\bvId\s*=\s*(\d+)', webpage, 'video id')
video_exp = self._search_regex(r'\bvEx\s*=\s*["\'](\d+)', webpage, 'video expiry')
video_hashes = self._search_json(
r'\bvHash\s*=\s*', webpage, 'video hashes', video_id,
contains_pattern=r'\[.+\]', ... | ```suggestion
'title': (self._og_search_title(webpage, default=None)
or remove_end(self._html_extract_title(webpage, 'title'), ' - Mojevideo')),
``` | video_id_dec = self._search_regex(
r'\bvId\s*=\s*(\d+)', webpage, 'video id', fatal=False) or str(int(video_id, 16))
video_exp = self._search_regex(r'\bvEx\s*=\s*["\'](\d+)', webpage, 'video expiry')
video_hashes = self._search_json(
r'\bvHash\s*=', webpage, 'video hashes... | @@ -0,0 +1,115 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.786 | refactor | 185 | 30 | 36 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
'view_count': int,
'comment_count': int,
},
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_... | ```suggestion
video_id_dec = self._search_regex(
r'\bvId\s*=\s*(\d+)', webpage, 'video id', fatal=False) or str(int(video_id, 16))
``` | 'view_count': int,
'comment_count': int,
},
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_... | @@ -0,0 +1,116 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.714 | suggestion | 157 | 51 | 51 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | pzhlkj6612 |
'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_session_nova_sportova_vodotesna_kamera.html',
'only_matching': True,
}, {
# 1080... | maybe just in case?
```suggestion
contains_pattern=r'\[(?s:.+)\]', transform_source=js_to_json)
``` | 'url': 'https://www.mojevideo.sk/video/358c8/dva_nissany_skyline_strielaju_v_londyne.html',
'only_matching': True,
}, {
# 720p
'url': 'https://www.mojevideo.sk/video/2455d/gopro_hero4_session_nova_sportova_vodotesna_kamera.html',
'only_matching': True,
}, {
# 1080... | @@ -0,0 +1,117 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.714 | suggestion | 114 | 51 | 51 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
}]
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, video_id)
video_id_dec = self._search_regex(
r'\bvId\s*=\s*(\d+)', webpage, 'video id', fatal=False) or str(int(video_id, 16))
video_exp... | just because I hate long lines:
```suggestion
'url': update_url_query(
f'https://cache01.mojevideo.sk/securevideos69/{video_id_dec}{suffix}.mp4', {
'md5': video_hash,
'expires': video_exp,
}),
```
not necessa... | }]
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).groups()
webpage = self._download_webpage(url, video_id)
video_id_dec = self._search_regex(
r'\bvId\s*=\s*(\d+)', webpage, 'video id', fatal=False) or str(int(video_id, 16))
video_exp... | @@ -0,0 +1,117 @@
+from .common import InfoExtractor
+from ..utils import js_to_json, remove_end
+
+
+class MojevideoIE(InfoExtractor):
+ IE_DESC = 'mojevideo.sk'
+ _VALID_URL = r'https?://(?:www\.)?mojevideo\.sk/video/(?P<id>\w+)/(?P<display_id>[\w()]+?)\.html'
+
+ _TESTS = [{
+ 'url': 'https://www.moj... | yt_dlp/extractor/mojevideo.py | 26 | Python | 0.857 | performance | 337 | 38 | 42 | false | [ie/Mojevideo] Add extractor | 11,019 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, url_or_none
from ..utils.traversal import traverse_obj
class SnapchatSpotlightIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>[\w]+)'
_TESTS = [{
'url': 'https://www.snapchat.com/spot... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>\w+)'
``` | from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, url_or_none
from ..utils.traversal import traverse_obj
class SnapchatSpotlightIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>\w+)'
_TESTS = [{
'url': 'https://www.snapchat.com/spotli... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class SnapchatSpotlightIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>[\w]+)' | yt_dlp/extractor/snapchat.py | 7 | Python | 0.571 | suggestion | 94 | 32 | 32 | false | [ie/SnapchatSpotlight] Add extractor | 11,030 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'md5': '4cd9626458c1a0e3e6dbe72c544a9ec2',
'info_dict': {
'id': 'W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
'ext': 'mp4',
'title': 'Spotlight Snap',
'description': 'How he flirt her teacher🤭🤭🤩😍 #kdrama#cdrama #dramaclips #dramaspotli... | I would use a temp var just for readability, let the keyerror rip for `pageProps`, and use 2 separate traversal paths instead doing the extra branching with `any`
```suggestion
page_props = self._search_nextjs_data(webpage, video_id)['props']['pageProps']
video_data = traverse_obj(page_props, (
... | 'md5': '4cd9626458c1a0e3e6dbe72c544a9ec2',
'info_dict': {
'id': 'W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
'ext': 'mp4',
'title': 'Spotlight Snap',
'description': 'How he flirt her teacher🤭🤭🤩😍 #kdrama#cdrama #dramaclips #dramaspotli... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class SnapchatSpotlightIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>[\w]+)'
+
+ _TESTS = [{
+ 'url': 'ht... | yt_dlp/extractor/snapchat.py | 26 | Python | 1 | suggestion | 463 | 51 | 51 | false | [ie/SnapchatSpotlight] Add extractor | 11,030 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'duration': 10.91,
'timestamp': 1722720291.307,
'upload_date': '20240803',
'view_count': int,
'repost_count': int,
'uploader': 'ganda0535',
'uploader_url': 'https://www.snapchat.com/add/ganda0535',
'tags': ['#dramaspotlight'... | I prefer `functools.partial` but up to you | 'duration': 10.91,
'timestamp': 1722720291.307,
'upload_date': '20240803',
'view_count': int,
'repost_count': int,
'uploader': 'ganda0535',
'uploader_url': 'https://www.snapchat.com/add/ganda0535',
'tags': ['#dramaspotlight'... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import float_or_none, int_or_none, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class SnapchatSpotlightIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>[\w]+)'
+
+ _TESTS = [{
+ 'url': 'ht... | yt_dlp/extractor/snapchat.py | 26 | Python | 0.286 | suggestion | 42 | 45 | 44 | false | [ie/SnapchatSpotlight] Add extractor | 11,030 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
'id': key,
'url': thumbnail_info['url'],
'width': int_or_none(thumbnail_info.get('width')),
'height': int_or_none(thumbnail_info.get('height')),
} for key, thumbnail_info in thumbnails.items() if url_or_none(thumbnail_info.get('url'))]
def _teaser_to_url_resu... | What should I do in case the ID can't be found? Continue (i.e. return no results) or raise an error? | import re
from .common import InfoExtractor
from ..utils import (
NO_DEFAULT,
ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.571 | question | 100 | 51 | 450 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | InvalidUsernameException | InvalidUsernameException |
episode_number=int_or_none(teaser.get('episodeNumber')))
def _real_extract(self, url):
channel_id = self._match_id(url)
webpage = self._download_webpage(url, channel_id)
main_video = None
playlist_videos = []
document_id = self._extract_document_id(webpage)
... | Same here: If I can't find a `main_video`, what should I do? | import re
from .common import InfoExtractor
from ..utils import (
NO_DEFAULT,
ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.429 | question | 60 | 42 | 450 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | InvalidUsernameException | InvalidUsernameException |
return self._extract_mobile(video_id)
class ZDFChannelIE(ZDFBaseIE):
_VALID_URL = r'https?://www\.zdf\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.zdf.de/sport/das-aktuelle-sportstudio',
'info_dict': {
'id': 'das-aktuelle-sportstudio',
'title... | Anything else I should verify in these tests? There is a whole bunch of per-entry data that might be worth testing, but I don't know how. The exact entries will certainly change frequently. | return self._extract_mobile(video_id)
class ZDFChannelIE(ZDFBaseIE):
_VALID_URL = r'https?://www\.zdf\.de/(?:[^/?#]+/)*(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.zdf.de/sport/das-aktuelle-sportstudio',
'info_dict': {
'id': 'das-aktuelle-sportstudio',
'tit... | @@ -387,18 +389,19 @@ class ZDFChannelIE(ZDFBaseIE):
'info_dict': {
'id': 'planet-e',
'title': 'planet e.',
+ 'description': 'md5:87e3b9c66a63cf1407ee443d2c4eb88e',
},
'playlist_mincount': 50,
}, {
'url': 'https://www.zdf.de/gesellschaft/akte... | yt_dlp/extractor/zdf.py | 26 | Python | 0.429 | suggestion | 189 | 51 | 51 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | InvalidUsernameException | InvalidUsernameException |
ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
urljoin,
)
class ZDFBaseIE(InfoExtractor):
_GEO_COUNTRIES = ['DE']
_Q... | method name too long IMO
```suggestion
def _download_v2_doc(self, document_id):
return self._download_json(
f'https://zdf-prod-futura.zdf.de/mediathekV2/document/{document_id}',
document_id)
``` | ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
urljoin,
)
class ZDFBaseIE(InfoExtractor):
_GEO_COUNTRIES = ['DE']
_Q... | @@ -25,6 +24,11 @@ class ZDFBaseIE(InfoExtractor):
_GEO_COUNTRIES = ['DE']
_QUALITIES = ('auto', 'low', 'med', 'high', 'veryhigh', 'hd', 'fhd', 'uhd')
+ def _download_mediathekv2_document(self, document_id):
+ return self._download_json(
+ f'https://zdf-prod-futura.zdf.de/mediathekV2/do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.786 | refactor | 236 | 51 | 51 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
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'),
... | ```suggestion
video = self._download_v2_doc(video_id)
``` | 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'),
... | @@ -320,9 +324,7 @@ def _extract_regular(self, url, player, video_id):
return self._extract_entry(player['content'], player, content, video_id)
def _extract_mobile(self, video_id):
- video = self._download_json(
- f'https://zdf-cdn.live.cellular.de/mediathekV2/document/{video_id}',
- ... | yt_dlp/extractor/zdf.py | 26 | Python | 0.571 | suggestion | 67 | 51 | 51 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
'playlist_mincount': 50,
}, {
'url': 'https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest',
'info_dict': {
'id': 'aktenzeichen-xy-ungeloest',
'title': 'Aktenzeichen XY... Ungelöst',
'description': 'md5:623ede5819c400c6d04943fa8100e6e7',
},
... | try to avoid methods only used once. and we would want to use `_search_regex` instead
```suggestion
``` | 'playlist_mincount': 50,
}, {
'url': 'https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest',
'info_dict': {
'id': 'aktenzeichen-xy-ungeloest',
'title': 'Aktenzeichen XY... Ungelöst',
'description': 'md5:623ede5819c400c6d04943fa8100e6e7',
},
... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.786 | suggestion | 105 | 51 | 51 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
'width': int_or_none(thumbnail_info.get('width')),
'height': int_or_none(thumbnail_info.get('height')),
} for key, thumbnail_info in thumbnails.items() if url_or_none(thumbnail_info.get('url'))]
def _teaser_to_url_result(self, teaser):
return self.url_result(
tea... | remove the conditional and dedent all of this | import re
from .common import InfoExtractor
from ..utils import (
NO_DEFAULT,
ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.143 | suggestion | 45 | 51 | 450 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
season_number=int_or_none(teaser.get('seasonNumber')),
episode_number=int_or_none(teaser.get('episodeNumber')))
def _real_extract(self, url):
channel_id = self._match_id(url)
webpage = self._download_webpage(url, channel_id)
main_video = None
playlist_video... | I know the old code was doing this, but we really should be using `_yes_playlist()` instead | import re
from .common import InfoExtractor
from ..utils import (
NO_DEFAULT,
ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.429 | suggestion | 91 | 43 | 450 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
def _real_extract(self, url):
channel_id = self._match_id(url)
webpage = self._download_webpage(url, channel_id)
main_video = None
playlist_videos = []
document_id = self._extract_document_id(webpage)
if document_id is not None:
data = self._download_me... | this `to_screen()` will be unnecessary if we use `yes_playlist()` | import re
from .common import InfoExtractor
from ..utils import (
NO_DEFAULT,
ExtractorError,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
merge_dicts,
parse_codecs,
qualities,
traverse_obj,
try_get,
unified_timestamp,
update_url_query,
url_or_none,
... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.429 | suggestion | 65 | 40 | 450 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
@classmethod
def suitable(cls, url):
return False if ZDFIE.suitable(url) else super().suitable(url)
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
... | this could be inlined in a single `traverse_obj` call | @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}),
'title': ('... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.429 | suggestion | 53 | 51 | 43 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
return re.split(r'\s+[-|]\s+ZDF(?:mediathek)?$', title or '')[0] or None
def _extract_document_id(self, webpage):
matches = re.search(r'docId\s*:\s*[\'"](?P<docid>[^\'"]+)[\'"]', webpage)
return matches and matches.group('docid')
def _get_playlist_description(self, page_data):
... | if there's only 1 thumbnail IMO it can just be `thumbnail=thumb_url` | entry['sharingUrl'], ZDFIE, **traverse_obj(entry, {
'id': ('basename', {str}),
'title': ('titel', {str}),
'description': ('beschreibung', {str}),
'duration': ('length', {float_or_none}),
# TODO: seasonNumber and episodeNumber ca... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.357 | suggestion | 68 | 51 | 37 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
def _get_playlist_description(self, page_data):
headline = traverse_obj(page_data, ('shortText', 'headline'))
text = traverse_obj(page_data, ('shortText', 'text'))
if headline is not None and text is not None:
return f'{headline}\n\n{text}'
return headline or text
d... | all of this should be a single `traverse_obj` call | # TODO: seasonNumber and episodeNumber can be extracted but need to also be in ZDFIE
}))
def _entries(self, data, document_id):
for entry in traverse_obj(data, (
'cluster', lambda _, v: v['type'] == 'teaser',
# If 'brandId' differs, it is a 'You might als... | @@ -410,32 +413,72 @@ 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 _extract_document_id(self, webpage):
+ matches = re.search(r'docId\s*:\s*[\'"](?P<do... | yt_dlp/extractor/zdf.py | 26 | Python | 0.429 | suggestion | 50 | 51 | 32 | false | [ie/ZDF] Rewrite channel extractor to use an API instead of HTML scraping | 11,041 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | InvalidUsernameException |
import math
from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
int_or_none,
str_or_none,
traverse_obj,
unified_strdate,
url_or_none,
)
class SubsplashVideoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?subsplash\.com/u/[^/]+/media/d/(?P<id>\w+)'
_TESTS =... | ```suggestion
'thumbnail': r're:https?://.*\.(?:jpg|png)$',
```
See https://discord.com/channels/807245652072857610/1112613156934668338/1293369656098160702. `re.match` is used here when running tests(which matches from the start of the string already)
| import math
from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
int_or_none,
parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambd... | @@ -0,0 +1,112 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ str_or_none,
+ traverse_obj,
+ unified_strdate,
+ url_or_none,
+)
+
+
+class SubsplashVideoIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?subsp... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.857 | suggestion | 268 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | grqz | subrat-lima |
class SubsplashVideoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?subsplash\.com/u/[^/]+/media/d/(?P<id>\w+)'
_TESTS = [{
'url': 'https://subsplash.com/u/skywatchtv/media/d/5whnx5s-the-grand-delusion-taking-place-right-now',
'md5': '2d67c50deac3c6c49c6e25c4a5b25afe',
'info_dict':... | ```suggestion
'thumbnail': r're:https?://.*\.(?:jpg|png)$',
``` |
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
if not token:
webpage, urlh = self._download_webpage_handle(url, display_id)
token = (
try_call(lambda: sel... | @@ -0,0 +1,112 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ str_or_none,
+ traverse_obj,
+ unified_strdate,
+ url_or_none,
+)
+
+
+class SubsplashVideoIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?subsp... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.571 | suggestion | 77 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | grqz | subrat-lima |
'format_id': 'direct',
'preference': 1,
**traverse_obj(mp4_entry, {
'height': ('height', {int_or_none}),
'width': ('width', {int_or_none}),
'filesize': ('file_size', {int_or_none}),
}),
... | ```suggestion
r'https?://(?:www\.)?subsplash\.com/u/[^/?#]+/media/d/(?P<id>\w+)',
``` | 'quality': 1,
**traverse_obj(mp4_entry, {
'height': ('height', {int_or_none}),
'width': ('width', {int_or_none}),
'filesize': ('file_size', {int_or_none}),
}),
})
return {
'id': vi... | @@ -0,0 +1,186 @@
+import functools
+import json
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ get_element_by_id,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(Info... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.571 | suggestion | 95 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
'preference': 1,
**traverse_obj(mp4_entry, {
'height': ('height', {int_or_none}),
'width': ('width', {int_or_none}),
'filesize': ('file_size', {int_or_none}),
}),
})
return {
'form... | ```suggestion
r'https?://(?:\w+\.)?subspla\.sh/(?P<id>\w+)',
``` | **traverse_obj(mp4_entry, {
'height': ('height', {int_or_none}),
'width': ('width', {int_or_none}),
'filesize': ('file_size', {int_or_none}),
}),
})
return {
'id': video_id,
'formats':... | @@ -0,0 +1,186 @@
+import functools
+import json
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ get_element_by_id,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(Info... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.571 | suggestion | 74 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
import math
from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
get_element_by_id,
int_or_none,
parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
... | ```suggestion
token = (
try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
or urlh.get_header('x-api-token')
or traverse_obj(webpage, ({find_element(id='shoebox-tokens')}, {json.loads}, 'apiToken', {str}))
or self._search_reg... |
from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
int_or_none,
parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get... | @@ -0,0 +1,186 @@
+import functools
+import json
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ get_element_by_id,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(Info... | yt_dlp/extractor/subsplash.py | 26 | Python | 1 | security | 805 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
if not token:
webpage, urlh = self._download_webpage_handle(url, display_id)
token = try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
if not token:
token = urlh.get_header('x-api-token')
if not token:
token = travers... | `preference` can't be overridden by the user's format sorting. So we'd only want to set this if the direct format URL is always the highest resolution/etc available | token = (
try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
or urlh.get_header('x-api-token')
or self._search_json(
r'<script[^>]+\bid="shoebox-tokens"[^>]*>', webpage, 'shoebox tokens',
display_id, defaul... | @@ -0,0 +1,186 @@
+import functools
+import json
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ get_element_by_id,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(Info... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.571 | suggestion | 164 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
'modified_date': '20241010',
'release_date': '20240903',
'release_timestamp': 1725379200,
'modified_timestamp': 1728577804,
},
}, {
'url': 'https://prophecywatchers.subspla.sh/8gps8cx',
'only_matching': True,
}]
def _real_extract(self,... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?subsplash\.com/[^/?#]+/(?:our-videos|media)/ms/\+(?P<id>\w+)'
``` | 'release_timestamp': 1725379200,
'modified_timestamp': 1728577804,
},
}, {
'url': 'https://subsplash.com/laiglesiadelcentro/vid/mi/+ecb6a6b?autoplay=true',
'md5': '013c9b1e391dd4b34d8612439445deef',
'info_dict': {
'id': 'ecb6a6b',
'ext'... | @@ -0,0 +1,186 @@
+import functools
+import json
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ get_element_by_id,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(Info... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.714 | suggestion | 119 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
int_or_none,
parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_... | oh there was another thing I forgot to ask about:
can requests be successfully made without the token? should the last `_search_regex` call just be fatal? | from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
int_or_none,
parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.571 | question | 157 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
'md5': '01982d58021af81c969958459bd81f13',
'info_dict': {
'id': 'e16348f1-040e-4596-b922-77b45fa8d253',
'ext': 'mp4',
'title': 'The Transhumanist Plan for Humanity | Billy Crone',
'description': None,
'upload_date': '20240903',
'dur... | ```suggestion
data = self._download_json(
'https://core.subsplash.com/media/v1/media-items',
display_id, headers=self._get_headers(url, display_id),
``` | 'md5': '01982d58021af81c969958459bd81f13',
'info_dict': {
'id': 'n4dr8b2',
'ext': 'mp4',
'title': 'The Transhumanist Plan for Humanity | Billy Crone',
'upload_date': '20240903',
'duration': 1709,
'thumbnail': r're:https?://.*\.(?:jp... | @@ -0,0 +1,185 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.714 | suggestion | 188 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
})
return {
'formats': formats,
**traverse_obj(data, {
'id': ('id', {str}),
'title': ('title', {str}),
'description': ('summary_text', {str}),
'thumbnail': ('_embedded', 'images', 0, '_links', 'related', 'href', ... | ```suggestion
'id': '5whnx5s',
``` | })
return {
'id': video_id,
'formats': formats,
**traverse_obj(data, {
'title': ('title', {str}),
'description': ('summary_text', {str}),
'thumbnail': ('_embedded', 'images', 0, '_links', 'related', 'href', {url_or_n... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.429 | suggestion | 48 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
_VALID_URL = [
r'https?://(?:www\.)?subsplash\.com/u/[^/?#]+/media/d/(?P<id>\w+)',
r'https?://(?:\w+\.)?subspla\.sh/(?P<id>\w+)',
]
_TESTS = [{
'url': 'https://subsplash.com/u/skywatchtv/media/d/5whnx5s-the-grand-delusion-taking-place-right-now',
'md5': 'd468729814e533cec86f1... | ```suggestion
'id': 'n4dr8b2',
``` | _VALID_URL = [
r'https?://(?:www\.)?subsplash\.com/(?:u/)?[^/?#]+/[^/?#]+/(?:d/|mi/\+)(?P<id>\w+)',
r'https?://(?:\w+\.)?subspla\.sh/(?P<id>\w+)',
]
_TESTS = [{
'url': 'https://subsplash.com/u/skywatchtv/media/d/5whnx5s-the-grand-delusion-taking-place-right-now',
'md5': 'd468... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.429 | suggestion | 48 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
'title': 'The Transhumanist Plan for Humanity | Billy Crone',
'description': None,
'upload_date': '20240903',
'duration': 1709,
'thumbnail': r're:https?://.*\.(?:jpg|png)$',
'timestamp': 1725321600,
'modified_date': '20241010',
... | ```suggestion
video_id = self._match_id(url)
data = self._download_json(
'https://core.subsplash.com/media/v1/media-items',
video_id, headers=self._get_headers(url, video_id),
query={
'filter[short_code]': video_id,
'include': 'i... | 'title': 'The Transhumanist Plan for Humanity | Billy Crone',
'upload_date': '20240903',
'duration': 1709,
'thumbnail': r're:https?://.*\.(?:jpg|png)$',
'timestamp': 1725321600,
'modified_date': '20241010',
'release_date': '20240903',
... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 1 | refactor | 534 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
'url': 'https://subsplash.com/prophecywatchers/media/ms/+n42mr48',
'info_dict': {
'id': 'n42mr48',
'title': 'Road to Zion Series',
},
'playlist_mincount': 13,
}, {
'url': 'https://subsplash.com/prophecywatchers/media/ms/+918b9f6',
'only_matchin... | ```suggestion
for entry in traverse_obj(data, ('_embedded', 'media-items', lambda _, v: v['short_code'])):
``` | return self._extract_video(traverse_obj(data, ('_embedded', 'media-items', 0)), video_id)
class SubsplashPlaylistIE(SubsplashBaseIE):
IE_NAME = 'subsplash:playlist'
_VALID_URL = r'https?://(?:www\.)?subsplash\.com/[^/?#]+/(?:our-videos|media)/ms/\+(?P<id>\w+)'
_PAGE_SIZE = 15
_TESTS = [{
... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.714 | suggestion | 120 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
},
'playlist_mincount': 13,
}, {
'url': 'https://subsplash.com/prophecywatchers/media/ms/+918b9f6',
'only_matching': True,
}]
def _entries(self, series_id, headers, page):
data = self._download_json(
'https://core.subsplash.com/media/v1/media-items', seri... | ```suggestion
entry_id = entry['short_code']
info = self._extract_video(entry, entry_id)
yield {
**info,
'webpage_url': f'https://subspla.sh/{entry_id}',
``` | IE_NAME = 'subsplash:playlist'
_VALID_URL = r'https?://(?:www\.)?subsplash\.com/[^/?#]+/(?:our-videos|media)/ms/\+(?P<id>\w+)'
_PAGE_SIZE = 15
_TESTS = [{
'url': 'https://subsplash.com/skywatchtv/our-videos/ms/+dbyjzp8',
'info_dict': {
'id': 'dbyjzp8',
'title': 'F... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.857 | refactor | 231 | 48 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
if not token:
webpage, urlh = self._dow... | ```suggestion
def _extract_video(self, data, video_id):
``` | parse_iso8601,
try_call,
url_or_none,
)
from ..utils.traversal import traverse_obj
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
if not token:
webpage, urlh = self._dow... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.643 | refactor | 65 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
if not token:
webpage, urlh = self._download_webpage_handle(url, display_id)
token = (
try_call(lambda: se... | ```suggestion
formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
``` |
class SubsplashBaseIE(InfoExtractor):
def _get_headers(self, url, display_id):
token = try_call(lambda: self._get_cookies(url)['ss-token-guest'].value)
if not token:
webpage, urlh = self._download_webpage_handle(url, display_id)
token = (
try_call(lambda: se... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.786 | refactor | 129 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
if not token:
self.report_warning('Unable to extract auth token')
return None
return {'Authorization': f'Bearer {token}'}
def _extract_video(self, data, display_id):
formats = []
video_data = traverse_obj(data, ('_embedded', 'video', '_embedded', {dict}))
... | ```suggestion
'id': video_id,
'formats': formats,
``` | if not token:
self.report_warning('Unable to extract auth token')
return None
return {'Authorization': f'Bearer {token}'}
def _extract_video(self, data, video_id):
formats = []
video_data = traverse_obj(data, ('_embedded', 'video', '_embedded', {dict}))
... | @@ -0,0 +1,184 @@
+import functools
+import math
+
+from .common import InfoExtractor
+from ..utils import (
+ InAdvancePagedList,
+ int_or_none,
+ parse_iso8601,
+ try_call,
+ url_or_none,
+)
+from ..utils.traversal import traverse_obj
+
+
+class SubsplashBaseIE(InfoExtractor):
+ def _get_headers(sel... | yt_dlp/extractor/subsplash.py | 26 | Python | 0.571 | suggestion | 80 | 51 | 51 | false | [ie/subsplash] Add extractors | 11,054 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | subrat-lima |
'ext': 'mp4',
'title': str,
'upload_date': str,
'description': str,
'thumbnail': r're:^https?://.*\.jpg$',
'alt-title': str,
'uploader': str,
'channel': str,
'uploader_id': str,
'channel_id': str,
... | ```suggestion
handle, video_id = self._match_valid_url(url).groups()
``` | 'tags': [],
'subtitles': {
'en': 'mincount:1',
},
},
}, {
'url': 'https://main.bsky.dev/profile/souris.moe/post/3l4qhp7bcs52c',
'md5': '5f2df8c200b5633eb7fb2c984d29772f',
'info_dict': {
'id': '3l4qhp7bcs52c',
... | @@ -0,0 +1,156 @@
+from .common import InfoExtractor
+from ..utils import parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https://bsky.app/profile/blu3blu... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 82 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'author_url': f'https://bsky.app/profile/{author_handle}',
'author_is_uploader': 'Yes' if author_did in root_uri else 'No',
}]
if replies := thread_node.get('replies'):
for reply in replies:
formatted_comments.extend(self.traverse_replies(reply, root_... | This does not extract the best available format.
For example, for https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g the best format at 634x1080 resolution can be downloaded via
```
https://bsky.social/xrpc/com.atproto.sync.getBlob?did=did:plc:pzdr5ylumf7vmvwasrpr5bf2&cid=bafkreiamqpagnuwf72e5zj2xypo... | 'duration': 321,
'age_limit': 0,
'like_count': int,
'view_count': int,
'comment_count': int,
'channel_follower_count': int,
'categories': ['Entertainment'],
'tags': [],
},
'add_ie': ['Youtube'],
}, {
... | @@ -0,0 +1,184 @@
+from .common import InfoExtractor
+from ..utils import parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https://bsky.app/profile/blu3blu... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | refactor | 545 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | mikf | DrearyWillow |
from .common import InfoExtractor
from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
class BlueskyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
_TESTS = [{
'url': 'https://bsky.app/profile/blu3bl... | ```suggestion
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
``` | from .common import InfoExtractor
from ..utils import (
ExtractorError,
format_field,
int_or_none,
mimetype2ext,
orderedSet,
parse_iso8601,
truncate_string,
update_url_query,
url_basename,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(I... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 16 | Python | 0.571 | suggestion | 89 | 41 | 41 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'upload_date': '20240921',
'description': 'OMG WE HAVE VIDEOS NOW',
'thumbnail': r're:^https://video.bsky.app/watch/.*\.jpg$',
'alt_title': None,
'uploader': 'Blu3Blu3Lilith',
'channel': 'blu3blue.bsky.social',
'uploader_id': 'did:plc:p... | ```suggestion
'title': r're:Bluesky: "Bluesky now has video!',
``` | )
from ..utils.traversal import traverse_obj
class BlueskyIE(InfoExtractor):
_VALID_URL = [
r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[\w.:%-]+)/post/(?P<id>\w+)',
r'at://(?P<handle>[\w.:%-]+)/app\.bsky\.feed\.post/(?P<id>\w+)',
]
_TESTS = [{
'url': 'htt... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 80 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'alt_title': None,
'uploader': 'Blu3Blu3Lilith',
'channel': 'blu3blue.bsky.social',
'uploader_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
'channel_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
'uploader_url': 'https://bsky.app/profile/blu3blue.bsky.social'... | ```suggestion
'description': r're:Bluesky now has video!',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
``` |
class BlueskyIE(InfoExtractor):
_VALID_URL = [
r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[\w.:%-]+)/post/(?P<id>\w+)',
r'at://(?P<handle>[\w.:%-]+)/app\.bsky\.feed\.post/(?P<id>\w+)',
]
_TESTS = [{
'url': 'https://bsky.app/profile/blu3blue.bsky.social/pos... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 147 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'upload_date': '20240911',
'description': r're:^Bluesky now has video!',
'thumbnail': r're:^https://video.bsky.app/watch/.*\.jpg$',
'alt_title': 'Bluesky video feature announcement',
'uploader': 'Bluesky',
'channel': 'bsky.app',
'upload... | ```suggestion
'title': r're:clockwork banana: "alright.',
``` | 'repost_count': int,
'comment_count': int,
'tags': [],
},
}, {
'url': 'https://bsky.app/profile/bsky.app/post/3l3vgf77uco2g',
'md5': 'b9e344fdbce9f2852c668a97efefb105',
'info_dict': {
'id': '3l3vgf77uco2g',
'ext': 'mp4',
... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 75 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'uploader': 'Bluesky',
'channel': 'bsky.app',
'uploader_id': 'did:plc:z72i7hdynmk6r22z27h6tvur',
'channel_id': 'did:plc:z72i7hdynmk6r22z27h6tvur',
'uploader_url': 'https://bsky.app/profile/bsky.app',
'channel_url': 'https://bsky.app/profile/did:plc... | ```suggestion
'description': r're:alright.\nthis was .. a tiny bit of a pain.',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
'alt_title': r're:me making a goofy little test video',
``` | }, {
'url': 'https://bsky.app/profile/bsky.app/post/3l3vgf77uco2g',
'md5': 'b9e344fdbce9f2852c668a97efefb105',
'info_dict': {
'id': '3l3vgf77uco2g',
'ext': 'mp4',
'uploader': 'Bluesky',
'uploader_id': 'bsky.app',
'uploader_url': 'ht... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | suggestion | 237 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'alt_title': r're:^me making a goofy little test video',
'uploader': 'clockwork banana',
'channel': 'clockworkbanana.fun',
'uploader_id': 'did:plc:3tndo2mqg2vgpxnpyrxiol6p',
'channel_id': 'did:plc:3tndo2mqg2vgpxnpyrxiol6p',
'uploader_url': 'https:/... | ```suggestion
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
``` | }, {
'url': 'https://main.bsky.dev/profile/souris.moe/post/3l4qhp7bcs52c',
'md5': '5f2df8c200b5633eb7fb2c984d29772f',
'info_dict': {
'id': '3l4qhp7bcs52c',
'ext': 'mp4',
'uploader': 'souris',
'uploader_id': 'souris.moe',
'uploader_u... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 89 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'alt_title': None,
'uploader': 'maeve',
'channel': 'souris.moe',
'uploader_id': 'did:plc:tj7g244gl5v6ai6cm4f4wlqp',
'channel_id': 'did:plc:tj7g244gl5v6ai6cm4f4wlqp',
'uploader_url': 'https://bsky.app/profile/souris.moe',
'channel_url': ... | ```suggestion
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
``` | 'uploader': 'clean',
'uploader_id': 'de1.pds.tentacle.expert',
'uploader_url': 'https://bsky.app/profile/de1.pds.tentacle.expert',
'channel_id': 'did:web:de1.tentacle.expert',
'channel_url': 'https://bsky.app/profile/did:web:de1.tentacle.expert',
'... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 89 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
parent_uri = traverse_obj(post, ('record', 'reply', 'parent', 'uri'))
author_handle = traverse_obj(post, ('author', 'handle'))
author_did = traverse_obj(post, ('author', 'did'), default='')
yield {
'id': post.get('uri'),
'text': traverse_obj(post, ('record', 'text... | ```suggestion
did = handle if handle.startswith('did:') else self._download_json(
'https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle',
video_id, query={'handle': handle}).get('did')
``` | 'uploader_id': 'laserbatx',
'uploader_url': 'https://laserbatx.bandcamp.com',
'artists': ['LASERBAT'],
'album_artists': ['LASERBAT'],
'album': 'Hari Nezumi [EP]',
'track': 'Forward to the End',
'title': 'LASERBAT - Forward to the End',
... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.929 | suggestion | 239 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'author': traverse_obj(post, ('author', 'displayName')),
'author_id': author_did,
'author_thumbnail': traverse_obj(post, ('author', 'avatar'), expected_type=url_or_none),
'author_url': f'https://bsky.app/profile/{author_handle}',
'author_is_uploader': 'Yes' if... | ```suggestion
meta = self._download_json(
'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
video_id, headers={'Content-Type': 'application/json'}, query={
'uri': f'at://{did}/app.bsky.feed.post/{video_id}',
'depth': 1000 if getcomments ... | 'track_id': '222792849',
'release_date': '20230423',
'upload_date': '20230423',
'timestamp': 1682276040.0,
'release_timestamp': 1682276040.0,
'track_number': 1,
},
'add_ie': ['Bandcamp'],
}, {
'url': 'https://bsky.app/pr... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.929 | suggestion | 423 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'webpage_url': 'https://bsky.app/profile/de1.pds.tentacle.expert/post/3l3w4tnezek2e',
'tags': 'count:1',
'subtitles': 'count:0',
'comments': list,
},
}]
def _get_comments(self, meta):
yield self.traverse_replies(meta, traverse_obj(meta, ('post', '... | This should be a boolean IMO
```suggestion
'author_is_uploader': author_did in root_uri,
``` | 'comment_count': int,
'channel_follower_count': int,
'categories': ['Entertainment'],
'tags': [],
},
'add_ie': ['Youtube'],
}, {
'url': 'https://bsky.app/profile/endshark.bsky.social/post/3jzxjkcemae2m',
'info_dict': {
'id':... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | security | 107 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
handle = traverse_obj(post, ('author', 'handle'))
uploader = traverse_obj(post, ('author', 'displayName'))
description = traverse_obj(post, ('record', 'text'))
extractor = self.extract_comments(meta)
return {
'id': video_id,
'title': f'{uploader}: "{descr... | ```suggestion
'subtitles': subs,
``` | 'channel_id': 'did:plc:7x6rtuenkuvxq3zsvffp2ide',
'channel_url': 'https://bsky.app/profile/did:plc:7x6rtuenkuvxq3zsvffp2ide',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
'title': 'crazy that i look like this tbh',
'description': 'crazy that i loo... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 50 | 28 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'id': '3l3w4tnezek2e',
'ext': 'mp4',
'title': 'clean: ""',
'upload_date': '20240911',
'description': '',
'thumbnail': r're:^https://video.bsky.app/watch/.*\.jpg$',
'alt_title': None,
'uploader': 'clean',
'channel... | ```suggestion
yield from self.traverse_replies(meta, traverse_obj(meta, ('post', 'uri'), default=''))
```
Must be applied together with the suggestions on Line 219 and Line 198 | 'uploader_id': '@yunayuispink',
'uploader_url': 'https://www.youtube.com/@yunayuispink',
'channel': 'yunayu',
'channel_id': 'UCPLvXnHa7lTyNoR_dGsU14w',
'channel_url': 'https://www.youtube.com/channel/UCPLvXnHa7lTyNoR_dGsU14w',
'thumbnail': 'https:/... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 187 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
handle = traverse_obj(post, ('author', 'handle'))
uploader = traverse_obj(post, ('author', 'displayName'))
description = traverse_obj(post, ('record', 'text'))
extractor = self.extract_comments(meta)
return {
'id': video_id,
'title': f'{uploader}: "{desc... | ```suggestion
'__post_extractor': self.extract_comments(meta),
```
not sure if this is what you're trying to do(the suggestions on Line 157 and Line 198 must be applied to make this work)
Please also remember to update tests, if necessary | 'uploader_url': 'https://bsky.app/profile/alt.bun.how',
'channel_id': 'did:plc:7x6rtuenkuvxq3zsvffp2ide',
'channel_url': 'https://bsky.app/profile/did:plc:7x6rtuenkuvxq3zsvffp2ide',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
'title': 'crazy that... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | refactor | 254 | 29 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
video_id, headers={'Content-Type': 'application/json'},
query={'uri': f'at://{did}/app.bsky.feed.post/{video_id}',
'depth': 1000 if getcomments else 0,
'parentHeight': 1000 if getcom... | ```suggestion
```
Must be applied together with the suggestions on Line 140 and Line 219 | 'title': 'Bluesky now has video! Update your app to versi...',
'alt_title': 'Bluesky video feature announcement',
'description': r're:(?s)Bluesky now has video! .{239}',
'upload_date': '20240911',
'timestamp': 1726074716,
'like_count': int,
... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 90 | 50 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
'filesize': traverse_obj(record_embed, ('video', 'size'), expected_type=int_or_none),
})
handle = traverse_obj(post, ('author', 'handle'))
uploader = traverse_obj(post, ('author', 'displayName'))
description = traverse_obj(post, ('record', 'text'))
extractor = self.e... | ```suggestion
```
this will be automatically added after extraction | 'uploader': 'cinnamon',
'uploader_id': 'alt.bun.how',
'uploader_url': 'https://bsky.app/profile/alt.bun.how',
'channel_id': 'did:plc:7x6rtuenkuvxq3zsvffp2ide',
'channel_url': 'https://bsky.app/profile/did:plc:7x6rtuenkuvxq3zsvffp2ide',
'thumbnail':... | @@ -0,0 +1,221 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.643 | refactor | 69 | 31 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | grqx | DrearyWillow |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.