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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tracks = playlist.get('tracks') or []
if not all(t.get('permalink_url') for t in tracks) and token:
tracks = self._call_api(
self._API_V2_BASE + 'tracks', playlist_id,
'Downloading tracks', query={
'ids': ','.join([str(t['id']) for t in tra... | ```suggestion
**traverse_obj(playlist, {
``` | tracks = playlist.get('tracks') or []
if not all(t.get('permalink_url') for t in tracks) and token:
tracks = self._call_api(
self._API_V2_BASE + 'tracks', playlist_id,
'Downloading tracks', query={
'ids': ','.join([str(t['id']) for t in tra... | @@ -671,7 +680,15 @@ def _extract_set(self, playlist, token=None):
return self.playlist_result(
entries, playlist_id,
playlist.get('title'),
- playlist.get('description'))
+ playlist.get('description'),
+ **(traverse_obj(playlist, { | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.571 | suggestion | 58 | 51 | 51 | false | [ie/soundcloud] Add more extracted fields | 11,945 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 7x11x13 |
'playlistId': playlist_id,
'playlistSecretToken': token,
}, headers=self._HEADERS)
entries = []
for track in tracks:
track_id = str_or_none(track.get('id'))
url = track.get('permalink_url')
if not url:
... | ```suggestion
}),
``` | 'playlistId': playlist_id,
'playlistSecretToken': token,
}, headers=self._HEADERS)
album_info = traverse_obj(playlist, {
'album': ('title', {str}),
'album_artist': ('user', 'username', {str}),
'album_type': ('set_type', ... | @@ -671,7 +680,15 @@ def _extract_set(self, playlist, token=None):
return self.playlist_result(
entries, playlist_id,
playlist.get('title'),
- playlist.get('description'))
+ playlist.get('description'),
+ **(traverse_obj(playlist, {
+ 'u... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.429 | suggestion | 35 | 51 | 51 | false | [ie/soundcloud] Add more extracted fields | 11,945 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 7x11x13 |
except ExtractorError as e:
if not isinstance(e.cause, HTTPError) or not e.cause.status == 429:
raise
self.report_warning(
'You have reached the API rate limit, which is ~600 requests per '
'10 minutes. Use the --ext... | maybe we also wanna do this...
```suggestion
'album_type': ('set_type', {str}, filter),
``` | except ExtractorError as e:
if not isinstance(e.cause, HTTPError) or not e.cause.status == 429:
raise
self.report_warning(
'You have reached the API rate limit, which is ~600 requests per '
'10 minutes. Use the --ext... | @@ -656,6 +665,11 @@ def _extract_set(self, playlist, token=None):
'playlistId': playlist_id,
'playlistSecretToken': token,
}, headers=self._HEADERS)
+ album_info = traverse_obj(playlist, {
+ 'album': ('title', {str}),
+ 'album_arti... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.857 | suggestion | 106 | 51 | 51 | false | [ie/soundcloud] Add more extracted fields | 11,945 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 7x11x13 |
track = self._call_api(
self._resolv_url(self._BASE_URL + slug),
slug, 'Downloading track info', headers=self._HEADERS)
if track.get('errors'):
raise ExtractorError(f'{self.IE_NAME} said: %s' % ','.join(
str(err['error_message']) for err in track['err... | ...so that we don't end up with this
```suggestion
``` | track = self._call_api(
self._resolv_url(self._BASE_URL + slug),
slug, 'Downloading track info', headers=self._HEADERS)
if track.get('errors'):
raise ExtractorError(f'{self.IE_NAME} said: %s' % ','.join(
str(err['error_message']) for err in track['err... | @@ -960,6 +985,11 @@ class SoundcloudPlaylistIE(SoundcloudPlaylistBaseIE):
'id': '4110309',
'title': 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]',
'description': 're:.*?TILT Brass - Bowery Poetry Club',
+ 'uploader': 'Non-Site Records',
+ ... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.571 | suggestion | 56 | 51 | 51 | false | [ie/soundcloud] Add more extracted fields | 11,945 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 7x11x13 |
except ExtractorError as e:
if not isinstance(e.cause, HTTPError) or not e.cause.status == 429:
raise
self.report_warning(
'You have reached the API rate limit, which is ~600 requests per '
'10 minutes. Use the --ext... | still wanna type check though
```suggestion
'album_type': ('set_type', {str}, {lambda x: x or 'playlist'}),
``` | except ExtractorError as e:
if not isinstance(e.cause, HTTPError) or not e.cause.status == 429:
raise
self.report_warning(
'You have reached the API rate limit, which is ~600 requests per '
'10 minutes. Use the --ext... | @@ -656,6 +665,11 @@ def _extract_set(self, playlist, token=None):
'playlistId': playlist_id,
'playlistSecretToken': token,
}, headers=self._HEADERS)
+ album_info = traverse_obj(playlist, {
+ 'album': ('title', {str}),
+ 'album_arti... | yt_dlp/extractor/soundcloud.py | 26 | Python | 0.857 | suggestion | 126 | 51 | 51 | false | [ie/soundcloud] Add more extracted fields | 11,945 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 7x11x13 |
from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
parse_resolution,
str_or_none,
try_get,
unified_timestamp,
url_or_none,
urljoin,
)
class PuhuTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-izle'
IE_NAME = 'puhutv'
_T... | line too long, use regex or md5 here | from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
parse_resolution,
str_or_none,
traverse_obj,
try_get,
unified_timestamp,
url_or_none,
urljoin,
)
class PuhuTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-izle'
IE_NAME... | @@ -18,20 +18,21 @@ class PuhuTVIE(InfoExtractor):
IE_NAME = 'puhutv'
_TESTS = [{
# film
- 'url': 'https://puhutv.com/sut-kardesler-izle',
- 'md5': 'a347470371d56e1585d1b2c8dab01c96',
+ 'url': 'https://puhutv.com/bi-kucuk-eylul-meselesi-izle',
+ 'md5': '4de98170ccb84c05779... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.143 | refactor | 36 | 51 | 51 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
_TESTS = [{
'url': 'https://puhutv.com/deniz-yildizi-detay',
'info_dict': {
'title': 'Deniz Yıldızı',
'id': 'deniz-yildizi',
},
'playlist_mincount': 205,
}, {
# a film detail page which is using same url with serie page
'url': 'https://puhu... | I'd prefer to keep the note as it was before. If we say we're downloading `episode 400-500` but there are only `456` episodes, this would be confusing for the user
```suggestion
f'https://appservice.puhutv.com/api/seasons/{season_id}/episodes?v=2',
season_id, f'Downloading pag... | IE_NAME = 'puhutv:serie'
_TESTS = [{
'url': 'https://puhutv.com/deniz-yildizi-detay',
'info_dict': {
'title': 'Deniz Yıldızı',
'id': 'deniz-yildizi',
},
'playlist_mincount': 205,
}, {
# a film detail page which is using same url with serie page... | @@ -191,27 +192,29 @@ def _extract_entries(self, seasons):
if not season_id:
continue
page = 1
+ per = 100
has_more = True
while has_more is True:
season = self._download_json(
- f'https://galadriel.puhut... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.857 | suggestion | 382 | 51 | 51 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
}
class PuhuTVSerieIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-detay'
IE_NAME = 'puhutv:serie'
_TESTS = [{
'url': 'https://puhutv.com/deniz-yildizi-detay',
'info_dict': {
'title': 'Deniz Yıldızı',
'id': 'deniz-yildizi',
... | if we're reverting the `_download_json` note, then we can inline this below again
```suggestion
``` | 'formats': formats,
}
class PuhuTVSerieIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-detay'
IE_NAME = 'puhutv:serie'
_TESTS = [{
'url': 'https://puhutv.com/deniz-yildizi-detay',
'info_dict': {
'title': 'Deniz Yıldızı',
... | @@ -191,27 +192,29 @@ def _extract_entries(self, seasons):
if not season_id:
continue
page = 1
+ per = 100 | yt_dlp/extractor/puhutv.py | 26 | Python | 0.714 | suggestion | 101 | 51 | 51 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
'url': 'https://puhutv.com/deniz-yildizi-detay',
'info_dict': {
'title': 'Deniz Yıldızı',
'id': 'deniz-yildizi',
},
'playlist_mincount': 205,
}, {
# a film detail page which is using same url with serie page
'url': 'https://puhutv.com/kaybedenl... | ```suggestion
'per': 100,
``` | _TESTS = [{
'url': 'https://puhutv.com/deniz-yildizi-detay',
'info_dict': {
'title': 'Deniz Yıldızı',
'id': 'deniz-yildizi',
},
'playlist_mincount': 205,
}, {
# a film detail page which is using same url with serie page
'url': 'https://puhu... | @@ -191,27 +192,29 @@ def _extract_entries(self, seasons):
if not season_id:
continue
page = 1
+ per = 100
has_more = True
while has_more is True:
season = self._download_json(
- f'https://galadriel.puhut... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.571 | suggestion | 55 | 51 | 51 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
for season in seasons:
season_id = season.get('id')
if not season_id:
continue
page = 1
per = 100
has_more = True
while has_more is True:
season = self._download_json(
f'https://appservice... | let's make the metadata extraction non-fatal
```suggestion
for episode in traverse_obj(season, ('episodes', lambda _, v: v.get('slug') or v['assets'][0]['slug'])):
slug = episode.get('slug') or episode['assets'][0]['slug']
yield self.url_result(
... | def _extract_entries(self, seasons):
for season in seasons:
season_id = season.get('id')
if not season_id:
continue
page = 1
has_more = True
while has_more is True:
season = self._download_json(
f... | @@ -191,27 +192,29 @@ def _extract_entries(self, seasons):
if not season_id:
continue
page = 1
+ per = 100
has_more = True
while has_more is True:
season = self._download_json(
- f'https://galadriel.puhut... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.857 | refactor | 415 | 47 | 44 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
if not season_id:
continue
page = 1
per = 100
has_more = True
while has_more is True:
season = self._download_json(
f'https://appservice.puhutv.com/api/seasons/{season_id}/episodes?v=2',
s... | why not `.get()`?
```suggestion
has_more = season.get('has_more')
```
I mean I'd even go in the other direction and make it even safer
```suggestion
has_more = traverse_obj(season, 'has_more')
``` | season_id = season.get('id')
if not season_id:
continue
page = 1
has_more = True
while has_more is True:
season = self._download_json(
f'https://appservice.puhutv.com/api/seasons/{season_id}/episodes?v=2',
... | @@ -191,27 +192,29 @@ def _extract_entries(self, seasons):
if not season_id:
continue
page = 1
+ per = 100
has_more = True
while has_more is True:
season = self._download_json(
- f'https://galadriel.puhut... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.786 | question | 235 | 45 | 42 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
})['data']
for episode in traverse_obj(season, ('episodes', lambda _, v: v.get('slug') or v['assets'][0]['slug'])):
slug = episode.get('slug') or episode['assets'][0]['slug']
yield self.url_result(
f'https://puhutv.com/... | can you explain what's going on here please | })['data']
for episode in traverse_obj(season, ('episodes', lambda _, v: v.get('slug') or v['assets'][0]['slug'])):
slug = episode.get('slug') or episode['assets'][0]['slug']
yield self.url_result(
f'https://puhutv.com/... | @@ -226,7 +223,6 @@ def _real_extract(self, url):
self._extract_entries(seasons), playlist_id, info.get('name'))
# For films, these are using same url with series
- video_id = info.get('slug') or info['assets'][0]['slug']
+ video_id = (info['slug'] or info['assets'][0]['slug'])... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.071 | suggestion | 43 | 27 | 31 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
'page': page,
'per': 100,
})['data']
for episode in traverse_obj(season, ('episodes', lambda _, v: v.get('slug') or v['assets'][0]['slug'])):
slug = episode.get('slug') or episode['assets'][0]['slug']
... | ```suggestion
video_id = info.get('slug')
if video_id:
video_id = video_id.removesuffix('-detay')
else:
video_id = info['assets'][0]['slug'].removesuffix('-izle')
``` | 'page': page,
'per': 100,
})['data']
for episode in traverse_obj(season, ('episodes', lambda _, v: v.get('slug') or v['assets'][0]['slug'])):
slug = episode.get('slug') or episode['assets'][0]['slug']
... | @@ -226,7 +223,6 @@ def _real_extract(self, url):
self._extract_entries(seasons), playlist_id, info.get('name'))
# For films, these are using same url with series
- video_id = info.get('slug') or info['assets'][0]['slug']
+ video_id = (info['slug'] or info['assets'][0]['slug'])... | yt_dlp/extractor/puhutv.py | 26 | Python | 0.857 | suggestion | 220 | 29 | 33 | false | [ie/puhutv] Fix playlists extraction | 11,955 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | e2dk4r |
line = line.strip()
if line:
if not line.startswith('#'):
if format_index and discontinuity_count != format_index:
continue
if ad_frag_next:
continue
frag_index += 1
... | If `byte_range` is truthy then we know it has an `end` key, or else if it doesn't then we should error because we messed up the code somewhere
```suggestion
byte_range_offset = byte_range['end']
``` | line = line.strip()
if line:
if not line.startswith('#'):
if format_index and discontinuity_count != format_index:
continue
if ad_frag_next:
continue
frag_index += 1
... | @@ -204,6 +205,11 @@ def is_ad_fragment_end(s):
})
media_sequence += 1
+ # If the byte_range is truthy, reset it after appending a fragment that uses it
+ if byte_range:
+ byte_range_offset = byte_range.get('end', 0... | yt_dlp/downloader/hls.py | 26 | Python | 1 | suggestion | 225 | 51 | 51 | false | [downloader/hlsnative] Fix byterange logic | 11,972 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | entourage8 |
# Enforce language and tz for extraction
client_context = traverse_obj(context, 'client', expected_type=dict, default={})
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
@staticmethod
def _make_sid_authorizatio... | Is there any reason for the `is None` conditionals instead of just a truthy check? Can the cookie values be empty strings? And do we want them to remain that way instead of overwriting them?
IMO we could condense this method a bit:
```py
def _load_sid_cookies(self):
yt_cookies = self._get_cookies('htt... | client_context = traverse_obj(context, 'client', expected_type=dict, default={})
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
@staticmethod
def _make_sid_authorization(scheme, sid, origin, additional_parts):
... | @@ -627,32 +633,78 @@ def _extract_context(self, ytcfg=None, default_client='web'):
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
- _SAPISID = None
+ @staticmethod
+ def _make_sid_authorization(scheme, sid, origin, addit... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | suggestion | 1,021 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
def _select_api_hostname(self, req_api_hostname, default_client=None):
return (self._configuration_arg('innertube_host', [''], ie_key=YoutubeIE.ie_key())[0]
or req_api_hostname or self._get_innertube_host(default_client or 'web'))
def _extract_context(self, ytcfg=None, default_client='... | ```suggestion
parts.append(''.join(additional_parts))
``` | def _select_api_hostname(self, req_api_hostname, default_client=None):
return (self._configuration_arg('innertube_host', [''], ie_key=YoutubeIE.ie_key())[0]
or req_api_hostname or self._get_innertube_host(default_client or 'web'))
def _extract_context(self, ytcfg=None, default_client='w... | @@ -627,32 +633,78 @@ def _extract_context(self, ytcfg=None, default_client='web'):
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
- _SAPISID = None
+ @staticmethod
+ def _make_sid_authorization(scheme, sid, origin, addit... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | suggestion | 71 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
def _generate_sid_authorization(self, origin='https://www.youtube.com', user_session_id=None):
"""
Generate API Session ID Authorization for Innertube requests. Assumes all requests are secure (https).
@param origin: Origin URL
@param user_session_id: Optional User Session ID
... | ```suggestion
for scheme, sid in (('SAPISIDHASH', self._SAPISID),
('SAPISID1PHASH', self._1PSAPISID),
('SAPISID3PHASH', self._3PSAPISID)):
if sid:
authorizations.append(self._make_sid_authorization(scheme, sid, origin, addi... | if user_session_id:
additional_parts['u'] = user_session_id
yt_sapisid, yt_1psapisid, yt_3psapisid = self._get_sid_cookies()
for scheme, sid in (('SAPISIDHASH', yt_sapisid),
('SAPISID1PHASH', yt_1psapisid),
('SAPISID3PHASH', y... | @@ -627,32 +633,78 @@ def _extract_context(self, ytcfg=None, default_client='web'):
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
- _SAPISID = None
+ @staticmethod
+ def _make_sid_authorization(scheme, sid, origin, addit... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | security | 339 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
@param origin: Origin URL
@param user_session_id: Optional User Session ID
@return: Authorization header value
"""
authorizations = []
additional_parts = {}
if user_session_id:
additional_parts['u'] = user_session_id
self._load_sid_cookies()
... | it's nice to be explicit when the return value matters IMO
```suggestion
return None
``` | yt_sapisid, yt_1psapisid, yt_3psapisid = self._get_sid_cookies()
for scheme, sid in (('SAPISIDHASH', yt_sapisid),
('SAPISID1PHASH', yt_1psapisid),
('SAPISID3PHASH', yt_3psapisid)):
if sid:
authorizations.append(self._ma... | @@ -627,32 +633,78 @@ def _extract_context(self, ytcfg=None, default_client='web'):
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
- _SAPISID = None
+ @staticmethod
+ def _make_sid_authorization(scheme, sid, origin, addit... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 103 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
@staticmethod
def _make_sid_authorization(scheme, sid, origin, additional_parts):
timestamp = str(round(time.time()))
hash_parts = []
if additional_parts:
hash_parts.append(':'.join(additional_parts.values()))
hash_parts.extend([timestamp, sid, origin])
sidha... | > `# YouTube also falls back to __Secure-3PAPISID if SAPISID is missing.`
so this means that setting a SAPISID cookie with the 3P value was unnecessary, hence why we're not doing it anymore? | @staticmethod
def _make_sid_authorization(scheme, sid, origin, additional_parts):
timestamp = str(round(time.time()))
hash_parts = []
if additional_parts:
hash_parts.append(':'.join(additional_parts.values()))
hash_parts.extend([timestamp, sid, origin])
sidha... | @@ -627,32 +632,66 @@ def _extract_context(self, ytcfg=None, default_client='web'):
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
- _SAPISID = None
+ @staticmethod
+ def _make_sid_authorization(scheme, sid, origin, addit... | yt_dlp/extractor/youtube.py | 26 | Python | 0.5 | question | 193 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
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):
cookies = self._get_cookies('https://www.youtube.c... | This change will result in "Logged in using cookies" being output when the extractor is initialized, which could be misleading if the cookies have been rotated/invalidated. Previously, the debug message wasn't triggered until after the initial webpage request, at which point the cookies would have been discarded if the... | 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):
cookies = self._get_cookies('https://www.youtube.c... | @@ -567,9 +566,15 @@ def _initialize_pref(self):
pref.update({'hl': self._preferred_lang or 'en', 'tz': 'UTC'})
self._set_cookie('.youtube.com', name='PREF', value=urllib.parse.urlencode(pref))
+ def _initialize_cookie_auth(self):
+ self._load_sid_cookies()
+ if self._SAPISID or sel... | yt_dlp/extractor/youtube.py | 26 | Python | 0.643 | bug | 342 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
def _initialize_consent(self):
cookies = self._get_cookies('https://www.youtube.com/')
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... | ```suggestion
self.write_debug('Found YouTube account cookies')
``` |
def _initialize_consent(self):
cookies = self._get_cookies('https://www.youtube.com/')
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... | @@ -567,9 +566,15 @@ def _initialize_pref(self):
pref.update({'hl': self._preferred_lang or 'en', 'tz': 'UTC'})
self._set_cookie('.youtube.com', name='PREF', value=urllib.parse.urlencode(pref))
+ def _initialize_cookie_auth(self):
+ self._load_sid_cookies()
+ if self._SAPISID or sel... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | bug | 81 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | coletdjnz | coletdjnz |
@staticmethod
def _extract_session_index(*data):
"""
Index of current account in account list.
See: https://github.com/yt-dlp/yt-dlp/pull/519
"""
for ytcfg in data:
session_index = int_or_none(try_get(ytcfg, lambda x: x['SESSION_INDEX']))
if sessio... | ```suggestion
if second:
return first, second
return None, first
```
This is easier to read imo | Index of current account in account list.
See: https://github.com/yt-dlp/yt-dlp/pull/519
"""
for ytcfg in data:
session_index = int_or_none(try_get(ytcfg, lambda x: x['SESSION_INDEX']))
if session_index is not None:
return session_index
@stati... | @@ -688,26 +727,46 @@ def _extract_session_index(*data):
if session_index is not None:
return session_index
- def _data_sync_id_to_delegated_session_id(self, data_sync_id):
+ @staticmethod
+ def _parse_data_sync_id(data_sync_id):
+ """
+ Parse data_sync_id into del... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 128 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | coletdjnz |
sidhash = hashlib.sha1(' '.join(hash_parts).encode()).hexdigest()
parts = [timestamp, sidhash]
if additional_parts:
parts.append(''.join(additional_parts))
return f'{scheme} {"_".join(parts)}'
_SAPISID = _3PSAPISID = _1PSAPISID = None
def _load_sid_cookies(self):
... | This will cache invalidated cookie values and send them with the API calls. It will make it difficult for us to debug what is happening when cookies are rotated, and it will hammer the API with invalid auth headers which could be detrimental to users' account standing
Would be better to not cache at all IMO | sidhash = hashlib.sha1(' '.join(hash_parts).encode()).hexdigest()
parts = [timestamp, sidhash]
if additional_parts:
parts.append(''.join(additional_parts))
return f'{scheme} {"_".join(parts)}'
def _get_sid_cookies(self):
"""
Get SAPISID, 1PSAPISID, 3PSA... | @@ -627,32 +632,66 @@ def _extract_context(self, ytcfg=None, default_client='web'):
client_context.update({'hl': self._preferred_lang or 'en', 'timeZone': 'UTC', 'utcOffsetMinutes': 0})
return context
- _SAPISID = None
+ @staticmethod
+ def _make_sid_authorization(scheme, sid, origin, addit... | yt_dlp/extractor/youtube.py | 26 | Python | 0.643 | bug | 311 | 51 | 51 | false | [ie/youtube] Refactor cookie SID auth | 11,989 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
(r'video\.westernreservepublicmedia\.org', 'Western Reserve PBS (WNEO)'), # http://www.WesternReservePublicMedia.org/
(r'video\.ideastream\.org', 'WVIZ/PBS ideastream (WVIZ)'), # http://www.wviz.org/
(r'video\.kcts9\.org', 'KCTS 9 (KCTS)'), # http://kcts9.org/
(r'video\.basinpbs\.org'... | If the `%` formatting causes linting errors:
```suggestion
(?:{})/(?:
```
and revert l.195-6. | (r'video\.westernreservepublicmedia\.org', 'Western Reserve PBS (WNEO)'), # http://www.WesternReservePublicMedia.org/
(r'video\.ideastream\.org', 'WVIZ/PBS ideastream (WVIZ)'), # http://www.wviz.org/
(r'video\.kcts9\.org', 'KCTS 9 (KCTS)'), # http://kcts9.org/
(r'video\.basinpbs\.org'... | @@ -185,14 +185,15 @@ class PBSIE(InfoExtractor):
_VALID_URL = r'''(?x)https?://
(?:
- # Direct video URL
- (?:{})/(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/]|$) |
- # Article with embedded player (or direct video)
- (?:www\.)?pbs\.org/(?:[^/]+/){{1,5}}(?... | yt_dlp/extractor/pbs.py | 26 | Python | 0.929 | suggestion | 109 | 51 | 51 | false | [ie/pbs] #11514 pbs patch | 12,024 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | krandor |
(r'video\.wtvi\.org', 'WTVI (WTVI)'), # http://www.wtvi.org/
# (r'whro\.org', 'WHRO (WHRO)'), # http://whro.org
(r'video\.westernreservepublicmedia\.org', 'Western Reserve PBS (WNEO)'), # http://www.WesternReservePublicMedia.org/
(r'video\.ideastream\.org', 'WVIZ/PBS ideastream (WVIZ)... | ```suggestion
(?:video|player)\.pbs\.org/(?:widget/)?partnerplayer/(?P<player_id>[^/?#]+) |
``` | (r'video\.wtvi\.org', 'WTVI (WTVI)'), # http://www.wtvi.org/
# (r'whro\.org', 'WHRO (WHRO)'), # http://whro.org
(r'video\.westernreservepublicmedia\.org', 'Western Reserve PBS (WNEO)'), # http://www.WesternReservePublicMedia.org/
(r'video\.ideastream\.org', 'WVIZ/PBS ideastream (WVIZ)... | @@ -185,12 +185,13 @@ class PBSIE(InfoExtractor):
_VALID_URL = r'''(?x)https?://
(?:
- # Direct video URL
- (?:{})/(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/]|$) |
- # Article with embedded player (or direct video)
- (?:www\.)?pbs\.org/(?:[^/]+/){{1,5}}(?... | yt_dlp/extractor/pbs.py | 26 | Python | 0.714 | suggestion | 109 | 51 | 51 | false | [ie/pbs] #11514 pbs patch | 12,024 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | krandor |
(r'video\.ideastream\.org', 'WVIZ/PBS ideastream (WVIZ)'), # http://www.wviz.org/
(r'video\.kcts9\.org', 'KCTS 9 (KCTS)'), # http://kcts9.org/
(r'video\.basinpbs\.org', 'Basin PBS (KPBT)'), # http://www.basinpbs.org
(r'video\.houstonpbs\.org', 'KUHT / Channel 8 (KUHT)'), # http://www... | ```suggestion
(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/#]|$) |
``` | (r'video\.ideastream\.org', 'WVIZ/PBS ideastream (WVIZ)'), # http://www.wviz.org/
(r'video\.kcts9\.org', 'KCTS 9 (KCTS)'), # http://kcts9.org/
(r'video\.basinpbs\.org', 'Basin PBS (KPBT)'), # http://www.basinpbs.org
(r'video\.houstonpbs\.org', 'KUHT / Channel 8 (KUHT)'), # http://www... | @@ -185,12 +185,13 @@ class PBSIE(InfoExtractor):
_VALID_URL = r'''(?x)https?://
(?:
- # Direct video URL
- (?:{})/(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/]|$) |
- # Article with embedded player (or direct video)
- (?:www\.)?pbs\.org/(?:[^/]+/){{1,5}}(?... | yt_dlp/extractor/pbs.py | 26 | Python | 0.571 | suggestion | 92 | 51 | 51 | false | [ie/pbs] #11514 pbs patch | 12,024 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | krandor |
(r'video\.kcts9\.org', 'KCTS 9 (KCTS)'), # http://kcts9.org/
(r'video\.basinpbs\.org', 'Basin PBS (KPBT)'), # http://www.basinpbs.org
(r'video\.houstonpbs\.org', 'KUHT / Channel 8 (KUHT)'), # http://www.houstonpublicmedia.org/
# (r'tamu\.edu', 'KAMU - TV (KAMU)'), # http://KAMU.tamu.... | `#`s in character classes don't need to be escaped
```suggestion
(?:[^/?#]+/){{1,5}}(?P<presumptive_id>[^/?#]+?)(?:\.html)?/?(?:$|[?#])
``` | (r'video\.kcts9\.org', 'KCTS 9 (KCTS)'), # http://kcts9.org/
(r'video\.basinpbs\.org', 'Basin PBS (KPBT)'), # http://www.basinpbs.org
(r'video\.houstonpbs\.org', 'KUHT / Channel 8 (KUHT)'), # http://www.houstonpublicmedia.org/
# (r'tamu\.edu', 'KAMU - TV (KAMU)'), # http://KAMU.tamu.... | @@ -185,12 +185,13 @@ class PBSIE(InfoExtractor):
_VALID_URL = r'''(?x)https?://
(?:
- # Direct video URL
- (?:{})/(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/]|$) |
- # Article with embedded player (or direct video)
- (?:www\.)?pbs\.org/(?:[^/]+/){{1,5}}(?... | yt_dlp/extractor/pbs.py | 26 | Python | 0.714 | security | 156 | 51 | 51 | false | [ie/pbs] #11514 pbs patch | 12,024 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | krandor |
description = None
presumptive_id = mobj.group('presumptive_id')
display_id = presumptive_id
if presumptive_id:
webpage = self._download_webpage(url, display_id)
description = strip_or_none(self._og_search_description(
webpage, default=None) or s... | > `# move to end to avoid false +ves?`
let's do that | description = None
presumptive_id = mobj.group('presumptive_id')
display_id = presumptive_id
if presumptive_id:
webpage = self._download_webpage(url, display_id)
description = strip_or_none(self._og_search_description(
webpage, default=None) or s... | @@ -460,6 +474,7 @@ def _extract_webpage(self, url):
return tabbed_videos, presumptive_id, upload_date, description
MEDIA_ID_REGEXES = [
+ r'\bhttps?://player\.pbs\.org/[\w-]+player/(\d+)', # move to end to avoid false +ves? | yt_dlp/extractor/pbs.py | 26 | Python | 0.429 | suggestion | 55 | 51 | 51 | false | [ie/pbs] #11514 pbs patch | 12,024 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | krandor |
})
meta = video_data['meta']
title = meta['subject']
formats = []
get_list = lambda x: try_get(video_data, lambda y: y[x + 's']['list'], list) or []
def extract_formats(streams, stream_type, query={}):
for stream in streams:
stream_url = s... | ```suggestion
'extra_param_to_segment_url': urllib.parse.urlencode(query, doseq=True) if stream_type == 'HLS' else None,
``` | })
meta = video_data['meta']
title = meta['subject']
formats = []
get_list = lambda x: try_get(video_data, lambda y: y[x + 's']['list'], list) or []
def extract_formats(streams, stream_type, query={}):
for stream in streams:
stream_url = s... | @@ -72,6 +72,8 @@ def extract_formats(streams, stream_type, query={}):
'abr': int_or_none(bitrate.get('audio')),
'filesize': int_or_none(stream.get('size')),
'protocol': 'm3u8_native' if stream_type == 'HLS' else None,
+ 'extra_param_to_s... | yt_dlp/extractor/naver.py | 26 | Python | 0.857 | suggestion | 146 | 51 | 51 | false | [ie/naver] Fix m3u8 formats download | 12,037 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kclauhk |
parse_duration,
parse_iso8601,
parse_qs,
qualities,
remove_end,
remove_start,
smuggle_url,
str_or_none,
str_to_int,
strftime_or_none,
traverse_obj,
try_call,
try_get,
unescapeHTML,
unified_strdate,
unified_timestamp,
unsmuggle_url,
update_url_query... | > `STREAMING_DATA_FETCH_PO_TOKEN = '__yt_dlp_fetch_po_token'`
The naming threw me off at first. Can we use names that make it more clear they point to a function?
```suggestion
STREAMING_DATA_PO_TOKEN_FUNC = '__yt_dlp_po_token_func'
```
or something? | parse_count,
parse_duration,
parse_iso8601,
parse_qs,
qualities,
remove_end,
remove_start,
smuggle_url,
str_or_none,
str_to_int,
strftime_or_none,
traverse_obj,
try_call,
try_get,
unescapeHTML,
unified_strdate,
unified_timestamp,
unsmuggle_url,
... | @@ -69,7 +69,15 @@
)
STREAMING_DATA_CLIENT_NAME = '__yt_dlp_client'
-STREAMING_DATA_PO_TOKEN = '__yt_dlp_po_token'
+STREAMING_DATA_INITIAL_PO_TOKEN = '__yt_dlp_po_token'
+STREAMING_DATA_FETCH_PO_TOKEN = '__yt_dlp_fetch_po_token' | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | question | 259 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
if not player_url and not tried_iframe_fallback and require_js_player:
player_url = self._download_player_url(video_id)
tried_iframe_fallback = True
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data... | since we `setdefault` for all clients, we don't need `.get()` and IMO we'd want a key error here to notice if we change things elsewhere and forget to here. I think it's also less taxing to read if we use a var for the required contexts instead of temp var for `require_player_po_token` since we do the same thing below
... | fetch_po_token_args = {
'client': client,
'visitor_data': visitor_data,
'video_id': video_id,
'data_sync_id': data_sync_id if self.is_authenticated else None,
'player_url': player_url if require_js_player else None,
... | @@ -4031,16 +4098,39 @@ def append_client(*client_names):
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
- po_token = self.fetch_po_... | yt_dlp/extractor/youtube.py | 26 | Python | 1 | bug | 539 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'player_url': player_url if require_js_player else None,
'session_index': self._extract_session_index(master_ytcfg, player_ytcfg),
'ytcfg': player_ytcfg,
}
player_po_token = self.fetch_po_token(
context=_PoTokenContext.PLAYER, **fe... | maybe this formatting is funky but I think it might be more readable?
```suggestion
if (
not gvs_po_token
and _PoTokenContext.GVS in po_token_required_contexts
and 'missing_pot' in self._configuration_arg('formats')
):
``` | player_po_token = self.fetch_po_token(
context=_PoTokenContext.PLAYER, **fetch_po_token_args)
gvs_po_token = self.fetch_po_token(
context=_PoTokenContext.GVS, **fetch_po_token_args)
required_pot_contexts = self._get_default_ytcfg(client)['PO_TOKEN_RE... | @@ -4031,16 +4098,39 @@ def append_client(*client_names):
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
- po_token = self.fetch_po_... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 301 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
self.report_warning(
'Cannot decrypt nsig without player_url: Some formats may be missing',
video_id=video_id, only_once=True)
continue
tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 10... | ```suggestion
and _PoTokenContext.GVS in self._get_default_ytcfg(client_name)['PO_TOKEN_REQUIRED_CONTEXTS']
``` | video_id=video_id, only_once=True)
continue
tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1000)
format_duration = traverse_obj(fmt, ('approxDurationMs', {float_or_none(scale=1000)}))
# Some formats may have much ... | @@ -4227,13 +4319,17 @@ def build_fragments(f):
f'{video_id}: Some formats are possibly damaged. They will be deprioritized', only_once=True)
client_name = fmt[STREAMING_DATA_CLIENT_NAME]
- po_token = fmt.get(STREAMING_DATA_PO_TOKEN)
+ po_token = fmt.get(STREAMI... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 129 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
skip_manifests = set(self._configuration_arg('skip'))
if (not self.get_param('youtube_include_hls_manifest', True)
or needs_live_processing == 'is_live' # These will be filtered out by YoutubeDL anyway
or (needs_live_processing and skip_bad_formats)):
skip_m... | ```suggestion
if not po_token and _PoTokenContext.GVS in self._get_default_ytcfg(client_name)['PO_TOKEN_REQUIRED_CONTEXTS'] and proto != 'hls':
``` | if (not self.get_param('youtube_include_hls_manifest', True)
or needs_live_processing == 'is_live' # These will be filtered out by YoutubeDL anyway
or (needs_live_processing and skip_bad_formats)):
skip_manifests.add('hls')
if not self.get_param('youtube_inc... | @@ -4322,7 +4418,7 @@ def process_manifest_format(f, proto, client_name, itag, po_token):
# Clients that require PO Token return videoplayback URLs that may return 403
# hls does not currently require PO Token
- if (not po_token and self._get_default_ytcfg(client_name).get('REQUIR... | yt_dlp/extractor/youtube.py | 26 | Python | 0.714 | suggestion | 161 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
phantomjs_hint = ''
if isinstance(e, JSInterpreter.Exception):
phantomjs_hint = (f' Install {self._downloader._format_err("PhantomJS", self._downloader.Styles.EMPHASIS)} '
f'to workaround the issue. {Phanto... | I'm a bit confused how we are adding the framework for a PO token fetcher but then we only use the initial PO token in the actual formats code | phantomjs_hint = (f' Install {self._downloader._format_err("PhantomJS", self._downloader.Styles.EMPHASIS)} '
f'to workaround the issue. {PhantomJSwrapper.INSTALL_HINT}\n')
if player_url:
self.report_war... | @@ -4227,13 +4319,17 @@ def build_fragments(f):
f'{video_id}: Some formats are possibly damaged. They will be deprioritized', only_once=True)
client_name = fmt[STREAMING_DATA_CLIENT_NAME]
- po_token = fmt.get(STREAMING_DATA_PO_TOKEN)
+ po_token = fmt.get(STREAMI... | yt_dlp/extractor/youtube.py | 26 | Python | 0.429 | style | 142 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
for token_str in po_token_strs:
po_token_meta, sep, po_token = token_str.partition('+')
if not sep:
self.report_warning(f'Invalid po_token configuration format. Expected "CLIENT.CONTEXT+PO_TOKEN", got "{token_str}"', only_once=True)
continue
p... | should be more explicit with what we catch. `UnicodeDecodeError`? what else? | for token_str in po_token_strs:
po_token_meta, sep, po_token = token_str.partition('+')
if not sep:
self.report_warning(
f'Invalid po_token configuration format. '
f'Expected "CLIENT.CONTEXT+PO_TOKEN", got "{token_str}"', only_once=... | @@ -3837,53 +3845,112 @@ def _generate_player_context(cls, sts=None):
**cls._get_checkok_params(),
}
- def _get_config_po_token(self, client):
+ def _get_config_po_token(self, client: str, context: _PoTokenContext):
po_token_strs = self._configuration_arg('po_token', [], ie_key=Yo... | yt_dlp/extractor/youtube.py | 26 | Python | 0.571 | question | 76 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
return itertools.islice(_real_comment_extract(contents), 0, max_comments)
@staticmethod
def _get_checkok_params():
return {'contentCheckOk': True, 'racyCheckOk': True}
@classmethod
def _generate_player_context(cls, sts=None):
context = {
'html5Preference': 'HTML5_PR... | the long line hurts me
```suggestion
self.report_warning(
'Invalid po_token configuration format. Expected '
f'"CLIENT.CONTEXT+PO_TOKEN", got "{token_str}"', only_once=True)
``` | return itertools.islice(_real_comment_extract(contents), 0, max_comments)
@staticmethod
def _get_checkok_params():
return {'contentCheckOk': True, 'racyCheckOk': True}
@classmethod
def _generate_player_context(cls, sts=None):
context = {
'html5Preference': 'HTML5_PR... | @@ -3837,53 +3845,112 @@ def _generate_player_context(cls, sts=None):
**cls._get_checkok_params(),
}
- def _get_config_po_token(self, client):
+ def _get_config_po_token(self, client: str, context: _PoTokenContext):
po_token_strs = self._configuration_arg('po_token', [], ie_key=Yo... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 238 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
if po_token_context.lower() != context.value:
continue
# Clean and validate the PO Token. This will strip invalid characters off
# (e.g. additional url params the user may accidentally include)
try:
return base64.urlsafe_b64encode(base64.... | do we want to stick to our formatting guidelines?
```suggestion
def fetch_po_token(self, client='web', context=_PoTokenContext.GVS, ytcfg=None, visitor_data=None,
data_sync_id=None, session_index=None, player_url=None, video_id=None, **kwargs):
``` | only_once=True)
po_token_context = _PoTokenContext.GVS.value
if po_token_context.lower() != context.value:
continue
# Clean and validate the PO Token. This will strip invalid characters off
# (e.g. additional url params the user m... | @@ -3837,53 +3845,112 @@ def _generate_player_context(cls, sts=None):
**cls._get_checkok_params(),
}
- def _get_config_po_token(self, client):
+ def _get_config_po_token(self, client: str, context: _PoTokenContext):
po_token_strs = self._configuration_arg('po_token', [], ie_key=Yo... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | question | 279 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
player_url = None
if not player_url and not tried_iframe_fallback and require_js_player:
player_url = self._download_player_url(video_id)
tried_iframe_fallback = True
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial... | didn't like the idea of putting `self._get_default_ytcfg(client)['PO_TOKEN_REQUIRED_CONTEXTS']` in a var? | data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
fetch_po_token_args = {
'client': client,
'visitor_data': visitor_data,
'video_id': video_id,
'data_sync_id': data_sync_id if self.is... | @@ -4031,17 +4098,43 @@ def append_client(*client_names):
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
- po_token = self.fetch_po_... | yt_dlp/extractor/youtube.py | 26 | Python | 0.5 | question | 105 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
skip_manifests = set(self._configuration_arg('skip'))
if (not self.get_param('youtube_include_hls_manifest', True)
or needs_live_processing == 'is_live' # These will be filtered out by YoutubeDL anyway
or (needs_live_processing and skip_bad_formats)):
skip_m... | just curious why we need the parentheses. is it a ruff thing? it's just `if x and y and z` right? | self._downloader.deprecated_feature('[youtube] include_incomplete_formats extractor argument is deprecated. '
'Use formats=incomplete extractor argument instead')
skip_manifests = set(self._configuration_arg('skip'))
if (not self.get_param('yo... | @@ -4322,7 +4414,7 @@ def process_manifest_format(f, proto, client_name, itag, po_token):
# Clients that require PO Token return videoplayback URLs that may return 403
# hls does not currently require PO Token
- if (not po_token and self._get_default_ytcfg(client_name).get('REQUIR... | yt_dlp/extractor/youtube.py | 26 | Python | 0.357 | question | 97 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
player_url = self._download_player_url(video_id)
tried_iframe_fallback = True
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, pla... | I meant doing something like this, cuz we can reuse `required_contexts` below and make things more readable
```suggestion
required_contexts = self._get_default_ytcfg(client)['PO_TOKEN_REQUIRED_CONTEXTS']
if not player_po_token and _PoTokenContext.PLAYER in required_contexts:
``` | player_url = self._download_player_url(video_id)
tried_iframe_fallback = True
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, pla... | @@ -4031,17 +4091,45 @@ def append_client(*client_names):
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
- po_token = self.fetch_po_... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | suggestion | 309 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
'ytcfg': player_ytcfg,
}
player_po_token = self.fetch_po_token(
context=_PoTokenContext.PLAYER, **fetch_po_token_args)
gvs_po_token = self.fetch_po_token(
context=_PoTokenContext.GVS, **fetch_po_token_args)
if (
... | see above comment
```suggestion
if (
not gvs_po_token
and _PoTokenContext.GVS in required_contexts
and 'missing_pot' in self._configuration_arg('formats')
):
``` | 'ytcfg': player_ytcfg,
}
player_po_token = self.fetch_po_token(
context=_PoTokenContext.PLAYER, **fetch_po_token_args)
gvs_po_token = self.fetch_po_token(
context=_PoTokenContext.GVS, **fetch_po_token_args)
required_pot_c... | @@ -4031,17 +4091,45 @@ def append_client(*client_names):
visitor_data = visitor_data or self._extract_visitor_data(master_ytcfg, initial_pr, player_ytcfg)
data_sync_id = data_sync_id or self._extract_data_sync_id(master_ytcfg, initial_pr, player_ytcfg)
- po_token = self.fetch_po_... | yt_dlp/extractor/youtube.py | 26 | Python | 0.786 | suggestion | 240 | 51 | 51 | false | [ie/youtube] Use different PO token for GVS and Player | 12,090 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | coletdjnz |
self._test('function f(){return "012345678".slice(0, 0)}', '')
self._test('function f(){return "012345678".slice(1, 0)}', '')
self._test('function f(){return "012345678".slice(0, 1)}', '0')
self._test('function f(){return "012345678".slice(3, 6)}', '345')
self._test('function f()... | very important code review suggestion
```suggestion
# (1000000000000000128, 10, '1000000000000000100')
``` | self._test('function f(){return "012345678".slice(0, 0)}', '')
self._test('function f(){return "012345678".slice(1, 0)}', '')
self._test('function f(){return "012345678".slice(0, 1)}', '0')
self._test('function f(){return "012345678".slice(3, 6)}', '345')
self._test('function f()... | @@ -431,6 +431,27 @@ def test_slice(self):
self._test('function f(){return "012345678".slice(-1, 1)}', '')
self._test('function f(){return "012345678".slice(-3, -1)}', '67')
+ def test_js_number_to_string(self):
+ for test, radix, expected in [
+ (0, None, '0'),
+ (-0... | test/test_jsinterp.py | 26 | Python | 0.714 | suggestion | 121 | 33 | 33 | false | [jsinterp] Add `js_number_to_string` | 12,110 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Grub4K |
result = collections.deque()
sign = val < 0
val = abs(val)
fraction, integer = math.modf(val)
delta = max(math.nextafter(.0, math.inf), math.ulp(val) / 2)
if fraction >= delta:
result.append(-2)
while fraction >= delta:
delta *= radix
fraction, digit = math.modf(fra... | maybe expand on why this is needed in the comment... we can already see that it's cringe |
result = collections.deque()
sign = val < 0
val = abs(val)
fraction, integer = math.modf(val)
delta = max(math.nextafter(.0, math.inf), math.ulp(val) / 2)
if fraction >= delta:
result.append(-2) # `.`
while fraction >= delta:
delta *= radix
fraction, digit = math.m... | @@ -95,6 +95,62 @@ def _js_ternary(cndn, if_true=True, if_false=False):
return if_true
+# Ref: https://es5.github.io/#x9.8.1
+def js_number_to_string(val: float, radix: int = 10):
+ if radix in (JS_Undefined, None):
+ radix = 10
+ assert radix in range(2, 37), 'radix must be an integer at least 2 ... | yt_dlp/jsinterp.py | 26 | Python | 0.214 | suggestion | 88 | 51 | 51 | false | [jsinterp] Add `js_number_to_string` | 12,110 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Grub4K |
if math.isnan(val):
return 'NaN'
if val == 0:
return '0'
if math.isinf(val):
return '-Infinity' if val < 0 else 'Infinity'
if radix == 10:
# TODO: implement special cases
...
ALPHABET = b'0123456789abcdefghijklmnopqrstuvwxyz.-'
result = collections.dequ... | ```suggestion
# if we need to round, propagate potential carry through fractional part
``` |
if math.isnan(val):
return 'NaN'
if val == 0:
return '0'
if math.isinf(val):
return '-Infinity' if val < 0 else 'Infinity'
if radix == 10:
# TODO: implement special cases
...
ALPHABET = b'0123456789abcdefghijklmnopqrstuvwxyz.-'
result = collections.dequ... | @@ -95,6 +95,62 @@ def _js_ternary(cndn, if_true=True, if_false=False):
return if_true
+# Ref: https://es5.github.io/#x9.8.1
+def js_number_to_string(val: float, radix: int = 10):
+ if radix in (JS_Undefined, None):
+ radix = 10
+ assert radix in range(2, 37), 'radix must be an integer at least 2 ... | yt_dlp/jsinterp.py | 26 | Python | 0.714 | suggestion | 100 | 51 | 51 | false | [jsinterp] Add `js_number_to_string` | 12,110 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | Grub4K |
result = collections.deque()
sign = val < 0
val = abs(val)
fraction, integer = math.modf(val)
delta = max(math.nextafter(.0, math.inf), math.ulp(val) / 2)
if fraction >= delta:
result.append(-2)
while fraction >= delta:
delta *= radix
fraction, digit = math.modf(fra... | ```suggestion
else:
integer += 1
break
``` |
result = collections.deque()
sign = val < 0
val = abs(val)
fraction, integer = math.modf(val)
delta = max(math.nextafter(.0, math.inf), math.ulp(val) / 2)
if fraction >= delta:
result.append(-2) # `.`
while fraction >= delta:
delta *= radix
fraction, digit = math.m... | @@ -95,6 +95,62 @@ def _js_ternary(cndn, if_true=True, if_false=False):
return if_true
+# Ref: https://es5.github.io/#x9.8.1
+def js_number_to_string(val: float, radix: int = 10):
+ if radix in (JS_Undefined, None):
+ radix = 10
+ assert radix in range(2, 37), 'radix must be an integer at least 2 ... | yt_dlp/jsinterp.py | 26 | Python | 0.571 | suggestion | 86 | 51 | 51 | false | [jsinterp] Add `js_number_to_string` | 12,110 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | Grub4K |
for tt in (request.get('text_tracks') or []):
subtitles.setdefault(tt['lang'], []).append({
'ext': 'vtt',
'url': urljoin('https://vimeo.com', tt['url']),
})
thumbnails = []
if not is_live:
for key, thumb in (video_data.get('thu... | I'd replace this block and the `video_data.get('thumbnail')` block above with the single line below:
```py
thumbnails.extend(traverse_obj(video_data, (('thumbnail', 'thumbnail_url'), {'url': {url_or_none}})))
``` |
for tt in (request.get('text_tracks') or []):
subtitles.setdefault(tt['lang'], []).append({
'ext': 'vtt',
'url': urljoin('https://vimeo.com', tt['url']),
})
thumbnails = []
if not is_live:
for key, thumb in (video_data.get('th... | @@ -217,6 +217,12 @@ def _parse_config(self, config, video_id):
'url': thumbnail,
})
+ thumbnail = video_data.get('thumbnail_url')
+ if thumbnail:
+ thumbnails.append({
+ 'url': thumbnail,
+ })
+ | yt_dlp/extractor/vimeo.py | 26 | Python | 0.857 | suggestion | 226 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'quality': 10,
})
for tt in (request.get('text_tracks') or []):
subtitles.setdefault(tt['lang'], []).append({
'ext': 'vtt',
'url': urljoin('https://vimeo.com', tt['url']),
})
thumbnails = []
if not is_live:
... | revert, this code still works for me
```suggestion
'uploader_id': video_uploader_url.split('/')[-1] if video_uploader_url else None,
'uploader_url': video_uploader_url,
``` | 'quality': 10,
})
for tt in (request.get('text_tracks') or []):
subtitles.setdefault(tt['lang'], []).append({
'ext': 'vtt',
'url': urljoin('https://vimeo.com', tt['url']),
})
thumbnails = []
if not is_live:
... | @@ -211,21 +212,15 @@ def _parse_config(self, config, video_id):
'width': int_or_none(key),
'url': thumb,
})
- thumbnail = video_data.get('thumbnail')
- if thumbnail:
- thumbnails.append({
- 'url': thumbna... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.786 | suggestion | 200 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'id': '56015672',
'ext': 'mp4',
'title': "youtube-dl test video '' ä↭𝕐-BaW jenozKc",
'description': 'md5:2d3305bad981a06ff79f027f19865021',
'timestamp': 1355990239,
'upload_date': '20121220',
'uploader_id': ... | revert
```suggestion
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
'uploader_id': 'businessofsoftware',
``` | 'md5': '8879b6cc097e987f02484baf890129e5',
'info_dict': {
'id': '56015672',
'ext': 'mp4',
'title': "youtube-dl test video '' ä↭𝕐-BaW jenozKc",
'description': 'md5:2d3305bad981a06ff79f027f19865021',
'timestamp': 1355... | @@ -385,10 +379,9 @@ class VimeoIE(VimeoBaseInfoExtractor):
'ext': 'mp4',
'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
'uploader': 'Business of Software',
- 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/busin... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.714 | suggestion | 169 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'id': '54469442',
'ext': 'mp4',
'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
'uploader': 'Business of Software',
'uploader_id': 14755329,
'duration': 3610,
'thumbnail'... | revert
```suggestion
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
'uploader_id': 'user18948128',
``` | 'md5': '619b811a4417aa4abe78dc653becf511',
'note': 'Videos that embed the url in the player page',
'info_dict': {
'id': '54469442',
'ext': 'mp4',
'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
... | @@ -407,13 +400,13 @@ class VimeoIE(VimeoBaseInfoExtractor):
'upload_date': '20130614',
'release_timestamp': 1371214555,
'release_date': '20130614',
- 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
- 'uploader_id': 'user... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.786 | suggestion | 157 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'upload_date': '20130614',
'release_timestamp': 1371214555,
'release_date': '20130614',
'uploader_id': 18948128,
'uploader': 'Jaime Marquínez Ferrándiz',
'duration': 10,
'comment_count': int,
... | partially revert
```suggestion
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio',
'uploader_id': 'atencio',
``` | 'id': '68375962',
'ext': 'mp4',
'title': 'youtube-dl password protected test video',
'timestamp': 1371214555,
'upload_date': '20130614',
'release_timestamp': 1371214555,
'release_date': '20130614',
... | @@ -428,16 +421,15 @@ class VimeoIE(VimeoBaseInfoExtractor):
'id': '75629013',
'ext': 'mp4',
'title': 'Key & Peele: Terrorist Interrogation',
- 'description': 'md5:6173f270cd0c0119f22817204b3eb86c',
- 'uploader_url': r're:https?://(?:www\.... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.714 | suggestion | 157 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'channel_id': 'keypeele',
'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
'timestamp': 1380339469,
'upload_date': '20130928',
'duration': 187,
'thumbnail': 'https://i.vimeocdn.com/video/450239872-a05512... | revert
```suggestion
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
'uploader_id': 'staff',
``` | 'title': 'Key & Peele: Terrorist Interrogation',
'description': 'md5:6173f270cd0c0119f22817204b3eb86c',
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio',
'uploader_id': 'atencio',
'uploader': 'Peter Atencio',
'cha... | @@ -457,13 +449,12 @@ class VimeoIE(VimeoBaseInfoExtractor):
'upload_date': '20131015',
'release_timestamp': 1381860509,
'release_date': '20131015',
- 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
- 'uploader_id': 'staff',
+ ... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.714 | suggestion | 143 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'duration': 62,
'comment_count': int,
'like_count': int,
'thumbnail': 'https://i.vimeocdn.com/video/452001751-8216e0571c251a09d7a8387550942d89f7f86f6398f8ed886e639b0dd50d3c90-d',
'subtitles': {
'de': 'count:3',
... | ```suggestion
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
'uploader_id': 'user28849593',
``` | 'upload_date': '20131015',
'release_timestamp': 1381860509,
'release_date': '20131015',
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
'uploader_id': 'staff',
'uploader': 'Vimeo',
'duration': 62,
... | @@ -485,54 +476,51 @@ class VimeoIE(VimeoBaseInfoExtractor):
'ext': 'mp4',
'title': 'Pier Solar OUYA Official Trailer',
'uploader': 'Tulio Gonçalves',
- 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
- 'uploader_id': 'us... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.786 | suggestion | 149 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
],
},
{
# from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
'url': 'https://player.vimeo.com/video/98044508',
'note': 'The js code contains assignments to the same variable as the config',
'info_dict': {
'id': '... | ```suggestion
'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci',
'uploader_id': 'dmci',
``` | 'fr': 'count:3',
},
},
'expected_warnings': [
'Ignoring subtitle tracks found in the HLS manifest',
'Failed to parse XML: not well-formed',
],
},
{
# from https://www.ouya.tv/game/Pier-Sol... | @@ -485,54 +476,51 @@ class VimeoIE(VimeoBaseInfoExtractor):
'ext': 'mp4',
'title': 'Pier Solar OUYA Official Trailer',
'uploader': 'Tulio Gonçalves',
- 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
- 'uploader_id': 'us... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.714 | suggestion | 133 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'ext': 'mp4',
'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
'uploader': 'The DMCI',
'uploader_id': 4719020,
'timestamp': 1324361742,
'upload_date': '20111220',
'release_date': '20111220',
... | ```suggestion
'uploader_id': 'frameworkla',
``` | 'expected_warnings': ['Failed to parse XML: not well-formed'],
},
{
# contains Original format
'url': 'https://vimeo.com/33951933',
# 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
'info_dict': {
'id': '33951933',
'e... | @@ -485,54 +476,51 @@ class VimeoIE(VimeoBaseInfoExtractor):
'ext': 'mp4',
'title': 'Pier Solar OUYA Official Trailer',
'uploader': 'Tulio Gonçalves',
- 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
- 'uploader_id': 'us... | yt_dlp/extractor/vimeo.py | 26 | Python | 0.571 | suggestion | 65 | 51 | 51 | false | [ie/vimeo] update thumbnail extraction logic (#11931) | 12,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jixunmoe |
'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', {str}),
'abr': ('audioBitrate', {int_or_none(scale=1000)}),
'vbr': ('videoBitrate', {int_or_no... | ```suggestion
'filesize': int_or_none(urlh.get_header('Content-Length')),
``` | 'width': ('width', {int_or_none}),
'height': ('height', {int_or_none}),
'vcodec': ('videoCodec', {str}),
'acodec': ('audioCodec', {str}),
'abr': ('audioBitrate', {int_or_none(scale=1000)}),
'vbr': ('videoBitrate', {int_or_no... | @@ -68,6 +69,20 @@ def _real_extract(self, url):
formats.extend(traverse_obj(info, (('mediaUrl', ('backupUrls', ...)), {
lambda u: url_or_none(u) and {'url': u, **format_info}})))
+ if origin_key := traverse_obj(note_info, ('video', 'consumer', 'originVideoKey', {str})):
+ ... | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.571 | suggestion | 99 | 51 | 51 | false | [ie/XiaoHongShu] Extract more formats | 12,147 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = traverse_obj(initial_state, ('note', 'noteDe... | This should be `masterUrl`, instead; `mediaUrl` doesn't exist afaik (https://github.com/yt-dlp/yt-dlp/issues/9529#issuecomment-2041337087).
```suggestion
formats.extend(traverse_obj(info, (('masterUrl', ('backupUrls', ...)), {
``` | display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
initial_state = self._search_json(
r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', display_id, transform_source=js_to_json)
note_info = traverse_obj(initial_state, ('note', 'noteDe... | @@ -68,6 +69,20 @@ def _real_extract(self, url):
formats.extend(traverse_obj(info, (('mediaUrl', ('backupUrls', ...)), { | yt_dlp/extractor/xiaohongshu.py | 26 | Python | 0.857 | suggestion | 245 | 51 | 51 | false | [ie/XiaoHongShu] Extract more formats | 12,147 | yt-dlp/yt-dlp | 132,642 | Python | DTrombett | seproDev |
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
str_or_none,
traverse_obj,
)
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
_VALID_URL = r'https?://goodgame\.ru/(?P<id>\w+)'
_TESTS = [{
'url': 'https://goodgame.ru/Pomi#autoplay',
... | As the old URLs still work, let's also match them
```suggestion
_VALID_URL = r'https?://goodgame\.ru/(?:channel/)?(?P<id>\w+)'
``` | from .common import InfoExtractor
from ..utils import (
int_or_none,
str_or_none,
traverse_obj,
url_or_none,
)
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
_VALID_URL = r'https?://goodgame\.ru/(?!channel/)(?P<id>[\w.*-]+)'
_TESTS = [{
'url': 'https://goodgame.ru/TGW... | @@ -9,16 +9,16 @@
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
- _VALID_URL = r'https?://goodgame\.ru/channel/(?P<id>\w+)'
+ _VALID_URL = r'https?://goodgame\.ru/(?P<id>\w+)' | yt_dlp/extractor/goodgame.py | 12 | Python | 0.714 | suggestion | 137 | 37 | 37 | false | [ie/GoodGame] Fix extractor | 12,173 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | NecroRomnt |
'channel': 'Pomi',
'channel_url': 'https://goodgame.ru/Pomi',
'description': 'md5:4a87b775ee7b2b57bdccebe285bbe171',
'thumbnail': r're:^https?://.*\.jpg$',
'live_status': 'is_live',
'view_count': int,
},
'params': {'skip_download': ... | Imo. the extra request for the description is not worth it. Arguably, this is also more the channel's about page than an actual description.
```suggestion
``` | 'channel_url': 'https://goodgame.ru/TGW',
'thumbnail': 'https://hls.goodgame.ru/previews/7998_240.jpg',
'uploader': 'TGW',
'channel': 'JosephStalin',
'live_status': 'is_live',
'age_limit': 18,
'channel_follower_count': int,
... | @@ -30,28 +30,30 @@ class GoodGameIE(InfoExtractor):
def _real_extract(self, url):
channel_name = self._match_id(url)
- response = self._download_json(f'https://api2.goodgame.ru/v2/streams/{channel_name}', channel_name)
- player_id = response['channel']['gg_player_src']
+ response =... | yt_dlp/extractor/goodgame.py | 26 | Python | 0.714 | suggestion | 160 | 41 | 51 | false | [ie/GoodGame] Fix extractor | 12,173 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | NecroRomnt |
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
str_or_none,
traverse_obj,
)
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
_VALID_URL = r'https?://goodgame\.ru/(?:channel/)?(?P<id>[\w.*-]+)'
_TESTS = [{
'url': 'https://goodgame.ru/Pom... | Okay, my bad we actually need to follow the redirects as channels can differ from the user
```suggestion
_VALID_URL = r'https?://goodgame\.ru/(?P<id>[\w.*-]+)'
```
`https://goodgame.ru/channel/JosephStalin` -> `https://goodgame.ru/TGW` | from .common import InfoExtractor
from ..utils import (
int_or_none,
str_or_none,
traverse_obj,
url_or_none,
)
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
_VALID_URL = r'https?://goodgame\.ru/(?!channel/)(?P<id>[\w.*-]+)'
_TESTS = [{
'url': 'https://goodgame.ru/TGW... | @@ -9,16 +9,16 @@
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
- _VALID_URL = r'https?://goodgame\.ru/channel/(?P<id>\w+)'
+ _VALID_URL = r'https?://goodgame\.ru/(?:channel/)?(?P<id>[\w.*-]+)' | yt_dlp/extractor/goodgame.py | 12 | Python | 0.857 | suggestion | 243 | 37 | 37 | false | [ie/GoodGame] Fix extractor | 12,173 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | NecroRomnt |
response = self._download_json(f'https://goodgame.ru/api/4/users/{channel_name}/stream', channel_name)
player_id = response['streamkey']
formats, subtitles = [], {}
if response.get('status'):
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
f'ht... | Let's write it like so, to simplify some calls and check more types:
```py
'is_live': bool(formats),
**traverse_obj(response, {
'title': ('title', {str}),
'channel': ('channelkey', {str}),
'channel_id': ('id', {str_or_none}),
... | 'only_matching': True,
}, {
'url': 'https://goodgame.ru/HeDoPa3yMeHue*',
'only_matching': True,
}]
def _real_extract(self, url):
channel_name = self._match_id(url)
response = self._download_json(f'https://goodgame.ru/api/4/users/{channel_name}/stream', channel_name)
... | @@ -30,28 +30,30 @@ class GoodGameIE(InfoExtractor):
def _real_extract(self, url):
channel_name = self._match_id(url)
- response = self._download_json(f'https://api2.goodgame.ru/v2/streams/{channel_name}', channel_name)
- player_id = response['channel']['gg_player_src']
+ response =... | yt_dlp/extractor/goodgame.py | 26 | Python | 1 | security | 954 | 28 | 38 | false | [ie/GoodGame] Fix extractor | 12,173 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | NecroRomnt |
)
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
_VALID_URL = r'https?://goodgame\.ru/(?:channel/)?(?P<id>[\w.*-]+)'
_TESTS = [{
'url': 'https://goodgame.ru/TGW#autoplay',
'info_dict': {
'id': '7998',
'ext': 'mp4',
'channel_id': '7998',
... | can we also have one of these in the matching tests
```suggestion
'url': 'https://goodgame.ru/channel/Mr.Gray',
``` | )
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
_VALID_URL = r'https?://goodgame\.ru/(?!channel/)(?P<id>[\w.*-]+)'
_TESTS = [{
'url': 'https://goodgame.ru/TGW#autoplay',
'info_dict': {
'id': '7998',
'ext': 'mp4',
'channel_id': '7998',
... | @@ -1,40 +1,48 @@
from .common import InfoExtractor
from ..utils import (
- clean_html,
int_or_none,
str_or_none,
traverse_obj,
+ url_or_none,
)
class GoodGameIE(InfoExtractor):
IE_NAME = 'goodgame:stream'
- _VALID_URL = r'https?://goodgame\.ru/channel/(?P<id>\w+)'
+ _VALID_URL =... | yt_dlp/extractor/goodgame.py | 26 | Python | 0.714 | suggestion | 126 | 51 | 51 | false | [ie/GoodGame] Fix extractor | 12,173 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | NecroRomnt |
manifest = call_playback_api('manifest', {'preferredCdn': 'akamai'})
video_id = try_get(manifest, lambda x: x['id'], str) or video_id
if manifest.get('playability') == 'nonPlayable':
self._raise_error(manifest['nonPlayable'])
playable = manifest['playable']
format... | IMO it would make more sense to do this stuff in the `_extract_nrk_formats` method (where we are already performing some URL surgery), and it could be simplified too
```diff
def _extract_nrk_formats(self, asset_url, video_id):
+ asset_url = update_url_query(asset_url, {
+ # Remove 'adap' to... | return self._call_api(f'playback/{item}/program/{video_id}', video_id, item, query=query)
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status == 400:
return self._call_api(f'playback/{item}/{video_id}', video_id, item, query=qu... | @@ -172,10 +182,13 @@ def call_playback_api(item, query=None):
format_url = url_or_none(asset.get('url'))
if not format_url:
continue
- # Remove the 'adap' query parameter
- format_url = update_url_query(format_url, {'adap': []})
asset_format... | yt_dlp/extractor/nrk.py | 26 | Python | 0.857 | refactor | 1,314 | 51 | 51 | false | [ie/nrk] Fix invalid HDR chunks returned | 12,193 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hexahigh |
asset_url = re.sub(r'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url)
formats = self._extract_m3u8_formats(
asset_url, video_id, 'mp4', 'm3u8_native', fatal=False)
if not formats and re.search(self._CDN_REPL_REGEX, asset_url):
formats = self._extract_m3u8_formats(... | if every API call is currently using the new header then we don't need to add a param
```suggestion
def _call_api(self, path, video_id, item=None, note=None, fatal=True, query=None):
``` | 'adap': [],
# Disable subtitles since they are fetched separately
's': 0,
})
if re.match(r'https?://[^/]+\.akamaihd\.net/i/', asset_url):
return self._extract_akamai_formats(asset_url, video_id)
asset_url = re.sub(r'(?:bw_(?:low|high)=\d+|no_audio_... | @@ -55,11 +55,13 @@ def _raise_error(self, data):
message = data.get('endUserMessage') or MESSAGES.get(message_type, message_type)
raise ExtractorError(f'{self.IE_NAME} said: {message}', expected=True)
- def _call_api(self, path, video_id, item=None, note=None, fatal=True, query=None):
+ def _... | yt_dlp/extractor/nrk.py | 26 | Python | 0.714 | suggestion | 193 | 51 | 51 | false | [ie/nrk] Fix invalid HDR chunks returned | 12,193 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hexahigh |
video_id, 'mp4', 'm3u8_native', fatal=False)
return formats
def _raise_error(self, data):
MESSAGES = {
'ProgramRightsAreNotReady': 'Du kan dessverre ikke se eller høre programmet',
'ProgramRightsHasExpired': 'Programmet har gått ut',
'NoProgramRig... | ```suggestion
fatal=fatal, query=query, headers={
# Needed for working stream URLs, see https://github.com/yt-dlp/yt-dlp/issues/12192
'Accept': 'application/vnd.nrk.psapi+json; version=9; player=tv-player; device=player-core',
})
``` | asset_url = re.sub(r'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url)
formats = self._extract_m3u8_formats(
asset_url, video_id, 'mp4', 'm3u8_native', fatal=False)
if not formats and re.search(self._CDN_REPL_REGEX, asset_url):
formats = self._extract_m3u8_formats(... | @@ -55,11 +55,13 @@ def _raise_error(self, data):
message = data.get('endUserMessage') or MESSAGES.get(message_type, message_type)
raise ExtractorError(f'{self.IE_NAME} said: {message}', expected=True)
- def _call_api(self, path, video_id, item=None, note=None, fatal=True, query=None):
+ def _... | yt_dlp/extractor/nrk.py | 26 | Python | 0.786 | suggestion | 294 | 51 | 51 | false | [ie/nrk] Fix invalid HDR chunks returned | 12,193 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hexahigh |
data = self._download_json(
f'https://images.cwtv.com/feed/app-2/video-meta/apiversion_22/device_web/guid_{video_id}', video_id)
if data.get('result') != 'ok':
raise ExtractorError(data['msg'], expected=True)
video_data = data['video']
title = video_data['title']
... | don't remove dead tests, add `skip` to the test dict with a reason why they are being skipped (e.g. "expired", "redirects to homepage", etc) | 'upload_date': '20151203',
'timestamp': 1449122100,
},
'params': {
# m3u8 download
'skip_download': True,
},
'skip': 'redirect to http://cwtv.com/shows/arrow/',
}, {
'url': 'http://www.cwseed.com/shows/whose-line-is-it-anyway/je... | @@ -13,68 +13,24 @@
class CWTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?cw(?:tv(?:pr)?|seed)\.com/(?:shows/)?(?:[^/]+/)+[^?]*\?.*\b(?:play|watch)=(?P<id>[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})'
_TESTS = [{
- 'url': 'https://www.cwtv.com/shows/all-american-homecoming/re... | yt_dlp/extractor/cwtv.py | 26 | Python | 0.571 | suggestion | 140 | 31 | 51 | false | [ie/cwtv] Fix extractor | 12,207 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | arantius |
'episode': title,
'episode_number': int_or_none(episode.get('episode')),
}
info.update(show_info)
return info
def _extract_show_info(self, show):
return {
'creator': show.get('author'),
'series': show.get('title'),
}
def _... | I know this is old code, but I'm always gonna fix it when I see it
```suggestion
(?P<channel>[^/?#]+)/(?:episodes/)?(?P<id>[^/#?"]+)
``` | 'episode': title,
'episode_number': int_or_none(episode.get('episode')),
}
info.update(show_info)
return info
def _extract_show_info(self, show):
return {
'creator': show.get('author'),
'series': show.get('title'),
}
def _... | @@ -43,14 +43,14 @@ class ACastIE(ACastBaseIE):
_VALID_URL = r'''(?x:
https?://
(?:
- (?:(?:embed|www)\.)?acast\.com/|
+ (?:(?:embed|www|shows)\.)?acast\.com/|
play\.acast\.com/s/
... | yt_dlp/extractor/acast.py | 26 | Python | 0.714 | suggestion | 163 | 51 | 51 | false | [ie/acast] Support shows.acast.com URLs | 12,223 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | barsnick |
'series': 'The Crush',
'season': 'Season 1',
'uploader': 'CWTV',
'season_number': 1,
'episode': 'Episode 1',
'episode_number': 1,
'thumbnail': r're:https?://.+\.jpe?g',
},
'params': {
# m3u8 download
... | ```suggestion
rf'CWTV\.Site\.viewInAppURL\s*=\s*["\']/shows/[\w-]+/watch-in-app/\?play=({self._UUID_RE})',
``` | 'series': 'The Crush',
'season': 'Season 1',
'uploader': 'CWTV',
'season_number': 1,
'episode': 'Episode 1',
'episode_number': 1,
'thumbnail': r're:https?://.+\.jpe?g',
},
'params': {
# m3u8 download
... | @@ -124,3 +131,50 @@ def _real_extract(self, url):
'ie_key': 'ThePlatform',
'thumbnail': video_data.get('large_thumbnail'),
}
+
+
+class CWTVMovieIE(InfoExtractor):
+ IE_NAME = 'cwtv:movie'
+ _VALID_URL = r'https?://(?:www\.)?cwtv\.com/shows/(?P<id>[\w-]+)/?\?(?:[^#]+&)?viewCont... | yt_dlp/extractor/cwtv.py | 26 | Python | 0.714 | suggestion | 128 | 31 | 31 | false | [ie/cwtv:movie] Add extractor | 12,227 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bashonly |
'duration': 5337,
'series': 'The Crush',
'season': 'Season 1',
'uploader': 'CWTV',
'season_number': 1,
'episode': 'Episode 1',
'episode_number': 1,
'thumbnail': r're:https?://.+\.jpe?g',
},
'params': {
... | ```suggestion
rf'CWTV\.Site\.curPlayingGUID\s*=\s*["\']({self._UUID_RE})',
``` | 'duration': 5337,
'series': 'The Crush',
'season': 'Season 1',
'uploader': 'CWTV',
'season_number': 1,
'episode': 'Episode 1',
'episode_number': 1,
'thumbnail': r're:https?://.+\.jpe?g',
},
'params': {
... | @@ -124,3 +131,50 @@ def _real_extract(self, url):
'ie_key': 'ThePlatform',
'thumbnail': video_data.get('large_thumbnail'),
}
+
+
+class CWTVMovieIE(InfoExtractor):
+ IE_NAME = 'cwtv:movie'
+ _VALID_URL = r'https?://(?:www\.)?cwtv\.com/shows/(?P<id>[\w-]+)/?\?(?:[^#]+&)?viewCont... | yt_dlp/extractor/cwtv.py | 26 | Python | 0.571 | suggestion | 96 | 32 | 32 | false | [ie/cwtv:movie] Add extractor | 12,227 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bashonly |
except xml.etree.ElementTree.ParseError:
doc = compat_etree_fromstring(webpage.encode())
if doc.tag == 'rss':
self.report_detected('RSS feed')
return self._extract_rss(url, video_id, doc)
elif doc.tag == 'SmoothStreamingMedia':
... | since we set `live_status` elsewhere in the extractor, let's use that instead of `is_live` for consistency
```suggestion
info_dict['live_status'] = 'is_live' if doc.get('type') == 'dynamic' else None
``` | webpage = self._webpage_read_content(
full_response, url, video_id, prefix=first_bytes)
if '<title>DPG Media Privacy Gate</title>' in webpage:
webpage = self._download_webpage(url, video_id)
self.report_extraction(video_id)
# Is it an RSS feed, a SMIL file, an ... | @@ -2521,6 +2521,7 @@ def _real_extract(self, url):
doc,
mpd_base_url=full_response.url.rpartition('/')[0],
mpd_url=url)
+ info_dict['is_live'] = doc.get('type') == 'dynamic' | yt_dlp/extractor/generic.py | 26 | Python | 1 | refactor | 222 | 51 | 51 | false | [ie/generic] Extract `live_status` for DASH manifest URLs | 12,256 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | mp3butcher |
'player_type': 'mirakulo_8k_hdr',
'video_id': video_id,
'quality': 'max',
'content_protection': 'widevine',
'vsid': f'{uuid.uuid4()}',
'consumption': 'streaming',
'capabilities': {'low_latency': True},
... | unfamiliar with the project – should I update `_TESTS` above to cover this?
| 'x-device-id': 'desktop',
'x-client-version': '2024.12-5',
})['data']['video']
formats = []
video = self._download_json(
'https://playback.video.globo.com/v4/video-session', video_id,
f'Downloading resource info for {video_id}',
... | @@ -137,8 +137,8 @@ def _real_extract(self, url):
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
main_source['url'], video_id, 'mp4', m3u8_id='hls')
self._merge_subtitles(traverse_obj(main_source, ('text', ..., {
- 'url': ('subtitle', 'srt', 'url', {url_... | yt_dlp/extractor/globo.py | 26 | Python | 0.429 | question | 77 | 51 | 51 | false | [ie/globo] Fix subtitles extraction | 12,270 | yt-dlp/yt-dlp | 132,642 | Python | pedro | pedro |
data=json.dumps(filter_dict({
'player_type': 'mirakulo_8k_hdr',
'video_id': video_id,
'quality': 'max',
'content_protection': 'widevine',
'vsid': f'{uuid.uuid4()}',
'consumption': 'streaming',
'ca... | should we branch and try for both?
```suggestion
self._merge_subtitles(traverse_obj(main_source, ('text', ..., ('caption', 'subtitle'), {
``` | 'x-platform-id': 'web',
'x-device-id': 'desktop',
'x-client-version': '2024.12-5',
})['data']['video']
formats = []
video = self._download_json(
'https://playback.video.globo.com/v4/video-session', video_id,
f'Downloadi... | @@ -137,8 +137,8 @@ def _real_extract(self, url):
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
main_source['url'], video_id, 'mp4', m3u8_id='hls')
self._merge_subtitles(traverse_obj(main_source, ('text', ..., { | yt_dlp/extractor/globo.py | 26 | Python | 0.786 | question | 152 | 51 | 51 | false | [ie/globo] Fix subtitles extraction | 12,270 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pedro |
import json
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
class TVWIE(InfoExtractor):
BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
_VALID_URL = r'https?://(?:www\.)?tvw... | ```suggestion
class TvwIE(InfoExtractor):
``` | import json
from .common import InfoExtractor
from ..utils import clean_html, remove_end, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class TvwIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://tvw.org/video/... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor): | yt_dlp/extractor/tvw.py | 8 | Python | 0.5 | refactor | 47 | 33 | 33 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
import json
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
class TVWIE(InfoExtractor):
BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
_VALID_URL = r'https?://(?:www\.)?tvw... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
``` | import json
from .common import InfoExtractor
from ..utils import clean_html, remove_end, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class TvwIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://tvw.org/video/... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor):
+ BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
+
+ _VALID_U... | yt_dlp/extractor/tvw.py | 11 | Python | 0.571 | suggestion | 89 | 36 | 36 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
def _extract_formats(self, response, video_id, stream_url):
extract_formats = lambda url, video_id: self._extract_m3u8_formats(url, video_id, 'mp4')
try:
return extract_formats(stream_url, video_id)
except ExtractorError:
self.report_warning('Failed to parse the m3u... | The key has been the same [since 2018](https://web.archive.org/web/20181204140323/https://player.invintus.com/app.js). Lets hard code it for now and save the additional request. If they start regularly changing the key we can always add this back. | 'timestamp': 1650394800,
'upload_date': '20220419',
'location': 'Hayner Media Center',
'display_id': 'washington-to-washington-a-new-space-race-2022041111',
'categories': ['Washington to Washington', 'General Interest'],
},
}]
def _real_extrac... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor):
+ BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
+
+ _VALID_U... | yt_dlp/extractor/tvw.py | 26 | Python | 0.429 | suggestion | 247 | 51 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
try:
return extract_formats(stream_url, video_id)
except ExtractorError:
self.report_warning('Failed to parse the m3u8 stream. Falling back to the backup stream if it exists.')
try:
stream_url = traverse_obj(response, ('streamingURIs', 'backup'))
... | Should be fatal
```suggestion
client_id = self._html_search_meta('clientID', webpage, fatal=True)
video_id = self._html_search_meta('eventID', webpage, fatal=True)
``` | 'display_id': 'washington-to-washington-a-new-space-race-2022041111',
'categories': ['Washington to Washington', 'General Interest'],
},
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
c... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor):
+ BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
+
+ _VALID_U... | yt_dlp/extractor/tvw.py | 26 | Python | 0.786 | suggestion | 187 | 51 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
app_js_code = self._get_js_code(video_id, webpage)
try:
api_key = self._search_regex(r'embedderAuth[\s]*:[\s]*{[^}]+vendorKey:\"(?P<token>\w+?)\"}',
app_js_code, 'token')
except RegexNotFoundError:
self.report_warning('Failed to ... | I would just use the yt-dlp build in error handling. If there are specific cases you want to catch (geo restrictions, account requirements), you should set the `expected_status` parameter and then throw appropriate error messages based on the response.
```suggestion
video_data = self._download_json(
... | headers={
'authorization': 'embedder',
'wsc-api-key': '7WhiEBzijpritypp8bqcU7pfU9uicDR',
},
data=json.dumps({
'clientID': client_id,
'eventID': video_id,
'showStreams': True,
}).encode())['dat... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor):
+ BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
+
+ _VALID_U... | yt_dlp/extractor/tvw.py | 26 | Python | 1 | security | 727 | 42 | 38 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
'description': 'md5:50c5bd73bde32fa6286a008dbc853386',
'timestamp': 1724310900,
'upload_date': '20240822',
'location': 'Ebey’s Landing State Park',
}},
{
'url': 'https://tvw.org/video/home-warranties-workgroup-2',
'info_dict': {
... | These don't need to be dedicated functions. Just inline the code. | 'title': 'Ebey\'s Landing State Park',
'thumbnail': r're:^https?://.*\.(?:jpe?g|png)$',
'description': 'md5:50c5bd73bde32fa6286a008dbc853386',
'timestamp': 1724310900,
'upload_date': '20240822',
'location': 'Ebey’s Landing State Park',
... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor):
+ BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
+
+ _VALID_U... | yt_dlp/extractor/tvw.py | 26 | Python | 0.214 | suggestion | 66 | 51 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
headers = {'authorization': 'embedder', 'wsc-api-key': api_key}
data = json.dumps({'clientID': client_id, 'eventID': video_id,
'showStreams': True}).encode('utf8')
response = self._download_json('https://api.v3.invintus.com/v2/Event/getDetailed',
... | Instead of using a bunch of `.get` calls you should use a single `traverse_obj` call | import json
from .common import InfoExtractor
from ..utils import clean_html, remove_end, unified_timestamp, url_or_none
from ..utils.traversal import traverse_obj
class TvwIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://tvw.org/video/... | @@ -0,0 +1,121 @@
+import json
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import ExtractorError, RegexNotFoundError, clean_html, traverse_obj, unified_timestamp
+
+
+class TVWIE(InfoExtractor):
+ BACKUP_API_KEY = '7WhiEBzijpritypp8bqcU7pfU9uicDR'
+
+ _VALID_U... | yt_dlp/extractor/tvw.py | 26 | Python | 0.429 | suggestion | 84 | 28 | 118 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
try:
return extract_formats(stream_urls.get('main'), video_id)
except ExtractorError:
self.report_warning('Failed to parse the m3u8 stream. Falling back to the backup stream if it exists.')
try:
return extract_formats(stream_urls.get('backup'), video_i... | Adjusted the formatting to fit with the yt-dlp conventions. Getting `data` can be fatal as it is required for all further steps anyway.
```suggestion
video_data = self._download_json(
'https://api.v3.invintus.com/v2/Event/getDetailed', video_id,
headers={
'authorizat... | 'categories': ['Legislative'],
},
}, {
'url': 'https://tvw.org/video/washington-to-washington-a-new-space-race-2022041111/?eventID=2022041111',
'md5': '6f5551090b351aba10c0d08a881b4f30',
'info_dict': {
'id': '2022041111',
'ext': 'mp4',
... | @@ -0,0 +1,96 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import ExtractorError, clean_html, traverse_obj, unified_timestamp, url_or_none
+
+
+class TvwIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
+ _TESTS = [{
+ 'url': 'https://tvw.org/video... | yt_dlp/extractor/tvw.py | 26 | Python | 0.786 | security | 606 | 45 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
'title': 'Home Warranties Workgroup',
'thumbnail': r're:^https?://.*\.jpg$',
'description': 'md5:861396cc523c9641d0dce690bc5c35f3',
'timestamp': 946389600,
'upload_date': '19991228',
}}]
def _extract_formats(self, response, video_id):
extr... | Lets keep this as the display_id instead of overwriting the variable.
```suggestion
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
``` | 'categories': ['Washington State Parks'],
},
}, {
'url': 'https://tvw.org/video/home-warranties-workgroup-2',
'md5': 'f678789bf94d07da89809f213cf37150',
'info_dict': {
'id': '1999121000',
'ext': 'mp4',
'title': 'Home Warranties Workgrou... | @@ -0,0 +1,96 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import ExtractorError, clean_html, traverse_obj, unified_timestamp, url_or_none
+
+
+class TvwIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
+ _TESTS = [{
+ 'url': 'https://tvw.org/video... | yt_dlp/extractor/tvw.py | 26 | Python | 0.786 | suggestion | 190 | 51 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
except ExtractorError:
self.report_warning('Failed to parse the m3u8 stream. Falling back to the backup stream if it exists.')
try:
return extract_formats(stream_urls.get('backup'), video_id)
except ExtractorError:
raise
def _real_extract(... | Let's simplify and inline
```suggestion
formats = []
subtitles = {}
for stream_url in traverse_obj(video_data, ('streamingURIs', ..., {url_or_none})):
fmts, subs = self._extract_m3u8_formats_and_subtitles(
stream_url, video_id, 'mp4', m3u8_id='hls', fatal=False)... | }, {
'url': 'https://tvw.org/video/washington-to-washington-a-new-space-race-2022041111/?eventID=2022041111',
'md5': '6f5551090b351aba10c0d08a881b4f30',
'info_dict': {
'id': '2022041111',
'ext': 'mp4',
'title': 'Washington to Washington - A New Space Race'... | @@ -0,0 +1,96 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import ExtractorError, clean_html, traverse_obj, unified_timestamp, url_or_none
+
+
+class TvwIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
+ _TESTS = [{
+ 'url': 'https://tvw.org/video... | yt_dlp/extractor/tvw.py | 26 | Python | 0.857 | refactor | 602 | 43 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
client_id = self._html_search_meta('clientID', webpage, fatal=True)
video_id = self._html_search_meta('eventID', webpage, fatal=True)
video_data = self._download_json('https://api.v3.invintus.com/v2/Event/getDetailed', video_id,
headers={
... | For the og tag title lets remove the fixed ` - TVW` part. I also moved the OG tag extraction outside. Due to the order they will still be used as a fallback.
```suggestion
'display_id': display_id,
'formats': formats,
'subtitles': subtitles,
'title': remove_end(self.... | 'upload_date': '20220419',
'location': 'Hayner Media Center',
'display_id': 'washington-to-washington-a-new-space-race-2022041111',
'categories': ['Washington to Washington', 'General Interest'],
},
}]
def _real_extract(self, url):
display_id = se... | @@ -0,0 +1,96 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import ExtractorError, clean_html, traverse_obj, unified_timestamp, url_or_none
+
+
+class TvwIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
+ _TESTS = [{
+ 'url': 'https://tvw.org/video... | yt_dlp/extractor/tvw.py | 26 | Python | 0.857 | refactor | 636 | 33 | 51 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | fries1234 |
webpage = self._download_webpage(url, display_id)
client_id = self._html_search_meta('clientID', webpage, fatal=True)
video_id = self._html_search_meta('eventID', webpage, fatal=True)
video_data = self._download_json(
'https://api.v3.invintus.com/v2/Event/getDetailed', vide... | ```suggestion
self._merge_subtitles({'en': [{'ext': 'vtt', 'url': caption_url}]}, target=subtitles)
``` | webpage = self._download_webpage(url, display_id)
client_id = self._html_search_meta('clientID', webpage, fatal=True)
video_id = self._html_search_meta('eventID', webpage, fatal=True)
video_data = self._download_json(
'https://api.v3.invintus.com/v2/Event/getDetailed', vide... | @@ -0,0 +1,117 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import clean_html, remove_end, unified_timestamp, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class TvwIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
+
+ _TESTS = [{
+ ... | yt_dlp/extractor/tvw.py | 26 | Python | 0.714 | suggestion | 117 | 45 | 45 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | fries1234 |
'authorization': 'embedder',
'wsc-api-key': '7WhiEBzijpritypp8bqcU7pfU9uicDR',
},
data=json.dumps({
'clientID': client_id,
'eventID': video_id,
'showStreams': True,
}).encode())['data']
formats =... | since these are just fallbacks I think warnings would be misleading
```suggestion
'title': remove_end(self._og_search_title(webpage, default=None), ' - TVW'),
'description': self._og_search_description(webpage, default=None),
``` | 'authorization': 'embedder',
'wsc-api-key': '7WhiEBzijpritypp8bqcU7pfU9uicDR',
},
data=json.dumps({
'clientID': client_id,
'eventID': video_id,
'showStreams': True,
}).encode())['data']
formats =... | @@ -0,0 +1,117 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import clean_html, remove_end, unified_timestamp, url_or_none
+from ..utils.traversal import traverse_obj
+
+
+class TvwIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?tvw\.org/video/(?P<id>[^/?#]+)'
+
+ _TESTS = [{
+ ... | yt_dlp/extractor/tvw.py | 26 | Python | 0.857 | suggestion | 257 | 37 | 37 | false | [ie/tvw] Add extractor | 12,271 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | fries1234 |
},
{
'url': 'https://www.softwhiteunderbelly.com/videos/tj-2-final-2160p',
'note': 'A single Soft White Underbelly Episode',
'md5': '286bd8851b4824c62afb369e6f307036',
'info_dict': {
'id': '3506029',
'ext': 'mp4',
... | IMO this can be inlined in the login function | 'info_dict': {
'id': '3506029',
'ext': 'mp4',
'display_id': 'tj-2-final-2160p',
'title': 'Fentanyl Addict interview-TJ (follow up)',
'description': 'Soft White Underbelly follow up interview and portrait of TJ, a fentanyl addict on Skid Row.',
... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.071 | suggestion | 45 | 51 | 51 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
'info_dict': {
'id': '3506029',
'ext': 'mp4',
'display_id': 'tj-2-final-2160p',
'title': 'Fentanyl Addict interview-TJ (follow up)',
'description': 'Soft White Underbelly follow up interview and portrait of TJ, a fentanyl addict... | I don't see a reason for this not to be `_perform_login` (which is called by core code before `_real_initialize` or `_real_extract`). Any usage of `display_id` can be changed to `None`
```suggestion
def _perform_login(self, username, password):
``` | 'description': 'Soft White Underbelly follow up interview and portrait of TJ, a fentanyl addict on Skid Row.',
'thumbnail': 'https://vhx.imgix.net/softwhiteunderbelly/assets/c883d531-5da0-4faf-a2e2-8eba97e5adfc.jpg',
'duration': 817,
'uploader': 'OTT Videos',
... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.857 | refactor | 255 | 51 | 47 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
},
]
def _get_authenticity_token(self, display_id):
signin_page = self._download_webpage(self._LOGIN_URL, display_id, note='Getting authenticity token')
return self._html_search_regex(
r'name=["\']authenticity_token["\'] value=["\'](.+?)["\']', signin_page, 'authenticity_tok... | I'd rather the POST request be fatal. If invalid user/pass gets an error response, we can try/except for the specific error status and raise an expected ExtractorError with an appropriate message
```suggestion
login_page = self._download_webpage(self._LOGIN_URL, None, 'Fetching authenticity token')
... | self._LOGIN_URL, None, 'Logging in',
data=urlencode_postdata({
'email': username,
'password': password,
'authenticity_token': self._html_search_regex(
r'name=["\']authenticity_token["\']\s+value=["\']([^"\']+)', signin_page, 'au... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 1 | security | 741 | 51 | 34 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
username, password = self._get_login_info()
if not username:
return True
response = self._download_webpage(
self._LOGIN_URL,
display_id,
note='Logging in',
fatal=False,
data=urlencode_postdata({
'email': use... | not sure if we need any of this. we can check for the cookie in `_real_extract` to determine whether we should `raise_login_required` or `raise ExtractorError`
```suggestion
``` | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.929 | refactor | 179 | 51 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
}),
)
user_has_subscription = self._search_regex(
r'user_has_subscription:\s*["\'](.+?)["\']', response, 'subscription status', default='none',
)
if user_has_subscription.lower() == 'true':
return
elif user_has_subscription.lower() == 'false':... | ```suggestion
webpage = self._download_webpage(url, display_id)
if '<div id="watch-unauthorized"' in webpage:
if self._get_cookies('https://www.softwhiteunderbelly.com').get('_session'):
raise ExtractorError('This account is not subscribed to this content', expected=True)... | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 1 | security | 366 | 51 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
if user_has_subscription.lower() == 'true':
return
elif user_has_subscription.lower() == 'false':
return 'Account is not subscribed'
else:
return 'Incorrect username/password'
def _real_extract(self, url):
display_id = self._match_id(url)
... | inline `thumbnail` and `title` below | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.214 | suggestion | 36 | 46 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
webpage = None
if self._get_cookies('https://www.softwhiteunderbelly.com').get('_session'):
webpage = self._download_webpage(url, display_id)
if not webpage or '<div id="watch-unauthorized"' in webpage:
login_err = self._login(display_id)
webpage = self._downl... | instead of the string splitting, use `update_url(thumbnail, query=None)` (import form `utils`) | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.429 | suggestion | 94 | 36 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
self.raise_login_required(method='any')
raise ExtractorError(login_err, expected=True)
embed_url = self._html_search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url')
thumbnail = self._og_search_thumbnail(webpage)
watch_info = get_element_by_id('wa... | what does this value look like? also it's not extracted in either of the tests | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.286 | refactor | 78 | 28 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
get_element_by_class,
get_element_by_id,
unified_strdate,
urlencode_postdata,
)
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com/l... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?softwhiteunderbelly\.com/videos/(?P<id>[\w-]+)'
``` | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,129 @@
+
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ unified_strdate,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'http... | yt_dlp/extractor/softwhiteunderbelly.py | 18 | Python | 0.714 | suggestion | 105 | 43 | 43 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
'url': 'https://www.softwhiteunderbelly.com/videos/tj-2-final-2160p',
'note': 'A single Soft White Underbelly Episode',
'md5': '286bd8851b4824c62afb369e6f307036',
'info_dict': {
'id': '3506029',
'ext': 'mp4',
'display_id': '... | please don't ignore the formatting in suggestions and make me suggest the same thing over again
```suggestion
self._LOGIN_URL, None, 'Logging in',
``` | 'id': '3506029',
'ext': 'mp4',
'display_id': 'tj-2-final-2160p',
'title': 'Fentanyl Addict interview-TJ (follow up)',
'description': 'Soft White Underbelly follow up interview and portrait of TJ, a fentanyl addict on Skid Row.',
'thumbnail': 'https... | @@ -0,0 +1,95 @@
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ update_url,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'https://www.... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.714 | suggestion | 165 | 51 | 51 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
'display_id': 'tj-2-final-2160p',
'title': 'Fentanyl Addict interview-TJ (follow up)',
'description': 'Soft White Underbelly follow up interview and portrait of TJ, a fentanyl addict on Skid Row.',
'thumbnail': 'https://vhx.imgix.net/softwhiteunderbelly/as... | here my regex suggestion was also ignored along with the formatting
```suggestion
r'name=["\']authenticity_token["\']\s+value=["\']([^"\']+)', signin_page, 'authenticity_token'),
``` | 'duration': 817,
'uploader': 'OTT Videos',
'uploader_url': 'https://vimeo.com/user80538407',
'uploader_id': 'user80538407',
},
'expected_warnings': ['Failed to parse XML: not well-formed'],
}]
def _perform_login(self, username, password):
... | @@ -0,0 +1,95 @@
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ update_url,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'https://www.... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.786 | security | 205 | 51 | 45 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
'duration': 512,
},
'expected_warnings': ['Failed to parse XML: not well-formed'],
},
{
'url': 'https://www.softwhiteunderbelly.com/videos/tj-2-final-2160p',
'note': 'A single Soft White Underbelly Episode',
'md5': '286bd8851b48... | line too long, don't need the param names
```suggestion
signin_page = self._download_webpage(self._LOGIN_URL, None, 'Fetching authenticity token')
``` | }, {
'url': 'https://www.softwhiteunderbelly.com/videos/tj-2-final-2160p',
'note': 'A single Soft White Underbelly Episode',
'md5': '286bd8851b4824c62afb369e6f307036',
'info_dict': {
'id': '3506029',
'ext': 'mp4',
'display_id': 'tj-2-final-2160p',
... | @@ -0,0 +1,95 @@
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ update_url,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'https://www.... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.714 | security | 161 | 51 | 51 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
signin_page = self._download_webpage(self._LOGIN_URL, video_id=None, note='Getting authenticity token')
self._download_webpage(
self._LOGIN_URL,
video_id=None,
note='Logging in',
data=urlencode_postdata({
'email': username,
... | let's kill two birds here
```suggestion
embed_url, embed_id = self._html_search_regex(
r'embed_url:\s*["\'](?P<url>https?://embed\.vhx\.tv/videos/(?P<id>\d+)[^"\']*)',
webpage, 'embed url', group=('url', 'id'))
``` | 'password': password,
'authenticity_token': self._html_search_regex(
r'name=["\']authenticity_token["\']\s+value=["\']([^"\']+)', signin_page, 'authenticity_token'),
'utf8': True,
}),
)
def _real_extract(self, url):
dis... | @@ -0,0 +1,95 @@
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ update_url,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'https://www.... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.786 | suggestion | 253 | 39 | 31 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
'email': username,
'password': password,
'authenticity_token': self._html_search_regex(
r'name=["\']authenticity_token["\'] value=["\'](.+?)["\']', signin_page, 'authenticity_token',
),
'utf8': True,
}),
... | ```suggestion
'id': embed_id,
``` | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,95 @@
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ update_url,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'https://www.... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.429 | suggestion | 47 | 32 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
'authenticity_token': self._html_search_regex(
r'name=["\']authenticity_token["\'] value=["\'](.+?)["\']', signin_page, 'authenticity_token',
),
'utf8': True,
}),
)
def _real_extract(self, url):
display_id = self._match... | could be nice to do this and remove the `watch_info` temp var (import `traverse_obj` and `find_element` from `..utils.traversal`)
```suggestion
'title': traverse_obj(webpage, ({find_element(id='watch-info')}, {find_element(cls='video-title')}, {clean_html})),
``` | from .common import InfoExtractor
from .vimeo import VHXEmbedIE
from ..utils import (
ExtractorError,
clean_html,
update_url,
urlencode_postdata,
)
from ..utils.traversal import find_element, traverse_obj
class SoftWhiteUnderbellyIE(InfoExtractor):
_LOGIN_URL = 'https://www.softwhiteunderbelly.com... | @@ -0,0 +1,95 @@
+from .common import InfoExtractor
+from .vimeo import VHXEmbedIE
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ get_element_by_class,
+ get_element_by_id,
+ update_url,
+ urlencode_postdata,
+)
+
+
+class SoftWhiteUnderbellyIE(InfoExtractor):
+ _LOGIN_URL = 'https://www.... | yt_dlp/extractor/softwhiteunderbelly.py | 26 | Python | 0.857 | suggestion | 278 | 30 | 88 | false | [ie/softwhiteunderbelly] Add extractor | 12,281 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | benfaerber |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.