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
path, display_id = self._match_valid_url(url).groups() webpage = self._download_webpage(url, display_id) title = self._og_search_title(webpage) entries = [] urqlJson = self._search_json(r'window\.svt\.nyh\.urqlState[^{]+', webpage, 'video_id', display_id, default=None) ...
for the playlist entries we can use a generator function with a single traversal, and we can use a set to eliminate duplicate IDs ```py def entries(): for video_id in set(traverse_obj(data, ( 'page', (('topMedia', 'svtId'), ('body', ..., 'video', 'svtId')), {str} )...
import json import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( determine_ext, dict_get, int_or_none, traverse_obj, try_get, unified_timestamp, ) class SVTBaseIE(InfoExtractor): _GEO_COUNTRIES = ['SE'] def _extract_video(self, video_info,...
@@ -429,24 +469,27 @@ def suitable(cls, url): def _real_extract(self, url): path, display_id = self._match_valid_url(url).groups() - article = self._download_json( - 'https://api.svt.se/nss-api/page/' + path, display_id, - query={'q': 'articles'})['articles']['content'][0] -...
yt_dlp/extractor/svt.py
26
Python
0.857
refactor
621
27
490
false
[SVTPage] Fix extractor
8,938
yt-dlp/yt-dlp
132,642
Python
bashonly
diman8
}] def _real_extract(self, url): video_id = self._match_id(url) release = self._download_json( f'https://api.ninaprotocol.com/v1/releases/{video_id}', video_id)['release'] video_id = release.get('publicKey') or video_id common_info = traverse_obj(release, { ...
don't need to expect `{dict}` since the filter already takes care of that, and we could start the enumeration from 1 ```suggestion for track_num, track in enumerate(traverse_obj(release, ( 'metadata', 'properties', 'files', lambda _, v: url_or_none(v['uri']))), 1): entries.append...
}] def _real_extract(self, url): video_id = self._match_id(url) release = self._download_json( f'https://api.ninaprotocol.com/v1/releases/{video_id}', video_id)['release'] video_id = release.get('publicKey') or video_id common_info = traverse_obj(release, { ...
@@ -0,0 +1,225 @@ +from .common import InfoExtractor +from ..utils import int_or_none, mimetype2ext, parse_iso8601, url_or_none +from ..utils.traversal import traverse_obj + + +class NinaprotocolIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ninaprotocol\.com/releases/(?P<id>[^/#?]+)' + _TESTS = [{ + ...
yt_dlp/extractor/ninaprotocol.py
26
Python
0.857
suggestion
377
50
50
false
[NinaProtocol] Add extractor
8,946
yt-dlp/yt-dlp
132,642
Python
bashonly
RaduManole
def _real_extract(self, url): video_id = self._match_id(url) release = self._download_json( f'https://api.ninaprotocol.com/v1/releases/{video_id}', video_id)['release'] video_id = release.get('publicKey') or video_id common_info = traverse_obj(release, { 'al...
we could also do this as a fallback. not mandatory if you think it's a bad idea though ```suggestion 'url': track['uri'], 'track_number': track_num, **traverse_obj(track, { ```
def _real_extract(self, url): video_id = self._match_id(url) release = self._download_json( f'https://api.ninaprotocol.com/v1/releases/{video_id}', video_id)['release'] video_id = release.get('publicKey') or video_id common_info = traverse_obj(release, { 'al...
@@ -0,0 +1,225 @@ +from .common import InfoExtractor +from ..utils import int_or_none, mimetype2ext, parse_iso8601, url_or_none +from ..utils.traversal import traverse_obj + + +class NinaprotocolIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ninaprotocol\.com/releases/(?P<id>[^/#?]+)' + _TESTS = [{ + ...
yt_dlp/extractor/ninaprotocol.py
26
Python
0.857
suggestion
229
48
48
false
[NinaProtocol] Add extractor
8,946
yt-dlp/yt-dlp
132,642
Python
bashonly
RaduManole
AENetworksCollectionIE, AENetworksShowIE, HistoryTopicIE, HistoryPlayerIE, BiographyIE, ) from .aeonco import AeonCoIE from .afreecatv import ( AfreecaTVIE, AfreecaTVLiveIE, AfreecaTVUserIE, ) from .agora import ( TokFMAuditionIE, TokFMPodcastIE, WyborczaPodcastIE, Wyborc...
Don't change unrelated lines ```suggestion ```
AENetworksCollectionIE, AENetworksShowIE, HistoryTopicIE, HistoryPlayerIE, BiographyIE, ) from .aeonco import AeonCoIE from .afreecatv import ( AfreecaTVIE, AfreecaTVLiveIE, AfreecaTVUserIE, ) from .agora import ( TokFMAuditionIE, TokFMPodcastIE, WyborczaPodcastIE, Wyborc...
@@ -84,6 +84,7 @@ AllstarIE, AllstarProfileIE, ) +
yt_dlp/extractor/_extractors.py
26
Python
0.5
suggestion
48
51
51
false
[CapitalTVCy] Add Capital TV Cyprus extractor
8,948
yt-dlp/yt-dlp
132,642
Python
seproDev
pompos02
'id': '?playlist=76011151&video=9e59909', 'title': 'Theme Builder Collection - Academy', 'age_limit': 0, 'timestamp': 1702196984.0, 'upload_date': '20231210', 'description': 'md5:7f52c52715ee9e54fd7f82210511673d', 'thumbnail': 'https://...
Import relevent extractors and do ```suggestion yield self.url_result(vimeo_url, ie=VimeoIE) ```
'url': 'https://elementor.com/academy/theme-builder-collection/?playlist=76011151&video=9e59909', 'info_dict': { 'id': '?playlist=76011151&video=9e59909', 'title': 'Theme Builder Collection - Academy', 'age_limit': 0, 'timestamp': 1702196984.0, ...
@@ -0,0 +1,70 @@ +import re + +from .common import InfoExtractor +from ..utils import unescapeHTML, url_or_none +from ..utils.traversal import traverse_obj + + +class ElementorEmbedIE(InfoExtractor): + _VALID_URL = False + _WEBPAGE_TESTS = [{ + 'url': 'https://capitaltv.cy/2023/12/14/υγεια-και-ζωη-14-12-20...
yt_dlp/extractor/elementorembed.py
26
Python
0.786
refactor
120
33
35
false
[CapitalTVCy] Add Capital TV Cyprus extractor
8,948
yt-dlp/yt-dlp
132,642
Python
pukkandan
pompos02
def _get_thumbnails(self, thumbnail): return [{ 'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', r'0x0\g<1>', thumbnail), 'preference': 1, }, { 'url': thumbnail, }] if thumbnail else None def _extract_twitch_m3u8_formats(self, type, id, token, signature)...
Maybe it would be simpler to do it like this: ```suggestion def _extract_twitch_m3u8_formats(self, video_id, token, signature): """Subclasses must define _M3U8_PATH""" return self._extract_m3u8_formats( f'{self._USHER_BASE}/{self._M3U8_PATH}/{video_id}.m3u8', video_id, 'mp4', query=...
def _get_thumbnails(self, thumbnail): return [{ 'url': re.sub(r'\d+x\d+(\.\w+)($|(?=[?#]))', r'0x0\g<1>', thumbnail), 'preference': 1, }, { 'url': thumbnail, }] if thumbnail else None def _extract_twitch_m3u8_formats(self, video_id, token, signature)...
@@ -191,6 +190,24 @@ def _get_thumbnails(self, thumbnail): 'url': thumbnail, }] if thumbnail else None + def _extract_twitch_m3u8_formats(self, type, id, token, signature): + URLS_MAP = { + 'video': '%s/vod/%s.m3u8', + 'stream': '%s/api/channel/hls/%s.m3u8' + ...
yt_dlp/extractor/twitch.py
26
Python
0.857
refactor
893
51
51
false
[ie/Twitch] Fix video formats extraction
8,960
yt-dlp/yt-dlp
132,642
Python
bashonly
DmitryScaletta
if not self._exact: return tag elif self._version_compare(tag, resolved_tag): return resolved_tag elif tag != resolved_tag: continue self._report_error( f'yt-d...
This should describe the type, so it would be `UpdateInfo`. Same below, `Optional[UpdateInfo]` or `UpdateInfo | None`
if not self._exact: return tag elif self._version_compare(tag, resolved_tag): return resolved_tag elif tag != resolved_tag: continue self._report_error( f'yt-d...
@@ -351,7 +351,9 @@ def _version_compare(self, a: str, b: str): return a == b def query_update(self, *, _output=False) -> UpdateInfo | None: - """Fetches and returns info about the available update""" + """Fetches info about the available update + @returns UpdateInfo() if there is...
yt_dlp/update.py
26
Python
0.714
suggestion
117
51
51
false
[docs] Misc Cleanup
8,977
yt-dlp/yt-dlp
132,642
Python
Grub4K
pukkandan
if not self._exact: return tag elif self._version_compare(tag, resolved_tag): return resolved_tag elif tag != resolved_tag: continue self._report_error( f'yt-d...
```suggestion @returns An `UpdateInfo` if there is an update available, else None ```
if not self._exact: return tag elif self._version_compare(tag, resolved_tag): return resolved_tag elif tag != resolved_tag: continue self._report_error( f'yt-d...
@@ -351,7 +351,9 @@ def _version_compare(self, a: str, b: str): return a == b def query_update(self, *, _output=False) -> UpdateInfo | None: - """Fetches and returns info about the available update""" + """Fetches info about the available update + @returns UpdateInfo() if there is...
yt_dlp/update.py
26
Python
0.571
suggestion
97
51
51
false
[docs] Misc Cleanup
8,977
yt-dlp/yt-dlp
132,642
Python
pukkandan
pukkandan
return None self.ydl.report_warning('No hash information found for the release, skipping verification') else: for ln in hashes.decode().splitlines(): if ln.endswith(_get_binary_name()): checksum = ln.split()[0] ...
```suggestion @param update_info `UpdateInfo | None` as returned by query_update() ```
return None self.ydl.report_warning('No hash information found for the release, skipping verification') else: for ln in hashes.decode().splitlines(): if ln.endswith(_get_binary_name()): checksum = ln.split()[0] ...
@@ -429,7 +431,9 @@ def query_update(self, *, _output=False) -> UpdateInfo | None: checksum=checksum) def update(self, update_info=NO_DEFAULT): - """Update yt-dlp executable to the latest version""" + """Update yt-dlp executable to the latest version + @param update_info Option...
yt_dlp/update.py
26
Python
0.571
suggestion
99
51
51
false
[docs] Misc Cleanup
8,977
yt-dlp/yt-dlp
132,642
Python
pukkandan
pukkandan
if mobj: resolutions[mobj.group('format_id')] = ( int(mobj.group('width')), int(mobj.group('height'))) for fmt_stream in fmt_stream_map: fmt_stream_split = fmt_stream.split('|') if len(fmt_stream_split) < 2: ...
Also needs `confirm` to download larger files ```suggestion 'export': 'download', 'confirm': 't', ```
if mobj: resolutions[mobj.group('format_id')] = ( int(mobj.group('width')), int(mobj.group('height'))) for fmt_stream in fmt_stream_map: fmt_stream_split = fmt_stream.split('|') if len(fmt_stream_split) < 2: ...
@@ -205,7 +208,7 @@ def get_value(key): formats.append(f) source_url = update_url_query( - 'https://drive.google.com/uc', { + 'https://drive.usercontent.google.com/download', { 'id': video_id, 'export': 'download',
yt_dlp/extractor/googledrive.py
26
Python
0.714
suggestion
137
51
51
false
[extractor/GoogleDrive] Update new Domain/URL for source file download
8,990
yt-dlp/yt-dlp
132,642
Python
seproDev
ghost
'id': 'ABD6213', 'title': 'Cuties', }, 'playlist_mincount': 2, }, { 'url': 'https://motherless.com/GVBCF7622', 'info_dict': { 'id': 'BCF7622', 'title': 'Vintage', }, 'playlist_count': 0, }, { 'url': 'https://...
```suggestion _VALID_URL = r'https?://(?:www\.)?motherless\.com/u/(?P<id>\w+)/?(?:$|[?#])' ```
'info_dict': { 'id': 'ABD6213', 'title': 'Cuties', }, 'playlist_mincount': 2, }, { 'url': 'https://motherless.com/GVBCF7622', 'info_dict': { 'id': 'BCF7622', 'title': 'Vintage', }, 'playlist_count': 0, }, { ...
@@ -270,3 +270,40 @@ class MotherlessGalleryIE(MotherlessPaginatedIE): def _correct_path(self, url, item_id): return urllib.parse.urljoin(url, f'/GV{item_id}') + + +class MotherlessUploaderIE(MotherlessPaginatedIE): + _VALID_URL = r'https?://(?:www\.)?motherless\.com/u/(?P<id>[a-zA-Z0-9_]+)($|\?t=v)'
yt_dlp/extractor/motherless.py
26
Python
0.714
suggestion
100
51
48
false
[extractor/MotherlessUploader] Add extractor for uploader playlists
8,994
yt-dlp/yt-dlp
132,642
Python
bashonly
dasidiot
'title': "Mrgo4hrs2023's Uploads - Videos", }, 'playlist_mincount': 32, }, { 'url': 'https://motherless.com/u/Happy_couple?t=v', 'info_dict': { 'id': 'Happy_couple', 'title': "Happy_couple's Uploads - Videos", }, 'playlist_mincount'...
instead of redefining all of this just to modify the pagination request query, I think we could do this: ```suggestion _EXTRA_QUERY = {'t': 'v'} ``` and then in the playlist baseclass, add this: ```py _EXTRA_QUERY = {} ``` and in the baseclass' `_real_extract()`, do this: ```py def get_page(...
import datetime import re import urllib.parse from .common import InfoExtractor from ..utils import ( ExtractorError, OnDemandPagedList, remove_end, str_to_int, unified_strdate, ) class MotherlessIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?motherless\.com/(?:g/[a-z0-9_]+/|G[VIG]?[A-F...
@@ -270,3 +270,40 @@ class MotherlessGalleryIE(MotherlessPaginatedIE): def _correct_path(self, url, item_id): return urllib.parse.urljoin(url, f'/GV{item_id}') + + +class MotherlessUploaderIE(MotherlessPaginatedIE): + _VALID_URL = r'https?://(?:www\.)?motherless\.com/u/(?P<id>[a-zA-Z0-9_]+)($|\?t=v)'...
yt_dlp/extractor/motherless.py
26
Python
0.857
refactor
633
30
298
false
[extractor/MotherlessUploader] Add extractor for uploader playlists
8,994
yt-dlp/yt-dlp
132,642
Python
bashonly
dasidiot
'title': 'Afterlife', 'description': 'md5:84951394f594f1fb1e62d9c43242fdf5', 'release_year': 1978, 'duration': 420.0, 'uploader': 'Ishu Patel', 'thumbnail': r're:^https?://.*\.jpg$', }, 'params': {'skip_download': 'm3u8'}, }] ...
DV sources (described video) can also be extracted: ```suggestion formats, subtitles = self._extract_m3u8_formats_and_subtitles( self._html_search_regex(r'source:\s*\'([^\']+)', player, 'm3u8 url'), video_id, 'mp4', m3u8_id='hls') if dv_source := self._html_search_...
'title': 'Afterlife', 'description': 'md5:84951394f594f1fb1e62d9c43242fdf5', 'release_year': 1978, 'duration': 420.0, 'uploader': 'Ishu Patel', 'thumbnail': r're:^https?://.*\.jpg$', }, 'params': {'skip_download': 'm3u8'}, }] ...
@@ -14,29 +58,183 @@ class NFBIE(InfoExtractor): 'thumbnail': r're:^https?://.*\.jpg$', 'uploader': 'Barrie Howells', 'release_year': 1972, + 'duration': 600.0, + }, + 'params': {'skip_download': 'm3u8'}, + }, { + 'note': 'ONF film', + 'ur...
yt_dlp/extractor/nfb.py
26
Python
0.857
refactor
786
51
51
false
[ie/nfb] Add series extractor, episode support, onf.ca support
8,997
yt-dlp/yt-dlp
132,642
Python
seproDev
rrgomes
'episode_number': 1, 'episode': 'Episode 1', # Then if the test run fails, it will output the missing/incorrect fields. # Properties can be added as: # * A value, e.g. # 'title': 'Video title goes here', # * MD5 checksum; start the ...
Use single quotes. Don't create single use variables (`endpoint_url`, `ajax_cookie`).
'display_id': '1-avis-akvasas-ka', 'title': '1. Avis akvasas ka', 'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6.mp3', 'timestamp': 1703835014, 'upload_date': '20231229', 'duration': 2495.0, 'a...
@@ -0,0 +1,74 @@ + +from .common import InfoExtractor + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' + _TESTS = [{ + 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', + 'md5': '43649f002d85e1c2f319bb478d479c40', + ...
yt_dlp/extractor/ilpost.py
26
Python
0.429
suggestion
85
51
49
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
# Then if the test run fails, it will output the missing/incorrect fields. # Properties can be added as: # * A value, e.g. # 'title': 'Video title goes here', # * MD5 checksum; start the string with 'md5:', e.g. # 'description': 'md5:098f6b...
Use `urlencode_postdata` from `..utils`
'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6.mp3', 'timestamp': 1703835014, 'upload_date': '20231229', 'duration': 2495.0, 'availability': 'public', 'series_id': '235598', 'description': '', ...
@@ -0,0 +1,74 @@ + +from .common import InfoExtractor + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' + _TESTS = [{ + 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', + 'md5': '43649f002d85e1c2f319bb478d479c40', + ...
yt_dlp/extractor/ilpost.py
26
Python
0.286
suggestion
39
51
47
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
'duration': 2495.0, 'availability': 'public', 'media_type': 'episode', 'series_id': '235598', 'episode_number': 1, 'episode': 'Episode 1', # Then if the test run fails, it will output the missing/incorrect fields. # Properti...
Line is too long. Please follow the style guidelines.
'md5': '43649f002d85e1c2f319bb478d479c40', 'info_dict': { 'id': '2972047', 'ext': 'mp3', 'display_id': '1-avis-akvasas-ka', 'title': '1. Avis akvasas ka', 'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6...
@@ -0,0 +1,74 @@ + +from .common import InfoExtractor + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' + _TESTS = [{ + 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', + 'md5': '43649f002d85e1c2f319bb478d479c40', + ...
yt_dlp/extractor/ilpost.py
26
Python
0.214
refactor
53
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
post_data = f"action=checkpodcast&cookie={ajax_cookie}&post_id={episode_id}&podcast_id={podcast_id}" podcast_metadata = self._download_json(endpoint_url, podcast_display_id, data=str.encode(post_data)) episodes = podcast_metadata["data"]["postcastList"] for idx, episode in enumerate(epi...
Episode number does not work for entries like https://www.ilpost.it/episodes/podcasts/timbuctu/ Is there anything other than "episode" as the `media_type`? If there is nothing else, I would remove it. ```suggestion episode = traverse_obj(podcast_metadata, ( 'data', 'postcastList', lambda _, v:...
import functools from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]...
@@ -0,0 +1,74 @@ + +from .common import InfoExtractor + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' + _TESTS = [{ + 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', + 'md5': '43649f002d85e1c2f319bb478d479c40', + ...
yt_dlp/extractor/ilpost.py
26
Python
1
refactor
1,351
27
70
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
'info_dict': { 'id': '2972047', 'ext': 'mp3', 'display_id': '1-avis-akvasas-ka', 'title': '1. Avis akvasas ka', 'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6.mp3', 'timestamp': 1703835014, ...
```suggestion endpoint_metadata = self._search_json( r'var\s+ilpostpodcast\s*=', webpage, 'metadata', podcast_display_id) ```
class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', 'md5': '43649f002d85e1c2f319bb478d479c40', 'info_dict': { 'id': '2972047', 'ext': 'mp3', ...
@@ -0,0 +1,65 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.857
suggestion
148
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
'duration': 2495.0, 'availability': 'public', 'series_id': '235598', 'description': '', } }] def _real_extract(self, url): podcast_display_id = self._match_id(url) webpage = self._download_webpage(url, podcast_display_id) endpoint...
```suggestion podcast_metadata = self._download_json( endpoint_metadata['ajax_url'], podcast_display_id, data=urlencode_postdata({ 'action': 'checkpodcast', 'cookie': endpoint_metadata['cookie'], 'post_id': episode_id, 'podcast_id...
'ext': 'mp3', 'display_id': '1-avis-akvasas-ka', 'title': '1. Avis akvasas ka', 'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6.mp3', 'timestamp': 1703835014, 'upload_date': '20231229', 'duratio...
@@ -0,0 +1,65 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.929
suggestion
356
46
50
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
start_pattern='var ilpostpodcast = ', end_pattern=';', string=webpage, name='endpoint-metadata', video_id=podcast_display_id, ) episode_id = endpoint_metadata['post_id'] podcast_id = endpoint_metadata['podcast_id'] podcast_metad...
```suggestion 'title': ('title', {str}), 'description': ('description', {str}), ```
def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) endpoint_metadata = self._search_json( r'var\s+ilpostpodcast\s*=', webpage, 'metadata', display_id) episode_id = endpoint_metadata['post_id'] podcast...
@@ -0,0 +1,65 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.714
suggestion
118
34
38
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
seproDev
CapacitorSet
import functools from .common import InfoExtractor from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata from ..utils.traversal import traverse_obj class IlPostExtractorIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' _TESTS ...
```suggestion import functools from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj ```
import functools from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj
yt_dlp/extractor/ilpost.py
5
Python
1
refactor
245
30
30
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
import functools from .common import InfoExtractor from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata from ..utils.traversal import traverse_obj class IlPostExtractorIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' _TESTS ...
```suggestion _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)' ```
import functools from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
9
Python
0.571
suggestion
94
34
34
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata from ..utils.traversal import traverse_obj class IlPostExtractorIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/...
`display_id` is the convention, shorter, and more distinct from `podcast_id` ```suggestion display_id = self._match_id(url) ```
from ..utils import ( ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.ilpo...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.857
suggestion
138
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
'description': '', } }] def _real_extract(self, url): podcast_display_id = self._match_id(url) webpage = self._download_webpage(url, podcast_display_id) endpoint_metadata = self._search_json( r'var\s+ilpostpodcast\s*=', webpage, 'metadata', podcast_displ...
```suggestion 'display_id': display_id, ```
'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6.mp3', 'timestamp': 1703835014, 'upload_date': '20231229', 'duration': 2495.0, 'availability': 'public', 'series_id': '235598', 'description': '', ...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.571
suggestion
57
39
47
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
'md5': '43649f002d85e1c2f319bb478d479c40', 'info_dict': { 'id': '2972047', 'ext': 'mp3', 'display_id': '1-avis-akvasas-ka', 'title': '1. Avis akvasas ka', 'url': 'https://www.ilpost.it/wp-content/uploads/2023/12/28/1703781217-l-invasione-pt1-v6...
```suggestion endpoint_metadata['ajax_url'], display_id, data=urlencode_postdata({ ```
class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', 'md5': '43649f002d85e1c2f319bb478d479c40', 'info_dict': { 'id': '2972047', 'ext': 'mp3',...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.714
suggestion
100
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
class IlPostExtractorIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', 'md5': '43649f002d85e1c2f319bb478d479c40', 'info_dict': { 'id': '2972047', 'ext'...
```suggestion r'var\s+ilpostpodcast\s*=', webpage, 'metadata', display_id) ```
url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', 'md5': '43649f002d85e1c2f319bb478d...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.714
suggestion
92
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
from .huya import HuyaLiveIE from .huffpost import HuffPostIE from .hungama import ( HungamaIE, HungamaSongIE, HungamaAlbumPlaylistIE, ) from .hypem import HypemIE from .hypergryph import MonsterSirenHypergryphMusicIE from .hytale import HytaleIE from .icareus import IcareusIE from .ichinanalive import ( ...
`Extractor` is redundant ```suggestion from .ilpost import IlPostIE ```
from .huya import HuyaLiveIE from .huffpost import HuffPostIE from .hungama import ( HungamaIE, HungamaSongIE, HungamaAlbumPlaylistIE, ) from .hypem import HypemIE from .hypergryph import MonsterSirenHypergryphMusicIE from .hytale import HytaleIE from .icareus import IcareusIE from .ichinanalive import ( ...
@@ -787,6 +787,7 @@ IHeartRadioIE, IHeartRadioPodcastIE, ) +from .ilpost import IlPostExtractorIE
yt_dlp/extractor/_extractors.py
26
Python
0.643
refactor
74
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
import functools from .common import InfoExtractor from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata from ..utils.traversal import traverse_obj class IlPostExtractorIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' _TESTS ...
```suggestion class IlPostIE(InfoExtractor): ```
import functools from .common import InfoExtractor from ..utils import ( ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor):
yt_dlp/extractor/ilpost.py
8
Python
0.643
refactor
50
33
33
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
from ..utils.traversal import traverse_obj class IlPostExtractorIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?]+).*' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/1-avis-akvasas-ka/', 'md5': '43649f002d85e1c2f319bb478d479c40', 'info_dict': { ...
```suggestion webpage = self._download_webpage(url, display_id) ```
ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata, ) from ..utils.traversal import traverse_obj class IlPostIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.ilpost.it/episodes/1-avis-...
@@ -0,0 +1,61 @@ +import functools + +from .common import InfoExtractor +from ..utils import ExtractorError, float_or_none, int_or_none, url_or_none, urlencode_postdata +from ..utils.traversal import traverse_obj + + +class IlPostExtractorIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?ilpost\.it/episodes/(?P...
yt_dlp/extractor/ilpost.py
26
Python
0.571
suggestion
77
51
51
false
[ie/ilpost] Add extractor
9,001
yt-dlp/yt-dlp
132,642
Python
bashonly
CapacitorSet
version=0, name=name, value=value, port=None, port_specified=False, domain=host, domain_specified=bool(host), domain_initial_dot=host.startswith('.'), path=path, path_specified=bool(path), secure=is_secure, expires=expiry, discard=False, ...
helps w/ readability for me ```suggestion for pattern in ('', '*/', 'Profiles/*/'): ```
version=0, name=name, value=value, port=None, port_specified=False, domain=host, domain_specified=bool(host), domain_initial_dot=host.startswith('.'), path=path, path_specified=bool(path), secure=is_secure, expires=expiry, discard=False, ...
@@ -182,12 +184,21 @@ def _extract_firefox_cookies(profile, container, logger): cursor.connection.close() -def _firefox_browser_dir(): +def _firefox_browser_dirs(): if sys.platform in ('cygwin', 'win32'): - return os.path.expandvars(R'%APPDATA%\Mozilla\Firefox\Profiles') + yield ...
yt_dlp/cookies.py
26
Python
0.571
suggestion
98
51
51
false
[cookies] Fix `--cookies-from-browser` for `snap` Firefox
9,016
yt-dlp/yt-dlp
132,642
Python
bashonly
Grub4K
class MLBArticleIE(InfoExtractor): _VALID_URL = r'https?://www\.mlb\.com/news/(?P<id>[\w-]+)' _TESTS = [{ 'url': 'https://www.mlb.com/news/manny-machado-robs-guillermo-heredia-reacts', 'info_dict': { 'id': '36db7394-343c-4ea3-b8ca-ead2e61bca9a', 'title': 'Machado\'s gra...
```suggestion traverse_obj(content_real_info, ('parts', lambda _, v: v['__typename'] == 'Video' or v['type'] == 'video')), ```
class MLBArticleIE(InfoExtractor): _VALID_URL = r'https?://www\.mlb\.com/news/(?P<id>[\w-]+)' _TESTS = [{ 'url': 'https://www.mlb.com/news/manny-machado-robs-guillermo-heredia-reacts', 'info_dict': { 'id': '36db7394-343c-4ea3-b8ca-ead2e61bca9a', 'title': 'Machado\'s gra...
@@ -355,27 +355,25 @@ class MLBArticleIE(InfoExtractor): 'info_dict': { 'id': '36db7394-343c-4ea3-b8ca-ead2e61bca9a', 'title': 'Machado\'s grab draws hilarious irate reaction', - 'modified_timestamp': 1650130737, + 'modified_timestamp': 1675888370, '...
yt_dlp/extractor/mlb.py
26
Python
0.857
suggestion
140
32
32
false
[ie/MLBArticle] Fix extractor
9,021
yt-dlp/yt-dlp
132,642
Python
bashonly
HobbyistDev
import re from .common import InfoExtractor from ..utils import ( encode_base_n, ExtractorError, int_or_none, merge_dicts, parse_duration, str_to_int, url_or_none, get_elements_by_class, join_nonempty ) class EpornerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?eporner\....
won't be needing it if my other suggestion is applied ```suggestion from .common import InfoExtractor ```
from .common import InfoExtractor from ..utils import ( ExtractorError, encode_base_n, get_elements_by_class, int_or_none, join_nonempty, merge_dicts, parse_duration, str_to_int, url_or_none, ) class EpornerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?eporner\.com/(?:(?...
@@ -1,3 +1,4 @@ +import re from .common import InfoExtractor
yt_dlp/extractor/eporner.py
2
Python
0.786
refactor
108
27
27
false
[eporner] Add support for AV1 codec
9,028
yt-dlp/yt-dlp
132,642
Python
bashonly
michal-repo
import re from .common import InfoExtractor from ..utils import ( encode_base_n, ExtractorError, int_or_none, merge_dicts, parse_duration, str_to_int, url_or_none, get_elements_by_class, join_nonempty ) class EpornerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?eporner\....
add a trailing comma and isort this
from .common import InfoExtractor from ..utils import ( ExtractorError, encode_base_n, get_elements_by_class, int_or_none, join_nonempty, merge_dicts, parse_duration, str_to_int, url_or_none, ) class EpornerIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?eporner\.com/(?:(?...
@@ -7,6 +8,8 @@ parse_duration, str_to_int, url_or_none, + get_elements_by_class, + join_nonempty
yt_dlp/extractor/eporner.py
12
Python
0.071
style
35
37
37
false
[eporner] Add support for AV1 codec
9,028
yt-dlp/yt-dlp
132,642
Python
bashonly
michal-repo
title = self._og_search_title(webpage, default=None) or self._html_search_regex( r'<title>(.+?) - EPORNER', webpage, 'title') # Reverse engineered from vjs.js def calc_hash(s): return ''.join((encode_base_n(int(s[lb:lb + 8], 16), 36) for lb in range(0, 32, 8))) ...
```suggestion has_av1 = bool(get_elements_by_class('download-av1', webpage)) ```
title = self._og_search_title(webpage, default=None) or self._html_search_regex( r'<title>(.+?) - EPORNER', webpage, 'title') # Reverse engineered from vjs.js def calc_hash(s): return ''.join((encode_base_n(int(s[lb:lb + 8], 16), 36) for lb in range(0, 32, 8))) ...
@@ -81,6 +84,7 @@ def calc_hash(s): sources = video['sources'] formats = [] + av1 = True if len(get_elements_by_class("download-av1", webpage)) > 0 else False
yt_dlp/extractor/eporner.py
26
Python
0.571
suggestion
90
51
51
false
[eporner] Add support for AV1 codec
9,028
yt-dlp/yt-dlp
132,642
Python
bashonly
michal-repo
for format_id, format_dict in formats_dict.items(): if not isinstance(format_dict, dict): continue src = url_or_none(format_dict.get('src')) if not src or not src.startswith('http'): continue if kind == '...
I'd just use a simple `str.replace` instead of the regex. If using regex though, always use raw strings for patterns ```suggestion if has_av1: formats.append({ 'url': src.replace('.mp4', '-av1.mp4'), 'format_id': jo...
if not isinstance(format_dict, dict): continue src = url_or_none(format_dict.get('src')) if not src or not src.startswith('http'): continue if kind == 'hls': formats.extend(self._extract_m3u8_form...
@@ -106,6 +110,14 @@ def calc_hash(s): 'height': height, 'fps': fps, }) + if av1: + formats.append({ + 'url': re.sub('(.*)(.mp4)', '\\1-av1\\2', src), + ...
yt_dlp/extractor/eporner.py
26
Python
0.857
suggestion
355
49
48
false
[eporner] Add support for AV1 codec
9,028
yt-dlp/yt-dlp
132,642
Python
bashonly
michal-repo
def mock_read(*args, **kwargs): raise raised() monkeypatch.setattr(res.fp, 'read', mock_read) with pytest.raises(expected, match=match) as exc_info: res.read() assert exc_info.type is expected def test_close(self, handler, monkeypatch): rh = handle...
I think this is enough, especially since the values come from us. Same for the other ones ```suggestion assert called ```
( lambda: urllib3.exceptions.ProtocolError('error', http.client.IncompleteRead(partial=b'abc', expected=4)), IncompleteRead, '3 bytes read, 4 more expected' ), ( lambda: urllib3.exceptions.ProtocolError('error', urllib3.exceptions.IncompleteRead(pa...
@@ -889,6 +889,33 @@ def mock_read(*args, **kwargs): assert exc_info.type is expected + def test_close(self, handler, monkeypatch): + rh = handler() + session = rh._get_instance(cookiejar=rh.cookiejar) + called = False + original_close = session.close + + def mock_clos...
test/test_networking.py
26
Python
0.714
suggestion
132
51
51
false
[rh] Remove additional logging handlers on close
9,032
yt-dlp/yt-dlp
132,642
Python
Grub4K
coletdjnz
rh = self.build_handler(ydl, UrllibRH) assert rh.enable_file_urls is True def test_compat_opt_prefer_urllib(self): # This assumes urllib only has a preference when this compat opt is given with FakeYDL({'compat_opts': ['prefer-legacy-http-handler']}) as ydl: dire...
I'm not sure if we would maybe want this? It asserts the cleanup occurs automatically when using `with` (`__exit__`). I would consider `.close()` convenience. ```suggestion assert called ```
def test_urllib_file_urls(self): with FakeYDL({'enable_file_urls': False}) as ydl: rh = self.build_handler(ydl, UrllibRH) assert rh.enable_file_urls is False with FakeYDL({'enable_file_urls': True}) as ydl: rh = self.build_handler(ydl, UrllibRH) asse...
@@ -1380,6 +1420,23 @@ def test_compat_opt_prefer_urllib(self): assert len(director.preferences) == 1 assert director.preferences.pop()(UrllibRH, None) + def test_close(self, monkeypatch): + with FakeYDL() as ydl: + director = ydl._request_director + called = ...
test/test_networking.py
26
Python
0.857
suggestion
201
51
51
false
[rh] Remove additional logging handlers on close
9,032
yt-dlp/yt-dlp
132,642
Python
Grub4K
coletdjnz
def _send(self, request: Request): return Response(fp=io.BytesIO(b'supported'), headers={}, url=request.url) def some_preference(rh, request): return (0 if not isinstance(rh, SomeRH) else 100 if 'prefer' in request.headers else -1)...
```suggestion assert called ```
def some_preference(rh, request): return (0 if not isinstance(rh, SomeRH) else 100 if 'prefer' in request.headers else -1) director.add_handler(SomeRH(logger=FakeLogger())) director.preferences.add(some_preference) assert director.se...
@@ -1198,6 +1234,19 @@ def some_preference(rh, request): assert director.send(Request('http://')).read() == b'' assert director.send(Request('http://', headers={'prefer': '1'})).read() == b'supported' + def test_close(self, monkeypatch): + director = RequestDirector(logger=FakeLogger()) + ...
test/test_networking.py
26
Python
0.429
suggestion
41
51
51
false
[rh] Remove additional logging handlers on close
9,032
yt-dlp/yt-dlp
132,642
Python
Grub4K
coletdjnz
def mock_read(*args, **kwargs): raise raised() monkeypatch.setattr(res.fp, 'read', mock_read) with pytest.raises(expected, match=match) as exc_info: res.read() assert exc_info.type is expected def test_close(self, handler, monkeypatch): rh = handle...
formatting between this and the other one is inconsistent, but i would prefer ```suggestion monkeypatch.setattr(session, 'close', mock_close) rh.close() assert called ```
def mock_read(*args, **kwargs): raise raised() monkeypatch.setattr(res.fp, 'read', mock_read) with pytest.raises(expected, match=match) as exc_info: res.read() assert exc_info.type is expected def test_close(self, handler, monkeypatch): rh = handle...
@@ -889,6 +908,23 @@ def mock_read(*args, **kwargs): assert exc_info.type is expected + def test_close(self, handler, monkeypatch): + rh = handler() + session = rh._get_instance(cookiejar=rh.cookiejar) + called = False + original_close = session.close + + def mock_clos...
test/test_networking.py
26
Python
0.786
suggestion
199
51
51
false
[rh] Remove additional logging handlers on close
9,032
yt-dlp/yt-dlp
132,642
Python
Grub4K
coletdjnz
except SocksProxyError as e: raise ProxyError(cause=e) from e except (websockets.exceptions.WebSocketException, RuntimeError, TimeoutError) as e: raise TransportError(cause=e) from e @register_rh class WebsocketsRH(WebSocketRequestHandler): """ Websockets request handle...
This being a list seems harder than it needs to be. We can do this instead: ```suggestion self.__logging_handlers = {} for name in WEBSOCKETS_LOGGERS: logger = logging.getLogger(name) handler = logging.StreamHandler(stream=sys.stdout) handler.setFormatter(loggin...
except (websockets.exceptions.WebSocketException, RuntimeError, TimeoutError) as e: raise TransportError(cause=e) from e @register_rh class WebsocketsRH(WebSocketRequestHandler): """ Websockets request handler https://websockets.readthedocs.io https://github.com/python-websockets/w...
@@ -90,10 +92,12 @@ class WebsocketsRH(WebSocketRequestHandler): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - for name in ('websockets.client', 'websockets.server'): + self.__logging_handlers = [] + for name in WEBSOCKETS_LOGGERS: logger = lo...
yt_dlp/networking/_websockets.py
26
Python
1
suggestion
573
51
51
false
[rh] Remove additional logging handlers on close
9,032
yt-dlp/yt-dlp
132,642
Python
Grub4K
coletdjnz
# from: https://www.ardmediathek.de/ard/sammlung/der-krieg-und-ich/68cMkqJdllm639Skj4c7sS/ r'.*(?P<ep_info> \((?:Folge |Teil )?(?P<episode_number>\d+)(?:/\d+)?\)).*', r'.*(?P<ep_info>Folge (?P<episode_number>\d+)(?:\:| -|) )\"(?P<episode>.+)\".*', # E.g.: title="Folge 25/...
when the cookie is not set, this fails, so I need a parameter here to ignore failures ERROR: [ARDMediathek] Y3JpZDovL2Rhc2Vyc3RlLmRlL29kZXJicnVjaC8yMDI0LTAxLTIwXzAwLTAwLU1FWg: Unable to download JSON metadata: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)
# E.g.: title="Fritjof aus Norwegen (2) (AD)" # from: https://www.ardmediathek.de/ard/sammlung/der-krieg-und-ich/68cMkqJdllm639Skj4c7sS/ r'.*(?P<ep_info> \((?:Folge |Teil )?(?P<episode_number>\d+)(?:/\d+)?\)).*', r'.*(?P<ep_info>Folge (?P<episode_number>\d+)(?:\:| -|) )\"...
@@ -360,11 +361,29 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) - page_data = self._download_json( - f'https://api.ardmediathek.de/page-gateway/pages/ard/item/{display_id}', display_id, query={ - 'embedded': 'f...
yt_dlp/extractor/ard.py
26
Python
0.643
bug
281
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
StefanLobbenmeier
StefanLobbenmeier
def _real_extract(self, url): display_id = self._match_id(url) token = self._download_json('https://sso.ardmediathek.de/sso/token', display_id) id_token = traverse_obj(token, 'idToken') if id_token: jwt_token_decoded = jwt_decode_hs256(id_token) user_id = ...
I would like to avoid having duplication here, maybe by instead writing to the query instead?
}), get_all=False) def _real_extract(self, url): display_id = self._match_id(url) query = {'embedded': 'false', 'mcV6': 'true'} headers = {} if self._get_cookies(self._TOKEN_URL).get('ams'): token = self._download_json( self._TOKEN_URL, display_i...
@@ -360,11 +361,29 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) - page_data = self._download_json( - f'https://api.ardmediathek.de/page-gateway/pages/ard/item/{display_id}', display_id, query={ - 'embedded': 'f...
yt_dlp/extractor/ard.py
26
Python
0.286
question
93
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
StefanLobbenmeier
StefanLobbenmeier
# from: https://www.ardmediathek.de/ard/sendung/die-fallers/Y3JpZDovL3N3ci5kZS8yMzAyMDQ4/ r'.*(?P<ep_info>Folge (?P<episode_number>\d+)(?:/\d+)?(?:\:| -|) ).*', # As a fallback use the full title r'(?P<title>.*)', ] return traverse_obj(patterns, (..., {pa...
can we check for cookies before making this request? e.g. ```py if self._get_cookies(url).get('COOKIENAME'): token = self._download_json( 'https://sso.ardmediathek.de/sso/token', display_id, fatal=False) ``` of course replacing `COOKIENAME` with an actually relevant cookie na...
# E.g.: title="Folge 1063 - Vertrauen" # from: https://www.ardmediathek.de/ard/sendung/die-fallers/Y3JpZDovL3N3ci5kZS8yMzAyMDQ4/ r'.*(?P<ep_info>Folge (?P<episode_number>\d+)(?:/\d+)?(?:\:| -|) ).*', # As a fallback use the full title r'(?P<title>.*)', ...
@@ -360,11 +361,26 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) + query = { + 'embedded': 'false', + 'mcV6': 'true' + } + headers = {} + + token = self._download_json('https://sso.ardmediathek....
yt_dlp/extractor/ard.py
26
Python
0.786
question
378
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
bashonly
StefanLobbenmeier
r'(?P<title>.*)', ] return traverse_obj(patterns, (..., {partial(re.match, string=title)}, { 'season_number': ('season_number', {int_or_none}), 'episode_number': ('episode_number', {int_or_none}), 'episode': (( ('episode', {str_or_none}), ...
let's use a class variable for `https://sso.ardmediathek.de/sso/token`, e.g. ```py _TOKEN_URL = 'https://sso.ardmediathek.de/sso/token' ``` and then ```suggestion if self._get_cookies(self._TOKEN_URL).get('ams'): token = self._download_json( self._TOKEN_URL, display_id, '...
# As a fallback use the full title r'(?P<title>.*)', ] return traverse_obj(patterns, (..., {partial(re.match, string=title)}, { 'season_number': ('season_number', {int_or_none}), 'episode_number': ('episode_number', {int_or_none}), 'episode': ...
@@ -360,11 +361,30 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) + query = { + 'embedded': 'false', + 'mcV6': 'true' + } + headers = {} + + ams_cookie = self._get_cookies("https://sso.ardmediath...
yt_dlp/extractor/ard.py
26
Python
0.857
suggestion
434
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
bashonly
StefanLobbenmeier
), {str.strip}), }), get_all=False) def _real_extract(self, url): display_id = self._match_id(url) query = { 'embedded': 'false', 'mcV6': 'true' } headers = {} ams_cookie = self._get_cookies("https://sso.ardmediathek.de/sso/token...
using the power of traversal, we can check both values before warning/aborting just to confirm, the `user_id` is found in both the `user_id` and `sub` fields of the JWT, right? ```suggestion id_token = traverse_obj(token, ('idToken', {str})) user_id = traverse_obj(id_token, ({jwt_decode_hs...
('title', {str}), ), {str.strip}), }), get_all=False) def _real_extract(self, url): display_id = self._match_id(url) query = {'embedded': 'false', 'mcV6': 'true'} headers = {} if self._get_cookies(self._TOKEN_URL).get('ams'): token = ...
@@ -360,11 +361,30 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) + query = { + 'embedded': 'false', + 'mcV6': 'true' + } + headers = {} + + ams_cookie = self._get_cookies("https://sso.ardmediath...
yt_dlp/extractor/ard.py
26
Python
0.857
security
646
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
bashonly
StefanLobbenmeier
query['userId'] = user_id page_data = self._download_json( f'https://api.ardmediathek.de/page-gateway/pages/ard/item/{display_id}', display_id, query=query, headers=headers) # For user convenience we use the old contentId instead of the longer crid # Ref...
```suggestion self.raise_login_required( 'This video is only available after 22:00. Try passing cookies to enable age verification') ```
f'https://api.ardmediathek.de/page-gateway/pages/ard/item/{display_id}', display_id, query=query, headers=headers) # For user convenience we use the old contentId instead of the longer crid # Ref: https://github.com/yt-dlp/yt-dlp/issues/8731#issuecomment-1874398283 old_i...
@@ -383,7 +403,9 @@ def _real_extract(self, url): media_data = traverse_obj(player_data, ('mediaCollection', 'embedded', {dict})) if player_data.get('blockedByFsk'): - self.raise_no_formats('This video is only available after 22:00', expected=True) + self.raise_no_formats( + ...
yt_dlp/extractor/ard.py
26
Python
0.714
suggestion
167
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
bashonly
StefanLobbenmeier
return traverse_obj(patterns, (..., {partial(re.match, string=title)}, { 'season_number': ('season_number', {int_or_none}), 'episode_number': ('episode_number', {int_or_none}), 'episode': (( ('episode', {str_or_none}), ('ep_info', {lambda x: ti...
To only decode the jwt once ```suggestion decoded_token = traverse_obj(id_token, ({jwt_decode_hs256}, {dict})) user_id = traverse_obj(decoded_token, (('user_id', 'sub'), {str}), get_all=False) if not decoded_token or not user_id: ```
return traverse_obj(patterns, (..., {partial(re.match, string=title)}, { 'season_number': ('season_number', {int_or_none}), 'episode_number': ('episode_number', {int_or_none}), 'episode': (( ('episode', {str_or_none}), ('ep_info', {lambda x: ti...
@@ -360,11 +362,32 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) + query = { + 'embedded': 'false', + 'mcV6': 'true' + } + headers = {} + + if self._get_cookies(self._TOKEN_URL).get('ams'): + ...
yt_dlp/extractor/ard.py
26
Python
0.857
suggestion
274
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
seproDev
StefanLobbenmeier
def _real_extract(self, url): display_id = self._match_id(url) query = { 'embedded': 'false', 'mcV6': 'true' } headers = {} if self._get_cookies(self._TOKEN_URL).get('ams'): token = self._download_json( self._TOKEN_URL, d...
We don't want to throw an additional warning if the token couldn't even be fetched. I would also not print the age rating, as for unverified accounts it is `None`. ```suggestion if decoded_token.get('age_rating') != 18: self.report_warning('Account is not verified as 18+; video m...
def _real_extract(self, url): display_id = self._match_id(url) query = {'embedded': 'false', 'mcV6': 'true'} headers = {} if self._get_cookies(self._TOKEN_URL).get('ams'): token = self._download_json( self._TOKEN_URL, display_id, 'Fetching token for age ...
@@ -360,11 +362,32 @@ def _extract_episode_info(self, title): def _real_extract(self, url): display_id = self._match_id(url) + query = { + 'embedded': 'false', + 'mcV6': 'true' + } + headers = {} + + if self._get_cookies(self._TOKEN_URL).get('ams'): + ...
yt_dlp/extractor/ard.py
26
Python
0.857
suggestion
344
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
seproDev
StefanLobbenmeier
'video might still be blocked') page_data = self._download_json( f'https://api.ardmediathek.de/page-gateway/pages/ard/item/{display_id}', display_id, query=query, headers=headers) # For user convenience we use the old contentId instead of the...
How about just: ```suggestion self.raise_login_required('This video is only available for age verified users or after 22:00') ```
# For user convenience we use the old contentId instead of the longer crid # Ref: https://github.com/yt-dlp/yt-dlp/issues/8731#issuecomment-1874398283 old_id = traverse_obj(page_data, ('tracking', 'atiCustomVars', 'contentId', {int})) if old_id is not None: video_id = str(old...
@@ -383,7 +406,9 @@ def _real_extract(self, url): media_data = traverse_obj(player_data, ('mediaCollection', 'embedded', {dict})) if player_data.get('blockedByFsk'): - self.raise_no_formats('This video is only available after 22:00', expected=True) + self.raise_login_required( ...
yt_dlp/extractor/ard.py
26
Python
0.786
suggestion
144
51
51
false
[ie/ARDBetaMediathekIE] Add age verification
9,037
yt-dlp/yt-dlp
132,642
Python
seproDev
StefanLobbenmeier
'url': 'https://burn7.newgrounds.com/movies', 'info_dict': { 'id': 'burn7', }, 'playlist_mincount': 2, }, { 'url': 'https://brian-beaton.newgrounds.com/movies', 'info_dict': { 'id': 'brian-beaton', }, 'playlist_mincount': 10, ...
could we do this? ```suggestion for post in traverse_obj(posts_info, ('items', ..., ..., {str})): ```
}, { 'url': 'https://burn7.newgrounds.com/movies', 'info_dict': { 'id': 'burn7', }, 'playlist_mincount': 2, }, { 'url': 'https://brian-beaton.newgrounds.com/movies', 'info_dict': { 'id': 'brian-beaton', }, 'playlist_mincount...
@@ -263,14 +262,14 @@ class NewgroundsUserIE(InfoExtractor): def _fetch_page(self, channel_id, url, page): page += 1 posts_info = self._download_json( - f'{url}/page/{page}', channel_id, + f'{url}?page={page}', channel_id, note=f'Downloading page {page}', header...
yt_dlp/extractor/newgrounds.py
26
Python
0.786
suggestion
112
39
37
false
[Newgrounds] Fix user page extractor
9,046
yt-dlp/yt-dlp
132,642
Python
bashonly
u-spec-png
video, ('creation_story', 'short_form_video_context', 'playback_video', {dict})) if reel_info: video = video['creation_story'] video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner')) ...
`get_first(x, y)` is just `traverse_obj(x, (..., y), get_all=False)` ```suggestion is_video_broadcast = traverse_obj(video, ('is_video_broadcast', {bool})) ```
video, ('creation_story', 'short_form_video_context', 'playback_video', {dict})) if reel_info: video = video['creation_story'] video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner')) ...
@@ -616,6 +603,32 @@ def parse_graphql_video(video): 'url': playable_url, }) extract_dash_manifest(video, formats) + + automatic_captions, subtitles = {}, {} + is_video_broadcast = get_first([video],...
yt_dlp/extractor/facebook.py
26
Python
0.857
suggestion
182
51
51
false
[ie/facebook] add handling of facebook.com/events
9,055
yt-dlp/yt-dlp
132,642
Python
bashonly
kclauhk
if determine_ext(playable_url) == 'mpd': formats.extend(self._extract_mpd_formats(playable_url, video_id)) else: formats.append({ 'format_id': format_id, ...
we don't have use the same var for the single `captions_url` and the `captions` list anymore ```suggestion if captions_url := traverse_obj(video, ('captions_url', {url_or_none})): locale = self._html_search_meta( ['og:locale', 'twitter:locale']...
if determine_ext(playable_url) == 'mpd': formats.extend(self._extract_mpd_formats(playable_url, video_id)) else: formats.append({ 'format_id': format_id, ...
@@ -616,6 +603,32 @@ def parse_graphql_video(video): 'url': playable_url, }) extract_dash_manifest(video, formats) + + automatic_captions, subtitles = {}, {} + is_video_broadcast = get_first([video],...
yt_dlp/extractor/facebook.py
26
Python
1
suggestion
937
51
51
false
[ie/facebook] add handling of facebook.com/events
9,055
yt-dlp/yt-dlp
132,642
Python
bashonly
kclauhk
info['title'] = description or 'Facebook video #%s' % v_id entries.append(info) def parse_attachment(attachment, key='media'): media = attachment.get(key) or {} if media.get('__typename') == 'Video': ...
it's not good to do `traverse_obj(data, ...) or data.get(...)` when we can pass multiple paths to `traverse_obj` instead ```suggestion video = traverse_obj(data, ( 'event', 'cover_media_renderer', 'cover_video'), 'video', expected_type=dict) or {} ```
def parse_attachment(attachment, key='media'): media = attachment.get(key) or {} if media.get('__typename') == 'Video': return parse_graphql_video(media) nodes = variadic(traverse_obj(data, 'nodes', 'node') or []) ...
@@ -659,7 +674,8 @@ def parse_attachment(attachment, key='media'): for edge in edges: parse_attachment(edge, key='node') - video = data.get('video') or {} + video = (traverse_obj(data, ('event', 'cover_media_renderer', 'cover_video', {dict})) # even...
yt_dlp/extractor/facebook.py
26
Python
1
suggestion
291
51
51
false
[ie/facebook] add handling of facebook.com/events
9,055
yt-dlp/yt-dlp
132,642
Python
bashonly
kclauhk
class LinkedInIE(LinkedInBaseIE): _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' _TESTS = [{ 'url': 'https://www.linkedin.com/posts/mishalkhawaja_sendinblueviews-toronto-digitalmarketing-ugcPost-6850898786781339649-mM20', 'info_dict': { 'id': '685089878678133...
`video_json` is a misnomer imo ```suggestion video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) sources = self._parse_json(video_attrs['data-sources'], video_id) ```
class LinkedInIE(LinkedInBaseIE): _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/[^/?#]+-(?P<id>\d+)-\w{4}/?(?:[?#]|$)' _TESTS = [{ 'url': 'https://www.linkedin.com/posts/mishalkhawaja_sendinblueviews-toronto-digitalmarketing-ugcPost-6850898786781339649-mM20', 'info_dict': { ...
@@ -104,12 +104,17 @@ def _real_extract(self, url): like_count = int_or_none(get_element_by_class('social-counts-reactions__social-counts-numRections', webpage)) creator = strip_or_none(clean_html(get_element_by_class('comment__actor-name', webpage))) - sources = self._parse_json(extract_attr...
yt_dlp/extractor/linkedin.py
26
Python
0.857
refactor
224
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
'ext': 'mp4', 'title': 'Mishal K. on LinkedIn: #sendinblueviews #toronto #digitalmarketing', 'description': 'md5:be125430bab1c574f16aeb186a4d5b19', 'creator': 'Mishal K.' }, }] def _real_extract(self, url): video_id = self._match_id(url) w...
```suggestion if sub_url := url_or_none(video_attrs.get('data-captions-url')): ``` `url_or_none` will need to be imported
'title': 'Mishal K. on LinkedIn: #sendinblueviews #toronto #digitalmarketing #nowhiring #sendinblue…', 'description': 'md5:2998a31f6f479376dd62831f53a80f71', 'uploader': 'Mishal K.', 'thumbnail': 're:^https?://media.licdn.com/dms/image/.*$', 'like_count': int ...
@@ -104,12 +104,17 @@ def _real_extract(self, url): like_count = int_or_none(get_element_by_class('social-counts-reactions__social-counts-numRections', webpage)) creator = strip_or_none(clean_html(get_element_by_class('comment__actor-name', webpage))) - sources = self._parse_json(extract_attr...
yt_dlp/extractor/linkedin.py
26
Python
0.714
suggestion
132
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
'title': 'Mishal K. on LinkedIn: #sendinblueviews #toronto #digitalmarketing', 'description': 'md5:be125430bab1c574f16aeb186a4d5b19', 'creator': 'Mishal K.' }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_we...
I'd do: ```suggestion subtitles = {'en': [{ 'url': video_attrs['data-captions-url'], 'ext': 'vtt', }]} if url_or_none(video_attrs.get('data-captions-url')) else {} ```
'description': 'md5:2998a31f6f479376dd62831f53a80f71', 'uploader': 'Mishal K.', 'thumbnail': 're:^https?://media.licdn.com/dms/image/.*$', 'like_count': int }, }, { 'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-a...
@@ -104,12 +104,17 @@ def _real_extract(self, url): like_count = int_or_none(get_element_by_class('social-counts-reactions__social-counts-numRections', webpage)) creator = strip_or_none(clean_html(get_element_by_class('comment__actor-name', webpage))) - sources = self._parse_json(extract_attr...
yt_dlp/extractor/linkedin.py
26
Python
0.786
suggestion
213
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
pukkandan
barsnick
query.update({ 'videoSlug': video_slug, 'resolution': '_%s' % resolution, }) sub = ' %dp' % resolution api_url = 'https://www.linkedin.com/learning-api/detailedCourses' if not self._get_cookies(api_url).get('JSESSIONID'): se...
we can still match the numeric id ```suggestion _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/[^/?#]+-(?P<id>\d+)-\w{4}/?(?:[?#]|$)' ```
query.update({ 'videoSlug': video_slug, 'resolution': '_%s' % resolution, }) sub = ' %dp' % resolution api_url = 'https://www.linkedin.com/learning-api/detailedCourses' if not self._get_cookies(api_url).get('JSESSIONID'): se...
@@ -83,42 +82,69 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/(?P<id>[^/?#]+)'
yt_dlp/extractor/linkedin.py
26
Python
0.714
suggestion
151
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
'description': 'md5:2998a31f6f479376dd62831f53a80f71', 'uploader': 'Mishal K.', 'thumbnail': 'https://media.licdn.com/dms/image/C4E05AQG7hCp7zIeciw/feedshare-thumbnail_720_1280/0/1633381554858?e=2147483647&v=beta&t=teGgAD-Z8A2K4UrwAtEgHz9xGMrRLmUK6cE3vm3csK0', 'like_count...
if we're changing these we might as well inline them in the return as well
'uploader': 'Mishal K.', 'thumbnail': 're:^https?://media.licdn.com/dms/image/.*$', 'like_count': int }, }, { 'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7', 'info_dict': { ...
@@ -83,42 +82,69 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.li...
yt_dlp/extractor/linkedin.py
26
Python
0.214
suggestion
74
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
'like_count': int }, }, { 'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7', 'info_dict': { 'id': 'D5610AQFKo9M0zqY2_g', 'display_id': 'the-mathworks_2_what-is-mathworks-cloud-center-ac...
```suggestion uploader = traverse_obj( self._yield_json_ld(webpage, video_id), (lambda _, v: v['@type'] == 'SocialMediaPosting', 'author', 'name', {str}), get_all=False) ``` this could be inlined too
}, }, { 'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7', 'info_dict': { 'id': '7151241570371948544', 'ext': 'mp4', 'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?', ...
@@ -83,42 +82,69 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.li...
yt_dlp/extractor/linkedin.py
26
Python
1
security
236
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
}, }, { 'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7', 'info_dict': { 'id': 'D5610AQFKo9M0zqY2_g', 'display_id': 'the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu...
inline below, and I would simplify/relax the regex a bit ```suggestion like_count = int_or_none(self._search_regex( r'\bdata-num-reactions="(\d+)"', webpage, 'reactions', default=None)) ```
}, { 'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7', 'info_dict': { 'id': '7151241570371948544', 'ext': 'mp4', 'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?', ...
@@ -83,42 +82,69 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.li...
yt_dlp/extractor/linkedin.py
26
Python
0.857
refactor
213
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
'display_id': 'the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7', 'ext': 'mp4', 'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?', 'description': 'md5:95f9d4eeb6337882fb47eefe13d7a40c', 'uploader': 'MathWorks', ...
Is there a need to change the id from the numeric id in the URL? are there posts URLs without a numeric id? I can't seem to find any. IMO we should keep the id the same as it was before. If there is a good reason to change it, though, then: - don't redefine built-ins / don't use `id` as var name - we still need to...
'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?', 'description': 'md5:95f9d4eeb6337882fb47eefe13d7a40c', 'uploader': 'MathWorks', 'thumbnail': 're:^https?://media.licdn.com/dms/image/.*$', 'like_count': int, 'subtitles': 'mincount:...
@@ -83,42 +82,69 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/(?P<id>[^/?#]+)' _TESTS = [{ 'url': 'https://www.li...
yt_dlp/extractor/linkedin.py
26
Python
0.643
suggestion
428
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
'like_count': int, 'subtitles': 'mincount:1' }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) ...
line too long ```suggestion 'like_count': int_or_none(self._search_regex( r'\bdata-num-reactions="(\d+)"', webpage, 'reactions', default=None)), ```
'like_count': int, 'subtitles': 'mincount:1' }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) ...
@@ -83,42 +82,58 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/[^/?#]+-(?P<id>\d+)-\w{4}/?(?:[?#]|$)' _TESTS = [{ ...
yt_dlp/extractor/linkedin.py
26
Python
0.714
refactor
180
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
}, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) sources = self._parse_json(video_attrs['data-sources'], video_id)...
- `traverse_obj` can traverse a generator - move `name` into the traversal path - line too long ```suggestion 'uploader': traverse_obj( self._yield_json_ld(webpage, video_id), (lambda _, v: v['@type'] == 'SocialMediaPosting', 'author', 'name', {str}), get_all=False) ``...
}, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) sources = self._parse_json(video_attrs['data-sources'], video_id)...
@@ -83,42 +82,58 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/[^/?#]+-(?P<id>\d+)-\w{4}/?(?:[?#]|$)' _TESTS = [{ ...
yt_dlp/extractor/linkedin.py
26
Python
1
security
321
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
from itertools import zip_longest import re from .common import InfoExtractor from ..utils import ( extract_attributes, ExtractorError, float_or_none, int_or_none, srt_subtitles_timecode, mimetype2ext, traverse_obj, try_get, url_or_none, urlencode_postdata, urljoin, ) clas...
this is not your doing, but while we're touching the imports let's fix it ```suggestion ExtractorError, extract_attributes, ```
from itertools import zip_longest import re from .common import InfoExtractor from ..utils import ( ExtractorError, extract_attributes, float_or_none, int_or_none, srt_subtitles_timecode, mimetype2ext, traverse_obj, try_get, url_or_none, urlencode_postdata, urljoin, ) clas...
@@ -3,16 +3,15 @@ from .common import InfoExtractor from ..utils import ( - clean_html, extract_attributes, ExtractorError,
yt_dlp/extractor/linkedin.py
7
Python
0.929
refactor
139
32
32
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) sources = self._parse_json(video_attrs['data-sources'], video_id) formats =...
```suggestion (lambda _, v: v['@type'] == 'SocialMediaPosting', 'author', 'name', {str}), get_all=False), ```
def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video')) sources = self._parse_json(video_attrs['data-sources'], video_id) formats =...
@@ -83,42 +82,60 @@ def _get_video_id(self, video_data, course_slug, video_slug): class LinkedInIE(LinkedInBaseIE): - _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/.+?(?P<id>\d+)' + _VALID_URL = r'https?://(?:www\.)?linkedin\.com/posts/[^/?#]+-(?P<id>\d+)-\w{4}/?(?:[?#]|$)' _TESTS = [{ ...
yt_dlp/extractor/linkedin.py
26
Python
0.857
security
127
51
51
false
[ie/LinkedIn] Fix metadata and extract subtitles
9,056
yt-dlp/yt-dlp
132,642
Python
bashonly
barsnick
return content or {} def _real_extract(self, url): video_id, host, display_id = self._match_valid_url(url).group('id', 'host', 'display_id') headers = {'Referer': url, 'X-Requested-With': 'XMLHttpRequest'} video_file = self._call_api( f'https://{host}/api/videofile.php?...
maybe we should use `url_or_none` just in case? Need to import it from `utils` ```suggestion 'thumbnail': traverse_obj(video_info, ('video', 'thumbsrc', {url_or_none})), ```
f'Txxx said: {content["error"]}', expected=True), fatal=fatal) return content or {} def _real_extract(self, url): video_id, host, display_id = self._match_valid_url(url).group('id', 'host', 'display_id') headers = {'Referer': url, 'X-Requested-With': 'XMLHttpRequest'} ...
@@ -371,6 +389,7 @@ def _real_extract(self, url): 'like_count': int_or_none(traverse_obj(video_info, ('video', 'statistics', 'likes'))), 'dislike_count': int_or_none(traverse_obj(video_info, ('video', 'statistics', 'dislikes'))), 'age_limit': 18, + 'thumbnail': traverse...
yt_dlp/extractor/txxx.py
26
Python
0.786
suggestion
188
51
51
false
[extractor/txxx] Added thumbnails
9,063
yt-dlp/yt-dlp
132,642
Python
Grub4K
shmohawk
self._API_BASE_URL + 'authentication/login', None, 'Logging in', self._LOGIN_ERR_MESSAGE, fatal=False, data=urlencode_postdata({ 'password': password, 'rememberMe': False, 'source': 'Web', 'us...
since you said this in the linked issue: > Currently there is no free German content, so we could just hardcode the login requirement for .de Links. But this may change once the site launches officially. There was free content a few weeks ago, so this may change at any time. I don't think we should hardcode this ...
try: access_token = (self._download_json( self._API_BASE_URL + 'authentication/login', None, 'Logging in', self._LOGIN_ERR_MESSAGE, fatal=False, data=urlencode_postdata({ 'password': password, 'rememberMe': False...
@@ -176,16 +176,29 @@ def _perform_login(self, username, password): def _real_extract(self, url): lang, video_id = self._match_valid_url(url).group('lang', 'id') + username, password = self._get_login_info() + # ADN requires login for German site (at least for now) + if lang == 'de'...
yt_dlp/extractor/adn.py
26
Python
0.857
refactor
562
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
if isinstance(e.cause, HTTPError) and e.cause.status == 401: resp = self._parse_json( e.cause.response.read().decode(), None, fatal=False) or {} message = resp.get('message') or resp.get('code') self.report_warning(message or self._LOGIN_ERR_ME...
same as above ```suggestion user = options['user'] ```
except ExtractorError as e: message = None if isinstance(e.cause, HTTPError) and e.cause.status == 401: resp = self._parse_json( e.cause.response.read().decode(), None, fatal=False) or {} message = resp.get('message') or resp.get('code'...
@@ -176,16 +176,29 @@ def _perform_login(self, username, password): def _real_extract(self, url): lang, video_id = self._match_valid_url(url).group('lang', 'id') + username, password = self._get_login_info() + # ADN requires login for German site (at least for now) + if lang == 'de'...
yt_dlp/extractor/adn.py
26
Python
0.643
suggestion
65
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
def _real_extract(self, url): lang, video_id = self._match_valid_url(url).group('lang', 'id') username, password = self._get_login_info() # ADN requires login for German site (at least for now) if lang == 'de' and (not username or not password): self.raise_login_required...
```suggestion if self._HEADERS: raise ExtractorError('This video requires a subscription', expected=True) self.raise_login_required(method='password') ```
message = resp.get('message') or resp.get('code') self.report_warning(message or self._LOGIN_ERR_MESSAGE) def _real_extract(self, url): lang, video_id = self._match_valid_url(url).group('lang', 'id') video_base_url = self._PLAYER_BASE_URL + 'video/%s/' % video_id ...
@@ -176,16 +176,29 @@ def _perform_login(self, username, password): def _real_extract(self, url): lang, video_id = self._match_valid_url(url).group('lang', 'id') + username, password = self._get_login_info() + # ADN requires login for German site (at least for now) + if lang == 'de'...
yt_dlp/extractor/adn.py
26
Python
0.929
refactor
198
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
self._HEADERS = {'authorization': 'Bearer ' + access_token} except ExtractorError as e: message = None if isinstance(e.cause, HTTPError) and e.cause.status == 401: resp = self._parse_json( e.cause.response.read().decode(), None, fatal=F...
```suggestion self.raise_login_required('This video requires a subscription', method='password') ```
})) or {}).get('accessToken') if access_token: self._HEADERS = {'authorization': 'Bearer ' + access_token} except ExtractorError as e: message = None if isinstance(e.cause, HTTPError) and e.cause.status == 401: resp = self._pars...
@@ -182,10 +182,15 @@ def _real_extract(self, url): 'Downloading player config JSON metadata', headers=self._HEADERS)['player'] options = player['options'] + video = options['video'] + startDate = video.get('startDate') + currentDate = video.get('currentDate') + ...
yt_dlp/extractor/adn.py
26
Python
0.714
suggestion
114
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
formats = [] for format_id, qualities in (links.get('streaming') or {}).items(): if not isinstance(qualities, dict): continue for quality, load_balancer_url in qualities.items(): load_balancer_data = self._download_json( load_b...
```suggestion self.raise_login_required('This video requires a subscription', method='password') ```
formats = [] for format_id, qualities in (links.get('streaming') or {}).items(): if not isinstance(qualities, dict): continue for quality, load_balancer_url in qualities.items(): load_balancer_data = self._download_json( load_b...
@@ -267,6 +272,9 @@ def _real_extract(self, url): f['language'] = 'de' formats.extend(m3u8_formats) + if not formats: + self.raise_login_required(msg='This video requires a subscription', method='password')
yt_dlp/extractor/adn.py
26
Python
0.714
suggestion
114
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
'source': 'Web', 'username': username, })) or {}).get('accessToken') if access_token: self._HEADERS = {'authorization': 'Bearer ' + access_token} except ExtractorError as e: message = None if isinstance(e...
Are these values unix timestamps? And if so, should we rely on `currentDate` instead of `time.time()`? IMO we should do this a bit more safely (and use snake_case): ```suggestion start_date = traverse_obj(options, ('video', 'startDate', {int})) current_date = traverse_obj(options, ('video', 'currentD...
'password': password, 'rememberMe': False, 'source': 'Web', 'username': username, })) or {}).get('accessToken') if access_token: self._HEADERS = {'authorization': 'Bearer ' + access_token} ...
@@ -182,10 +182,15 @@ def _real_extract(self, url): 'Downloading player config JSON metadata', headers=self._HEADERS)['player'] options = player['options'] + video = options['video'] + startDate = video.get('startDate') + currentDate = video.get('currentDate') + ...
yt_dlp/extractor/adn.py
26
Python
1
refactor
690
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
})) or {}).get('accessToken') if access_token: self._HEADERS = {'authorization': 'Bearer ' + access_token} except ExtractorError as e: message = None if isinstance(e.cause, HTTPError) and e.cause.status == 401: resp = self._pars...
```suggestion self.raise_login_required('This video requires a subscription', method='password') ```
})) or {}).get('accessToken') if access_token: self._HEADERS = {'authorization': 'Bearer ' + access_token} except ExtractorError as e: message = None if isinstance(e.cause, HTTPError) and e.cause.status == 401: resp = self._pars...
@@ -185,7 +187,10 @@ def _real_extract(self, url): user = options['user'] if not user.get('hasAccess'): - self.raise_login_required() + start_date = traverse_obj(options, ('video', 'startDate', {str})) + if (parse_iso8601(start_date) or 0) > time.time(): + ...
yt_dlp/extractor/adn.py
26
Python
0.714
suggestion
114
51
51
false
[ie/adn] require subscriptions in German
9,068
yt-dlp/yt-dlp
132,642
Python
bashonly
infanf
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', 'duration': 1322, } }, { 'url': 'https://www.nytimes.com/2023/11/29/business/dealbook/kamala-harris-biden-voters.html', 'md5': '3eb5ddb1d6f86254fe4f233826778737', 'info_dict': { 'id': '100000...
These URLs still work. I know the extractor was broken, and I see that you removed/renamed/rewrote the method it was using to perform most of the extraction, but we still shouldn't remove the extractor or tests. Mark it as `_WORKING = False` and have it just return an `id`-only info dict for now
video_url, video_id, 'mp4', 'm3u8_native', m3u8_id=format_id or 'hls', fatal=False) formats.extend(m3u8_fmts) self._merge_subtitles(m3u8_subs, target=subtitles) elif ext == 'mpd': continue # all mpd urls give 404 errors...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.643
bug
296
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
creator = ', '.join( traverse_obj(article_json, ('bylines', ..., 'creators', ..., 'displayName'), get_all=True)) # more than 1 video in the article, treat it as a playlist if len(blocks_json) > 1: entries = [] for block_json in blocks_json: vi...
This URL still works too, although it redirects to `https://archive.nytimes.com/www.nytimes.com/news/minute/2014/03/17/times-minute-whats-next-in-crimea/?_php=true&_php=true&_r=1&_type=blogs&_type=blogs` We'll probably need to add a new `NYTimesArchive` extractor for this, which can be a separate PR. Just noting it ...
'description': 'md5:93603dada88ddbda9395632fdc5da260', 'timestamp': 1398631707, # FIXME 'upload_date': '20140427', # FIXME 'creator': 'Brett Weiner', 'thumbnail': r're:https?://\w+\.nyt.com/images/.+\.jpg', 'duration': 419, }, }, { ...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.786
refactor
351
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
image_url = image.get('url') if not image_url: continue thumbnails.append({ 'url': image_url, 'width': int_or_none(image.get('width')), 'height': int_or_none(image.get('height')), }) return { ...
IMO keep this named `NYTimesCookingIE` you can add `IE_NAME = 'NYTimesCookingRecipes'` if you want (note the spelling of "Recipes")
'skip_download': 'm3u8', }, }, { # multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html', 'info_dict': { 'id': 'air-traffic-controllers-safety', 'title': 'Drunk and Asleep on th...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.5
suggestion
132
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'width': int_or_none(image.get('width')), 'height': int_or_none(image.get('height')), }) entries.append({ 'id': media_id, 'title': title, 'description': description, 'duration': duration,...
single quotes all over this extractor
import json import uuid from .common import InfoExtractor from ..utils import ( ExtractorError, clean_html, determine_ext, extract_attributes, float_or_none, get_elements_html_by_class, int_or_none, merge_dicts, mimetype2ext, parse_iso8601, remove_end, remove_start, ...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.143
refactor
37
51
417
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
# single video example 'url': 'https://cooking.nytimes.com/guides/50-how-to-make-mac-and-cheese', 'md5': '64415805fe0b8640fce6b0b9def5989a', 'info_dict': { 'id': '100000005835845', 'ext': 'mp4', 'title': 'How to Make Mac and Cheese', 'descr...
we should try to remove any of the fields we're not using for metadata from the query
lead_video_id = self._search_regex( r'data-video-player-id="(\d+)"></div>', webpage, 'lead video') media_ids = traverse_obj( get_elements_html_by_class('video-item', webpage), (..., {extract_attributes}, 'data-video-id')) if media_ids: media_ids.append(lead_v...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.286
suggestion
85
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
formats, subtitles = self._extract_media_from_json(media_id, media_content) thumbnails = [] for image in traverse_obj(json_obj, ('promotionalMedia', 'crops', ..., 'renditions', ...)): image_url = image.get('url') if not url_or_none(image_url): ...
don't redefine built-ins ```suggestion def _json_from_graphql(self, media_id): ```
import json import uuid from .common import InfoExtractor from ..utils import ( ExtractorError, clean_html, determine_ext, extract_attributes, float_or_none, get_elements_html_by_class, int_or_none, merge_dicts, mimetype2ext, parse_iso8601, remove_end, remove_start, ...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.571
suggestion
89
51
417
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
headers = { "Content-Type": "application/json", "Nyt-App-Type": "vhs", "Nyt-App-Version": "v3.52.21", "Nyt-Token": self._TOKEN, "Origin": "https://cooking.nytimes.com", "Referer": "https://www.google.com/", } return self._...
would this work? ```suggestion r'<span itemprop="author">([^<]+)</span></p>', webpage, 'author', default=None) ```
import json import uuid from .common import InfoExtractor from ..utils import ( ExtractorError, clean_html, determine_ext, extract_attributes, float_or_none, get_elements_html_by_class, int_or_none, merge_dicts, mimetype2ext, parse_iso8601, remove_end, remove_start, ...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.714
security
129
51
417
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'id': video_id, 'title': media_title, 'description': media_description, 'timestamp': timestamp, 'upload_date': unified_strdate(publication_date), 'uploader': uploader, 'creator': c...
this is duplicating the code above, move it into a method
'uploader': 'Matthew Williams', 'creator': 'Patricia Cohen', 'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', 'duration': 119.0, }, }, { # article with audio and no video 'url': 'https://www.nytimes.com/2023/09/29/health/mosquitoes-gene...
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
0.286
suggestion
57
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'duration': 97, }, 'params': { # inconsistant md5 'skip_download': True, }, }, { # multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html', 'info_dict': { ...
- `article_json` can be fatal since we don't have anything to extract without it - escape the dot and match any amount of whitespace before `=` in the pattern - instead of replacing `:undefined` with `:null` when setting `webpage`, try `transform_source=js_to_json` in the `_search_json()` params, or else if necessary...
'ext': ext, }) return formats, subtitles def _extract_video(self, media_id): data = self._call_api(media_id) formats, subtitles = self._extract_formats_and_subtitles(media_id, data) return { 'id': media_id, 'title': data....
@@ -59,204 +51,546 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False...
yt_dlp/extractor/nytimes.py
26
Python
1
security
659
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
int_or_none, merge_dicts, mimetype2ext, parse_iso8601, remove_end, remove_start, str_or_none, traverse_obj, unified_strdate, url_or_none, ) class NYTimesBaseIE(InfoExtractor): _GRAPHQL_API = 'https://samizdat-graphql.nytimes.com/graphql/v2' @staticmethod def _get_f...
this helper is only used once and it has been obsoleted by `traverse_obj()`, so we can just use that below ```suggestion def _extract_media_from_json(self, video_id, content_media_json): ```
float_or_none, get_elements_html_by_class, int_or_none, merge_dicts, mimetype2ext, parse_iso8601, remove_end, remove_start, str_or_none, traverse_obj, url_or_none, ) class NYTimesBaseIE(InfoExtractor): _DNS_NAMESPACE = uuid.UUID('36dd619a-56dc-595b-9e09-37f4152c7b5d') ...
@@ -1,50 +1,42 @@ -import hmac -import hashlib -import base64 +import json +import uuid from .common import InfoExtractor from ..utils import ( + clean_html, determine_ext, - float_or_none, + extract_attributes, + get_elements_html_by_class, int_or_none, - js_to_json, + merge_dicts, ...
yt_dlp/extractor/nytimes.py
26
Python
0.786
refactor
197
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
urls = [] formats = [] subtitles = {} for video in content_media_json: video_url = video.get('url') format_id = video.get('type') if not video_url or format_id == 'thumbs' or video_url in urls: continue urls.append(video_url...
```suggestion 'filesize': traverse_obj(video, ( ('file_size', 'fileSize'), (None, ('value')), {int_or_none}), get_all=False), ```
promotionalMedia { ... on Image { crops { name renditions { name width height url } } } } renditions { type width height url bitrate ...
@@ -59,51 +51,25 @@ def get_file_size(file_size): subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue - # formats.extend(self._extract_mpd_formats( - # video_url, video_id, format_id or 'dash', fatal=False))...
yt_dlp/extractor/nytimes.py
26
Python
0.714
suggestion
176
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'ext': 'mp4', 'title': 'Kamala Harris Defends Biden Policies, but Says ‘More Work’ Needed to Reach Voters', 'description': 'md5:de4212a7e19bb89e4fb14210ca915f1f', 'timestamp': 1701290997, 'upload_date': '20231129', 'uploader': 'By The New York Time...
```suggestion # FIXME ```
class NYTimesIE(NYTimesBaseIE): _VALID_URL = r'https?://(?:(?:www\.)?nytimes\.com/video/(?:[^/]+/)+?|graphics8\.nytimes\.com/bcvideo/\d+(?:\.\d+)?/iframe/embed\.html\?videoId=)(?P<id>\d+)' _EMBED_REGEX = [r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//graphics8\.nytimes\.com/bcvideo/[^/]+/iframe/embed\.html.+?...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url)
yt_dlp/extractor/nytimes.py
26
Python
0.429
suggestion
37
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
# inconsistant md5 'skip_download': True, }, }, { # multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html', 'info_dict': { 'id': 'air-traffic-controllers-safety', 'ti...
formatting nitpick ```suggestion 'series': ('podcastSeries', {str}), }, get_all=False) ```
'description': 'md5:93603dada88ddbda9395632fdc5da260', 'timestamp': 1398631707, # FIXME 'upload_date': '20140427', # FIXME 'creator': 'Brett Weiner', 'thumbnail': r're:https?://\w+\.nyt.com/images/.+\.jpg', 'duration': 419, }, }, { ...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.857
suggestion
114
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
}, 'params': { # inconsistant md5 'skip_download': True, }, }, { # multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html', 'info_dict': { 'id': 'air-traffic-contr...
`upload_date` is calculated from `timestamp` by core code, so this is unnecessary if you're using the same value as you use for `timestamp` ```suggestion ```
'ext': 'mp4', 'title': 'Verbatim: What Is a Photocopier?', 'description': 'md5:93603dada88ddbda9395632fdc5da260', 'timestamp': 1398631707, # FIXME 'upload_date': '20140427', # FIXME 'creator': 'Brett Weiner', 'thumbnail': r're:https?:...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.786
suggestion
159
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
remove_end, remove_start, str_or_none, traverse_obj, unified_strdate, url_or_none, ) class NYTimesBaseIE(InfoExtractor): _GRAPHQL_API = 'https://samizdat-graphql.nytimes.com/graphql/v2' @staticmethod def _get_file_size(file_size): if isinstance(file_size, int): ...
IMO it makes more sense to do the traversal here instead of doing `.get('renditions')` etc 3+ times before passing it to this function ```suggestion for video in traverse_obj(content_media_json, ('renditions', ...)): ```
mimetype2ext, parse_iso8601, remove_end, remove_start, str_or_none, traverse_obj, url_or_none, ) class NYTimesBaseIE(InfoExtractor): _DNS_NAMESPACE = uuid.UUID('36dd619a-56dc-595b-9e09-37f4152c7b5d') _TOKEN = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuNIzKBOFB77aT/jN/FQ+/QVKWq5V...
@@ -1,50 +1,42 @@ -import hmac -import hashlib -import base64 +import json +import uuid from .common import InfoExtractor from ..utils import ( + clean_html, determine_ext, - float_or_none, + extract_attributes, + get_elements_html_by_class, int_or_none, - js_to_json, + merge_dicts, ...
yt_dlp/extractor/nytimes.py
26
Python
0.857
suggestion
231
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
}, { # multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html', 'info_dict': { 'id': 'air-traffic-controllers-safety', 'title': 'Drunk and Asleep on the Job: Air Traffic Controllers Pushed to the Bri...
```suggestion formats, subtitles = self._extract_media_from_json(details.get('id'), block) ```
'creator': 'Brett Weiner', 'thumbnail': r're:https?://\w+\.nyt.com/images/.+\.jpg', 'duration': 419, }, }, { 'url': 'http://www.nytimes.com/video/travel/100000003550828/36-hours-in-dubai.html', 'only_matching': True, }] def _real_extract(self, url...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.786
refactor
104
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'info_dict': { 'id': 'air-traffic-controllers-safety', 'title': 'Drunk and Asleep on the Job: Air Traffic Controllers Pushed to the Brink', 'description': 'md5:549e5a5e935bf7d048be53ba3d2c863d', }, 'playlist_count': 3, }, { 'url': 'https://www.nyt...
`get_all=False` isn't needed here but a `url_or_none` transformation could help ```suggestion url = traverse_obj(block, ('fileUrl', {url_or_none})) ```
}, }, { 'url': 'http://www.nytimes.com/video/travel/100000003550828/36-hours-in-dubai.html', 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) return self._extract_video(video_id) class NYTimesArticleIE(NYTimesBaseIE): _VAL...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.786
suggestion
162
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'only_matching': True, }] def _extract_content_from_block(self, block): details = traverse_obj(block, { 'id': ('sourceId', {str}), 'uploader': ('bylines', ..., 'renderedRepresentation', {str}), 'duration': (('duration', 'length', ...), {int_or_none}), ...
`merge_dicts` is particularly useful when you're merging 2 dicts that may share the same keys, but the values of the shared keys may be `None` in one dict -- it will prioritize the values that are not `None`. Here we can just unpack IMO ```suggestion return { **details, 'form...
return self._extract_video(video_id) class NYTimesArticleIE(NYTimesBaseIE): _VALID_URL = r'https?://(?:www\.)?nytimes\.com/\d{4}/\d{2}/\d{2}/(?!books|podcasts)[^/?#]+/(?:\w+/)?(?P<id>[^./?#]+)(?:\.html)?' _TESTS = [{ 'url': 'http://www.nytimes.com/2015/04/14/business/owner-of-gravity-payments-...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.857
suggestion
395
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
formats, subtitles = self._extract_media_from_json(details.get('id'), media) # audio articles will have an url and no formats url = traverse_obj(block, ('fileUrl'), get_all=False) if not formats and url: formats.append({'url': url, 'ext': determine_ext(url)}) return...
```suggestion return traverse_obj(thumbs, (lambda _, v: url_or_none(v['url']), { 'url': 'url', 'width': ('width', {int_or_none}), 'height': ('height', {int_or_none}), })) ```
'timestamp': 1429047468, 'upload_date': '20150414', 'uploader': 'Matthew Williams', 'creator': 'Patricia Cohen', 'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', 'duration': 119.0, }, }, { # article with audio and no vid...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.786
suggestion
232
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
{ 'formats': formats, 'subtitles': subtitles }) def _extract_thumbnails(self, thumbs): thumbnails = [] for image in thumbs: image_url = image.get('url') if not image_url: continue thumbnails....
I'd break this line up also, it's not really json anymore at this point, I'd just name it `blocks` ```suggestion blocks_json = traverse_obj(article_json, ( 'sprinkledBody', 'content', ..., ('ledeMedia', None), lambda _, v: v['__typename'] in ('Video', 'Audio'))) ```
'url': 'https://www.nytimes.com/2023/09/29/health/mosquitoes-genetic-engineering.html', 'md5': '2365b3555c8aa7f4dd34ca735ad02e6a', 'info_dict': { 'id': '100000009110381', 'ext': 'mp3', 'title': 'The Gamble: Can Genetically Modified Mosquitoes End Disease?', ...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.929
suggestion
306
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
image_url = image.get('url') if not image_url: continue thumbnails.append({ 'url': image_url, 'width': int_or_none(image.get('width')), 'height': int_or_none(image.get('height')), }) return thumbnails...
`get_all=True` is the default ```suggestion traverse_obj(article_json, ('bylines', ..., 'creators', ..., 'displayName'))) ```
'upload_date': '20230929', 'creator': 'Stephanie Nolen, Natalija Gormalova', 'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', 'duration': 1322, }, }, { 'url': 'https://www.nytimes.com/2023/11/29/business/dealbook/kamala-harris-biden-voters.html...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.714
suggestion
140
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
article_json, ('sprinkledBody', 'content', ..., ('ledeMedia', None), lambda _, v: v['__typename'] in ('Video', 'Audio'))) art_title = remove_end(self._html_extract_title(webpage), ' - The New York Times') art_description = traverse_obj( article_json, ('sprinkledBody', 'content',...
```suggestion entries.append(merge_dicts(self._extract_content_from_block(block_json), { 'title': art_title, 'description': art_description, 'creator': creator, # TODO: change to 'creators' (list) 'thumbnails': self._e...
'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', 'duration': 97.631, }, 'params': { 'skip_download': 'm3u8', }, }, { # multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-s...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.857
refactor
471
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
creator = ', '.join( traverse_obj(article_json, ('bylines', ..., 'creators', ..., 'displayName'), get_all=True)) # more than 1 video in the article, treat it as a playlist if len(blocks_json) > 1: entries = [] for block_json in blocks_json: co...
this can all be inlined in the return ```py return merge_dicts(self._extract_content_from_block(blocks_json[0]), { 'title': art_title, 'description': art_description, 'creator': creator, # TODO: change to 'creators' 'upload_date': unified_strdate(art_uplo...
# multiple videos in the same article 'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html', 'info_dict': { 'id': 'air-traffic-controllers-safety', 'title': 'Drunk and Asleep on the Job: Air Traffic Controllers Pushed to the Brink', ...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.857
refactor
659
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'md5': 'd665342765db043f7e225cff19df0f2d', 'info_dict': { 'id': '100000002847155', 'ext': 'mov', 'title': 'Verbatim: What Is a Photocopier?', 'description': 'md5:93603dada88ddbda9395632fdc5da260', 'timestamp': 1398631707, 'upload_da...
```suggestion _VALID_URL = r'https?://(?:www\.)?nytimes\.com/\d{4}/\d{2}/\d{2}/(?!books|podcasts)[^/?#]+/(?:\w+/)?(?P<id>[^./?#]+)(?:\.html)?' ```
'Origin': 'https://nytimes.com', }, fatal=False), ('data', 'video', {dict})) or {} def _extract_thumbnails(self, thumbs): return traverse_obj(thumbs, (lambda _, v: url_or_none(v['url']), { 'url': 'url', 'width': ('width', {int_or_none}), 'heig...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.857
suggestion
152
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'timestamp': 1701302400, 'upload_date': '20231130', 'creator': 'Sue Li', 'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', }, }, { 'url': 'https://cooking.nytimes.com/recipes/1019516-overnight-oats', 'md5': '2fe7965a3adc899913b8e25ada360...
it's ok to make this fatal. `_search_nextjs_data` already is, and we have nothing to extract w/o this variable. I'd also use a var name like `next_data` ```suggestion next_data = self._search_nextjs_data(webpage, page_id)['props']['pageProps'] ```
entries.append(merge_dicts(self._extract_content_from_block(block), common_info)) if len(entries) > 1: return self.playlist_result(entries, page_id, **common_info) return { 'id': page_id, **entries[0], } class NYTimesCookingIE(NYTimesBaseIE): ...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.857
refactor
258
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'ext': 'mp4', 'timestamp': 1546387200, 'description': 'md5:8856ce10239161bd2596ac335b9f9bfb', 'upload_date': '20190102', 'title': 'Overnight Oats', 'creator': 'Genevieve Ko', 'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', ...
inline this traversal in the return *except* for the `videoSrc` URL, let's do format extraction first and keep that out of this dict also `upload_date` is unnecessary as explained above, unless the `timestamp` value is unavailable on some pages
class NYTimesCookingIE(NYTimesBaseIE): IE_NAME = 'NYTimesCookingGuide' _VALID_URL = r'https?://cooking\.nytimes\.com/guides/(?P<id>[\w-]+)' _TESTS = [{ 'url': 'https://cooking.nytimes.com/guides/13-how-to-cook-a-turkey', 'info_dict': { 'id': '13-how-to-cook-a-turkey', ...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
0.643
refactor
250
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling
'upload_date': '20190102', 'title': 'Overnight Oats', 'creator': 'Genevieve Ko', 'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg', } }] def _real_extract(self, url): page_id = self._match_id(url) webpage = self._download_webpage(url...
`entry_protocol='m3u8_native'` is the default just use `page_id` matched from the url for the video id -- it looks like it's the same as what's found in the next js data and again, the `_extract_m3u8_formats` call here is fatal so it's fine to risk a KeyError too ```suggestion next_data['recipe']['v...
_VALID_URL = r'https?://cooking\.nytimes\.com/guides/(?P<id>[\w-]+)' _TESTS = [{ 'url': 'https://cooking.nytimes.com/guides/13-how-to-cook-a-turkey', 'info_dict': { 'id': '13-how-to-cook-a-turkey', 'title': 'How to Cook a Turkey', 'description': 'md5:726cfd3f9...
@@ -125,138 +91,427 @@ class NYTimesIE(NYTimesBaseIE): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_video_from_id(video_id) + return { + 'id': video_id + } class NYTimesArticleIE(NYTimesBaseIE): - _VALID_URL = r'https?://(?:w...
yt_dlp/extractor/nytimes.py
26
Python
1
refactor
366
51
51
false
[ie/NYTimes] - Extractor overhaul - Article, Cooking Recipes and Guides
9,075
yt-dlp/yt-dlp
132,642
Python
bashonly
SirElderling