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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transform_source=lambda s: js_to_json(re.sub(r'ivw:[^},]+', '', s)))
vdata = traverse_obj(player_data, ('setup', 'source'))
formats = []
if vdata.get('progressive'):
formats.append({
'format_id': 'mp4-0',
'url': vdata['progressive'],
... | ```suggestion
'thumbnail': ('poster', {url_or_none}),
``` | 'timestamp': 1699688294,
'upload_date': '20231111',
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
info = self._search_json(
r'article:', webpage, 'info', video_id, transform... | @@ -33,41 +32,39 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- info = self._parse_json(self._search_regex(
- r'(?s)ntv\.pageInfo\.article\s*=\s*(\{.*?\});', webpage, 'info'),
- video_id, transform_source... | yt_dlp/extractor/ntvde.py | 26 | Python | 0.571 | suggestion | 75 | 31 | 44 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | 1100101 |
import re
from .common import InfoExtractor
from ..utils import (
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class NTVDeIE(InfoExtractor):
IE_NAME = 'n-tv.de'
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/videos/[^/?#]+/[^/?#]+-article(?P<id>.+)\.ht... | ```suggestion
from ..utils.traversal import traverse_obj
``` | import re
from .common import InfoExtractor
from ..utils import (
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class NTVDeIE(InfoExtractor):
IE_NAME = 'n-tv.de'
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/(?:videos|magazine)/[^/?#]+/[^/?#]+-article(?... | @@ -1,29 +1,30 @@
import re
from .common import InfoExtractor
-from ..compat import compat_urlparse
from ..utils import (
int_or_none,
js_to_json,
- parse_duration,
+ url_or_none,
)
+from ..utils.traversal import traverse_obj | yt_dlp/extractor/ntvde.py | 10 | Python | 0.571 | suggestion | 62 | 35 | 35 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 1100101 |
class NTVDeIE(InfoExtractor):
IE_NAME = 'n-tv.de'
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/videos/[^/?#]+/[^/?#]+-article(?P<id>.+)\.html'
_TESTS = [{
'url': 'http://www.n-tv.de/mediathek/videos/panorama/Schnee-und-Glaette-fuehren-zu-zahlreichen-Unfaellen-und-Staus-article14438086.html'... | `_search_json` already appends `\s*` to the start pattern
```suggestion
info = self._search_json(
r'article:', webpage, 'info', video_id, transform_source=js_to_json)
``` | IE_NAME = 'n-tv.de'
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/(?:videos|magazine)/[^/?#]+/[^/?#]+-article(?P<id>[^/?#]+)\.html'
_TESTS = [{
'url': 'http://www.n-tv.de/mediathek/videos/panorama/Schnee-und-Glaette-fuehren-zu-zahlreichen-Unfaellen-und-Staus-article14438086.html',
'm... | @@ -33,41 +34,38 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- info = self._parse_json(self._search_regex(
- r'(?s)ntv\.pageInfo\.article\s*=\s*(\{.*?\});', webpage, 'info'),
- video_id, transform_source... | yt_dlp/extractor/ntvde.py | 26 | Python | 0.714 | suggestion | 194 | 51 | 51 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 1100101 |
'title': 'Schnee und Glätte führen zu zahlreichen Unfällen und Staus',
'alt_title': 'Winterchaos auf deutschen Straßen',
'description': 'Schnee und Glätte sorgen deutschlandweit für einen chaotischen Start in die Woche: Auf den Straßen kommt es zu kilometerlangen Staus und Dutzenden ... | Core code will automatically add a `-0`, `-1`, etc suffix when there are multiple formats with the same format_id, if that's what was trying to be emulated here. So why not just use `mp4`?
```suggestion
'format_id': 'mp4',
``` | 'alt_title': 'Winterchaos auf deutschen Straßen',
'description': 'Schnee und Glätte sorgen deutschlandweit für einen chaotischen Start in die Woche: Auf den Straßen kommt es zu kilometerlangen Staus und Dutzenden Glätteunfällen. In Düsseldorf und München wirbelt der Schnee zudem den Flugplan dur... | @@ -33,41 +34,38 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- info = self._parse_json(self._search_regex(
- r'(?s)ntv\.pageInfo\.article\s*=\s*(\{.*?\});', webpage, 'info'),
- video_id, transform_source... | yt_dlp/extractor/ntvde.py | 26 | Python | 0.857 | suggestion | 245 | 49 | 51 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 1100101 |
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
info = self._search_json(
r'article:\s*', webpage, 'info', video_id, transform_source=js_to_json)
player_data = self._search_json(
r'\$\(\s*"... | ```suggestion
formats.extend(self._extract_mpd_formats(vdata['dash'], video_id, fatal=False, mpd_id='dash'))
``` | 'url': 'https://www.n-tv.de/mediathek/magazine/auslandsreport/Juedische-Siedler-wollten-Rache-die-wollten-nur-toeten-article24523089.html',
'md5': 'c5c6014c014ccc3359470e1d34472bfd',
'info_dict': {
'id': '24523089',
'ext': 'mp4',
'thumbnail': r're:^https?://.*... | @@ -33,41 +34,38 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- info = self._parse_json(self._search_regex(
- r'(?s)ntv\.pageInfo\.article\s*=\s*(\{.*?\});', webpage, 'info'),
- video_id, transform_source... | yt_dlp/extractor/ntvde.py | 26 | Python | 0.786 | refactor | 126 | 42 | 51 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 1100101 |
'md5': '6bcf2a6638cb83f45d5561659a1cb498',
'info_dict': {
'id': '14438086',
'ext': 'mp4',
'thumbnail': r're:^https?://.*\.jpg$',
'title': 'Schnee und Glätte führen zu zahlreichen Unfällen und Staus',
'alt_title': 'Winterchaos auf deutschen Stra... | If we really want `vdata`-related code to be non-fatal, then we'd want this:
```suggestion
vdata = traverse_obj(self._search_json(
r'\$\(\s*"#playerwrapper"\s*\)\s*\.data\(\s*"player",',
webpage, 'player data', video_id, default={},
transform_source=lambda s: js_to_json(... | 'info_dict': {
'id': '14438086',
'ext': 'mp4',
'thumbnail': r're:^https?://.*\.jpg$',
'title': 'Schnee und Glätte führen zu zahlreichen Unfällen und Staus',
'alt_title': 'Winterchaos auf deutschen Straßen',
'description': 'Schnee und Glätte... | @@ -33,41 +34,38 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- info = self._parse_json(self._search_regex(
- r'(?s)ntv\.pageInfo\.article\s*=\s*(\{.*?\});', webpage, 'info'),
- video_id, transform_source... | yt_dlp/extractor/ntvde.py | 26 | Python | 0.786 | suggestion | 792 | 51 | 51 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 1100101 |
import re
from .common import InfoExtractor
from ..utils import (
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class NTVDeIE(InfoExtractor):
IE_NAME = 'n-tv.de'
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/videos/[^/?#]+/[^/?#]+-article(?P<id>.+)\.ht... | I know the PR didn't touch this code, but I need to fix
```suggestion
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/videos/[^/?#]+/[^/?#]+-article(?P<id>[^/?#]+)\.html'
``` | import re
from .common import InfoExtractor
from ..utils import (
int_or_none,
js_to_json,
url_or_none,
)
from ..utils.traversal import traverse_obj
class NTVDeIE(InfoExtractor):
IE_NAME = 'n-tv.de'
_VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/(?:videos|magazine)/[^/?#]+/[^/?#]+-article(?... | @@ -1,29 +1,30 @@
import re
from .common import InfoExtractor
-from ..compat import compat_urlparse
from ..utils import (
int_or_none,
js_to_json,
- parse_duration,
+ url_or_none,
)
+from ..utils.traversal import traverse_obj
+
class NTVDeIE(InfoExtractor):
IE_NAME = 'n-tv.de'
_VALI... | yt_dlp/extractor/ntvde.py | 15 | Python | 0.714 | suggestion | 186 | 40 | 40 | false | Fix n-tv.de extractor, website format has changed | 8,414 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 1100101 |
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
parse_duration,
traverse_obj,
unified_timestamp,
url_or_none,
)
import re
from urllib.parse import urlparse
class RTVSLOIE(InfoExtractor):
IE_NAME = 'rtvslo.si'
_VALID_URL = r'''(?x)
https?://(... | I would move this to a separate extractor instead of having a single extractor deal with both individual videos and playlists of videos. | import re
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
parse_duration,
traverse_obj,
unified_timestamp,
url_or_none,
urljoin,
)
class RTVSLOIE(InfoExtractor):
IE_NAME = 'rtvslo.si'
_VALID_URL = r'''(?x)
https?://(?:
(?:36... | @@ -7,14 +7,17 @@
unified_timestamp,
url_or_none,
)
+import re
+from urllib.parse import urlparse
class RTVSLOIE(InfoExtractor):
IE_NAME = 'rtvslo.si'
_VALID_URL = r'''(?x)
https?://(?:
(?:365|4d)\.rtvslo.si/arhiv/[^/?#&;]+|
- (?:www\.)?rtvslo\.si/rtv365/arhiv
... | yt_dlp/extractor/rtvslo.py | 20 | Python | 0.429 | refactor | 136 | 45 | 45 | false | [ie/rtvslo.si:show] Add extractor | 8,418 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | JSubelj |
self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
if any('dummy_720p.mp4' in x.get('manifest_url', '') for x in formats) and meta.get('stub') == 'error':
raise ExtractorError(f'{self.IE_NAME} said: Clip not available', expected=True)
return {
... | ```suggestion
title = self._html_extract_title(html, v_id)
``` | 'thumbnails': thumbs,
'description': meta.get('description'),
'timestamp': unified_timestamp(traverse_obj(meta, 'broadcastDate', ('broadcastDates', 0))),
'release_timestamp': unified_timestamp(meta.get('recordingDate')),
'duration': meta.get('duration') or par... | @@ -164,3 +175,28 @@ def _real_extract(self, url):
'series': meta.get('showName'),
'series_id': meta.get('showId'),
}
+
+ def _get_show_urls(self, url, v_id):
+ html = self._download_webpage(url, v_id)
+ all_urls = set(re.findall(r'<a.*href=\"(/arhiv/.+)\".*aria-label... | yt_dlp/extractor/rtvslo.py | 26 | Python | 0.643 | refactor | 72 | 45 | 33 | false | [ie/rtvslo.si:show] Add extractor | 8,418 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | JSubelj |
for mediafile in traverse_obj(media, ('mediaFiles', lambda _, v: url_or_none(v['streams']['hls_sec']))):
formats.extend(self._extract_wowza_formats(
mediafile['streams']['hls_sec'], v_id, skip_protocols=skip_protocols))
if any('intermission.mp4' in x['url'] for x in formats)... | I would keep this code inline in the `_real_extract` function. | 'id': v_id,
'webpage_url': ''.join(traverse_obj(meta, ('canonical', ('domain', 'path')))),
'title': meta.get('title'),
'formats': formats,
'subtitles': subs,
'thumbnails': thumbs,
'description': meta.get('description'),
'tim... | @@ -164,3 +175,28 @@ def _real_extract(self, url):
'series': meta.get('showName'),
'series_id': meta.get('showId'),
}
+
+ def _get_show_urls(self, url, v_id): | yt_dlp/extractor/rtvslo.py | 26 | Python | 0.429 | refactor | 62 | 50 | 38 | false | [ie/rtvslo.si:show] Add extractor | 8,418 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | JSubelj |
'series': meta.get('showName'),
'series_id': meta.get('showId'),
}
def _get_show_urls(self, url, v_id):
html = self._download_webpage(url, v_id)
all_urls = set(re.findall(r'<a.*href=\"(/arhiv/.+)\".*aria-label=.*>', html))
parsed = urlparse(url)
res =... | Don't extract the info for all videos ahead of time
```suggestion
return self.playlist_result(
[self.url_result(url, RTVSLOIE, url_id) for url in urls], url_id, title)
``` | import re
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
parse_duration,
traverse_obj,
unified_timestamp,
url_or_none,
urljoin,
)
class RTVSLOIE(InfoExtractor):
IE_NAME = 'rtvslo.si'
_VALID_URL = r'''(?x)
https?://(?:
(?:36... | @@ -164,3 +175,28 @@ def _real_extract(self, url):
'series': meta.get('showName'),
'series_id': meta.get('showId'),
}
+
+ def _get_show_urls(self, url, v_id):
+ html = self._download_webpage(url, v_id)
+ all_urls = set(re.findall(r'<a.*href=\"(/arhiv/.+)\".*aria-label... | yt_dlp/extractor/rtvslo.py | 26 | Python | 0.857 | refactor | 203 | 29 | 191 | false | [ie/rtvslo.si:show] Add extractor | 8,418 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | JSubelj |
return {
'id': v_id,
'webpage_url': ''.join(traverse_obj(meta, ('canonical', ('domain', 'path')))),
'title': meta.get('title'),
'formats': formats,
'subtitles': subs,
'thumbnails': thumbs,
'description': meta.get('description')... | not needed
```suggestion
``` | return {
'id': v_id,
'webpage_url': ''.join(traverse_obj(meta, ('canonical', ('domain', 'path')))),
'title': meta.get('title'),
'formats': formats,
'subtitles': subs,
'thumbnails': thumbs,
'description': meta.get('description'),... | @@ -164,3 +166,28 @@ def _real_extract(self, url):
'series': meta.get('showName'),
'series_id': meta.get('showId'),
}
+
+
+class RTVSLOShowIE(InfoExtractor):
+ IE_NAME = 'rtvslo.si:show'
+ _VALID_URL = r'https?://(?:365|4d)\.rtvslo.si/oddaja/[^/?#&]+/(?P<id>\d+)'
+
+ _TESTS =... | yt_dlp/extractor/rtvslo.py | 26 | Python | 0.429 | suggestion | 30 | 42 | 39 | false | [ie/rtvslo.si:show] Add extractor | 8,418 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JSubelj |
}
class RTVSLOShowIE(InfoExtractor):
IE_NAME = 'rtvslo.si:show'
_VALID_URL = r'https?://(?:365|4d)\.rtvslo.si/oddaja/[^/?#&]+/(?P<id>\d+)'
_TESTS = [{
'url': 'https://365.rtvslo.si/oddaja/ekipa-bled/173250997',
'info_dict': {
'_type': 'playlist',
'id': '173... | - `playlist_from_matches()` already uses `orderedSet`
- `self._html_extract_title(webpage, playlist_id)` isn't correct, don't pass a 2nd arg
```suggestion
webpage = self._download_webpage(url, playlist_id)
return self.playlist_from_matches(
re.findall(r'<a [^>]*\bhref="(/arhiv/[^"]+... | import re
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
parse_duration,
traverse_obj,
unified_timestamp,
url_or_none,
urljoin,
)
class RTVSLOIE(InfoExtractor):
IE_NAME = 'rtvslo.si'
_VALID_URL = r'''(?x)
https?://(?:
(?:36... | @@ -164,3 +166,28 @@ def _real_extract(self, url):
'series': meta.get('showName'),
'series_id': meta.get('showId'),
}
+
+
+class RTVSLOShowIE(InfoExtractor):
+ IE_NAME = 'rtvslo.si:show'
+ _VALID_URL = r'https?://(?:365|4d)\.rtvslo.si/oddaja/[^/?#&]+/(?P<id>\d+)'
+
+ _TESTS =... | yt_dlp/extractor/rtvslo.py | 26 | Python | 0.857 | refactor | 480 | 27 | 191 | false | [ie/rtvslo.si:show] Add extractor | 8,418 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JSubelj |
'ext': 'mp4',
'title': 'Извержение вулкана из спичек: зрелищный опыт',
'description': 'md5:053ad3c61b5596d510c9a199dc8ee633',
'thumbnail': 're:^https://avatars.dzeninfra.ru/',
'uploader': 'TechInsider',
'upload_date': '20210123',
'times... | ```suggestion
r'"data"\s*[=:]', webpage, 'metadata', video_id, contains_pattern=r'{["\']_*serverState_*video.+}')
```
Just in case. Same below | 'ext': 'mp4',
'title': 'Извержение вулкана из спичек: зрелищный опыт',
'description': 'md5:053ad3c61b5596d510c9a199dc8ee633',
'thumbnail': 're:^https://avatars.dzeninfra.ru/',
'uploader': 'TechInsider',
'upload_date': '20210123',
'times... | @@ -258,7 +258,7 @@ def _real_extract(self, url):
video_id = self._match_id(redirect)
webpage = self._download_webpage(redirect, video_id, note='Redirecting')
data_json = self._search_json(
- r'data\s*=', webpage, 'metadata', video_id, contains_pattern=r'{["\']_*serverState... | yt_dlp/extractor/yandexvideo.py | 26 | Python | 0.714 | suggestion | 159 | 51 | 51 | false | [ZenYandex] Fix downloader | 8,454 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | starius |
import random
import itertools
import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoEx... | can assign headers dict to a variable here as it will be used in multiple requests
```suggestion
headers = {'Referer': visitor_url}
chrome_ver = self._search_regex(
``` | import json
import random
import itertools
import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboB... | @@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex( | yt_dlp/extractor/weibo.py | 24 | Python | 0.786 | suggestion | 188 | 49 | 49 | false | [extractor/weibo] Fix visitor request | 8,463 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
import random
import itertools
import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoEx... | the `User-Agent` key will always exist in `params['http_headers']`
```suggestion
r'Chrome/(\d+)', self.get_param('http_headers')['User-Agent'], 'user agent version', default='90')
``` | import json
import random
import itertools
import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboB... | @@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex(
+ r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str}))... | yt_dlp/extractor/weibo.py | 24 | Python | 0.786 | suggestion | 198 | 49 | 49 | false | [extractor/weibo] Fix visitor request | 8,463 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, vis... | ```suggestion
headers=headers, transform_source=strip_jsonp,
``` | import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoExtractor):
def _update_visit... | @@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex(
+ r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str}))... | yt_dlp/extractor/weibo.py | 26 | Python | 0.571 | suggestion | 78 | 51 | 51 | false | [extractor/weibo] Fix visitor request | 8,463 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, visitor_url, video_id):
chrome_ver = self._search_regex(
... | IMO this will be easier to maintain and read
(import json)
```suggestion
'fp': json.dumps({
'os': '1',
'browser': f'Chrome{chrome_ver},0,0,0',
'fonts': 'undefined',
'screenInfo': '1920*1080*24',
'... | int_or_none,
make_archive_id,
mimetype2ext,
parse_resolution,
str_or_none,
strip_jsonp,
traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, visitor_url, video_id):
headers = {'Referer': visito... | @@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex(
+ r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str}))... | yt_dlp/extractor/weibo.py | 26 | Python | 0.929 | suggestion | 391 | 51 | 51 | false | [extractor/weibo] Fix visitor request | 8,463 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, visitor_url, video_id):
chrome_ver = self._search_regex(
r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str})),
'user ... | ```suggestion
headers=headers, query={
``` | traverse_obj,
url_or_none,
urlencode_postdata,
urljoin,
)
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, visitor_url, video_id):
headers = {'Referer': visitor_url}
chrome_ver = self._search_regex(
r'Chrome/(\d+)', self.get_param('http_headers')['Use... | @@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex(
+ r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str}))... | yt_dlp/extractor/weibo.py | 26 | Python | 0.571 | suggestion | 56 | 51 | 51 | false | [extractor/weibo] Fix visitor request | 8,463 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, visitor_url, video_id):
chrome_ver = self._search_regex(
r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str})),
'user agent version', default='90')
visitor_data = sel... | can use f-string here
```suggestion
'c': f'{visitor_data.get("confidence", 100):03d}',
``` | )
class WeiboBaseIE(InfoExtractor):
def _update_visitor_cookies(self, visitor_url, video_id):
headers = {'Referer': visitor_url}
chrome_ver = self._search_regex(
r'Chrome/(\d+)', self.get_param('http_headers')['User-Agent'], 'user agent version', default='90')
visitor_data = se... | @@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex(
+ r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str}))... | yt_dlp/extractor/weibo.py | 26 | Python | 0.786 | suggestion | 109 | 51 | 51 | false | [extractor/weibo] Fix visitor request | 8,463 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | c-basalt |
from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_iso8601,
traverse_obj,
unescapeHTML,
)
class PeriscopeBaseIE(InfoExtractor):
_M3U8_HEADERS = {
'Referer': 'https://www.periscope.tv/'
}
def _call_api(self, method, query, item_id):
return self._down... | ```suggestion
unescapeHTML,
)
from ..utils.traversal import traverse_obj
``` | from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_iso8601,
unescapeHTML,
)
from ..utils.traversal import traverse_obj
class PeriscopeBaseIE(InfoExtractor):
_M3U8_HEADERS = {
'Referer': 'https://www.periscope.tv/'
}
def _call_api(self, method, query, item_id):
... | @@ -2,6 +2,7 @@
from ..utils import (
int_or_none,
parse_iso8601,
+ traverse_obj,
unescapeHTML,
) | yt_dlp/extractor/periscope.py | 7 | Python | 0.571 | security | 84 | 32 | 32 | false | [ie/twitter:broadcast] Support `--wait-for-video` | 8,475 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | bashonly |
import binascii
import hashlib
import json
import re
import uuid
from .common import InfoExtractor
from ..aes import aes_cbc_decrypt_bytes, unpad_pkcs7
from ..compat import compat_etree_fromstring, compat_urllib_parse_unquote
from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
mimetype2ex... | Not sure why you added this import. Both are unused and should be removed. | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
mimetype2ext,
parse_iso8601,
try_call,
update_url_query,
url_or_none,
)
from ..utils.traversal import traverse_obj
SERIES_API = 'https://production-cdn.dr-massive.com/api/page?devic... | @@ -1,10 +1,12 @@
import binascii
import hashlib
+import json
import re
+import uuid
from .common import InfoExtractor
from ..aes import aes_cbc_decrypt_bytes, unpad_pkcs7
-from ..compat import compat_urllib_parse_unquote
+from ..compat import compat_etree_fromstring, compat_urllib_parse_unquote | yt_dlp/extractor/drtv.py | 9 | Python | 0.286 | suggestion | 74 | 34 | 34 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'info_dict': {
'ext': 'mp4',
'id': '14802310112',
'timestamp': 1678786200,
'duration': 120.043,
'season_id': 'urn:dr:mu:bundle:63a4f7c87140143504b6710f',
'series': 'P4 København regionale nyheder',
'upload_date': '20230314',
... | Use `random_uuidv4()` and inline the variable | 'lang': 'da',
'supportFallbackToken': 'true',
}, data=json.dumps({
'deviceId': str(uuid.uuid4()),
'scopes': ['Catalog'],
'optout': True,
}).encode())
self._TOKEN = traverse_obj(
token_response, (... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.286 | suggestion | 45 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'ext': 'mp4',
'id': '14802310112',
'timestamp': 1678786200,
'duration': 120.043,
'season_id': 'urn:dr:mu:bundle:63a4f7c87140143504b6710f',
'series': 'P4 København regionale nyheder',
'upload_date': '20230314',
'release_year'... | Use the `query` parameter and split into multiple lines. Something along the lines of:
```suggestion
token_response = self._download_json(
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'conten... | 'supportFallbackToken': 'true',
}, data=json.dumps({
'deviceId': str(uuid.uuid4()),
'scopes': ['Catalog'],
'optout': True,
}).encode())
self._TOKEN = traverse_obj(
token_response, (lambda _, x: x['type'] == 'Use... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 1 | security | 978 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'description': '',
'upload_date': '20220505',
},
'params': {
'skip_download': True,
},
'skip': 'this video has been removed',
}, {
'url': 'https://www.dr.dk/lyd/p4kbh/regionale-nyheder-kh4/regionale-nyheder-2023-03-14-10-30-9',
'inf... | `is_radio_url` is now completely unused. Does the new API no longer require different treatment for radio programs?
If yes, it should no longer be matched. | return
token_response = self._download_json(
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'content-type': 'application/json',
}, query={
'device': 'web_bro... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio') | yt_dlp/extractor/drtv.py | 26 | Python | 0.571 | suggestion | 156 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
_VALID_URL = r'https?://(?:www\.)?(?:dr\.dk|dr-massive\.com)/drtv/serie/(?P<display_id>[\w-]+)_(?P<id>\d+)'
_GEO_COUNTRIES = ['DK']
_TESTS = [{
'url': 'https://www.dr.dk/drtv/serie/frank-and-kastaniegaarden_6954',
'info_dict': {
'id': '6954',
'display_id': 'frank-and-... | Is this data just not present anymore? Can any other endpoints be called to retrieve this data? | 'playlist_mincount': 8
}, {
'url': 'https://www.dr.dk/drtv/saeson/frank-and-kastaniegaarden_8761',
'info_dict': {
'id': '8761',
'display_id': 'frank-and-kastaniegaarden',
'title': 'Frank & Kastaniegaarden',
'series': 'Frank & Kastaniegaarden',
... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.214 | question | 95 | 35 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'id': '14802310112',
'timestamp': 1678786200,
'duration': 120.043,
'season_id': 'urn:dr:mu:bundle:63a4f7c87140143504b6710f',
'series': 'P4 København regionale nyheder',
'upload_date': '20230314',
'release_year': 0,
'descript... | Use the `query` parameter and split into multiple lines. Also use f-strings. | }, data=json.dumps({
'deviceId': str(uuid.uuid4()),
'scopes': ['Catalog'],
'optout': True,
}).encode())
self._TOKEN = traverse_obj(
token_response, (lambda _, x: x['type'] == 'UserAccount', 'value', {str}), get_all=False)
... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.429 | suggestion | 76 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'skip': 'this video has been removed',
}, {
'url': 'https://www.dr.dk/lyd/p4kbh/regionale-nyheder-kh4/regionale-nyheder-2023-03-14-10-30-9',
'info_dict': {
'ext': 'mp4',
'id': '14802310112',
'timestamp': 1678786200,
'duration': 120.043,
... | Should be equivalent to:
```suggestion
item = traverse_obj(json_data, ('cache', 'page', ..., 'entries', 0, 'item'), get_all=False)
```
Can there be multiple pages in the cache or multiple entries in the page?
Taking a quick look at the site, maybe `https://production-cdn.dr-massive.com/api/items/{video_i... | }, query={
'device': 'web_browser',
'ff': 'idp,ldp,rpt',
'lang': 'da',
'supportFallbackToken': 'true',
}, data=json.dumps({
'deviceId': str(uuid.uuid4()),
'scopes': ['Catalog'],
'optou... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.857 | performance | 391 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
import binascii
import hashlib
import json
import re
import uuid
from .common import InfoExtractor
from ..aes import aes_cbc_decrypt_bytes, unpad_pkcs7
from ..compat import compat_etree_fromstring, compat_urllib_parse_unquote
from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
mimetype2ex... | There are a couple code style violations. Do actually run flake8. | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
mimetype2ext,
parse_iso8601,
try_call,
update_url_query,
url_or_none,
)
from ..utils.traversal import traverse_obj
SERIES_API = 'https://production-cdn.dr-massive.com/api/page?devic... | @@ -19,7 +21,6 @@
SERIES_API = 'https://production-cdn.dr-massive.com/api/page?device=web_browser&item_detail_expand=all&lang=da&max_list_prefetch=3&path=%s'
- | yt_dlp/extractor/drtv.py | 22 | Python | 0.214 | style | 65 | 47 | 47 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'url': 'https://www.dr.dk/lyd/p4kbh/regionale-nyheder-kh4/regionale-nyheder-2023-03-14-10-30-9',
'info_dict': {
'ext': 'mp4',
'id': '14802310112',
'timestamp': 1678786200,
'duration': 120.043,
'season_id': 'urn:dr:mu:bundle:63a4f7c87140143504b6... | I wonder if the regular id could be used as the video instead of this one.
From the URLs posted in #8298 the new URL format seems to have the regular id as part of the URL. Is this always the case and the could the id be extracted from there? | 'ff': 'idp,ldp,rpt',
'lang': 'da',
'supportFallbackToken': 'true',
}, data=json.dumps({
'deviceId': str(uuid.uuid4()),
'scopes': ['Catalog'],
'optout': True,
}).encode())
self._TOKEN = traver... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.5 | refactor | 243 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
'upload_date': '20230314',
'release_year': 0,
'description': 'Hør seneste regionale nyheder fra P4 København.',
'season': 'Regionale nyheder',
'title': 'Regionale nyheder',
},
}]
def _real_extract(self, url):
raw_video_id, is_radio_url... | Use snake_case and make this non-fatal:
```suggestion
format_id = fmt.get('format', 'na')
access_service = fmt.get('accessService')
```
|
self._TOKEN = traverse_obj(
token_response, (lambda _, x: x['type'] == 'UserAccount', 'value', {str}), get_all=False)
if not self._TOKEN:
raise ExtractorError('Unable to get anonymous token')
def _real_extract(self, url):
url_slug = self._match_id(url)
webpa... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.786 | suggestion | 165 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
if '>Programmet er ikke længere tilgængeligt' in webpage:
raise ExtractorError(
'Video %s is not available' % raw_video_id, expected=True)
json_data = self._search_json(r'window\.__data\s*=', webpage, 'data', raw_video_id)
item = traverse_obj(json_data, ('cache', 'pag... | I only checked a single video, but for `169521` the subtitle language is set to `DanishLanguageSubtitles`. Do both need to be accepted, and are there other possible values? | r'window\.__data\s*=', webpage, 'data', url_slug, fatal=False) or {}
item = traverse_obj(
json_data, ('cache', 'page', ..., (None, ('entries', 0)), 'item', {dict}), get_all=False)
if item:
item_id = item.get('id')
else:
item_id = url_slug.rsplit('_... | @@ -161,191 +162,54 @@ class DRTVIE(InfoExtractor):
def _real_extract(self, url):
raw_video_id, is_radio_url = self._match_valid_url(url).group('id', 'radio')
-
webpage = self._download_webpage(url, raw_video_id)
-
if '>Programmet er ikke længere tilgængeligt' in webpage:
... | yt_dlp/extractor/drtv.py | 26 | Python | 0.5 | question | 172 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | almx |
import json
import uuid
from .common import InfoExtractor
from ..utils import (
int_or_none,
mimetype2ext,
parse_iso8601,
try_call,
update_url_query,
url_or_none,
)
from ..utils.traversal import traverse_obj
SERIES_API = 'https://production-cdn.dr-massive.com/api/page?device=web_browser&item_d... | exclude query and fragment from the match
```suggestion
(?:www\.)?dr\.dk/tv/se(?:/ondemand)?/(?:[^/?#]+/)*|
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
mimetype2ext,
parse_iso8601,
try_call,
update_url_query,
url_or_none,
)
from ..utils.traversal import traverse_obj
SERIES_API = 'https://production-cdn.dr-massive.com/api/page?devic... | @@ -24,7 +19,7 @@ class DRTVIE(InfoExtractor):
_VALID_URL = r'''(?x)
https?://
(?:
- (?:www\.)?dr\.dk/(?:tv/se|nyheder|(?P<radio>radio|lyd)(?:/ondemand)?)/(?:[^/]+/)*|
+ (?:www\.)?dr\.dk/tv/se(?:/ondemand)?/(?:[^/]+... | yt_dlp/extractor/drtv.py | 22 | Python | 0.714 | suggestion | 142 | 47 | 47 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
'only_matching': True,
}, {
'url': 'https://dr-massive.com/drtv/se/bonderoeven_71769',
'only_matching': True,
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
}]
_TOKEN = None
SUBTITLE_LANGS = {
'DanishLanguageSubtit... | ```suggestion
}, query={
``` | 'url': 'https://www.dr.dk/drtv/episode/bonderoeven_71769',
'only_matching': True,
}, {
'url': 'https://dr-massive.com/drtv/se/bonderoeven_71769',
'only_matching': True,
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
}]
... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.429 | suggestion | 42 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
'only_matching': True,
}]
_TOKEN = None
SUBTITLE_LANGS = {
'DanishLanguageSubtitles': 'da',
'ForeignLanguageSubtitles': 'da_foreign',
'CombinedLanguageSubtitles': 'da_combined',
}
def _real_initialize(self):
if self._TOKEN:
return
token_... | ```suggestion
}, data=json.dumps({
``` | 'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
}]
SUBTITLE_LANGS = {
'DanishLanguageSubtitles': 'da',
'ForeignLanguageSubtitles': 'da_foreign',
'CombinedLanguageSubtitles': 'da_combined',
}
_TOKEN = None
def _real_initialize(s... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.571 | suggestion | 52 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
SUBTITLE_LANGS = {
'DanishLanguageSubtitles': 'da',
'ForeignLanguageSubtitles': 'da_foreign',
'CombinedLanguageSubtitles': 'da_combined',
}
def _real_initialize(self):
if self._TOKEN:
return
token_response = self._download_json(
'https://prod... | ```suggestion
'scopes': ['Catalog'],
``` | SUBTITLE_LANGS = {
'DanishLanguageSubtitles': 'da',
'ForeignLanguageSubtitles': 'da_foreign',
'CombinedLanguageSubtitles': 'da_combined',
}
_TOKEN = None
def _real_initialize(self):
if self._TOKEN:
return
token_response = self._download_json(
... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.571 | suggestion | 58 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
def _real_initialize(self):
if self._TOKEN:
return
token_response = self._download_json(
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'content-type': 'application/json',
... | this could fail silently; shouldn't we raise `if not self._TOKEN`? | _TOKEN = None
def _real_initialize(self):
if self._TOKEN:
return
token_response = self._download_json(
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'content-type': 'a... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.429 | bug | 66 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'content-type': 'application/json',
},
query={
'device': 'web_browser',
'ff': 'idp,ldp,rpt',
... | `_search_json` appends `\s*` to the start pattern already
```suggestion
json_data = self._search_json(
r'window\.__data\s*=', webpage, 'data', url_slug, fatal=False) or {}
``` |
token_response = self._download_json(
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'content-type': 'application/json',
}, query={
'device': 'web_browser',
... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.714 | suggestion | 199 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
note='Downloading anonymous token', headers={
'content-type': 'application/json',
},
query={
'device': 'web_browser',
'ff': 'idp,ldp,rpt',
'lang': 'da',
'supportFallbackToken': 'true',
},
... | expect the type
```suggestion
item = traverse_obj(
json_data, ('cache', 'page', ..., (None, ('entries', 0)), 'item', {dict}), get_all=False)
``` | token_response = self._download_json(
'https://production.dr-massive.com/api/authorization/anonymous-sso', None,
note='Downloading anonymous token', headers={
'content-type': 'application/json',
}, query={
'device': 'web_browser',
... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.857 | performance | 168 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
self._TOKEN = traverse_obj(
token_response, (lambda _, x: x['type'] == 'UserAccount', 'value', {str}), get_all=False)
def _real_extract(self, url):
url_slug = self._match_id(url)
webpage = self._download_webpage(url, url_slug)
json_data = self._search_json(r'window\.__d... | add newline for readability
```suggestion
})
video_id = try_call(lambda: item['customId'].rsplit(':', 1)[-1]) or item_id
``` | if not self._TOKEN:
raise ExtractorError('Unable to get anonymous token')
def _real_extract(self, url):
url_slug = self._match_id(url)
webpage = self._download_webpage(url, url_slug)
json_data = self._search_json(
r'window\.__data\s*=', webpage, 'data', url_... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.714 | suggestion | 154 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
item = self._download_json(
f'https://production-cdn.dr-massive.com/api/items/{item_id}', item_id,
note='Attempting to download backup item data', query={
'device': 'web_browser',
'expand': 'all',
'ff': 'idp,ldp,rpt'... | ```suggestion
}, headers={'authorization': f'Bearer {self._TOKEN}'})
``` | else:
item_id = url_slug.rsplit('_', 1)[-1]
item = self._download_json(
f'https://production-cdn.dr-massive.com/api/items/{item_id}', item_id,
note='Attempting to download backup item data', query={
'device': 'web_browser',
... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.571 | security | 86 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
'expand': 'all',
'ff': 'idp,ldp,rpt',
'geoLocation': 'dk',
'isDeviceAbroad': 'false',
'lang': 'da',
'segments': 'drtv,optedout',
'sub': 'Anonymous',
})
vide... | this is enough to determine it's a dict
```suggestion
for fmt in traverse_obj(stream_data, (lambda _, x: x['url'])):
```
More importantly, I'm not a fan of using `fmt` as the variable name here... can be easily confused with fmts/formats.
`stream` would be better IMO | note='Attempting to download backup item data', query={
'device': 'web_browser',
'expand': 'all',
'ff': 'idp,ldp,rpt',
'geoLocation': 'dk',
'isDeviceAbroad': 'false',
'lang': 'da',
... | @@ -123,226 +123,125 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
- }, {
- 'url': 'https://www.dr.dk/lyd/p4aarhus/regionale-nyheder-ar4/regionale-nyheder-2022-05-05-12-30-3',
- 'info_dict': {
- 'id':... | yt_dlp/extractor/drtv.py | 26 | Python | 0.857 | suggestion | 288 | 51 | 51 | false | [DRTV extractor] Fix drtv.py | 8,484 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | almx |
_TESTS = [{
'url': 'https://sound.orf.at/podcast/oe3/fruehstueck-bei-mir/nicolas-stockhammer-15102023',
'md5': '526a5700e03d271a1505386a8721ab9b',
'info_dict': {
'id': 'nicolas-stockhammer-15102023',
'ext': 'mp3',
'title': 'Nicolas Stockhammer (15.10.2023)... | ```suggestion
'ext': 'mp3',
**traverse_obj(data, ('payload', {
'url': ('enclosures', 0, 'url'),
'title': 'title',
'description': ('description', {clean_html}),
'duration': ('duration', {functools.partial(float_or_none, scale=1... | _VALID_URL = rf'https?://sound\.orf\.at/podcast/(?P<station>{_STATION_RE})/(?P<show>[\w-]+)/(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://sound.orf.at/podcast/oe3/fruehstueck-bei-mir/nicolas-stockhammer-15102023',
'md5': '526a5700e03d271a1505386a8721ab9b',
'info_dict': {
'id': ... | @@ -334,6 +334,42 @@ def _real_extract(self, url):
self._entries(data, station or station2), show_id, data.get('title'), clean_html(data.get('subtitle')))
+class ORFPodcastIE(InfoExtractor):
+ IE_NAME = 'orf:podcast'
+
+ _STATION_RE = 'noe|wie|bgl|ooe|stm|ktn|sbg|tir|vbg|oe3|oe1|tv'
+
+ _VALID... | yt_dlp/extractor/orf.py | 26 | Python | 0.929 | suggestion | 467 | 51 | 51 | false | [ie/orf] Add extractor for sound.orf.at podcasts | 8,486 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | Esokrates |
'ext': 'mp3',
'url': f'https://loopstream01.apa.at/?channel={loop_station}&id={item_id}',
'_old_archive_ids': [make_archive_id(old_ie, video_id)],
'title': data.get('title'),
'description': clean_html(data.get('subtitle')),
... | ```suggestion
_VALID_URL = rf'https?://sound\.orf\.at/podcast/(?P<station>{_STATION_RE})/(?P<show>[a-zA-Z0-9_-]+)/(?P<id>[a-zA-Z0-9_-]+)'
``` | yield {
'id': video_id,
'ext': 'mp3',
'url': f'https://loopstream01.apa.at/?channel={loop_station}&id={item_id}',
'_old_archive_ids': [make_archive_id(old_ie, video_id)],
'title': data.get('title'),
'description'... | @@ -334,6 +334,42 @@ def _real_extract(self, url):
self._entries(data, station or station2), show_id, data.get('title'), clean_html(data.get('subtitle')))
+class ORFPodcastIE(InfoExtractor):
+ IE_NAME = 'orf:podcast'
+
+ _STATION_RE = 'noe|wie|bgl|ooe|stm|ktn|sbg|tir|vbg|oe3|oe1|tv'
+
+ _VALID... | yt_dlp/extractor/orf.py | 26 | Python | 0.857 | suggestion | 147 | 51 | 51 | false | [ie/orf] Add extractor for sound.orf.at podcasts | 8,486 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | Esokrates |
'_old_archive_ids': [make_archive_id(old_ie, video_id)],
'title': data.get('title'),
'description': clean_html(data.get('subtitle')),
'duration': try_call(lambda: (info['end'] - info['start']) / 1000),
'timestamp': int_or_none(info.get('sta... | for the stations, let's use an alphabetized tuple to make it easier to read/maintain
```suggestion
IE_NAME = 'orf:podcast'
_STATION_RE = '|'.join(map(re.escape, (
'bgl', 'fm4', 'ktn', 'noe', 'oe1', 'oe3',
'ooe', 'sbg', 'stm', 'tir', 'tv', 'vbg', 'wie')))
_VALID_URL = rf'https?://sound\... | 'url': f'https://loopstream01.apa.at/?channel={loop_station}&id={item_id}',
'_old_archive_ids': [make_archive_id(old_ie, video_id)],
'title': data.get('title'),
'description': clean_html(data.get('subtitle')),
'duration': try_call(lambda: (... | @@ -334,6 +335,45 @@ def _real_extract(self, url):
self._entries(data, station or station2), show_id, data.get('title'), clean_html(data.get('subtitle')))
+class ORFPodcastIE(InfoExtractor):
+ IE_NAME = 'orf:podcast'
+
+ _STATION_RE = 'noe|wie|bgl|ooe|stm|ktn|sbg|tir|vbg|oe3|oe1|fm4|tv'
+
+ _V... | yt_dlp/extractor/orf.py | 26 | Python | 1 | security | 418 | 51 | 51 | false | [ie/orf] Add extractor for sound.orf.at podcasts | 8,486 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Esokrates |
_STATION_RE = 'noe|wie|bgl|ooe|stm|ktn|sbg|tir|vbg|oe3|oe1|fm4|tv'
_VALID_URL = rf'https?://sound\.orf\.at/podcast/(?P<station>{_STATION_RE})/(?P<show>[\w-]+)/(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://sound.orf.at/podcast/oe3/fruehstueck-bei-mir/nicolas-stockhammer-15102023',
'md5': '52... | Are we sure that it is always an mp3?
In the API response JSON there is a mimetype given in the `payload.enclosures.0.type` field
So you could keep `'ext': 'mp3'` here as a default, but then also add
```diff
**traverse_obj(data, ('payload', {
'url': ('enclosures', 0, 'url'),
+ ... | IE_NAME = 'orf:podcast'
_STATION_RE = '|'.join(map(re.escape, (
'bgl', 'fm4', 'ktn', 'noe', 'oe1', 'oe3',
'ooe', 'sbg', 'stm', 'tir', 'tv', 'vbg', 'wie')))
_VALID_URL = rf'https?://sound\.orf\.at/podcast/(?P<station>{_STATION_RE})/(?P<show>[\w-]+)/(?P<id>[\w-]+)'
_TESTS = [{
'url... | @@ -334,6 +335,45 @@ def _real_extract(self, url):
self._entries(data, station or station2), show_id, data.get('title'), clean_html(data.get('subtitle')))
+class ORFPodcastIE(InfoExtractor):
+ IE_NAME = 'orf:podcast'
+
+ _STATION_RE = 'noe|wie|bgl|ooe|stm|ktn|sbg|tir|vbg|oe3|oe1|fm4|tv'
+
+ _V... | yt_dlp/extractor/orf.py | 26 | Python | 1 | refactor | 431 | 51 | 51 | false | [ie/orf] Add extractor for sound.orf.at podcasts | 8,486 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Esokrates |
import functools
import re
from .common import InfoExtractor
from ..networking import HEADRequest
from ..utils import (
clean_html,
determine_ext,
float_or_none,
InAdvancePagedList,
int_or_none,
join_nonempty,
orderedSet,
remove_end,
make_archive_id,
smuggle_url,
strip_jsonp... | can you run `isort` on this please? | import functools
import re
from .common import InfoExtractor
from ..networking import HEADRequest
from ..utils import (
InAdvancePagedList,
clean_html,
determine_ext,
float_or_none,
int_or_none,
join_nonempty,
make_archive_id,
mimetype2ext,
orderedSet,
remove_end,
smuggle_ur... | @@ -20,7 +20,9 @@
unified_strdate,
unsmuggle_url,
url_or_none,
+ mimetype2ext, | yt_dlp/extractor/orf.py | 23 | Python | 0.214 | question | 35 | 48 | 48 | false | [ie/orf] Add extractor for sound.orf.at podcasts | 8,486 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Esokrates |
webpage = self._download_webpage(
f'https://www.bitchute.com/video/{video_id}', video_id, headers=self._HEADERS)
self._raise_if_restricted(webpage)
publish_date = clean_html(get_element_by_class('video-publish-date', webpage))
entries = self._parse_html5_media_entries(url, w... | How about something like this:
```suggestion
'channel': clean_html(get_element_by_class('name', details)),
'uploader': clean_html(get_element_by_class('creator', details)),
```
with
```python
details = get_element_by_class('details', webpage) or ''
```
Potentially, the `channel_url` and... | re.sub(r'(^https?://)(seed\d+)(?=\.bitchute\.com)', fr'\g<1>{host}', video_url)
for host in (r'\g<2>', 'seed122', 'seed125', 'seed126', 'seed128',
'seed132', 'seed150', 'seed151', 'seed152', 'seed153',
'seed167', 'seed171', 'seed177', 'seed305', ... | @@ -126,7 +126,7 @@ def _real_extract(self, url):
'title': self._html_extract_title(webpage) or self._og_search_title(webpage),
'description': self._og_search_description(webpage, default=None),
'thumbnail': self._og_search_thumbnail(webpage),
- 'uploader': clean_html(g... | yt_dlp/extractor/bitchute.py | 26 | Python | 0.857 | refactor | 386 | 51 | 51 | false | [BitChute] - Fix 'uploader' and playlist tests md5 result | 8,507 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
self.to_screen(f'{video_id}: URL is invalid, skipping: {e.cause}')
continue
return {
'url': url,
'filesize': int_or_none(response.headers.get('Content-Length'))
}
def _raise_if_restricted(self, webpage):
page_title = cl... | 1. all of this "details" extraction should be moved down near the return for better code flow/readability
2. `uploader_path` and `channel_path` are currently fatal because `get_element_html_by_class` can return `None` and throws when its html input is `None`
3. matching `base_url` in `_VALID_URL` is overkill, we can ... | _GEO_BYPASS = False
_HEADERS = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.57 Safari/537.36',
'Referer': 'https://www.bitchute.com/',
}
def _check_format(self, video_url, video_id):
urls = orderedSet(
... | @@ -100,13 +106,18 @@ def _raise_if_restricted(self, webpage):
self.raise_geo_restricted(reason)
def _real_extract(self, url):
- video_id = self._match_id(url)
+ base_url, video_id = self._match_valid_url(url).group('base_url', 'id')
webpage = self._download_webpage(
... | yt_dlp/extractor/bitchute.py | 26 | Python | 0.857 | refactor | 1,137 | 51 | 51 | false | [BitChute] - Fix 'uploader' and playlist tests md5 result | 8,507 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
# flake8: noqa: F401
from .youtube import ( # Youtube is moved to the top to improve performance
YoutubeIE,
YoutubeClipIE,
YoutubeFavouritesIE,
YoutubeNotificationsIE,
YoutubeHistoryIE,
YoutubeTabIE,
YoutubeLivestreamEmbedIE,
YoutubePlaylistIE,
YoutubeRecommendedIE,
YoutubeSear... | I assume the line break was put there on purpose to have the YouTube extractors stand alone at the top. | # flake8: noqa: F401
from .youtube import ( # Youtube is moved to the top to improve performance
YoutubeIE,
YoutubeClipIE,
YoutubeFavouritesIE,
YoutubeNotificationsIE,
YoutubeHistoryIE,
YoutubeTabIE,
YoutubeLivestreamEmbedIE,
YoutubePlaylistIE,
YoutubeRecommendedIE,
YoutubeSear... | @@ -23,7 +23,6 @@
YoutubeShortsAudioPivotIE,
YoutubeConsentRedirectIE,
)
- | yt_dlp/extractor/_extractors.py | 26 | Python | 0.429 | refactor | 103 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
import re
from collections import namedtuple
from .common import InfoExtractor
from ..utils import (
int_or_none,
)
class RadioComercialBaseExtractor(InfoExtractor):
def _extract_page_content(self, url):
video_id = RadioComercialIE._match_id(url)
webpage = self._download_webpage(url, video_id... | I don't think it makes sense to use a base class like this here.
Currently, when extracting a playlist of 100 items, first all 100 pages need to be fetched. Instead, returning URL results makes more sense. | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor): | yt_dlp/extractor/radiocomercial.py | 10 | Python | 0.5 | refactor | 206 | 35 | 35 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
date = self._html_search_regex(r'<div[^"]+"date">(\d{4}-\d{2}-\d{2})</div>', webpage, 'date')
thumbnail = self._html_search_regex(r'<source[^"]+"image/jpeg[^/]+(.+?)\">', webpage, 'thumbnail')
season = int_or_none(self._html_search_regex(r'<h2>\w+\s(\d+)</h2>', webpage, 'season'))
episod... | Should be `upload_date` or `release_date` and formatted `YYYYMMDD` | update_url,
urljoin
)
from ..utils.traversal import traverse_obj
class RadioComercialIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t?(?P<season>\d+)/(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao/t6/tay... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.429 | suggestion | 66 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
thumbnail = self._html_search_regex(r'<source[^"]+"image/jpeg[^/]+(.+?)\">', webpage, 'thumbnail')
season = int_or_none(self._html_search_regex(r'<h2>\w+\s(\d+)</h2>', webpage, 'season'))
episode_id = int_or_none(self._html_search_regex(r'episodeid=(\d+)&', url, 'episode_id'))
return {
... | Should be a URL starting with https:// | urljoin
)
from ..utils.traversal import traverse_obj
class RadioComercialIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t?(?P<season>\d+)/(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao/t6/taylor-swift-entran... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.143 | suggestion | 38 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
class RadioComercialBaseExtractor(InfoExtractor):
def _extract_page_content(self, url):
video_id = RadioComercialIE._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
url = self._html_search_rege... | How about we extract the season based on the URL. I would expect this to be more robust.
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/]+/\w(?P<season>\d+)/(?P<id>[-\w]+)/*$'
``` | get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
update_url,
urljoin
)
from ..utils.traversal import traverse_obj
class RadioComercialIE(InfoExtractor):
_VAL... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | refactor | 218 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
import re
from collections import namedtuple
from .common import InfoExtractor
from ..utils import (
int_or_none,
)
class RadioComercialBaseExtractor(InfoExtractor):
def _extract_page_content(self, url):
video_id = RadioComercialIE._match_id(url)
webpage = self._download_webpage(url, video_id... | Then this will need to be
```suggestion
video_id, season = self._match_valid_url(url).group('id', 'season')
``` | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url) | yt_dlp/extractor/radiocomercial.py | 12 | Python | 0.714 | suggestion | 122 | 37 | 37 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
from .common import InfoExtractor
from ..utils import (
int_or_none,
)
class RadioComercialBaseExtractor(InfoExtractor):
def _extract_page_content(self, url):
video_id = RadioComercialIE._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<t... | This should be non-fatal and inline:
```suggestion
return {
'id': video_id,
'title': self._html_extract_title(webpage),
'release_date': unified_strdate(
get_element_by_class('date', get_element_html_by_class('descriptions', webpage))),
'thum... | from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
update... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.857 | refactor | 742 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'thumbnail': r're:/upload/[^.]+.jpg',
'season': 6,
'episode_id': 220899
}
},
{
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3/convenca-me-num-minuto-que-os-lobisomens-existem',
'md5': '47e96c273aef96a8eb160cd6cf46d782',
... | The returned id should reflect which season is being downloaded. Otherwise, different seasons would end up with the same id. | 'release_date': '20231026',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 3
}
}, {
'url': 'https://radiocomercial.pt/podcasts/inacreditavel-by-ines-castel-branco/t2/o-desastre-de-aviao',
'md5': '69be64255420fec23b7259955d771e54',... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.429 | suggestion | 124 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
if not next_page.path or not next_page.page:
return None
number_section = f'{next_page.page if not next_page.add_one else next_page.page + 1}'
next_page = f'https://radiocomercial.pt{next_page.path}{number_section}'
video_id = self._match_id(next_page)
return self._do... | ```suggestion
name = try_call(lambda: get_element_text_and_html_by_tag('h1', webpage)[0])
season = self._html_extract_title(webpage)
title = name if name == season else join_nonempty(name, season, delim=' - ')
``` | 'playlist_mincount': 19
}, {
'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas',
'info_dict': {
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.857 | refactor | 241 | 38 | 47 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
yield f'https://radiocomercial.pt{match.group(1)}'
def _generate_sorted_entries(self, list_of_podcasts):
entries = [self._extract_page_content(item) for item in list_of_podcasts]
sorted_entries = sorted(entries, key=lambda x: x['date'], reverse=True)
for entry in sorted_entries:... | This seems overly complex. Take a look at `OnDemandPagedList`. | 'id': 'tnt-todos-no-top_t2023',
'title': 'TNT - Todos No Top - Temporada 2023',
},
'playlist_mincount': 39
}]
def _entries(self, url, playlist_id):
for page in itertools.count(1):
try:
webpage = self._download_webpage(
... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.357 | suggestion | 62 | 27 | 36 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
video_id = self._match_id(next_page)
return self._download_webpage(next_page, video_id, headers={'X-Requested-With': 'XMLHttpRequest'})
def _collect_hrefs(self, webpage):
regex = re.compile(r'rounded-site-bottom"><a class="tm-ouvir-podcast" href="([^"]+)"')
matches = regex.finditer(... | I think `get_elements_html_by_class('tm-ouvir-podcast', webpage)` could be used here | 'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
'info_dict': {
'id': 'tnt-todos-no-top_t2023',
'title': 'TNT... | @@ -0,0 +1,141 @@
+import re
+from collections import namedtuple
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class RadioComercialBaseExtractor(InfoExtractor):
+ def _extract_page_content(self, url):
+ video_id = RadioComercialIE._match_id(url)
+ webpage = self.... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.571 | suggestion | 84 | 34 | 43 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
int_or_none,
unified_strdate,
get_element_by_class,
get_element_html_by_class,
extract_attributes,
try_call,
get_element_text_and_html_by_tag,
join_nonempty,
get_elements_html_by_class,
traverse_obj,
On... | Applied isort
```suggestion
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
)
from ..ut... | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 16 | Python | 0.857 | refactor | 358 | 41 | 41 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
extract_attributes,
try_call,
get_element_text_and_html_by_tag,
join_nonempty,
get_elements_html_by_class,
traverse_obj,
OnDemandPagedList
)
class RadioComercialIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/]+/\w(?P<season>\d+)/(?P<id>[-\w]+)/*$'
... | ```suggestion
'season': 6,
},
}, {
``` | get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
update_url,
urljoin
)
from ..utils.traversal import traverse_obj
class RadioComercialIE(InfoExtractor):
_VALID_URL = r'https?://(?:www... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.571 | suggestion | 66 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao/t6/taylor-swift-entranhando-se-que-nem-uma-espada-no-ventre-dos-fas',
'md5': '5f4fe8e485b29d2e8fd495605bc2c7e4',
'info_dict': {
'id': 'taylor-swift-entranhando-se-que-nem-uma-espada-no-ventre-dos-fas',
'e... | ```suggestion
'season': 3,
},
}, {
``` | class RadioComercialIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t?(?P<season>\d+)/(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao/t6/taylor-swift-entranhando-se-que-nem-uma-espada-no-ventre-dos-fas#page-content-... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.571 | suggestion | 66 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3/convenca-me-num-minuto-que-os-lobisomens-existem',
'md5': '47e96c273aef96a8eb160cd6cf46d782',
'info_dict': {
'id': 'convenca-me-num-minuto-que-os-lobisomens-existem',
'ext': 'mp3',
'title': '... | ```suggestion
'season': 2,
},
}]
``` | }, {
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3/convenca-me-num-minuto-que-os-lobisomens-existem',
'md5': '47e96c273aef96a8eb160cd6cf46d782',
'info_dict': {
'id': 'convenca-me-num-minuto-que-os-lobisomens-existem',
'ext': 'mp3',
'... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.571 | suggestion | 64 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 3
}
},
{
'url': 'https://radiocomercial.pt/podcasts/inacreditavel-by-ines-castel-branco/t2/o-desastre-de-aviao',
'md5': '69be64255420fec23b7259955d771e54',
'info_dict': {
... | ```suggestion
'description': self._og_search_description(webpage, default=None),
```
Please update tests accordingly. | 'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 3
}
}, {
'url': 'https://radiocomercial.pt/podcasts/inacreditavel-by-ines-castel-branco/t2/o-desastre-de-aviao',
'md5': '69be64255420fec23b7259955d771e54',
'info_dict': {
'id'... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.714 | suggestion | 132 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
int_or_none,
unified_strdate,
get_element_by_class,
get_element_html_by_class,
extract_attributes,
try_call,
get_element_text_and_html_by_tag,
join_nonempty,
get_elements_html_by_class,
traverse_obj,
On... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[\w-]+/t?(?P<season>\d+)/(?P<id>[\w-]+)'
```
Adjust to also match https://radiocomercial.pt/podcasts/tnt-todos-no-top/2023/t-n-t-29-de-outubro correctly. Maybe there should be a test case for this? | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 20 | Python | 1 | question | 280 | 45 | 45 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'id': 'o-homem-que-mordeu-o-cao',
'title': 'O Homem Que Mordeu o Cão',
},
'playlist_mincount': 19
}, {
'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas',
'info_dict': {
'id': 'as-minhas-coisas-favoritas',
'title': '... | ```suggestion
podcast, season = self._match_valid_url(url).group('id', 'season')
playlist_id = join_nonempty(podcast, season, delim='_')
```
And then use `playlist_id` as the id. | class RadioComercialPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/(?P<id>[\w-]+)(?:/t?(?P<season>\d+))?/?(?:$|[?#])'
_TESTS = [{
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3',
'info_dict': {
'id': 'convenca-me-num-min... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.929 | suggestion | 198 | 35 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'id': 'convenca-me-num-minuto',
'title': 'Convença-me num Minuto - Temporada 3',
},
'playlist_mincount': 32
}, {
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-mordeu-o-cao',
'tit... | Is this special handling needed?
```suggestion
webpage = self._download_webpage(f'{url}/{page}', playlist_id, note=f'Downloading page {page}')
``` | 'date', get_element_html_by_class('descriptions', webpage) or '')),
'thumbnail': self._og_search_thumbnail(webpage),
'season': int_or_none(season),
'url': extract_attributes(get_element_html_by_class('audiofile', webpage) or '').get('href'),
}
class RadioCom... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.714 | question | 157 | 42 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
_PAGE_SIZE = 19
_TESTS = [{
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3',
'info_dict': {
'id': 'convenca-me-num-minuto',
'title': 'Convença-me num Minuto - Temporada 3',
},
'playlist_mincount': 32
}, {
'url': 'https://r... | Hmm, passing the URL is a bit unclean as urls such as `https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas#page-content-wrapper` now get blindly appended the page number.
I guess it would be cleaner to pass the playlist and season to reconstruct the url. | 'id': video_id,
'title': self._html_extract_title(webpage),
'description': self._og_search_description(webpage, default=None),
'release_date': unified_strdate(get_element_by_class(
'date', get_element_html_by_class('descriptions', webpage) or '')),
... | @@ -0,0 +1,123 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+ get_element_by_class,
+ get_element_html_by_class,
+ extract_attributes,
+ try_call,
+ get_element_text_and_html_by_tag,
+ join_nonempty,
+ get_elements_html_by_... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.714 | suggestion | 265 | 46 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
)... | Oh sorry, I should have been clearer on this. I didn't mean that you should indent the tests one more, but just to add the missing trailing commas and combine some of the lines. Take a look at any of the recently added extractors to see how tests are usually formatted ([example](https://github.com/yt-dlp/yt-dlp/pull/76... | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,142 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 21 | Python | 0.5 | refactor | 331 | 46 | 46 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
{
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3/convenca-me-num-minuto-que-os-lobisomens-existem',
'md5': '47e96c273aef96a8eb160cd6cf46d782',
'info_dict': {
'id': 'convenca-me-num-minuto-que-os-lobisomens-existem',
'ext':... | Actually sorry, this would be better to still check if the metadata is correct:
```suggestion
'params': {
# inconsistant md5
'skip_download': True,
},
``` | }, {
'url': 'https://radiocomercial.pt/podcasts/convenca-me-num-minuto/t3/convenca-me-num-minuto-que-os-lobisomens-existem',
'md5': '47e96c273aef96a8eb160cd6cf46d782',
'info_dict': {
'id': 'convenca-me-num-minuto-que-os-lobisomens-existem',
'ext': 'mp3',
'... | @@ -0,0 +1,142 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.857 | suggestion | 216 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
'ext': 'mp3',
'title': 'T.N.T 29 de outubro',
'description': None,
'release_date': '20231029',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 2023
}
}]
def _real_extract(self, url):
video_id, seaso... | mb for the regex colliding previously. I wanted to also match URLs that have query parameters or use anchors. Hopefully this works:
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/(?P<id>[\w-]+)(?:/\D*(?P<season>\d+))?/?(?:$|[?#])'
``` | 'id': 't-n-t-29-de-outubro',
'ext': 'mp3',
'title': 'T.N.T 29 de outubro',
'release_date': '20231029',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 2023
}
}]
def _real_extract(self, url):
video_i... | @@ -0,0 +1,135 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | suggestion | 270 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | SirElderling |
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
urljoin
)
from ..utils.traversal import traverse_... | don't need to add fields with a value of `None` | from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
update... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.214 | suggestion | 47 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
... | can the pattern be more restrictive with the season segment of the URL? `\D*` is too lax
are there any examples where it isn't `/t\d+/` ?
also we want to prevent matching query/fragments with the `[^/]+`
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t(?P<season>\d+)/(?P... | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 21 | Python | 0.929 | suggestion | 337 | 46 | 46 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'skip_download': True,
},
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/2023/t-n-t-29-de-outubro',
'md5': '91d32d4d4b1407272068b102730fc9fa',
'info_dict': {
'id': 't-n-t-29-de-outubro',
'ext': 'mp3',
'title': 'T.N.T 2... | it's fine to inline all of the date code
```suggestion
return {
'id': video_id,
'title': self._html_extract_title(webpage),
'description': self._og_search_description(webpage, default=None),
'release_date': unified_strdate(
get_element_by_... | 'skip_download': True,
},
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/2023/t-n-t-29-de-outubro',
'md5': '91d32d4d4b1407272068b102730fc9fa',
'info_dict': {
'id': 't-n-t-29-de-outubro',
'ext': 'mp3',
'title': 'T.N.T 2... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.857 | refactor | 398 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'title': 'T.N.T 29 de outubro',
'description': None,
'release_date': '20231029',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 2023
}
}]
def _real_extract(self, url):
video_id, season = self._match_valid_url(... | same reasoning as the other `_VALID_URL` suggestion
is there any reason why we're doing `[\w-]+` for the series name in this one and `[^/?#]+` in `RadioComercial._VALID_URL` ?
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/(?P<id>[\w-]+)(?:/t(?P<season>\d+))?/?(?:$|[?#])'
``` | 'title': 'T.N.T 29 de outubro',
'release_date': '20231029',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 2023
}
}]
def _real_extract(self, url):
video_id, season = self._match_valid_url(url).group('id', 'season')
... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.929 | suggestion | 315 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'info_dict': {
'id': 'convenca-me-num-minuto',
'title': 'Convença-me num Minuto - Temporada 3',
},
'playlist_mincount': 32
}, {
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-mordeu-o... | IMO it's simpler to just pass the url and id to the page func (sorry, I know this is the opposite of what sepro suggested)
Also fyi `urljoin` didn't really need to be used where you had used it; it's particularly useful when:
- the 2nd argument's value is uncertain, and you want to return `None` if it's falsy
- th... | },
'playlist_mincount': 32
}, {
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-mordeu-o-cao',
'title': 'O Homem Que Mordeu o Cão',
},
'playlist_mincount': 19
}, {
'url': 'http... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | refactor | 1,319 | 42 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
},
'playlist_mincount': 32
}, {
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-mordeu-o-cao',
'title': 'O Homem Que Mordeu o Cão',
},
'playlist_mincount': 19
}, {
'url': 'http... | just formatting nitpick
```suggestion
episodes = set(traverse_obj(
get_elements_html_by_class('tm-ouvir-podcast', webpage),
(..., {extract_attributes}, 'href')))
``` | 'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-mordeu-o-cao',
'title': 'O Homem Que Mordeu o Cão',
},
'playlist_mincount': 19
}, {
'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favo... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | refactor | 202 | 39 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'title': 'O Homem Que Mordeu o Cão',
},
'playlist_mincount': 19
}, {
'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas',
'info_dict': {
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
... | The playlist id should include the season if there is one. Using only `podcast` isn't correct; e.g. season 1 would share the same id with season 2, and any single season would share the same id with the complete series. Constructing the `playlist_id` here also lets us pass it to the page func
We also need to use `ut... | }, {
'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas',
'info_dict': {
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-t... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | suggestion | 748 | 33 | 46 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}]
def _fetch_page(self, podcast, season, page):
page += 1
url = urljoin('https://radiocomercial.pt/podcasts/', podcast + (f'/t{season}' if season else ... | passing the url and playlist_id to the page func
```suggestion
return self.playlist_result(OnDemandPagedList(
functools.partial(self._fetch_page, url, playlist_id), self._PAGE_SIZE), playlist_id, title)
``` | 'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
'info_dict': {
'id': 'tnt-todos-no-top_t2023',
'title': 'TNT - Todos No Top - Temporada 2023',
},
'playlist_mincount': 39
}]
def _entries(self, u... | @@ -0,0 +1,137 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.786 | suggestion | 230 | 27 | 40 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
... | will need this for other suggestion
```suggestion
import itertools
``` | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,147 @@
+import functools | yt_dlp/extractor/radiocomercial.py | 1 | Python | 0.571 | suggestion | 73 | 26 | 26 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
... | will need these below
```suggestion
from .common import InfoExtractor
from .networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
``` | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes, | yt_dlp/extractor/radiocomercial.py | 6 | Python | 0.929 | refactor | 191 | 31 | 31 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
import functools
from .common import InfoExtractor
from ..utils import (
OnDemandPagedList,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_nonempty,
try_call,
unified_strdate,
... | Having `/` in the character class defeats the purpose of that group at the end of the pattern. We are not doing a `fullmatch` with this pattern, only a `match`. Also, `|` is not needed inside a character class
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t?(?P<season>\d+)/(?... | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 22 | Python | 0.929 | suggestion | 350 | 47 | 47 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'id': 't-n-t-29-de-outubro',
'ext': 'mp3',
'title': 'T.N.T 29 de outubro',
'release_date': '20231029',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 2023
}
}]
def _real_extract(self, url):
video_i... | same as above
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/(?P<id>[\w-]+)(?:/t?(?P<season>\d+))?/?(?:$|[?#])'
``` | 'info_dict': {
'id': 't-n-t-29-de-outubro',
'ext': 'mp3',
'title': 'T.N.T 29 de outubro',
'release_date': '20231029',
'thumbnail': r're:https://radiocomercial.pt/upload/[^.]+.jpg',
'season': 2023
}
}]
def _real_extract(self... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.857 | suggestion | 151 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'params': {
# inconsistant md5
'skip_download': True,
},
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/2023/t-n-t-29-de-outubro',
'md5': '91d32d4d4b1407272068b102730fc9fa',
'info_dict': {
'id': 't-n-t-29-de-outubro',
... | line too long
```suggestion
'release_date': unified_strdate(get_element_by_class(
'date', get_element_html_by_class('descriptions', webpage) or '')),
``` | },
'params': {
# inconsistant md5
'skip_download': True,
},
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/2023/t-n-t-29-de-outubro',
'md5': '91d32d4d4b1407272068b102730fc9fa',
'info_dict': {
'id': 't-n-t-29-de-out... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.714 | refactor | 185 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'info_dict': {
'id': 'convenca-me-num-minuto_t3',
'title': 'Convença-me num Minuto - Temporada 3',
},
'playlist_mincount': 32
}, {
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-morde... | these counts will need to be adjusted after these other suggestions are applied | 'info_dict': {
'id': 'convenca-me-num-minuto_t3',
'title': 'Convença-me num Minuto - Temporada 3',
},
'playlist_mincount': 32
}, {
'url': 'https://radiocomercial.pt/podcasts/o-homem-que-mordeu-o-cao',
'info_dict': {
'id': 'o-homem-que-morde... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.214 | suggestion | 79 | 51 | 51 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
'info_dict': {
'id': 'tnt-todos-no-top_t2023',
'title': 'TNT... | ```suggestion
def _entries(self, url, playlist_id):
for page in itertools.count(1):
try:
webpage, urlh = self._download_webpage_handle(
f'{url}/{page}', playlist_id, f'Downloading page {page}')
except ExtractorError as e:
if ... | 'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
'info_dict': {
'id': 'tnt-todos-no-top_t2023',
'title': 'TNT... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | refactor | 844 | 40 | 43 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
def _fetch_page(self, url, playlist_id, page):
page += 1
webpage = self._download_webpage(
f'{url}/{page}', playlist_id, note=f'Downloading page: {page}', expected_status=404)
# Note: episodes not available will default to the URL https://radiocomercial.pt/podcasts/<season>.
... | ```suggestion
return self.playlist_from_matches(
self._entries(url, playlist_id), playlist_id, title, ie=RadioComercialIE)
``` | def _entries(self, url, playlist_id):
for page in itertools.count(1):
try:
webpage = self._download_webpage(
f'{url}/{page}', playlist_id, f'Downloading page {page}')
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and... | @@ -0,0 +1,147 @@
+import functools
+
+from .common import InfoExtractor
+from ..utils import (
+ OnDemandPagedList,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
+ int_or_none,
+ join_nonempty,
+ t... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 0.714 | suggestion | 149 | 27 | 30 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t?(?P<season>\d+)/(?P<id>[\w-]+)/?(?:$|[?#])'
``` | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,149 @@
+import itertools
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
... | yt_dlp/extractor/radiocomercial.py | 23 | Python | 0.857 | suggestion | 139 | 48 | 48 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
'info_dict': {
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
'info_dict': {
'id': 'tnt-todos-no-top_t2023',
... | on second look, doing this is simpler and safer
```suggestion
webpage = self._download_webpage(
f'{url}/{page}', playlist_id, f'Downloading page {page}')
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status == 404:
... | 'info_dict': {
'id': 'as-minhas-coisas-favoritas',
'title': 'As Minhas Coisas Favoritas',
},
'playlist_mincount': 131
}, {
'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
'info_dict': {
'id': 'tnt-todos-no-top_t2023',
... | @@ -0,0 +1,149 @@
+import itertools
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
... | yt_dlp/extractor/radiocomercial.py | 26 | Python | 1 | refactor | 501 | 43 | 44 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | Read https://github.com/yt-dlp/yt-dlp/pull/8535#discussion_r1390220122
Here I have the same question:
```suggestion
_VALID_URL = r'https?://(?:www\.)?radiocomercial\.pt/podcasts/[^/?#]+/t?(?P<season>\d+)/(?P<id>[\w-]+)'
```
It's needed in `RadioComercialPlaylistIE._VALID_URL`, but I don't think we need it here... | import itertools
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
extract_attributes,
get_element_by_class,
get_element_html_by_class,
get_element_text_and_html_by_tag,
get_elements_html_by_class,
int_or_none,
join_non... | @@ -0,0 +1,150 @@
+import itertools
+
+from .common import InfoExtractor
+from ..networking.exceptions import HTTPError
+from ..utils import (
+ ExtractorError,
+ extract_attributes,
+ get_element_by_class,
+ get_element_html_by_class,
+ get_element_text_and_html_by_tag,
+ get_elements_html_by_class,
... | yt_dlp/extractor/radiocomercial.py | 23 | Python | 0.929 | suggestion | 352 | 48 | 48 | false | [RadioComercial] Add extractor | 8,508 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
}
},
{
'url': 'https://zenporn.com/video/15872038/glad-you-came/',
'md5': '296ccab437f5bac6099433768449d8e1',
'info_dict': {
'id': '15872038',
'extr_id': '111585',
'ext': 'mp4',
'title': 'Glad... | This can fatal since `int_or_none` can return `None`, which we cant divide. Let's secure against that:
```suggestion
extr_id = int_or_none(extr_id)
if extr_id is None:
raise ExtractorError('Unable to generate the `gen_info_url`')
dyn_a = extr_id // 1_000_000 * 1_000_000
... | 'title': 'Glad You Came',
'description': '',
'thumbnail': 'https://vpim.m3pd.com/contents/videos_screenshots/111000/111585/480x270/1.jpg',
'upload_date': '20231024',
'uploader': 'Martin Rudenko',
'age_limit': 18,
}
}]
def _gen_info... | @@ -71,33 +69,24 @@ class ZenPornIE(InfoExtractor):
'title': 'Glad You Came',
'description': '',
'thumbnail': 'https://vpim.m3pd.com/contents/videos_screenshots/111000/111585/480x270/1.jpg',
- 'post_date': '2023-10-24 15:50:03',
+ 'post_da... | yt_dlp/extractor/zenporn.py | 26 | Python | 1 | refactor | 582 | 51 | 51 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
# Check for characters not in the custom character set and handle errors
if any(char not in cust_char_set for char in encoded_url):
return None
# Filter out characters not in the custom character set
encoded_url = ''.join(char for char in encoded_url if char in cust_char_set... | This whole function is basically a b64 decode, so we can implement it as such (import `base64` and `binascii`):
```suggestion
@staticmethod
def _decode_video_url(encoded_url):
""" This function is a reverse engineering from the website javascript """
# Replace lookalike characters and stand... | webpage = self._download_webpage(url, display_id)
ext_domain, video_id = self._search_regex(
r'https://(?P<ext_domain>[\w.-]+\.\w{3})/embed/(?P<extr_id>\d+)/',
webpage, 'embed info', group=('ext_domain', 'extr_id'))
info_json = self._download_json(
self._gen... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 1 | bug | 677 | 51 | 34 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
ext_domain, extr_id = self._search_regex(
r'https:\/\/(?P<ext_domain>[\w.-]+\.\w{3})\/embed\/(?P<extr_id>\d+)\/',
webpage, 'embed_info', group=('ext_domain',... | With above changes. For consistency, it also only uses a single backtick (<code>`</code>) for the error message.
```suggestion
decoded_url = self._decode_video_url(encoded_url)
if not decoded_url:
raise ExtractorError('Unable to retrieve the `download_url`')
``` | import base64
import binascii
from .common import InfoExtractor
from ..utils import ExtractorError, determine_ext, unified_strdate, url_or_none
from ..utils.traversal import traverse_obj
class ZenPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 1 | refactor | 295 | 40 | 119 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
video_json = self._download_json(f'https://{ext_domain}/api/videofile.php?video_id={extr_id}&lifetime=8640000',
video_id, note="Downloading JSON metadata for the video location.")
if not video_json:
raise ExtractorError('Unable to retrieve the the vi... | Again, relying on above base64 changes. We also use `traverse_obj` dict key to simplify the traversal (import `url_or_none`):
```suggestion
return {
'id': video_id,
'extr_id': extr_id,
'ext': determine_ext(video_json[0].get('format')),
'url': f'https://{ext_... | import base64
import binascii
from .common import InfoExtractor
from ..utils import ExtractorError, determine_ext, unified_strdate, url_or_none
from ..utils.traversal import traverse_obj
class ZenPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 0.857 | refactor | 735 | 27 | 119 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
from .common import InfoExtractor
from ..utils import (
ExtractorError,
determine_ext,
int_or_none,
traverse_obj,
unified_strdate
)
class ZenPornIE(InfoExtractor):
IE_DESC = 'ZenPorn'
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url': 'https://... | ```suggestion
unified_strdate,
```
Try to always use a trailing comma in multiline cases, to ease the diff in case of changes | import base64
import binascii
from .common import InfoExtractor
from ..utils import ExtractorError, determine_ext, unified_strdate, url_or_none
from ..utils.traversal import traverse_obj
class ZenPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate | yt_dlp/extractor/zenporn.py | 7 | Python | 0.786 | suggestion | 132 | 32 | 32 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
# Filter out characters not in the custom character set
encoded_url = ''.join(char for char in encoded_url if char in cust_char_set)
while cur_pos < len(encoded_url):
o = cust_char_set.index(encoded_url[cur_pos])
i = cust_char_set.index(encoded_url[cur_pos + 1])
... | ```suggestion
def _real_extract(self, url):
video_id = self._match_id(url)
``` | webpage, 'embed info', group=('ext_domain', 'extr_id'))
info_json = self._download_json(
self._gen_info_url(ext_domain, video_id), video_id, fatal=False)
video_json = self._download_json(
f'https://{ext_domain}/api/videofile.php', video_id, query={
'... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 0.643 | refactor | 93 | 51 | 30 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
o = (o << 2) | (i >> 4)
i = ((i & 15) << 4) | (s >> 2)
l = ((s & 3) << 6) | a
decoded_url += chr(o)
if s != 64:
decoded_url += chr(i)
if a != 64:
decoded_url += chr(l)
cur_pos += 4
return f'ht... | Use single quotes and generally try to avoid deep indents like this by immediately breaking the line and don't end these notes with a `.`:
```suggestion
info_json = self._download_json(
self._gen_info_url(ext_domain, extr_id), video_id, note='Downloading video info JSON')
```
Removing the dots ... | import base64
import binascii
from .common import InfoExtractor
from ..utils import ExtractorError, determine_ext, unified_strdate, url_or_none
from ..utils.traversal import traverse_obj
class ZenPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 1 | refactor | 369 | 51 | 119 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
decoded_url += chr(o)
if s != 64:
decoded_url += chr(i)
if a != 64:
decoded_url += chr(l)
cur_pos += 4
return f'https://{ext_domain}{decoded_url}'
def _real_extract(self, url):
video_id = self._match_id(url)
... | Again here. Heres how I would write it:
```suggestion
video_json = self._download_json(f'https://{ext_domain}/api/videofile.php', video_id, query={
'video_id': extr_id,
'lifetime': 8640000,
}, note='Downloading video location JSON')
``` | import base64
import binascii
from .common import InfoExtractor
from ..utils import ExtractorError, determine_ext, unified_strdate, url_or_none
from ..utils.traversal import traverse_obj
class ZenPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 0.786 | suggestion | 294 | 50 | 119 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | SirElderling |
i = cust_char_set.index(encoded_url[cur_pos + 1])
s = cust_char_set.index(encoded_url[cur_pos + 2])
a = cust_char_set.index(encoded_url[cur_pos + 3])
o = (o << 2) | (i >> 4)
i = ((i & 15) << 4) | (s >> 2)
l = ((s & 3) << 6) | a
decode... | ```suggestion
ext_domain, extr_id = self._search_regex(
r'https://(?P<ext_domain>[\w.-]+\.\w{3})/embed/(?P<extr_id>\d+)/',
webpage, 'embed info', group=('ext_domain', 'extr_id'))
``` | import base64
import binascii
from .common import InfoExtractor
from ..utils import ExtractorError, determine_ext, unified_strdate, url_or_none
from ..utils.traversal import traverse_obj
class ZenPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
_TESTS = [{
'url... | @@ -0,0 +1,151 @@
+from .common import InfoExtractor
+from ..utils import (
+ ExtractorError,
+ determine_ext,
+ int_or_none,
+ traverse_obj,
+ unified_strdate
+)
+
+
+class ZenPornIE(InfoExtractor):
+ IE_DESC = 'ZenPorn'
+ _VALID_URL = r'https?://(?:www\.)?zenporn\.com/video/(?P<id>\d+)'
+ _TES... | yt_dlp/extractor/zenporn.py | 26 | Python | 0.786 | suggestion | 218 | 51 | 119 | false | [ZenPorn] Add extractor | 8,509 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | SirElderling |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.