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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
import itertools
import re
from .common import InfoExtractor
from ..compat import compat_str, compat_HTTPError
from ..utils import (
determine_ext,
int_or_none,
parse_iso8601,
try_get,
unescapeHTML,
ExtractorError,
)
class RumbleEmbedIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?ru... | ```suggestion
formats.extend(self._extract_m3u8_formats(
video_info['url'], video_id, ext='mp4', m3u8_id='hls', fatal=False))
``` | 'duration': 103,
'live_status': 'not_live',
}
},
{
'note': 'Rumble JS embed',
'url': 'https://therightscoop.com/what-does-9-plus-1-plus-1-equal-listen-to-this-audio-of-attempted-kavanaugh-assassins-call-and-youll-get-it',
'm... | @@ -62,26 +123,48 @@ def _extract_embed_urls(cls, url, webpage):
def _real_extract(self, url):
video_id = self._match_id(url)
video = self._download_json(
- 'https://rumble.com/embedJS/', video_id,
- query={'request': 'video', 'v': video_id})
- title = unescapeHTML(vi... | yt_dlp/extractor/rumble.py | 26 | Python | 0.786 | refactor | 176 | 141 | 51 | false | [rumble] add HLS formats | 5,280 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | flashdagger |
'id': 'YTmgRiNU',
'ext': 'mp4',
'title': '1980 Ski People',
'timestamp': 1610407738,
'description': 'md5:cf9c3d101452c91e141f292b19fe4843',
'thumbnail': 'https://cdn.jwplayer.com/v2/media/YTmgRiNU/poster.jpg?width=720',
... | not strictly related to the PR, but could u move these tests into rumble.py?
It'll become `_WEBPAGE_TESTS = [...]` (and run as `test_Rumble_webpage_all`) | 'id': 'YTmgRiNU',
'ext': 'mp4',
'title': '1980 Ski People',
'timestamp': 1610407738,
'description': 'md5:cf9c3d101452c91e141f292b19fe4843',
'thumbnail': 'https://cdn.jwplayer.com/v2/media/YTmgRiNU/poster.jpg?width=720',
... | @@ -2414,6 +2414,7 @@ class GenericIE(InfoExtractor):
'channel_url': 'https://rumble.com/c/c-546523',
'thumbnail': 'https://sp.rmbl.ws/s8/1/5/f/x/x/5fxxb.OvCc.1-small-Moose-The-Dog-Helps-Girls-D.jpg',
'duration': 103,
+ 'live_status': 'not_live', | yt_dlp/extractor/generic.py | 26 | Python | 0.571 | suggestion | 154 | 51 | 51 | false | [rumble] add HLS formats | 5,280 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | flashdagger |
from .common import InfoExtractor
from ..utils import unified_strdate
class ZeeNewsIE(InfoExtractor):
_VALID_URL = r'''(?x)
(?:
zeenews:|
https?://(?:zeenews\.)?india\.com/(?:[^#?]+/)(?:video)/)
(?P<display_id>[^#/?]+)/(?P<id>[^#/?]+... | ```suggestion
_VALID_URL = r'https?://(?:zeenews\.)?india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>[^#/?]+)/?(?:$|[?#])'
```
1. Use `display_id` in real_extract
1. Add test case without `zeenews.`
1. Add test case for non-number `id` | from .common import InfoExtractor
from ..utils import ExtractorError, traverse_obj
class ZeeNewsIE(InfoExtractor):
_VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>\d+)'
_TESTS = [
{
'url': 'https://zeenews.india.com/hindi/india/delhi-ncr-haryana/delh... | @@ -0,0 +1,57 @@
+from .common import InfoExtractor
+from ..utils import unified_strdate
+
+
+class ZeeNewsIE(InfoExtractor):
+
+ _VALID_URL = r'''(?x)
+ (?:
+ zeenews:|
+ https?://(?:zeenews\.)?india\.com/(?:[^#?]+/)(?:video)/)
+ (?P<displa... | yt_dlp/extractor/zeenews.py | 12 | Python | 0.857 | refactor | 252 | 37 | 37 | false | [zeenews] Add extractor | 5,289 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
from .common import InfoExtractor
from ..utils import unified_strdate
class ZeeNewsIE(InfoExtractor):
_VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>[0-9]+)'
_TESTS = [
{
'url': 'https://zeenews.india.com/hindi/india/delhi-ncr-haryana/delhi-ncr/vid... | ```suggestion
_VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>\d+)'
``` | from .common import InfoExtractor
from ..utils import ExtractorError, traverse_obj
class ZeeNewsIE(InfoExtractor):
_VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>\d+)'
_TESTS = [
{
'url': 'https://zeenews.india.com/hindi/india/delhi-ncr-haryana/delh... | @@ -0,0 +1,53 @@
+from .common import InfoExtractor
+from ..utils import unified_strdate
+
+
+class ZeeNewsIE(InfoExtractor):
+
+ _VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>[0-9]+)' | yt_dlp/extractor/zeenews.py | 7 | Python | 0.714 | suggestion | 117 | 32 | 32 | false | [zeenews] Add extractor | 5,289 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
'id': '1402138',
'description': 'md5:d9cbfcfb906666241e3659ebfe775e65',
'ext': 'mp4',
'title': 'Greater Noida Video: हमलावरों ने दिनदहाड़े दुकान में घुसकर की मारपीट, देखें वीडियो',
'display_id': 'greater-noida-video-viral-on-social-media-at... | ```suggestion
content_id, display_id = self._match_valid_url(url).group('id', 'display_id')
``` | 'ext': 'mp4',
'title': 'Greater Noida Video: हमलावरों ने दिनदहाड़े दुकान में घुसकर की मारपीट, देखें वीडियो',
'display_id': 'greater-noida-video-viral-on-social-media-attackers-beat-businessman-and-his-son-oppose-market-closed-atdnh',
'upload_date': '202210... | @@ -0,0 +1,53 @@
+from .common import InfoExtractor
+from ..utils import unified_strdate
+
+
+class ZeeNewsIE(InfoExtractor):
+
+ _VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>[0-9]+)'
+ _TESTS = [
+ {
+ 'url': 'https://zeenews.india.com/hindi/india/delh... | yt_dlp/extractor/zeenews.py | 26 | Python | 0.714 | suggestion | 105 | 43 | 48 | false | [zeenews] Add extractor | 5,289 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
'display_id': 'videsh-superfast-queen-elizabeth-iis-funeral-today',
'upload_date': '20220919',
'thumbnail': r're:^https?://.*\.jpg*',
}
}
]
def _real_extract(self, url):
match = self._match_valid_url(url).groupdict()
content_id... | ```suggestion
json_ld_list = list(self._yield_json_ld(webpage, display_id))
embed_url = traverse_obj(json_ld_list, (lambda _, v: v['@type'] == 'VideoObject', 'embedURL'))
formats = self._extract_m3u8_formats(embed_url, content_id, 'mp4')
self._sort_formats(formats)
retur... | 'title': 'Videsh Superfast: महारानी के अंतिम संस्कार की तैयारी शुरू',
'display_id': 'videsh-superfast-queen-elizabeth-iis-funeral-today',
'upload_date': '20220919',
'thumbnail': r're:^https?://.*\.jpg*',
'timestamp': 1663556881,
... | @@ -0,0 +1,53 @@
+from .common import InfoExtractor
+from ..utils import unified_strdate
+
+
+class ZeeNewsIE(InfoExtractor):
+
+ _VALID_URL = r'https?://zeenews\.india\.com/[^#?]+/video/(?P<display_id>[^#/?]+)/(?P<id>[0-9]+)'
+ _TESTS = [
+ {
+ 'url': 'https://zeenews.india.com/hindi/india/delh... | yt_dlp/extractor/zeenews.py | 26 | Python | 1 | refactor | 515 | 27 | 32 | false | [zeenews] Add extractor | 5,289 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
'skip_download': True,
},
}]
def _real_extract(self, url):
video_type, display_id, video_id = self._match_valid_url(url).group('type', 'display_id', 'id')
if 'show' in video_type:
video_type = 'episode'
data_json = self._download_json(
f'http... |
```suggestion
streams = traverse_obj(data_json, ('stream', {
'm3u8': ((('thirdParty', 'hlsUrl'), ('hls', 'high')), )
'mpd': ((('thirdParty', 'dashUrl'), ('dash', 'high')), )
}, get_all=False)
formats, subtitles = [], {}
if 'm3u8' in streams:
f... | }]
def _real_extract(self, url):
video_type, display_id, video_id = self._match_valid_url(url).group('type', 'display_id', 'id')
if 'show' in video_type:
video_type = 'episode'
data_json = self._download_json(
f'https://api.mxplay.com/v1/web/detail/video?type={v... | @@ -157,21 +171,28 @@ def _real_extract(self, url):
data_json = self._download_json(
f'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id)
- streams = traverse_obj(data_json, ('stream', {'m3u8': ('hls', 'high'), 'mpd': ('dash', 'high')}))
- form... | yt_dlp/extractor/mxplayer.py | 26 | Python | 0.857 | refactor | 1,543 | 51 | 51 | false | [mxplayer] Improve extractor | 5,303 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
int_or_none,
traverse_obj,
try_get,
urljoin
)
class MxplayerIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?mxplayer\.in/(?P<type>movie|show/[-\w]+/[-\w]+)/(?P<display_id>[-\w]+)-(?P<id>\w+)'
_TESTS = ... | ```suggestion
urljoin,
``` | from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
int_or_none,
traverse_obj,
try_get,
urljoin,
)
class MxplayerIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?mxplayer\.in/(?P<type>movie|show/[-\w]+/[-\w]+)/(?P<display_id>[-\w]+)-(?P<id>\w+)'
_TESTS =... | @@ -4,6 +4,7 @@
int_or_none,
traverse_obj,
try_get,
+ urljoin | yt_dlp/extractor/mxplayer.py | 7 | Python | 0.429 | suggestion | 32 | 32 | 32 | false | [mxplayer] Improve extractor | 5,303 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
'ext': 'mp4',
'description': 'md5:1d0948d2a5312d7013792d53542407f9',
'series': 'Ek Thi Begum (Hindi)',
'season': 'Season 2',
'season_number': 2,
'episode': 'Episode 2',
'episode_number': 2,
},
'params': {
'fo... | ```suggestion
'params': {'skip_download': 'm3u8'},
``` | 'ext': 'mp4',
'description': 'md5:1d0948d2a5312d7013792d53542407f9',
'series': 'Ek Thi Begum (Hindi)',
'season': 'Season 2',
'season_number': 2,
'episode': 'Episode 2',
'episode_number': 2,
},
'params': {
'fo... | @@ -147,6 +148,20 @@ class MxplayerIE(InfoExtractor):
'format': 'bv',
'skip_download': True,
},
+ }, {
+ 'url': 'https://www.mxplayer.in/movie/watch-deewane-huye-paagal-movie-online-4f9175c40a11c3994182a65afdd37ec6?watch=true',
+ 'info_dict': {
+ 'id': '4f9... | yt_dlp/extractor/mxplayer.py | 26 | Python | 0.571 | suggestion | 64 | 51 | 51 | false | [mxplayer] Improve extractor | 5,303 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | m4tu4g |
import re
from yt_dlp.utils import ExtractorError
from .common import InfoExtractor
class BeatBumpIE(InfoExtractor):
_VALID_URL = r'https:\/\/beatbump\.ml\/(?:(?:listen\?id=)|(?:playlist\/)|(?:artist\/)|(?:release\?id=))(?P<id>.*)'
_TESTS = [{
# Single video
'url': 'https://beatbump.ml/listen... | ```suggestion
from ..utils import ExtractorError
``` | from .common import InfoExtractor
from .youtube import YoutubeIE, YoutubeTabIE
class BeatBumpVideoIE(InfoExtractor):
_VALID_URL = r'https://beatbump\.ml/listen\?id=(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://beatbump.ml/listen?id=MgNrAu2pzNs',
'md5': '5ff3fff41d3935b9810a9731e485fe66',
... | @@ -0,0 +1,112 @@
+import re
+
+from yt_dlp.utils import ExtractorError | yt_dlp/extractor/beatbump.py | 3 | Python | 0.786 | refactor | 54 | 28 | 28 | false | [extractor/beatbump] Add extractor | 5,304 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | Bobscorn |
import re
from yt_dlp.utils import ExtractorError
from .common import InfoExtractor
class BeatBumpIE(InfoExtractor):
_VALID_URL = r'https:\/\/beatbump\.ml\/(?:(?:listen\?id=)|(?:playlist\/)|(?:artist\/)|(?:release\?id=))(?P<id>.*)'
_TESTS = [{
# Single video
'url': 'https://beatbump.ml/listen... | Split this into 4 extractors, for each branch | from .common import InfoExtractor
from .youtube import YoutubeIE, YoutubeTabIE
class BeatBumpVideoIE(InfoExtractor):
_VALID_URL = r'https://beatbump\.ml/listen\?id=(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://beatbump.ml/listen?id=MgNrAu2pzNs',
'md5': '5ff3fff41d3935b9810a9731e485fe66',
... | @@ -0,0 +1,112 @@
+import re
+
+from yt_dlp.utils import ExtractorError
+from .common import InfoExtractor
+
+
+class BeatBumpIE(InfoExtractor): | yt_dlp/extractor/beatbump.py | 7 | Python | 0.143 | refactor | 45 | 32 | 32 | false | [extractor/beatbump] Add extractor | 5,304 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | Bobscorn |
'uploader_url': 'http://www.youtube.com/channel/UC49r4GNHHpc-eQ9hmD2Rg6A',
'album': 'Legacy',
'age_limit': 0,
'channel': 'Eagles',
'availability': 'public',
}
}, {
# Artist url
'url': 'https://beatbump.ml/artist/UCfSIVkF2grhFG80NnJQ... | 1. Add `'add_ie': ['Youtube'],` for the first test and `'add_ie': ['YoutubeTab'],` for others
2. Remove the whole `info_dict` for all tests; they're not from this IE | 'tags': 'count:11',
'creator': 'Stephen',
'channel_id': 'UC-pWHpBjdGG69N9mM2auIAA',
}
}]
def _real_extract(self, url):
id_ = self._match_id(url)
return self.url_result(f'https://music.youtube.com/watch?v={id_}', YoutubeIE, id_)
class BeatBumpPlaylis... | @@ -0,0 +1,112 @@
+import re
+
+from yt_dlp.utils import ExtractorError
+from .common import InfoExtractor
+
+
+class BeatBumpIE(InfoExtractor):
+ _VALID_URL = r'https:\/\/beatbump\.ml\/(?:(?:listen\?id=)|(?:playlist\/)|(?:artist\/)|(?:release\?id=))(?P<id>.*)'
+ _TESTS = [{
+ # Single video
+ 'url'... | yt_dlp/extractor/beatbump.py | 26 | Python | 0.571 | suggestion | 166 | 51 | 51 | false | [extractor/beatbump] Add extractor | 5,304 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | Bobscorn |
_TESTS = [{
'url': 'https://www.listennotes.com/podcasts/thriving-on-overload/tim-oreilly-on-noticing-KrDgvNb_u1n/',
'md5': '5b91a32f841e5788fb82b72a1a8af7f7',
'info_dict': {
'id': 'KrDgvNb_u1n',
'ext': 'mp3',
'title': 'Tim O’Reilly on noticing things othe... | I think you can set like this
```suggestion
json_data = self._search_json(
r'<script id="original-content" type="application/json">\s*', webpage, 'content', audio_id)
```
and then return audio in return like this:
```
'url': json_data['audio']
``` | get_element_by_class,
get_element_html_by_id,
get_element_text_and_html_by_tag,
parse_duration,
strip_or_none,
traverse_obj,
try_call,
)
class ListenNotesIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?listennotes\.com/podcasts/[^/]+/[^/]+-(?P<id>.+)/'
_TESTS = [{
'url... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+import re
+
+
+class ListenNotesIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?listennotes\.com/podcasts/[^/]+/[^/]+-(?P<id>.+)/'
+ _TESTS = [{
+ 'url': 'https://www.listennotes.com/podcasts/thriving-on-overload/tim-oreilly-on-noticing-KrDgvNb_u1... | yt_dlp/extractor/listennotes.py | 26 | Python | 0.929 | suggestion | 282 | 42 | 51 | false | [listennotes.com] Add extractor | 5,310 | yt-dlp/yt-dlp | 132,642 | Python | HobbyistDev | lksj |
'id': 'KrDgvNb_u1n',
'ext': 'mp3',
'title': 'Tim O’Reilly on noticing things other people don’t notice, the value of soft focus, framing open source and Web 2.0, and patience in building narratives (Ep1)',
'description': '00:35:48 - ‘’We shape reality by what we notice an... | as far i can see, we can set the `duration` and `description` from the `description` field in `json_data`. It looks like this:
```suggestion
description_raw = self._html_search_meta(
['og:description', 'description', 'twitter:description'], webpage, 'description')
duration, description =... | strip_or_none,
traverse_obj,
try_call,
)
class ListenNotesIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?listennotes\.com/podcasts/[^/]+/[^/]+-(?P<id>.+)/'
_TESTS = [{
'url': 'https://www.listennotes.com/podcasts/thriving-on-overload/tim-oreilly-on-noticing-KrDgvNb_u1n/',
'md... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+import re
+
+
+class ListenNotesIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?listennotes\.com/podcasts/[^/]+/[^/]+-(?P<id>.+)/'
+ _TESTS = [{
+ 'url': 'https://www.listennotes.com/podcasts/thriving-on-overload/tim-oreilly-on-noticing-KrDgvNb_u1... | yt_dlp/extractor/listennotes.py | 26 | Python | 0.786 | bug | 536 | 38 | 51 | false | [listennotes.com] Add extractor | 5,310 | yt-dlp/yt-dlp | 132,642 | Python | HobbyistDev | lksj |
return f'{version}.{revision}' if revision else version
def get_git_head():
with contextlib.suppress(Exception):
sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE)
return sp.communicate()[0].decode().strip() or None
VERSION = get_new_version((sys.argv + ['... | if the env var doesnt exist (running locally), this should be skipped | return f'{version}.{revision}' if revision else version
def get_git_head():
with contextlib.suppress(Exception):
sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE)
return sp.communicate()[0].decode().strip() or None
VERSION = get_new_version((sys.argv + ['... | @@ -50,5 +50,5 @@ def get_git_head():
'''
write_file('yt_dlp/version.py', VERSION_FILE)
-print(f'::set-output name=ytdlp_version::{VERSION}')
+write_file(os.getenv('GITHUB_OUTPUT'), f'ytdlp_version={VERSION}\n', 'a') | devscripts/update-version.py | 26 | Python | 0.286 | suggestion | 69 | 28 | 30 | false | Replace all `set-outut` usages with $GITHUB_OUTPUT | 5,315 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
... | ```suggestion
from .common import InfoExtractor
```
not needed | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor | yt_dlp/extractor/qingting.py | 4 | Python | 0.643 | refactor | 65 | 29 | 29 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
... | ```suggestion
from ..utils import traverse_obj
```
`utils` should be a relative import, and import only what is needed from it.
if changes suggested below are applied, `traverse_obj` will be needed, and `url_or_none` and `ExtractorError` will be unnecessary | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils | yt_dlp/extractor/qingting.py | 6 | Python | 1 | refactor | 263 | 31 | 31 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
... | ```suggestion
```
not needed. the initial value of `IE_NAME` is the class name minus the last 2 characters | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing' | yt_dlp/extractor/qingting.py | 10 | Python | 0.714 | suggestion | 108 | 35 | 35 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
... | ```suggestion
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
```
simplify, and capture both numeric ID values for a change suggested below | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 14 | Python | 0.857 | refactor | 214 | 39 | 39 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
from __future__ import unicode_literals
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
... | ```suggestion
channel_id, pid = self._match_valid_url(url).groups()
webpage = self._download_webpage(
f'https://m.qtfm.cn/vchannels/{channel_id}/programs/{pid}/', pid)
```
instead of downloading and parsing the desktop webpage to get the mobile page URL, let's skip a step: we can captur... |
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 26 | Python | 0.857 | suggestion | 400 | 51 | 47 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
channels/\d+/programs/(?P<id>\d+... | ```suggestion
```
should inline `title` in `return`, see below |
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd1888fb3c',
'info_dict': {
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 26 | Python | 0.643 | suggestion | 64 | 51 | 45 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
title = self._html_search_regex(r'(?s)<title\b[^>]*>(.*)</title>', webpage, 'title',
default=None) or self._og_search_title(webpage)
urlType = self._search_regex(
self._VALID_URL,
url, 'audio URL', group="m")
if urlType == 'm.':
... | ```suggestion
```
this is all no longer needed if we're not downloading the desktop webpages anymore | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 26 | Python | 0.714 | suggestion | 102 | 27 | 48 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
'ext': 'mp3',
'title': '用了十年才修改,谁在乎教科书?-睡前消息-蜻蜓FM听头条',
}
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'(?s)<title\b[^>]*>(.*)</title>', webpage, 'title',
... | ```suggestion
return {
'id': pid,
'title': traverse_obj(info, ('ProgramStore', 'programInfo', 'title')),
'channel_id': channel_id,
'url': traverse_obj(info, ('ProgramStore', 'programInfo', 'audioUrl')),
'ext': 'm4a',
}
```
use `travers... | 'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
'md5': '2703120b6abe63b5fa90b975a58f4c0e',
'info_dict': {
'id': '23023573',
'title': '【睡前消息488】重庆山火之后,有图≠真相',
'channel_id': '378005',
'channel': '睡前消息',
'uploader': '马督工',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 26 | Python | 0.857 | refactor | 514 | 35 | 29 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from yt_dlp import utils
class QingTingIE(InfoExtractor):
IE_NAME = 'QingTing'
_VALID_URL = r'''(?x)
(?:https?://)?(?:www\.)?
(?P<m>m\.)?(?:qingting\.fm|qtfm\.cn)/(?(m)v|)
... | ```suggestion
_TESTS = {
```
should add a test for the other valid URL format (e.g. `https://m.qtfm.cn/vchannels/378005/programs/23023573/`)
will also need to update the first test's info_dict if the suggested change for `return` is applied | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 15 | Python | 0.857 | suggestion | 250 | 40 | 40 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
channels/\d+/programs/(?P<id>\d+)'''
_TEST = {
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd1888fb3c',
'info_dict': {
'id': '22257411',
'ext': 'mp3',
'title': '用了十年才修改,谁在乎教科书?... | ```suggestion
info = self._search_json(r'window\.__initStores\s*=', webpage, 'program info', pid)
```
don't use regex to get values from JSON. use `_search_json` to find the JSON and parse it.
if we are only downloading the mobile webpage, the rest of this block can be removed. in the future, use `snake_c... | 'channel_id': '378005',
'channel': '睡前消息',
'uploader': '马督工',
'ext': 'm4a',
}
}, {
'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
'md5': '2703120b6abe63b5fa90b975a58f4c0e',
'info_dict': {
'id': '23023573',
... | @@ -0,0 +1,53 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from yt_dlp import utils
+
+
+class QingTingIE(InfoExtractor):
+ IE_NAME = 'QingTing'
+ _VALID_URL = r'''(?x)
+ (?:https?://)?(?:www\.)?
+ (?P<m>m\.)?(?:qi... | yt_dlp/extractor/qingting.py | 26 | Python | 0.857 | suggestion | 361 | 41 | 35 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = {
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | ```suggestion
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd1888fb3c',
'info_dict': {
'id': '22257411',
'ext': 'mp3',
'title': '用了十年才修改,谁在乎教科书?-睡前消息-蜻蜓FM听头条',
}
}]
``` | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,29 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = {
+ 'url': 'https://www.qingting.fm/channels/378005/pr... | yt_dlp/extractor/qingting.py | 16 | Python | 0.786 | suggestion | 320 | 30 | 41 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | changren-wcr |
from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | ```suggestion
'vcodec': 'none',
'acodec': 'm4a',
'ext': 'm4a',
``` | 'md5': '2703120b6abe63b5fa90b975a58f4c0e',
'info_dict': {
'id': '23023573',
'title': '【睡前消息488】重庆山火之后,有图≠真相',
'channel_id': '378005',
'channel': '睡前消息',
'uploader': '马督工',
'ext': 'm4a',
}
}]
def _real_extract(self, ... | @@ -0,0 +1,29 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.qingting.fm/channels/378005/p... | yt_dlp/extractor/qingting.py | 26 | Python | 0.714 | suggestion | 106 | 30 | 28 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | changren-wcr |
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd1888fb3c',
'info_dict': {
'id': '22257411',
'title': '用了十年才修改,谁在乎教科书?',
'channel_id': '378005',
'channel_name': '睡前消息',
... | ```suggestion
channel_id, pid = self._match_valid_url(url).group('channel', 'id')
``` | _TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd1888fb3c',
'info_dict': {
'id': '22257411',
'title': '用了十年才修改,谁在乎教科书?',
'channel_id': '378005',
'channel': '睡前消息',
'upl... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.qingting.fm/channels/378005/p... | yt_dlp/extractor/qingting.py | 26 | Python | 0.571 | suggestion | 95 | 41 | 41 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | changren-wcr |
'info_dict': {
'id': '22257411',
'title': '用了十年才修改,谁在乎教科书?',
'channel_id': '378005',
'channel_name': '睡前消息',
'podcaster': '马督工',
'ext': 'm4a',
}
}, {
'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
... | ```suggestion
webpage = self._download_webpage(
f'https://m.qtfm.cn/vchannels/{channel_id}/programs/{pid}/', pid)
info = self._search_json(r'window\.__initStores\s*=', webpage, 'program info', pid)
``` | 'info_dict': {
'id': '22257411',
'title': '用了十年才修改,谁在乎教科书?',
'channel_id': '378005',
'channel': '睡前消息',
'uploader': '马督工',
'ext': 'm4a',
}
}, {
'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
'md5... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.qingting.fm/channels/378005/p... | yt_dlp/extractor/qingting.py | 26 | Python | 0.786 | suggestion | 233 | 38 | 38 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | changren-wcr |
'ext': 'm4a',
}
}, {
'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
'md5': '2703120b6abe63b5fa90b975a58f4c0e',
'info_dict': {
'id': '23023573',
'title': '【睡前消息488】重庆山火之后,有图≠真相',
'channel_id': '378005',
'chan... | ```suggestion
'channel': traverse_obj(info, ('ProgramStore', 'channelInfo', 'title')),
'uploader': traverse_obj(info, ('ProgramStore', 'podcasterInfo', 'podcaster', 'nickname')),
``` | 'ext': 'm4a',
}
}, {
'url': 'https://m.qtfm.cn/vchannels/378005/programs/23023573/',
'md5': '2703120b6abe63b5fa90b975a58f4c0e',
'info_dict': {
'id': '23023573',
'title': '【睡前消息488】重庆山火之后,有图≠真相',
'channel_id': '378005',
'chan... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.qingting.fm/channels/378005/p... | yt_dlp/extractor/qingting.py | 26 | Python | 0.929 | suggestion | 209 | 32 | 32 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | ```suggestion
'channel': '睡前消息',
'uploader': '马督工',
``` | from .common import InfoExtractor
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.qingting.fm/channels/378005/p... | yt_dlp/extractor/qingting.py | 16 | Python | 0.571 | suggestion | 82 | 41 | 41 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd... | ```suggestion
'channel': '睡前消息',
'uploader': '马督工',
``` |
from ..utils import traverse_obj
class QingTingIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.qingting.fm/channels/378005/programs/22257411/',
'md5': '47e6a94f4e621ed832c316fd... | @@ -0,0 +1,47 @@
+from .common import InfoExtractor
+
+from ..utils import traverse_obj
+
+
+class QingTingIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.|m\.)?(?:qingting\.fm|qtfm\.cn)/v?channels/(?P<channel>\d+)/programs/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.qingting.fm/channels/378005/p... | yt_dlp/extractor/qingting.py | 26 | Python | 0.571 | suggestion | 82 | 47 | 47 | false | New extractor for Qingting.fm(蜻蜓FM) | 5,329 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | changren-wcr |
season_search = self._download_json(
'https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_%s_season_desc_production' % slug,
season, headers={
'Origin': 'https://www.americastestkitchen.com',
'X-Algolia-API-Key': '8d504d0099ed27c1b73708d22871d805'... | ```suggestion
'url': f'https://www.americastestkitchen.com{show_path or ""}{search_url}',
``` | season_search = self._download_json(
'https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_%s_season_desc_production' % slug,
season, headers={
'Origin': 'https://www.americastestkitchen.com',
'X-Algolia-API-Key': '8d504d0099ed27c1b73708d22871d805',... | @@ -136,12 +147,12 @@ def _real_extract(self, url):
def entries():
for episode in (season_search.get('hits') or []):
- search_url = episode.get('search_url')
+ search_url = episode.get('search_url') # always formatted like '/episode/123-title-of-episode'
... | yt_dlp/extractor/americastestkitchen.py | 26 | Python | 0.857 | suggestion | 115 | 38 | 37 | false | [extractor/americastestkitchen] Fix `_VALID_URL` and season extraction | 5,343 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
class AmericasTestKitchenSeasonIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?americastestkitchen\.com(?P<show>/cookscountry)?/episodes/browse/season_(?P<id>\d+)'
_TESTS = [{
# ATK Season
'url': 'https://www.americastestkitchen.com/episodes/browse/season_1',
'info_dict': {
... | ```suggestion
```
show above | class AmericasTestKitchenSeasonIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?americastestkitchen\.com(?P<show>/cookscountry)?/episodes/browse/season_(?P<id>\d+)'
_TESTS = [{
# ATK Season
'url': 'https://www.americastestkitchen.com/episodes/browse/season_1',
'info_dict': {
... | @@ -110,17 +120,18 @@ class AmericasTestKitchenSeasonIE(InfoExtractor):
}]
def _real_extract(self, url):
- show_name, season_number = self._match_valid_url(url).groups()
+ show_path, season_number = self._match_valid_url(url).group('show', 'id')
season_number = int(season_number)
- ... | yt_dlp/extractor/americastestkitchen.py | 26 | Python | 0.429 | suggestion | 30 | 51 | 51 | false | [extractor/americastestkitchen] Fix `_VALID_URL` and season extraction | 5,343 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'info_dict': {
'id': '64095316',
'ext': 'mp4',
'title': 'Uliczny Foxtrot — Wypożyczalnia kaset. Kto pamięta DVD-Video?',
'age_limit': 0,
'duration': 374,
'thumbnail': r're:https://.+',
},
'expected_warnings': [
'... | From UK, I'm sure this worked one time, but now always gives the message as below.
```suggestion
'add_ie': ['TVPEmbed'],
'skip': 'Video is geo restricted',
},
```
For handling geo-blocking I used the `raise_geo_restricted()` method with this in the `TVPEmbedIE`:
```py
# XFF is not ef... | # TVPlayer 2 in js wrapper
'url': 'https://swipeto.pl/64095316/uliczny-foxtrot-wypozyczalnia-kaset-kto-pamieta-dvdvideo',
'info_dict': {
'id': '64095316',
'ext': 'mp4',
'title': 'Uliczny Foxtrot — Wypożyczalnia kaset. Kto pamięta DVD-Video?',
'age_... | @@ -38,6 +44,8 @@ class TVPIE(InfoExtractor):
'ext': 'mp4',
'title': 'TVP Gorzów pokaże filmy studentów z podroży dookoła świata',
'description': 'TVP Gorzów pokaże filmy studentów z podroży dookoła świata',
+ 'age_limit': 0,
+ 'thumbnail': r're:https://.+',
... | yt_dlp/extractor/tvp.py | 26 | Python | 1 | suggestion | 581 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | selfisekai |
video_id = self._match_id(url)
# it could be anything that is a valid JS function name
callback = random.choice((
'jebac_pis',
'jebacpis',
'ziobro',
'sasin70',
'sasin_przejebal_70_milionow_PLN',
'tvp_is_a_state_propaganda_s... | Maybe more defensive, and expect a reported error?
```py
error = self._parse_json(datastr[5:], video_id, fatal=False)
# or use traverse_obj() ...
error_desc = try_get(error, lambda x: x[0]['desc'], str)
if error_desc == 'Obiekt wymaga płatności':
e... | 'url': 'https://www.tvp.pl/shared/details.php?copy_id=52205981&object_id=52204505&autoplay=false&is_muted=false&allowfullscreen=true&template=external-embed/video/iframe-video.html',
'only_matching': True,
}]
def _real_extract(self, url):
video_id = self._match_id(url)
# it cou... | @@ -362,7 +385,12 @@ def _real_extract(self, url):
datastr = webpage[15 + len(callback):-3]
if datastr.startswith('null,'):
error = self._parse_json(datastr[5:], video_id)
- raise ExtractorError(error[0]['desc'])
+ error_desc = error[0]['desc']
+
+ if erro... | yt_dlp/extractor/tvp.py | 26 | Python | 1 | refactor | 509 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | selfisekai |
formats.extend(self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls', fatal=False, live=is_live))
elif video_url.endswith('.mpd'):
if is_live:
# doesn't work with either ffmpeg or native downloader
continue
forma... | Maybe some formats are blocked and some not? Also, say which countr/y/ies to use, or use `_GEO_COUNTRIES`.
```suggestion
# or use `nonlocal geo_block`
self.__geo_block = False
def not_geo_blocked(f):
blkd = 'material_niedostepny.mp4' in f.get('url')
if blkd:
... | # actual country list is not provided, we just assume it's always available in PL
self.raise_geo_restricted(countries=['PL'])
formats = []
for file in content['files']:
video_url = url_or_none(file.get('url'))
if not video_url:
continue
... | @@ -397,6 +425,10 @@ def _real_extract(self, url):
'height': int_or_none(quality.get('height')),
})
+ # https://s.tvp.pl/files/player/video/material_niedostepny.mp4
+ if any(('/material_niedostepny.mp4' in fmt['url'] for fmt in formats)):
+ self.raise_geo... | yt_dlp/extractor/tvp.py | 26 | Python | 0.857 | suggestion | 552 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | selfisekai |
'season': info.get('season'),
'episode_number': info.get('episode'),
})
return info_dict
class TVPVODBaseIE(InfoExtractor):
_API_BASE_URL = 'https://vod.tvp.pl/api/products'
def _api_request(self, resource, video_id, **kwargs):
return self._downloa... | Should these be conditioned to non-empty strings, eg with `strip_or_none(...) or None`? | if info.get('vortalName') == 'vod':
info_dict.update({
'title': '%s, %s' % (info.get('title'), info.get('subtitle')),
'series': info.get('title'),
'season': info.get('season'),
'episode_number': info.get('episode'),
})
... | @@ -449,57 +481,101 @@ def _real_extract(self, url):
return info_dict
-class TVPWebsiteIE(InfoExtractor):
- IE_NAME = 'tvp:series'
- _VALID_URL = r'https?://vod\.tvp\.pl/website/(?P<display_id>[^,]+),(?P<id>\d+)'
+class TVPVODBaseIE(InfoExtractor):
+ _API_BASE_URL = 'https://vod.tvp.pl/api/product... | yt_dlp/extractor/tvp.py | 26 | Python | 0.429 | question | 87 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | selfisekai |
yield self._extract_vue_video(video)
for video in wd.get('items') or []:
yield self._extract_vue_video(video)
yield from extract_videos(website_data)
if website_data.get('items_total_count') > website_data.get('items_per_page'):
for page in itert... | Maybe:
```suggestion
for ie_cls in (TVPVODSeriesIE, TVPVODVideoIE):
if ie_cls.suitable(urlh.url):
return self.url_result(urlh.url, ie=ie_cls.ie_key(), video_id=page_id)
``` |
def extract_videos(wd):
if wd.get('latestVideo'):
yield self._extract_vue_video(wd['latestVideo'])
for video in wd.get('videos') or []:
yield self._extract_vue_video(video)
for video in wd.get('items') or []:
yield self._extrac... | @@ -217,8 +229,10 @@ def _real_extract(self, url):
# The URL may redirect to a VOD
# example: https://vod.tvp.pl/48463890/wadowickie-spotkania-z-janem-pawlem-ii
- if TVPWebsiteIE.suitable(urlh.url):
- return self.url_result(urlh.url, ie=TVPWebsiteIE.ie_key(), video_id=page_id)
+ ... | yt_dlp/extractor/tvp.py | 26 | Python | 0.786 | suggestion | 213 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | selfisekai |
}, {
'url': 'https://vod.tvp.pl/dla-dzieci,24/laboratorium-alchemika-odcinki,309338',
'only_matching': True,
}]
def _entries(self, seasons, playlist_id):
for season in seasons:
episodes = self._api_request(
f'vods/serials/{playlist_id}/seasons/{season["id... | `title` is not mandatory in a playlist, but there should be an ID. Also, could use `playlist_result()` method; consider extracting `metadata['mainCategory']['name']` as a category.
```suggestion
return self.playlist_result(
self._entries(seasons, playlist_id),
playlist_id, metadata.g... | 'title': 'Ranczo',
'age_limit': 12,
'categories': ['seriale'],
},
'playlist_count': 129,
}, {
'url': 'https://vod.tvp.pl/programy,88/rolnik-szuka-zony-odcinki,284514',
'only_matching': True,
}, {
'url': 'https://vod.tvp.pl/dla-dzieci,24... | @@ -449,57 +481,101 @@ def _real_extract(self, url):
return info_dict
-class TVPWebsiteIE(InfoExtractor):
- IE_NAME = 'tvp:series'
- _VALID_URL = r'https?://vod\.tvp\.pl/website/(?P<display_id>[^,]+),(?P<id>\d+)'
+class TVPVODBaseIE(InfoExtractor):
+ _API_BASE_URL = 'https://vod.tvp.pl/api/product... | yt_dlp/extractor/tvp.py | 26 | Python | 0.857 | refactor | 411 | 27 | 35 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | selfisekai |
if not website_data:
return None
return self._parse_json(website_data, page_id, transform_source=js_to_json)
def _extract_vue_video(self, video_data, page_id=None):
if isinstance(video_data, str):
video_data = self._parse_json(video_data, page_id, transform_source=js... | ```suggestion
'ie_key': (TVPIE if is_website else TVPEmbedIE).ie_key(),
``` | if not website_data:
return None
return self._parse_json(website_data, page_id, transform_source=js_to_json)
def _extract_vue_video(self, video_data, page_id=None):
if isinstance(video_data, str):
video_data = self._parse_json(video_data, page_id, transform_source=js... | @@ -151,16 +171,13 @@ def _extract_vue_video(self, video_data, page_id=None):
is_website = video_data.get('type') == 'website'
if is_website:
url = video_data['url']
- fucked_up_url_parts = re.match(r'https?://vod\.tvp\.pl/(\d+)/([^/?#]+)', url)
- if fucked_up_url_pa... | yt_dlp/extractor/tvp.py | 26 | Python | 0.571 | suggestion | 89 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
webpage = self._download_webpage(channel_url, channel_id, 'Downloading channel webpage')
if not channel_id:
channel_id = self._search_regex(self._PLAYER_BOX_RE % 'channel',
webpage, 'default channel id')
video_id = self._search_regex(self._... | ```suggestion
_GEO_BYPASS = False
```
That's the only reason this is ever set | webpage = self._download_webpage(channel_url, channel_id, 'Downloading channel webpage')
if not channel_id:
channel_id = self._search_regex(self._PLAYER_BOX_RE % 'channel',
webpage, 'default channel id')
video_id = self._search_regex(self._... | @@ -297,12 +315,14 @@ def _real_extract(self, url):
class TVPEmbedIE(InfoExtractor):
IE_NAME = 'tvp:embed'
IE_DESC = 'Telewizja Polska'
+ # XFF is not effective
+ _GEO_BYPASS = False | yt_dlp/extractor/tvp.py | 26 | Python | 0.571 | suggestion | 84 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
# actual country list is not provided, we just assume it's always available in PL
self.raise_geo_restricted(countries=['PL'])
formats = []
for file in content['files']:
video_url = url_or_none(file.get('url'))
if not video_url:
continue
... | ```suggestion
quality = file.get('quality') or {}
```
| self.raise_geo_restricted(countries=['PL'])
formats = []
for file in content['files']:
video_url = url_or_none(file.get('url'))
if not video_url:
continue
ext = determine_ext(video_url, None)
if ext == 'm3u8':
f... | @@ -361,38 +390,51 @@ def _real_extract(self, url):
# stripping JSONP padding
datastr = webpage[15 + len(callback):-3]
if datastr.startswith('null,'):
- error = self._parse_json(datastr[5:], video_id)
- raise ExtractorError(error[0]['desc'])
+ error = self._pa... | yt_dlp/extractor/tvp.py | 26 | Python | 0.571 | suggestion | 73 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
for file in content['files']:
video_url = url_or_none(file.get('url'))
if not video_url:
continue
ext = determine_ext(video_url)
if ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls', fatal=F... | ```suggestion
'ext': ext or file.get('type'),
```
see next comment | video_url = url_or_none(file.get('url'))
if not video_url:
continue
ext = determine_ext(video_url, None)
if ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls', fatal=False, live=is_live))
... | @@ -361,38 +390,51 @@ def _real_extract(self, url):
# stripping JSONP padding
datastr = webpage[15 + len(callback):-3]
if datastr.startswith('null,'):
- error = self._parse_json(datastr[5:], video_id)
- raise ExtractorError(error[0]['desc'])
+ error = self._pa... | yt_dlp/extractor/tvp.py | 26 | Python | 0.714 | suggestion | 89 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
# stripping JSONP padding
datastr = webpage[15 + len(callback):-3]
if datastr.startswith('null,'):
error = self._parse_json(datastr[5:], video_id, fatal=False)
error_desc = traverse_obj(error, (0, 'desc'))
if error_desc == 'Obiekt wymaga płatności':
... | ```suggestion
ext = determine_ext(video_url, None)
``` | # stripping JSONP padding
datastr = webpage[15 + len(callback):-3]
if datastr.startswith('null,'):
error = self._parse_json(datastr[5:], video_id, fatal=False)
error_desc = traverse_obj(error, (0, 'desc'))
if error_desc == 'Obiekt wymaga płatności':
... | @@ -361,38 +390,51 @@ def _real_extract(self, url):
# stripping JSONP padding
datastr = webpage[15 + len(callback):-3]
if datastr.startswith('null,'):
- error = self._parse_json(datastr[5:], video_id)
- raise ExtractorError(error[0]['desc'])
+ error = self._pa... | yt_dlp/extractor/tvp.py | 26 | Python | 0.571 | suggestion | 68 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'thumbnails': thumbnails,
'age_limit': age_limit,
'is_live': is_live,
'duration': duration,
'formats': formats,
'subtitles': subtitles,
}
# vod.tvp.pl
if info.get('vortalName') == 'vod':
info_dict.update({
... | ```suggestion
f'{self._API_BASE_URL}/{resource}', video_id,
query={'lang': 'pl', 'platform': 'BROWSER'}, **kwargs)
``` | }
# vod.tvp.pl
if info.get('vortalName') == 'vod':
info_dict.update({
'title': '%s, %s' % (info.get('title'), info.get('subtitle')),
'series': info.get('title'),
'season': info.get('season'),
'episode_number': info.get(... | @@ -449,57 +491,104 @@ def _real_extract(self, url):
return info_dict
-class TVPWebsiteIE(InfoExtractor):
- IE_NAME = 'tvp:series'
- _VALID_URL = r'https?://vod\.tvp\.pl/website/(?P<display_id>[^,]+),(?P<id>\d+)'
+class TVPVODBaseIE(InfoExtractor):
+ _API_BASE_URL = 'https://vod.tvp.pl/api/product... | yt_dlp/extractor/tvp.py | 26 | Python | 0.714 | suggestion | 145 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'title': title,
'description': description,
'thumbnails': thumbnails,
'age_limit': age_limit,
'is_live': is_live,
'duration': duration,
'formats': formats,
'subtitles': subtitles,
}
# vod.tvp.pl
if i... | `_call_api` is conventionally used as the name. Not mandatory though | 'formats': formats,
'subtitles': subtitles,
}
# vod.tvp.pl
if info.get('vortalName') == 'vod':
info_dict.update({
'title': '%s, %s' % (info.get('title'), info.get('subtitle')),
'series': info.get('title'),
'seas... | @@ -449,57 +491,104 @@ def _real_extract(self, url):
return info_dict
-class TVPWebsiteIE(InfoExtractor):
- IE_NAME = 'tvp:series'
- _VALID_URL = r'https?://vod\.tvp\.pl/website/(?P<display_id>[^,]+),(?P<id>\d+)'
+class TVPVODBaseIE(InfoExtractor):
+ _API_BASE_URL = 'https://vod.tvp.pl/api/product... | yt_dlp/extractor/tvp.py | 26 | Python | 0.429 | style | 68 | 51 | 51 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
IE_NAME = 'tvp:vod:series'
_VALID_URL = r'https?://vod\.tvp\.pl/[a-z\d-]+,\d+/[a-z\d-]+-odcinki,(?P<id>\d+)(?:\?[^#]+)?(?:#.+)?$'
_TESTS = [{
'url': 'https://vod.tvp.pl/seriale,18/ranczo-odcinki,316445',
'info_dict': {
'id': '316445',
'title': 'Ranczo',
'... | ```suggestion
yield from map(self._parse_video, episodes)
``` | 'info_dict': {
'id': '316445',
'title': 'Ranczo',
'age_limit': 12,
'categories': ['seriale'],
},
'playlist_count': 129,
}, {
'url': 'https://vod.tvp.pl/programy,88/rolnik-szuka-zony-odcinki,284514',
'only_matching': True,
},... | @@ -449,57 +491,104 @@ def _real_extract(self, url):
return info_dict
-class TVPWebsiteIE(InfoExtractor):
- IE_NAME = 'tvp:series'
- _VALID_URL = r'https?://vod\.tvp\.pl/website/(?P<display_id>[^,]+),(?P<id>\d+)'
+class TVPVODBaseIE(InfoExtractor):
+ _API_BASE_URL = 'https://vod.tvp.pl/api/product... | yt_dlp/extractor/tvp.py | 26 | Python | 0.571 | suggestion | 75 | 42 | 37 | false | tvp: vod refactor, domain list update, general improvements | 5,346 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'categories': gif_data.get('tags') or [],
'tags': gif_data.get('tags'),
'age_limit': 18,
'formats': formats,
}
def _fetch_oauth_token(self, video_id):
# https://github.com/Redgifs/api/wiki/Temporary-tokens
auth = self._download_json('https://a... | - the first `_fetch_oauth_token` call can be moved inside the loop to get rid of the duplication
- the `assert` line can also be removed since `_fetch_oauth_token` is fatal
- `data` should be defined before `try/except` in case there are two consecutive 401 responses for some unforeseen reason
```py
def _cal... | 'formats': formats,
}
def _fetch_oauth_token(self, video_id):
# https://github.com/Redgifs/api/wiki/Temporary-tokens
auth = self._download_json('https://api.redgifs.com/v2/auth/temporary',
video_id, note='Fetching temporary token')
if n... | @@ -76,10 +80,22 @@ def _call_api(self, ep, video_id, *args, **kwargs):
self._fetch_oauth_token(video_id)
assert 'authorization' in self._API_HEADERS
- headers = dict(self._API_HEADERS)
- headers['x-customheader'] = f'https://www.redgifs.com/watch/{video_id}'
- data = self._... | yt_dlp/extractor/redgifs.py | 26 | Python | 1 | security | 1,290 | 51 | 51 | false | [RedGifs] Refresh auth token when API returns HTTP 401 | 5,352 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | endotronic |
import functools
import urllib
from .common import InfoExtractor
from ..compat import compat_parse_qs
from ..utils import (
ExtractorError,
int_or_none,
qualities,
try_get,
OnDemandPagedList,
)
# The temporary token may expire. Make only one attempt to refresh it.
MAX_TOKEN_REFRESH_ATTEMPTS = 1
... | ```suggestion
```
unnecessary | import functools
import urllib
from .common import InfoExtractor
from ..compat import compat_parse_qs
from ..utils import (
ExtractorError,
int_or_none,
qualities,
try_get,
OnDemandPagedList,
)
class RedGifsBaseInfoExtractor(InfoExtractor):
_FORMATS = {
'gif': 250,
'sd': 480,
... | @@ -10,6 +11,9 @@
OnDemandPagedList,
)
+# The temporary token may expire. Make only one attempt to refresh it.
+MAX_TOKEN_REFRESH_ATTEMPTS = 1
+ | yt_dlp/extractor/redgifs.py | 16 | Python | 0.429 | suggestion | 33 | 41 | 41 | false | [RedGifs] Refresh auth token when API returns HTTP 401 | 5,352 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | endotronic |
self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
def _call_api(self, ep, video_id, *args, **kwargs):
# Possibly repeat if re-authorization is needed
attempts = 0
while True:
if 'authorization' not in self._API_HEADERS:
self._fetch_oauth_toke... | ```suggestion
for attempt in range(2):
if 'authorization' not in self._API_HEADERS:
self._fetch_oauth_token(video_id)
try:
headers = dict(self._API_HEADERS)
headers['x-customheader'] = f'https://www.redgifs.com/watch/{video_id}'
... | self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
def _call_api(self, ep, video_id, *args, **kwargs):
for attempt in range(2):
if 'authorization' not in self._API_HEADERS:
self._fetch_oauth_token(video_id)
try:
headers = dict(self... | @@ -72,14 +73,30 @@ def _fetch_oauth_token(self, video_id):
self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
def _call_api(self, ep, video_id, *args, **kwargs):
- if 'authorization' not in self._API_HEADERS:
- self._fetch_oauth_token(video_id)
- assert 'authorizati... | yt_dlp/extractor/redgifs.py | 26 | Python | 1 | security | 736 | 51 | 51 | false | [RedGifs] Refresh auth token when API returns HTTP 401 | 5,352 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | endotronic |
'age_limit': 18,
'formats': formats,
}
def _fetch_oauth_token(self, video_id):
# https://github.com/Redgifs/api/wiki/Temporary-tokens
auth = self._download_json('https://api.redgifs.com/v2/auth/temporary',
video_id, note='Fetching t... | ```suggestion
if not attempt and isinstance(e.cause, urllib.error.HTTPError) and e.cause.code == 401:
del self._API_HEADERS['authorization'] # refresh the token
raise
``` | 'age_limit': 18,
'formats': formats,
}
def _fetch_oauth_token(self, video_id):
# https://github.com/Redgifs/api/wiki/Temporary-tokens
auth = self._download_json('https://api.redgifs.com/v2/auth/temporary',
video_id, note='Fetching t... | @@ -72,14 +73,20 @@ def _fetch_oauth_token(self, video_id):
self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'
def _call_api(self, ep, video_id, *args, **kwargs):
- if 'authorization' not in self._API_HEADERS:
- self._fetch_oauth_token(video_id)
- assert 'authorizati... | yt_dlp/extractor/redgifs.py | 26 | Python | 1 | security | 227 | 51 | 51 | false | [RedGifs] Refresh auth token when API returns HTTP 401 | 5,352 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | endotronic |
},
}, {
# 2-video post with 'single' query param and --yes-playlist
'url': 'https://t.me/vorposte/29343?single',
'info_dict': {
'id': 'vorposte-29343',
'title': 'Форпост 29343',
'description': 'md5:4d573fd641c3a21f58ad6bb5f16fe526',
},
... | Use utils.parse_qs and self._yes_playlist
noplaylist=None is not a thing. If `?single` is given, that should take precedence over yes/no-playlist | 'channel_id': 'vorposte',
'channel': 'Форпост',
'thumbnail': r're:^https?://.+',
'timestamp': 1666384480,
'upload_date': '20221021',
'duration': 33,
},
}]
def _real_extract(self, url):
channel_id, msg_id = self._match_valid... | @@ -1,41 +1,141 @@
+import re
+
from .common import InfoExtractor
-from ..utils import clean_html, get_element_by_class
+from ..utils import (
+ clean_html,
+ get_element_by_class,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+ update_url_query,
+ url_basename,
+)
class TelegramEmbe... | yt_dlp/extractor/telegram.py | 26 | Python | 0.571 | suggestion | 148 | 51 | 51 | false | [extractor/telegram] Add playlist support and more metadata | 5,358 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
for video in re.findall(r'<a class="tgme_widget_message_video_player(?s:.+?)</time>', embed):
video_url = self._search_regex(
r'<video[^>]+src="([^"]+)"', video, 'video URL', fatal=False)
webpage_url = self._search_regex(
r'<a class="tgme_widget_message_vi... | if we are getting all video info and then filtering anyway, why update `single` in the query above? | 'url': video_url,
'ext': 'mp4',
}]
self._sort_formats(formats)
videos.append({
'id': url_basename(webpage_url),
'webpage_url': update_url_query(webpage_url, {'single': True}),
'duration': parse_duration(s... | @@ -1,41 +1,141 @@
+import re
+
from .common import InfoExtractor
-from ..utils import clean_html, get_element_by_class
+from ..utils import (
+ clean_html,
+ get_element_by_class,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+ update_url_query,
+ url_basename,
+)
class TelegramEmbe... | yt_dlp/extractor/telegram.py | 26 | Python | 0.357 | question | 99 | 30 | 26 | false | [extractor/telegram] Add playlist support and more metadata | 5,358 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
webpage_url = self._search_regex(
r'<a class="tgme_widget_message_video_player[^>]+href="([^"]+)"',
video, 'webpage URL', fatal=False)
if not video_url or not webpage_url:
continue
formats = [{
'url': video_url,
... | title/description should be non-fatal | import re
from .common import InfoExtractor
from ..utils import (
clean_html,
format_field,
get_element_by_class,
parse_duration,
parse_qs,
traverse_obj,
unified_timestamp,
update_url_query,
url_basename,
)
class TelegramEmbedIE(InfoExtractor):
IE_NAME = 'telegram:embed'
_... | @@ -1,41 +1,141 @@
+import re
+
from .common import InfoExtractor
-from ..utils import clean_html, get_element_by_class
+from ..utils import (
+ clean_html,
+ get_element_by_class,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+ update_url_query,
+ url_basename,
+)
class TelegramEmbe... | yt_dlp/extractor/telegram.py | 26 | Python | 0.143 | suggestion | 37 | 27 | 138 | false | [extractor/telegram] Add playlist support and more metadata | 5,358 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
query = {'embed': '1'}
if self.get_param('noplaylist'):
query['single'] = True
elif self.get_param('noplaylist') is False:
pass
elif '?single' in url: # param 'noplaylist' is None
query['single'] = True
url = update_url_query(url, {'single': ... | ```suggestion
'id': url_basename(webpage_url),
'webpage_url': update_url_query(webpage_url, {'single': True}),
```
Playlist entries should have `webpage_url` if possible. When returning `url_result`, core code handles this, but when directly returning video, extractor has to manual... | description = clean_text('tgme_widget_message_text', embed)
message = {
'title': description or '',
'description': description,
'channel': clean_text('tgme_widget_message_author', embed),
'channel_id': channel_id,
'timestamp': unified_timestamp... | @@ -1,41 +1,141 @@
+import re
+
from .common import InfoExtractor
-from ..utils import clean_html, get_element_by_class
+from ..utils import (
+ clean_html,
+ get_element_by_class,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+ update_url_query,
+ url_basename,
+)
class TelegramEmbe... | yt_dlp/extractor/telegram.py | 26 | Python | 1 | refactor | 329 | 50 | 46 | false | [extractor/telegram] Add playlist support and more metadata | 5,358 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'params': {
'noplaylist': True,
}
}, {
# 2-video post with 'single' query param
'url': 'https://t.me/vorposte/29342?single',
'md5': 'd20b202f1e41400a9f43201428add18f',
'info_dict': {
'id': '29342',
'ext': 'mp4',
'title':... | does this not work?
```suggestion
url msg_id, query={'embed': '1', 'single': []},
note='Downloading embed frame')
``` | 'params': {
'noplaylist': True,
}
}, {
# 2-video post with 'single' query param
'url': 'https://t.me/vorposte/29342?single',
'md5': 'd20b202f1e41400a9f43201428add18f',
'info_dict': {
'id': '29342',
'ext': 'mp4',
'title':... | @@ -1,41 +1,138 @@
+import re
+
from .common import InfoExtractor
-from ..utils import clean_html, get_element_by_class
+from ..utils import (
+ clean_html,
+ format_field,
+ get_element_by_class,
+ parse_duration,
+ parse_qs,
+ traverse_obj,
+ unified_timestamp,
+ update_url_query,
+ url_ba... | yt_dlp/extractor/telegram.py | 26 | Python | 0.714 | question | 145 | 51 | 51 | false | [extractor/telegram] Add playlist support and more metadata | 5,358 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'id': '29342',
'ext': 'mp4',
'title': 'md5:922c99739691bfe6f052cab5f2d099ae',
'description': 'md5:9d92e22169a3e136d5d69df25f82c3dc',
'channel_id': 'vorposte',
'channel': 'Форпост',
'thumbnail': r're:^https?://.+',
'timestamp... | Either use full description, or set to `''` | 'id': '29342',
'ext': 'mp4',
'title': 'md5:9d92e22169a3e136d5d69df25f82c3dc',
'description': 'md5:9d92e22169a3e136d5d69df25f82c3dc',
'channel_id': 'vorposte',
'channel': 'Форпост',
'thumbnail': r're:^https?://.+',
'timestamp... | @@ -1,41 +1,138 @@
+import re
+
from .common import InfoExtractor
-from ..utils import clean_html, get_element_by_class
+from ..utils import (
+ clean_html,
+ format_field,
+ get_element_by_class,
+ parse_duration,
+ parse_qs,
+ traverse_obj,
+ unified_timestamp,
+ update_url_query,
+ url_ba... | yt_dlp/extractor/telegram.py | 26 | Python | 0.286 | suggestion | 43 | 51 | 51 | false | [extractor/telegram] Add playlist support and more metadata | 5,358 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
import re
from ..utils import (
ExtractorError,
clean_html,
float_or_none,
int_or_none,
join_nonempty,
smuggle_url,
traverse_obj,
unsmuggle_url
)
from .common import InfoExtractor
class ShugiinItvBaseIE(InfoExtractor):
@classmethod
def _find_rooms(cls, webpage):
return... | ```suggestion
} for x in re.finditer(r'<a\s+href="[^"]+\?room_id=(room\d+)"\s*class="play_live".+?class="s12_14">(.+?)</td>', webpage)]
```
The regex looks fragile. Though I haven't looked at the page, so not sure if there's a better way | import re
from ..utils import (
ExtractorError,
clean_html,
int_or_none,
join_nonempty,
parse_qs,
smuggle_url,
traverse_obj,
try_call,
unsmuggle_url
)
from .common import InfoExtractor
def _parse_japanese_date(text):
if not text:
return None
ERA_TABLE = {
'... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 25 | Python | 0.857 | suggestion | 250 | 50 | 50 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
year, month, day = map(int, (year, month, day))
if era:
# example input: 令和5年3月34日
# even though each era have their end, don't check here
year += ERA_TABLE[era]
return '%04d%02d%02d' % (year, month, day)
@staticmethod
def _parse_japanese_duration(tex... | Are these standard enough to go into parse_duration/unified_strdate? | return
days, hours, mins, secs = [int_or_none(x, default=0) for x in mobj.groups()]
return secs + mins * 60 + hours * 60 * 60 + days * 24 * 60 * 60
class ShugiinItvBaseIE(InfoExtractor):
_INDEX_ROOMS = None
@classmethod
def _find_rooms(cls, webpage):
return [{
'_type':... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.214 | question | 68 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
if not mobj:
return None
days, hours, mins, secs = map(int_or_none, mobj.groups())
duration = 0
if secs:
duration += float(secs)
if mins:
duration += float(mins) * 60
if hours:
duration += float(hours) * 60 * 60
if ... | ```suggestion
self.to_screen(
'Downloading all running proceedings. To specify one proceeding, use direct link from the website')
``` | 'id': x.group(1),
'title': clean_html(x.group(2)).strip(),
'url': smuggle_url(f'https://www.shugiintv.go.jp/jp/index.php?room_id={x.group(1)}', {'g': x.groups()}),
'ie_key': ShugiinItvLiveIE.ie_key(),
} for x in re.finditer(r'(?s)<a\s+href="[^"]+\?room_id=(room\d+... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.786 | suggestion | 156 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
@classmethod
def suitable(cls, url):
return super().suitable(url) and not any(x.suitable(url) for x in (ShugiinItvLiveRoomIE, ShugiinItvVodIE))
def _real_extract(self, url):
self.report_warning('Listing up all running proceedings as of now. To specify one proceedings to record, use link di... | ```suggestion
encoding='euc-jp', note='Looking up stream title')
``` | _TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.php',
'info_dict': {
'_type': 'playlist',
'title': 'All proceedings for today',
},
# expect at least one proceedings is running
'playlist_mincount': 1,
}]
@classmethod
def suitable(c... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.571 | suggestion | 86 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(
f'https://www.shugiintv.go.jp/jp/index.php?ex=VL&media_type=&deli_id={video_id}', video_id,
encoding='euc-jp')
m3u8_url = self._search_regex(
r'id="vtag... | ```suggestion
for chp in re.finditer(r'(?i)<a\s+href="[^"]+php\?[^"]+?&deli_id=\d+&time=([\d.]+)"\s*class="play_vod">(?!<img)(.+?)</a>', webpage):
```
Capture the whole URL and parse query later imo. Currently this breaks if order of query params change | 'formats': formats,
'subtitles': subtitles,
'is_live': True,
}
class ShugiinItvVodIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)/index\.php\?ex=VL(?:\&[^=]+=[^&]*)*\&deli_id=(?P<id>\d+)'
IE_DESC = '衆議院インターネット審議中継 (ビデオライブラリ)'
... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.857 | suggestion | 264 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
self._sort_formats(formats)
title = self._html_search_regex(
(r'<td\s+align="left">(.+)\s*\(\d+分\)',
r'<TD.+?<IMG\s*src=".+?/spacer\.gif".+?height="15">(.+?)<IMG'), webpage, 'title', fatal=False)
release_date = self._parse_japanese_date(self._html_search_regex(
... | set this to `duration` instead | 'title': 'ウクライナ大統領国会演説(オンライン)',
'release_date': '20220323',
'chapters': 'count:4',
}
}, {
'url': 'https://www.shugiintv.go.jp/en/index.php?ex=VL&media_type=&deli_id=53846',
'only_matching': True
}]
def _real_extract(self, url):
video_id = ... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.286 | suggestion | 30 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
class ShugiinItvLiveIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)(?:/index\.php)?$'
IE_DESC = '衆議院インターネット審議中継'
@classmethod
def suitable(cls, url):
return super().suitable(url) and not any(x.suitable(url) for x in (ShugiinItvLiveRoomIE, ShugiinItvVodIE))
... | add a test even if it'll become outdated |
class ShugiinItvLiveIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)(?:/index\.php)?$'
IE_DESC = '衆議院インターネット審議中継'
_TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.php',
'info_dict': {
'_type': 'playlist',
'title': 'All proc... | @@ -0,0 +1,259 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ float_or_none,
+ int_or_none,
+ join_nonempty,
+ smuggle_url,
+ traverse_obj,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ def _find... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.071 | suggestion | 40 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
year, month, day = map(int, (year, month, day))
if era:
# example input: 令和5年3月34日
# even though each era have their end, don't check here
year += ERA_TABLE[era]
return '%04d%02d%02d' % (year, month, day)
@staticmethod
def _parse_japanese_duration(tex... | ```suggestion
mobj = re.search(r'(?:(\d+)日間?)?(?:(\d+)時間?)?(?:(\d+)分)?(?:(\d+)秒)?', re.sub(r'[\s\u3000]+', '', text or ''))
if not mobj:
return
days, hours, mins, secs = [int_or_none(x, default=0) for x in mobj.groups()]
return secs + mins * 60 + hours * 60 * 60 + days *... | days, hours, mins, secs = [int_or_none(x, default=0) for x in mobj.groups()]
return secs + mins * 60 + hours * 60 * 60 + days * 24 * 60 * 60
class ShugiinItvBaseIE(InfoExtractor):
_INDEX_ROOMS = None
@classmethod
def _find_rooms(cls, webpage):
return [{
'_type': 'url',
... | @@ -0,0 +1,281 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ parse_qs,
+ smuggle_url,
+ traverse_obj,
+ try_call,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ ... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.786 | suggestion | 338 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
mobj = re.search(r'(?:(\d+)日間?)?(?:(\d+)時間?)?(?:(\d+)分)?(?:(\d+)秒)?', re.sub(r'[\s\u3000]+', '', text))
if not mobj:
return None
days, hours, mins, secs = map(int_or_none, mobj.groups())
duration = 0
if secs:
duration += float(secs)
if mins:
... | why only_matching? The playlist metadata should be static | 'id': x.group(1),
'title': clean_html(x.group(2)).strip(),
'url': smuggle_url(f'https://www.shugiintv.go.jp/jp/index.php?room_id={x.group(1)}', {'g': x.groups()}),
'ie_key': ShugiinItvLiveIE.ie_key(),
} for x in re.finditer(r'(?s)<a\s+href="[^"]+\?room_id=(room\d+... | @@ -0,0 +1,281 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ parse_qs,
+ smuggle_url,
+ traverse_obj,
+ try_call,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ ... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.286 | question | 57 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
if secs:
duration += float(secs)
if mins:
duration += float(mins) * 60
if hours:
duration += float(hours) * 60 * 60
if days:
duration += float(days) * 24 * 60 * 60
return duration
class ShugiinItvLiveIE(ShugiinItvBaseIE):
_VAL... | We really need to generalize this pattern 🤔 | def _fetch_rooms(self):
if not self._INDEX_ROOMS:
webpage = self._download_webpage(
'https://www.shugiintv.go.jp/jp/index.php', None,
encoding='euc-jp', note='Downloading proceedings info')
ShugiinItvBaseIE._INDEX_ROOMS = self._find_rooms(webpage)
... | @@ -0,0 +1,281 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ parse_qs,
+ smuggle_url,
+ traverse_obj,
+ try_call,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ ... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.071 | suggestion | 44 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
duration += float(days) * 24 * 60 * 60
return duration
class ShugiinItvLiveIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)(?:/index\.php)?$'
IE_DESC = '衆議院インターネット審議中継'
_TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.php',
# ... | I would recommend adding either an id or title. Maybe `all proceedings`? |
class ShugiinItvLiveIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)(?:/index\.php)?$'
IE_DESC = '衆議院インターネット審議中継'
_TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.php',
'info_dict': {
'_type': 'playlist',
'title': 'All pro... | @@ -0,0 +1,281 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ parse_qs,
+ smuggle_url,
+ traverse_obj,
+ try_call,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ ... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.357 | question | 72 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
return self.playlist_result(self._find_rooms(webpage))
class ShugiinItvLiveRoomIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)/index\.php\?room_id=(?P<id>room\d+)'
IE_DESC = '衆議院インターネット審議中継 (中継)'
_TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.... | ```suggestion
url, smug = unsmuggle_url(url, default={})
if smug.get('g'):
``` |
class ShugiinItvLiveRoomIE(ShugiinItvBaseIE):
_VALID_URL = r'https?://(?:www\.)?shugiintv\.go\.jp/(?:jp|en)/index\.php\?room_id=(?P<id>room\d+)'
IE_DESC = '衆議院インターネット審議中継 (中継)'
_TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.php?room_id=room01',
'info_dict': {
'id': 'r... | @@ -0,0 +1,281 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ parse_qs,
+ smuggle_url,
+ traverse_obj,
+ try_call,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ ... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.571 | suggestion | 97 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
_TESTS = [{
'url': 'https://www.shugiintv.go.jp/jp/index.php?room_id=room01',
'info_dict': {
'id': 'room01',
'title': '内閣委員会',
},
'skip': 'this runs for a time and not every day',
}, {
'url': 'https://www.shugiintv.go.jp/jp/index.php?room_id=room1... | maybe this should be cached in RAM? To speed up `-a` | 'url': 'https://www.shugiintv.go.jp/jp/index.php?room_id=room01',
'info_dict': {
'id': 'room01',
'title': '内閣委員会',
},
'skip': 'this runs for a time and not every day',
}, {
'url': 'https://www.shugiintv.go.jp/jp/index.php?room_id=room11',
'info... | @@ -0,0 +1,281 @@
+import re
+
+from ..utils import (
+ ExtractorError,
+ clean_html,
+ int_or_none,
+ join_nonempty,
+ parse_qs,
+ smuggle_url,
+ traverse_obj,
+ try_call,
+ unsmuggle_url
+)
+from .common import InfoExtractor
+
+
+class ShugiinItvBaseIE(InfoExtractor):
+ @classmethod
+ ... | yt_dlp/extractor/japandiet.py | 26 | Python | 0.429 | performance | 52 | 51 | 51 | false | [extractor/japandiet] Add extractors | 5,368 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
'url': 'https://www.swearnet.com/shows/gettin-learnt-with-ricky/seasons/1/episodes/1',
'info_dict': {
'id': '232819',
'ext': 'mp4',
'episode_number': 1,
'episode': 'Episode 1',
'duration': 719,
'description': 'md5:c48ef71440ce466284... | ```suggestion
formats.extend({
'url': video_mp4.get('url'),
'ext': 'mp4'
} for video_mp4 in value)
``` | 'url': 'https://www.swearnet.com/shows/gettin-learnt-with-ricky/seasons/1/episodes/1',
'info_dict': {
'id': '232819',
'ext': 'mp4',
'episode_number': 1,
'episode': 'Episode 1',
'duration': 719,
'description': 'md5:c48ef71440ce466284... | @@ -0,0 +1,76 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, traverse_obj
+
+
+class SwearnetShowIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.swearnet\.com/shows/(?P<id>[\w-]+)/seasons/(?P<season_num>\d+)/episodes/(?P<episode_num>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.swear... | yt_dlp/extractor/swearnet.py | 26 | Python | 0.714 | suggestion | 179 | 51 | 51 | false | [extractor/swearnet] Add SwearnetEpisode Extractor | 5,371 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
formats, subtitles = [], {}
for key, value in video_source.items():
if key == 'mp4':
for video_mp4 in value:
fmts = [{
'url': video_mp4.get('url'),
'ext': 'mp4'
}]
form... | ```suggestion
subs.setdefault(caption.get('language') or 'und', []).append({
'url': caption.get('vttUrl'),
'name': caption.get('name')
})
``` | formats, subtitles = [], {}
for key, value in video_source.items():
if key == 'hls':
for video_hls in value:
fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id)
formats.extend(fmts)
... | @@ -0,0 +1,76 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, traverse_obj
+
+
+class SwearnetShowIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.swearnet\.com/shows/(?P<id>[\w-]+)/seasons/(?P<season_num>\d+)/episodes/(?P<episode_num>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.swear... | yt_dlp/extractor/swearnet.py | 26 | Python | 0.786 | suggestion | 202 | 51 | 50 | false | [extractor/swearnet] Add SwearnetEpisode Extractor | 5,371 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
})
return subs
def _real_extract(self, url):
display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')
webpage = self._download_webpage(url, display_id)
external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)',... | ```suggestion
'thumbnails': [{'url': thumbnail_url}
for thumbnail_url in traverse_obj(json_data, ('thumbnailUrls', ...))]
``` | return subs
def _real_extract(self, url):
display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')
webpage = self._download_webpage(url, display_id)
external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)', webpage, 'exter... | @@ -0,0 +1,74 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, traverse_obj
+
+
+class SwearnetEpisodeIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.swearnet\.com/shows/(?P<id>[\w-]+)/seasons/(?P<season_num>\d+)/episodes/(?P<episode_num>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.sw... | yt_dlp/extractor/swearnet.py | 26 | Python | 0.714 | suggestion | 167 | 28 | 27 | false | [extractor/swearnet] Add SwearnetEpisode Extractor | 5,371 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
'info_dict': {
'id': '232819',
'ext': 'mp4',
'episode_number': 1,
'episode': 'Episode 1',
'duration': 719,
'description': 'md5:c48ef71440ce466284c07085cd7bd761',
'season': 'Season 1',
'title': 'Episode 1 - Grilled Ch... | ```suggestion
else:
``` | 'info_dict': {
'id': '232819',
'ext': 'mp4',
'episode_number': 1,
'episode': 'Episode 1',
'duration': 719,
'description': 'md5:c48ef71440ce466284c07085cd7bd761',
'season': 'Season 1',
'title': 'Episode 1 - Grilled Ch... | @@ -0,0 +1,74 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, traverse_obj
+
+
+class SwearnetEpisodeIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.swearnet\.com/shows/(?P<id>[\w-]+)/seasons/(?P<season_num>\d+)/episodes/(?P<episode_num>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.sw... | yt_dlp/extractor/swearnet.py | 26 | Python | 0.429 | suggestion | 37 | 51 | 51 | false | [extractor/swearnet] Add SwearnetEpisode Extractor | 5,371 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | HobbyistDev |
banner['preference'] = -10
if channel_banners:
uncropped_banner = _get_uncropped(channel_banners[0]['url'])
if uncropped_banner:
channel_banners.append({
'url': uncropped_banner,
'id': 'banner_uncropped',
... | I think it would be nice to change `get_first` like this:
```py
def get_first(obj, *keys, **kwargs):
return traverse_obj(obj, *[(..., *variadic(k)) for k in keys], **kwargs, get_all=False)
```
that'd make this just:
```suggestion
(primary_sidebar_renderer, playlist_header_renderer), 'stats', 'bri... | banner['preference'] = -10
if channel_banners:
uncropped_banner = _get_uncropped(channel_banners[0]['url'])
if uncropped_banner:
channel_banners.append({
'url': uncropped_banner,
'id': 'banner_uncropped',
... | @@ -4646,14 +4636,33 @@ def _get_uncropped(url):
'preference': -5
})
+ # Deprecated - remove when old layout is discontinued
primary_thumbnails = self._extract_thumbnails(
primary_sidebar_renderer, ('thumbnailRenderer', ('playlistVideoThumbnailRendere... | yt_dlp/extractor/youtube.py | 26 | Python | 0.857 | suggestion | 403 | 51 | 51 | false | [extractor/youtube] Update playlist metadata extraction for new layout | 5,376 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | coletdjnz |
'info_dict': {
'id': 'aa9ceecd-a127-453d-a2de-7153d6fd69b6',
'ext': 'mp4',
'title': 'Kash Patel: A ‘6-Year-Saga’ of Government Corruption, From Russiagate to Mar-a-Lago',
}
},
{
'url': 'https://www.theepochtimes.com/dick... | looks unnecessarily complicated. Why not use `extract_attributes(get_element_html_by_attribute(...)`? | 'url': 'https://www.theepochtimes.com/kash-patel-a-6-year-saga-of-government-corruption-from-russiagate-to-mar-a-lago_4690250.html',
'info_dict': {
'id': 'aa9ceecd-a127-453d-a2de-7153d6fd69b6',
'ext': 'mp4',
'title': 'Kash Patel: A ‘6-Year-Saga’ of... | @@ -28,13 +28,26 @@ class EpochIE(InfoExtractor):
'title': 'Kash Patel: A ‘6-Year-Saga’ of Government Corruption, From Russiagate to Mar-a-Lago',
}
},
+ {
+ 'url': 'https://www.theepochtimes.com/dick-morris-discusses-his-book-the-return-trumps-big-2024-comeback_4... | yt_dlp/extractor/epoch.py | 26 | Python | 0.571 | refactor | 101 | 36 | 32 | false | [extractor/epoch] Support videos without data-trailer | 5,387 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | gibson042 |
}
}, {
'url': 'https://2m.ma/fr/replay/single/635c0aeab4eec832622356da',
'info_dict': {
'id': '635c0aeab4eec832622356da',
'ext': 'mp4',
'title': 'Journal Amazigh : Vendredi 28 Octobre 2022',
'thumbnail': 'https://2msoread-ww.amagi.tv/mediasfil... | ```suggestion
video = self._download_json(
f'https://2m.ma/api/watchDetail/{video_id}', video_id)['response']['News']
return {
'id': video_id,
'title': video.get('titre'),
'url': video['url'],
'description': video.get('description'),
... | 'url': 'https://2m.ma/fr/replay/single/635c0aeab4eec832622356da',
'md5': 'ad6af2f5e4d5b2ad2194a84b6e890b4c',
'info_dict': {
'id': '635c0aeab4eec832622356da',
'ext': 'mp4',
'title': 'Journal Amazigh : Vendredi 28 Octobre 2022',
'thumbnail': r're:^h... | @@ -0,0 +1,83 @@
+from .common import InfoExtractor
+from ..utils import (
+ url_or_none,
+ traverse_obj
+)
+
+
+class DeuxMIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)'
+
+ _TESTS = [{
+ 'url': 'https://2m.ma/fr/replay/single/6351... | yt_dlp/extractor/deuxm.py | 26 | Python | 0.786 | suggestion | 391 | 51 | 51 | false | Add extractors for 2m.ma | 5,388 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | CrankDatSouljaBoy |
info = self._download_json(
'https://2m.ma/api/watchDetail/%s' % (video_id),
video_id, "Downloading media JSON") or {}
video = traverse_obj(info, ('response', 'News'))
title = video.get('titre')
thumbnail = url_or_none(video.get('image'))
return {
... | is this permanant? If not, use regex | f'https://2m.ma/api/watchDetail/{video_id}', video_id)['response']['News']
return {
'id': video_id,
'title': video.get('titre'),
'url': video['url'],
'description': video.get('description'),
'thumbnail': url_or_none(video.get('image')),
... | @@ -0,0 +1,83 @@
+from .common import InfoExtractor
+from ..utils import (
+ url_or_none,
+ traverse_obj
+)
+
+
+class DeuxMIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)'
+
+ _TESTS = [{
+ 'url': 'https://2m.ma/fr/replay/single/6351... | yt_dlp/extractor/deuxm.py | 26 | Python | 0.143 | question | 36 | 51 | 47 | false | Add extractors for 2m.ma | 5,388 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | CrankDatSouljaBoy |
from .common import InfoExtractor
from ..utils import url_or_none
class DeuxMIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)'
_TESTS = [{
'url': 'https://2m.ma/fr/replay/single/6351d439b15e1a613b3debe8',
'md5': '7ab69a170493c7b7... | What do u intend by `(?:[A-Za-z0-9_.]{1,24})+`? Did you mean just `[\w.]{1,24}`? | from .common import InfoExtractor
from ..utils import url_or_none
class DeuxMIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>([\w.]{1,24})+)'
_TESTS = [{
'url': 'https://2m.ma/fr/replay/single/6351d439b15e1a613b3debe8',
'md5': '5f761f04c9d686e553b685134d... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import url_or_none
+
+
+class DeuxMIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)' | yt_dlp/extractor/deuxm.py | 6 | Python | 0.357 | question | 80 | 31 | 31 | false | Add extractors for 2m.ma | 5,388 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | CrankDatSouljaBoy |
_TESTS = [{
'url': 'https://2m.ma/fr/news/Kan-Ya-Mkan-d%C3%A9poussi%C3%A8re-l-histoire-du-phare-du-Cap-Beddouza-20221028',
'md5': 'f434e2552b1bd1004fc04737b59c03a9',
'info_dict': {
'id': '635c5d1233b83834e35b282e',
'ext': 'mp4',
'title': 'Kan Ya Mkan d\u0... | ```suggestion
article_name, lang = self._match_valid_url(url).group('id', 'lang')
``` |
_TESTS = [{
'url': 'https://2m.ma/fr/news/Kan-Ya-Mkan-d%C3%A9poussi%C3%A8re-l-histoire-du-phare-du-Cap-Beddouza-20221028',
'md5': '43d5e693a53fa0b71e8a5204c7d4542a',
'info_dict': {
'id': '635c5d1233b83834e35b282e',
'ext': 'mp4',
'title': 'Kan Ya Mkan d\u0... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import url_or_none
+
+
+class DeuxMIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)'
+
+ _TESTS = [{
+ 'url': 'https://2m.ma/fr/replay/single/6351d439b15e1a613b3debe8',
+ ... | yt_dlp/extractor/deuxm.py | 26 | Python | 0.571 | suggestion | 95 | 36 | 35 | false | Add extractors for 2m.ma | 5,388 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | CrankDatSouljaBoy |
}, {
'url': 'https://2m.ma/fr/replay/single/635c0aeab4eec832622356da',
'md5': 'ad6af2f5e4d5b2ad2194a84b6e890b4c',
'info_dict': {
'id': '635c0aeab4eec832622356da',
'ext': 'mp4',
'title': 'Journal Amazigh : Vendredi 28 Octobre 2022',
'thumbnail'... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?2m\.ma/(?P<lang>\w+)/news/(?P<id>[^/#?]+)'
``` | }, {
'url': 'https://2m.ma/fr/replay/single/635c0aeab4eec832622356da',
'md5': 'ad6af2f5e4d5b2ad2194a84b6e890b4c',
'info_dict': {
'id': '635c0aeab4eec832622356da',
'ext': 'mp4',
'title': 'Journal Amazigh : Vendredi 28 Octobre 2022',
'thumbnail'... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import url_or_none
+
+
+class DeuxMIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)'
+
+ _TESTS = [{
+ 'url': 'https://2m.ma/fr/replay/single/6351d439b15e1a613b3debe8',
+ ... | yt_dlp/extractor/deuxm.py | 26 | Python | 0.714 | suggestion | 100 | 51 | 51 | false | Add extractors for 2m.ma | 5,388 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | CrankDatSouljaBoy |
'info_dict': {
'id': '635c5d1233b83834e35b282e',
'ext': 'mp4',
'title': 'Kan Ya Mkan d\u00e9poussi\u00e8re l\u2019histoire du phare du Cap Beddouza',
'description': 'md5:99dcf29b82f1d7f2a4acafed1d487527',
'thumbnail': 'https://2msoread-ww.amagi.tv/medi... | ```suggestion
'id': video['id'],
```
id is mandatory | 'info_dict': {
'id': '635c5d1233b83834e35b282e',
'ext': 'mp4',
'title': 'Kan Ya Mkan d\u00e9poussi\u00e8re l\u2019histoire du phare du Cap Beddouza',
'description': 'md5:99dcf29b82f1d7f2a4acafed1d487527',
'thumbnail': r're:^https?://2msoread-ww.amagi.t... | @@ -0,0 +1,77 @@
+from .common import InfoExtractor
+from ..utils import url_or_none
+
+
+class DeuxMIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?2m\.ma/[^/]+/replay/single/(?P<id>(?:[A-Za-z0-9_.]{1,24})+)'
+
+ _TESTS = [{
+ 'url': 'https://2m.ma/fr/replay/single/6351d439b15e1a613b3debe8',
+ ... | yt_dlp/extractor/deuxm.py | 26 | Python | 0.571 | suggestion | 67 | 32 | 31 | false | Add extractors for 2m.ma | 5,388 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | CrankDatSouljaBoy |
return 'png'
elif content_type == 'image/jpeg':
return 'jpg'
return 'bin'
formats = []
thumbnails = []
for a in data['assets']:
aurl = a.get('url')
if not aurl:
continue
astat... | ```suggestion
aext = a.get('ext') or get_real_ext(aurl)
``` | title = data['name']
formats = []
thumbnails = []
for a in data['assets']:
aurl = a.get('url')
if not aurl:
continue
astatus = a.get('status')
atype = a.get('type')
if (astatus is not None and astatus != 2) or a... | @@ -51,13 +67,15 @@ def _extract_media(self, embed_config):
continue
elif atype in ('still', 'still_image'):
thumbnails.append({
- 'url': aurl,
+ 'url': aurl.replace('.bin', f'.{get_real_ext(aurl)}'),
'width': int_... | yt_dlp/extractor/wistia.py | 26 | Python | 0.571 | suggestion | 77 | 51 | 51 | false | [extractor/wistia] Improve extension detection | 5,415 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
error = traverse_obj(embed_config, 'error')
if error:
raise ExtractorError(
f'Error while getting the playlist: {error}', expected=True)
return embed_config
def _extract_media(self, embed_config):
data = embed_config['media']
video_id = data['has... | move outside closure imo. It may even be moved o common | })
error = traverse_obj(embed_config, 'error')
if error:
raise ExtractorError(
f'Error while getting the playlist: {error}', expected=True)
return embed_config
def _get_real_ext(self, url):
ext = determine_ext(url, default_ext='bin')
... | @@ -39,6 +40,21 @@ def _extract_media(self, embed_config):
video_id = data['hashedId']
title = data['name']
+ def get_real_ext(url):
+ res = self._request_webpage(HEADRequest(url), None, note=False, errnote=False)
+ if res:
+ meta_ext = res.headers.get('x-... | yt_dlp/extractor/wistia.py | 26 | Python | 0.286 | suggestion | 55 | 51 | 51 | false | [extractor/wistia] Improve extension detection | 5,415 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
class WistiaBaseIE(InfoExtractor):
_VALID_ID_REGEX = r'(?P<id>[a-z0-9]{10})'
_VALID_URL_BASE = r'https?://(?:\w+\.)?wistia\.(?:net|com)/(?:embed/)?'
_EMBED_BASE_URL = 'http://fast.wistia.net/embed/'
def _download_embed_config(self, config_type, config_id, referer):
base_url = self._EMBED_BASE_U... | note=errnote=False creates a complete lack of feedback. I recommend keeping a note
Also, we need `fatal=False` |
class WistiaBaseIE(InfoExtractor):
_VALID_ID_REGEX = r'(?P<id>[a-z0-9]{10})'
_VALID_URL_BASE = r'https?://(?:\w+\.)?wistia\.(?:net|com)/(?:embed/)?'
_EMBED_BASE_URL = 'http://fast.wistia.net/embed/'
def _download_embed_config(self, config_type, config_id, referer):
base_url = self._EMBED_BASE... | @@ -39,6 +40,21 @@ def _extract_media(self, embed_config):
video_id = data['hashedId']
title = data['name']
+ def get_real_ext(url):
+ res = self._request_webpage(HEADRequest(url), None, note=False, errnote=False) | yt_dlp/extractor/wistia.py | 26 | Python | 0.5 | suggestion | 113 | 51 | 51 | false | [extractor/wistia] Improve extension detection | 5,415 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
'x-ms-wmv': 'wmv',
'x-msvideo': 'avi',
# application (streaming playlists)
'dash+xml': 'mpd',
'f4m+xml': 'f4m',
'hds+xml': 'f4m',
'vnd.apple.mpegurl': 'm3u8',
'vnd.ms-sstr+xml': 'ism',
'x-mpegurl': 'm3u8',
# audio
('audio', 'mp4')... | Suggestion
```diff
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index eee257f16..b01f22370 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -3467,13 +3467,13 @@ def mimetype2ext(mt, default=NO_DEFAULT):
'x-mpegurl': 'm3u8',
# audio
- ('audio', 'mp4'): 'm4a',
+ 'audio/m... | except ValueError:
return not assume_new
def ytdl_is_updateable():
""" Returns if yt-dlp can be updated with -U """
from .update import is_non_updateable
return not is_non_updateable()
def args_to_str(args):
# Get a short string representation for a subprocess command
return ' '.jo... | @@ -3433,68 +3433,106 @@ def error_to_str(err):
return f'{type(err).__name__}: {err}'
-def mimetype2ext(mt):
- if mt is None:
+def mimetype2ext(mt, default=NO_DEFAULT): | yt_dlp/utils.py | 26 | Python | 1 | suggestion | 1,957 | 51 | 51 | false | [extractor/wistia] Improve extension detection | 5,415 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bashonly |
for data_media in re.findall(r'<[^>]+data-media="?({[^>]+})"?', webpage):
media = self._parse_json(data_media, playlist_id, transform_source=unescapeHTML, fatal=False)
if not media.get('file') or not media.get('desc'):
continue
media_url = self._proto_relativ... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?polskieradio(?:24)?\.pl/\d+/\d+/[Aa]rtykul/(?P<id>\d+)'
``` |
for data_media in re.findall(r'<[^>]+data-media="?({[^>]+})"?', webpage):
media = self._parse_json(data_media, playlist_id, transform_source=unescapeHTML, fatal=False)
if not media.get('file') or not media.get('desc'):
continue
media_url = self._proto_relativ... | @@ -48,28 +50,11 @@ def _extract_webpage_player_entries(self, webpage, playlist_id, base_data):
yield entry
-class PolskieRadioIE(PolskieRadioBaseExtractor):
- _VALID_URL = r'https?://(?:www\.)?polskieradio(?:24)?\.pl/\d+/\d+/Artykul/(?P<id>[0-9]+)'
- _TESTS = [{ # Old-style single broadcast.
- ... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.714 | suggestion | 113 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'timestamp': 1592654400,
'upload_date': '20200620',
'duration': 1430,
'thumbnail': r're:^https?://static\.prsa\.pl/images/.*\.jpg$'
},
}],
}, {
# PR4 audition - other frontend
'url': 'https://www.polskieradio.pl/10/6... | ```suggestion
if PolskieRadioIE.suitable(urlh.url):
return self.url_result(urlh.url, PolskieRadioIE, playlist_id)
``` | 'timestamp': 1592654400,
'upload_date': '20200620',
'duration': 1430,
'thumbnail': r're:^https?://static\.prsa\.pl/images/.*\.jpg$'
},
}],
}, {
# PR4 audition - other frontend
'url': 'https://www.polskieradio.pl/10/6... | @@ -114,7 +89,10 @@ class PolskieRadioIE(PolskieRadioBaseExtractor):
def _real_extract(self, url):
playlist_id = self._match_id(url)
- webpage = self._download_webpage(url, playlist_id)
+ webpage, urlh = self._download_webpage_handle(url, playlist_id)
+ # follow redirect if old url ... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.714 | suggestion | 140 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
if not content:
return {
'id': playlist_id,
'url': self._proto_relative_url(
self._search_regex(
r"source:\s*'(//static\.prsa\.pl/[^']+)'",
webpage, 'audition record url')),
'title': ... | ```suggestion
_VALID_URL = r'https?://(?:[^/]+\.)?polskieradio(?:24)?\.pl/artykul/(?P<id>\d+)'
``` | if not content:
return {
'id': playlist_id,
'url': self._proto_relative_url(
self._search_regex(
r"source:\s*'(//static\.prsa\.pl/[^']+)'",
webpage, 'audition record url')),
'title': t... | @@ -153,23 +131,168 @@ def _real_extract(self, url):
return self.playlist_result(entries, playlist_id, title, description)
-class PolskieRadioCategoryIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
+class PolskieRadioIE(InfoExtractor):
+ # new next.... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.714 | suggestion | 104 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
for page_num in itertools.count(2):
for a_entry, entry_id in re.findall(
r'(?s)<article[^>]+>.*?(<a[^>]+href=["\']/\d+/\d+/Artykul/(\d+)[^>]+>).*?</article>',
content):
entry = extract_attributes(a_entry)
href = entry.get('href'... | ```suggestion
webpage, urlh = self._download_webpage_handle(url, category_id)
if PolskieRadioAuditionIE.suitable(urlh.url):
return self.url_result(urlh.url, PolskieRadioAuditionIE, category_id)
``` | compat_urlparse.urljoin(url, href), PolskieRadioLegacyIE,
entry_id, entry.get('title'))
mobj = re.search(
r'<div[^>]+class=["\']next["\'][^>]*>\s*<a[^>]+href=(["\'])(?P<url>(?:(?!\1).)+)\1',
content)
if not mobj:
... | @@ -222,7 +342,10 @@ def _entries(self, url, page, category_id):
def _real_extract(self, url):
category_id = self._match_id(url)
- webpage = self._download_webpage(url, category_id)
+ webpage, urlh = self._download_webpage_handle(url, category_id)
+ # follow redirect if old url was ... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.929 | suggestion | 229 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'categoryId': playlist_id,
'PageSize': 9,
'skip': i,
'format': 400,
}, playlist_id, f'Downloading article list (page #{i})')
for article in page['data']:
yield {
... | ```suggestion
page_props = traverse_obj(
self._search_nextjs_data(self._download_webpage(url, playlist_id), playlist_id),
('props', 'pageProps', ('data', None)))
``` | for article in page['data']:
yield {
'_type': 'url_transparent',
'ie_key': PolskieRadioIE.ie_key(),
'id': str(article['id']),
'url': article['url'],
'title': article.get('shortTitle'),
... | @@ -153,23 +131,168 @@ def _real_extract(self, url):
return self.playlist_result(entries, playlist_id, title, description)
-class PolskieRadioCategoryIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
+class PolskieRadioIE(InfoExtractor):
+ # new next.... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.786 | suggestion | 201 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
return self._download_json(
f'https://lp3test.polskieradio.pl/{path}', video_id, note,
query=query, headers={'x-api-key': '9bf6c5a2-a7d0-4980-9ed7-a3f7291f2a81'})
def _entries(self, playlist_id, has_episodes, has_articles):
if has_episodes:
not_empty = True
... | ```suggestion
for i in itertools.count(1) if has_episodes else []:
page = self._call_lp3(
'AudioArticle/GetListByCategoryId', {
'categoryId': playlist_id,
'PageSize': 10,
'skip': i,
'format': 400,
... | f'https://lp3test.polskieradio.pl/{path}', video_id, note,
query=query, headers={'x-api-key': '9bf6c5a2-a7d0-4980-9ed7-a3f7291f2a81'})
def _entries(self, playlist_id, has_episodes, has_articles):
for i in itertools.count(1) if has_episodes else []:
page = self._call_lp3(... | @@ -153,23 +131,168 @@ def _real_extract(self, url):
return self.playlist_result(entries, playlist_id, title, description)
-class PolskieRadioCategoryIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
+class PolskieRadioIE(InfoExtractor):
+ # new next.... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.786 | suggestion | 839 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'_type': 'url_transparent',
'id': str(article['id']),
'title': article['shortTitle'],
'url': article['url'],
'ie_key': PolskieRadioIE,
'description': traverse_obj(article, ('de... | ```suggestion
has_episodes = bool(traverse_obj(page_props, 'episodes', 'audios'))
has_articles = bool(traverse_obj(page_props, 'articles'))
return self.playlist_result(
self._entries(playlist_id, has_episodes, has_articles),
playlist_id, title=traverse_obj(page_pro... | 'title': article.get('shortTitle'),
'description': traverse_obj(article, ('description', 'lead')),
'timestamp': parse_iso8601(article.get('datePublic')),
}
def _real_extract(self, url):
playlist_id = self._match_id(url)
pa... | @@ -153,23 +130,166 @@ def _real_extract(self, url):
return self.playlist_result(entries, playlist_id, title, description)
-class PolskieRadioCategoryIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
+class PolskieRadioIE(InfoExtractor):
+ # new next.... | yt_dlp/extractor/polskieradio.py | 26 | Python | 0.786 | suggestion | 508 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | selfisekai |
'title': episode['title'],
'url': episode['file'],
'duration': int_or_none(episode.get('duration')),
'timestamp': parse_iso8601(episode.get('datePublic')),
}
not_empty = len(page['data']) ... | hm, this doesn't seem to work? works with `.ie_key()`
```
ERROR: No suitable extractor (<class 'yt_dlp.extractor.polskieradio.PolskieRadioIE'>) found for URL https://jedynka.polskieradio.pl/artykul/1587425,Historia-zywa-nowy-cykl-w-radiowej-Jedynce
``` | 'title': episode.get('title'),
'duration': int_or_none(episode.get('duration')),
'timestamp': parse_iso8601(episode.get('datePublic')),
}
for i in itertools.count(1) if has_articles else []:
page = self._call_lp3(
... | @@ -153,23 +130,166 @@ def _real_extract(self, url):
return self.playlist_result(entries, playlist_id, title, description)
-class PolskieRadioCategoryIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+(?:,[^/]+)?/(?P<id>\d+)'
+class PolskieRadioIE(InfoExtractor):
+ # new next.... | yt_dlp/extractor/polskieradio.py | 26 | Python | 1 | refactor | 255 | 51 | 51 | false | [polskieradio] adapt to next.js redesigns | 5,416 | yt-dlp/yt-dlp | 132,642 | Python | selfisekai | selfisekai |
from ..compat import compat_str, compat_urllib_parse_unquote
from ..utils import (
ExtractorError,
HEADRequest,
OnDemandPagedList,
UnsupportedError,
determine_ext,
int_or_none,
mimetype2ext,
parse_qs,
try_get,
urljoin,
)
class LBRYBaseIE(InfoExtractor):
_BASE_URL_REGEX = r'... | ```suggestion
token = try_get(self._get_cookies('https://odysee.com'), lambda x: x['auth_token'].value)
if token:
headers['x-lbry-auth-token'] = token
``` | from ..compat import compat_str, compat_urllib_parse_unquote
from ..utils import (
ExtractorError,
HEADRequest,
OnDemandPagedList,
UnsupportedError,
determine_ext,
int_or_none,
mimetype2ext,
parse_qs,
try_get,
urljoin,
)
class LBRYBaseIE(InfoExtractor):
_BASE_URL_REGEX = r'... | @@ -24,10 +24,14 @@ class LBRYBaseIE(InfoExtractor):
_SUPPORTED_STREAM_TYPES = ['video', 'audio']
def _call_api_proxy(self, method, display_id, params, resource):
+ headers = {'Content-Type': 'application/json-rpc'}
+ cookies = self._get_cookies('https://odysee.com')
+ if 'auth_token' i... | yt_dlp/extractor/lbry.py | 26 | Python | 0.714 | security | 186 | 51 | 51 | false | [lbry] pass authentication token from cookies | 5,435 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | flashdagger |
'only_matching': True,
}, {
'url': 'https://lbry.tv/@lacajadepandora:a/TRUMP-EST%C3%81-BIEN-PUESTO-con-Pilar-Baselga,-Carlos-Senra,-Luis-Palacios-(720p_30fps_H264-192kbit_AAC):1',
'only_matching': True,
}, {
'url': 'lbry://@lbry#3f/odysee#7',
'only_matching': True,
}]... | ```suggestion
HEADRequest(streaming_url), display_id, headers=headers,
``` | 'only_matching': True,
}, {
'url': 'https://lbry.tv/@lacajadepandora:a/TRUMP-EST%C3%81-BIEN-PUESTO-con-Pilar-Baselga,-Carlos-Senra,-Luis-Palacios-(720p_30fps_H264-192kbit_AAC):1',
'only_matching': True,
}, {
'url': 'lbry://@lbry#3f/odysee#7',
'only_matching': True,
}]... | @@ -197,23 +224,26 @@ def _real_extract(self, url):
display_id = compat_urllib_parse_unquote(display_id)
uri = 'lbry://' + display_id
result = self._resolve_url(uri, display_id, 'stream')
+ headers = {'Referer': 'https://odysee.com/'}
if result['value'].get('stream_type') in s... | yt_dlp/extractor/lbry.py | 26 | Python | 0.571 | suggestion | 92 | 51 | 51 | false | [lbry] pass authentication token from cookies | 5,435 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | flashdagger |
if display_id.startswith('$/'):
display_id = display_id.split('/', 2)[-1].replace('/', ':')
else:
display_id = display_id.replace(':', '#')
display_id = compat_urllib_parse_unquote(display_id)
uri = 'lbry://' + display_id
result = self._resolve_url(uri, di... | ```suggestion
streaming_url = final_url = live_data.get('VideoURL')
# Upcoming videos may still give VideoURL
if not live_data.get('Live'):
streaming_url = final_url = None
self.raise_no_formats('This stream is not live', True, claim_id)
``` | if display_id.startswith('$/'):
display_id = display_id.split('/', 2)[-1].replace('/', ':')
else:
display_id = display_id.replace(':', '#')
display_id = compat_urllib_parse_unquote(display_id)
uri = 'lbry://' + display_id
result = self._resolve_url(uri, di... | @@ -197,23 +224,25 @@ def _real_extract(self, url):
display_id = compat_urllib_parse_unquote(display_id)
uri = 'lbry://' + display_id
result = self._resolve_url(uri, display_id, 'stream')
+ headers = {'Referer': 'https://odysee.com/'}
if result['value'].get('stream_type') in s... | yt_dlp/extractor/lbry.py | 26 | Python | 0.786 | suggestion | 315 | 51 | 51 | false | [lbry] pass authentication token from cookies | 5,435 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | flashdagger |
'uploader_id': 'UC0intLFzLaudFG-xAvUEO-A',
'channel_id': 'UC0intLFzLaudFG-xAvUEO-A',
'uploader_url': 'https://www.youtube.com/channel/UC0intLFzLaudFG-xAvUEO-A',
'channel': 'Not Just Bikes',
},
'playlist_mincount': 10,
}, {
# Streams/live tab
... | There is no standard way to test this. If you want, a test can be added to `test_youtube_lists` | },
'playlist_mincount': 10,
}, {
# Streams tab
'url': 'https://www.youtube.com/channel/UC3eYAvjCVwNHgkaGbXX3sig/streams',
'info_dict': {
'id': 'UC3eYAvjCVwNHgkaGbXX3sig',
'title': '中村悠一 - Live',
'tags': 'count:7',
'channel_id': ... | @@ -5705,6 +5706,120 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
},
'playlist_mincount': 50,
+ }, {
+ # Channel with a real live tab (not to be mistaken with streams tab)
+ # Do not treat like it should redirect to live stream
+ 'url': 'https://www.youtube.com/channel... | yt_dlp/extractor/youtube.py | 26 | Python | 0.357 | suggestion | 95 | 51 | 51 | false | [extractor/youtube] Improve channel tab handling | 5,439 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | coletdjnz |
'caller': 'sky',
'id': video_id,
'token': token
}, headers=self.geo_verification_headers())
return self._parse_video(video, video_id)
class SkyItVideoIE(SkyItPlayerIE):
IE_NAME = 'video.sky.it'
_VALID_URL = r'https?://(?:masterchef|video|xfac... | ```suggestion
'params': {'skip_download': 'm3u8'},
``` | 'caller': 'sky',
'id': video_id,
'token': token
}, headers=self.geo_verification_headers())
return self._parse_video(video, video_id)
class SkyItVideoIE(SkyItPlayerIE):
IE_NAME = 'video.sky.it'
_VALID_URL = r'https?://(?:masterchef|video|xfac... | @@ -80,14 +75,20 @@ class SkyItVideoIE(SkyItPlayerIE):
_VALID_URL = r'https?://(?:masterchef|video|xfactor)\.sky\.it(?:/[^/]+)*/video/[0-9a-z-]+-(?P<id>\d+)'
_TESTS = [{
'url': 'https://video.sky.it/news/mondo/video/uomo-ucciso-da-uno-squalo-in-australia-631227',
- 'md5': 'fe5c91e59a84a3437eaa... | yt_dlp/extractor/skyit.py | 26 | Python | 0.571 | suggestion | 64 | 51 | 51 | false | [extractor/skyit] Various fixes and cleanups | 5,442 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | nixxo |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.