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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
from .common import InfoExtractor
from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
class BlueskyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
_TESTS = [{
'url': 'https://bsky.app/profile/blu3bl... | You don't need to test for `None` values
```suggestion
``` | from .common import InfoExtractor
from ..utils import (
ExtractorError,
format_field,
int_or_none,
mimetype2ext,
orderedSet,
parse_iso8601,
truncate_string,
update_url_query,
url_basename,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(I... | @@ -0,0 +1,223 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 17 | Python | 0.571 | suggestion | 60 | 42 | 42 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
'comments': None, # 'count:29' if getcomments
},
}, {
'url': 'https://bsky.app/profile/bsky.app/post/3l3vgf77uco2g',
'md5': 'b9e344fdbce9f2852c668a97efefb105',
'info_dict': {
'id': '3l3vgf77uco2g',
'ext': 'mp4',
'title': r're:Bluesky: ... | If you want to test for subtitles, you can test like so:
```suggestion
'subtitles': {
'en': 'mincount:1',
},
``` | 'uploader_url': 'https://bsky.app/profile/blu3blue.bsky.social',
'channel_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
'channel_url': 'https://bsky.app/profile/did:plc:pzdr5ylumf7vmvwasrpr5bf2',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
'title': 'O... | @@ -0,0 +1,223 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 157 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
parent_uri = traverse_obj(post, ('record', 'reply', 'parent', 'uri'))
author_handle = traverse_obj(post, ('author', 'handle'))
author_did = traverse_obj(post, ('author', 'did'), default='')
yield {
'id': post_uri,
'text': traverse_obj(post,... | We don't need to request the `did` here, do we?
we can just call `getPostThread` with `f'at://{handle}/app.bsky.feed.post/{video_id}'`
For the `getBlob` request, we can use the did from the `getPostThread` response. | 'artists': ['LASERBAT'],
'album_artists': ['LASERBAT'],
'album': 'Hari Nezumi [EP]',
'track': 'Forward to the End',
'title': 'LASERBAT - Forward to the End',
'thumbnail': 'https://f4.bcbits.com/img/a2507705510_5.jpg',
'duration': 228.57... | @@ -0,0 +1,223 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | suggestion | 219 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
'author': traverse_obj(post, ('author', 'displayName')),
'author_id': author_did,
'author_thumbnail': traverse_obj(post, ('author', 'avatar'), expected_type=url_or_none),
'author_url': f'https://bsky.app/profile/{author_handle}',
'author_is... | Since the variable is mandatory
```suggestion
})['thread']
``` | 'upload_date': '20230423',
'timestamp': 1682276040.0,
'release_timestamp': 1682276040.0,
'track_number': 1,
},
'add_ie': ['Bandcamp'],
}, {
'url': 'https://bsky.app/profile/dannybhoix.bsky.social/post/3l6oe5mtr2c2j',
'md5': 'b9e344fdbce... | @@ -0,0 +1,223 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 77 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
if replies := thread_node.get('replies'):
for reply in replies:
yield from self.traverse_replies(reply, root_uri)
if parent := thread_node.get('parent'):
yield from self.traverse_replies(parent, root_uri)
def _real_extract(self, url):
handle, video_id... | You should differentiate between the different kinds of post response. This will break for posts with embeds such as `https://bsky.app/profile/yunayuispink.bsky.social/post/3l7gqcfes742o`
You also don't need to define the complete path always.
```py
traverse_obj(post, ('embed', 'playlist'), ('embed', 'media', 'playl... | }, {
'url': 'https://bsky.app/profile/dannybhoix.bsky.social/post/3l6oe5mtr2c2j',
'md5': 'b9e344fdbce9f2852c668a97efefb105',
'info_dict': {
'id': '3l3vgf77uco2g',
'ext': 'mp4',
'uploader': 'Bluesky',
'uploader_id': 'bsky.app',
'uplo... | @@ -0,0 +1,223 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | bug | 425 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
video_id, query={'handle': handle}).get('did')
getcomments = self.get_param('getcomments', False)
meta = self._download_json(
'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
video_id, headers={'Content-Type': 'application/json'}, query={
... | You can combine `traverse_obj` calls. Please also do this for the info dict below.
```suggestion
**traverse_obj(record_embed, {
'ext': ('video', 'mimeType', {mimetype2ext}),
'width': ('aspectRatio', 'width', {int_or_none}),
'height': ('asp... | 'channel_url': 'https://bsky.app/profile/did:plc:z72i7hdynmk6r22z27h6tvur',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
'title': 'Bluesky now has video! Update your app to versi...',
'alt_title': 'Bluesky video feature announcement',
'description... | @@ -0,0 +1,223 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bsky\.app/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.929 | suggestion | 449 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
from .common import InfoExtractor
from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
class BlueskyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
_TESTS = [{
'url': 'https://bsk... | Imo. Let's also support `at://` urls
```suggestion
_VALID_URL = [
r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>\w+)',
r'at://(?P<handle>[^/]+)/app.bsky.feed.post/(?P<id>\w+)',
]
``` | from .common import InfoExtractor
from ..utils import (
ExtractorError,
format_field,
int_or_none,
mimetype2ext,
orderedSet,
parse_iso8601,
truncate_string,
update_url_query,
url_basename,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(I... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)' | yt_dlp/extractor/bluesky.py | 6 | Python | 0.929 | suggestion | 255 | 31 | 31 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
'ext': 'webm',
'uploader_id': '@yunayuispink',
'live_status': 'not_live',
'view_count': int,
'channel_url': 'https://www.youtube.com/channel/UCPLvXnHa7lTyNoR_dGsU14w',
'thumbnail': 'https://i.ytimg.com/vi_webp/XxK3t_5V3ao/maxresdefault.webp',
... | Let's not. If the data is sporadically missing, this is a bug in the YouTube extractor and should be fixed there.
Tests shouldn't be changed to accommodate for broken extractors. | 'uploader_url': 'https://www.youtube.com/@yunayuispink',
'channel': 'yunayu',
'channel_id': 'UCPLvXnHa7lTyNoR_dGsU14w',
'channel_url': 'https://www.youtube.com/channel/UCPLvXnHa7lTyNoR_dGsU14w',
'thumbnail': 'https://i.ytimg.com/vi_webp/XxK3t_5V3ao/maxresdefau... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ ... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | bug | 179 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
def traverse_replies(self, thread_node, root_uri):
post_uri = traverse_obj(thread_node, ('post', 'uri'))
if post_uri != root_uri:
post = thread_node.get('post')
parent_uri = traverse_obj(post, ('record', 'reply', 'parent', 'uri'))
author_handle = traverse_obj(post... | Would you mind creating a separate PR for the comment extraction code?
I would like to include this extractor in the next release scheduled for this weekend, and this will require some more thought from our side. | 'upload_date': '20241021',
'timestamp': 1729523172,
'like_count': int,
'repost_count': int,
'comment_count': int,
'tags': [],
},
}, {
'url': 'https://bsky.app/profile/purpleicetea.bsky.social/post/3l7gv55dc2o2w',
'info_d... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ ... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.5 | refactor | 213 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
for reply in replies:
yield from self.traverse_replies(reply, root_uri)
if parent := thread_node.get('parent'):
yield from self.traverse_replies(parent, root_uri)
def get_service_endpoint(self, did, video_id):
services = self._download_json(
f'htt... | With no comment extraction for now we could do:
```suggestion
post = self._download_json(
'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
video_id, headers={'Content-Type': 'application/json'}, query={
'uri': f'at://{handle}/app.bsky.feed.post/{video_... | 'channel_url': 'https://bsky.app/profile/did:plc:bjh5ffwya5f53dfy47dezuwx',
'like_count': int,
'channel_id': 'did:plc:bjh5ffwya5f53dfy47dezuwx',
'repost_count': int,
'timestamp': 1729973202,
'tags': [],
'uplo... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ ... | yt_dlp/extractor/bluesky.py | 26 | Python | 1 | refactor | 514 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
**traverse_obj(post, {
'text': ('record', 'text'),
'timestamp': ('record', 'createdAt', {parse_iso8601}),
'author': ('author', 'displayName'),
'author_thumbnail': ('author', 'avatar', {url_or_none}),
}),
... | `identity.foundation` is a third-party thing, right?
Might be better to just do this directly:
```suggestion
def get_service_endpoint(self, did, video_id):
if did.startswith('did:web:'):
url = f'https://{did.split(":")[-1]}/.well-known/did.json'
else:
url = f'https://p... | 'info_dict': {
'id': '3l7gv55dc2o2w',
},
'playlist': [{
'info_dict': {
'id': '3l7gv55dc2o2w',
'ext': 'mp4',
'upload_date': '20241026',
'description': 'One of my favorite videos',
'comment_coun... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ ... | yt_dlp/extractor/bluesky.py | 26 | Python | 1 | suggestion | 624 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
tags = traverse_obj(post, ('record', 'langs'), default=[])
if label_list := post.get('labels'):
tags.extend(label.get('val') for label in label_list)
return {
'id': video_id,
'title': f'{uploader} on Bluesky',
**video_info,
'uploader'... | The remainder I would restructure to have a generic extraction method that can then be called with the separate sub paths:
```suggestion
entries = []
# app.bsky.embed.video.view/app.bsky.embed.external.view
entries.extend(self._extract_videos(post, video_id))
# app.bsky.embed.record... | did = traverse_obj(root, ('author', 'did', {str}))
if did and video_cid:
endpoint = self._get_service_endpoint(did, video_id)
formats.append({
'format_id': 'blob',
'url': update_url_query(
self._BLOB_URL_TMPL.format(endpoint),... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ ... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | refactor | 1,022 | 27 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
meta = self._download_json(
'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
video_id, headers={'Content-Type': 'application/json'}, query={
'uri': f'at://{handle}/app.bsky.feed.post/{video_id}',
'depth': 1000 if getcomments else 0,
... | For the video extract method, this is what I came up with:
```suggestion
@staticmethod
def _build_profile_url(path):
return format_field(path, None, 'https://bsky.app/profile/%s', default=None)
def _extract_videos(self, root, video_id, embed_path='embed', record_path='record', record_subpat... | 'channel_url': 'https://bsky.app/profile/did:plc:6ttyq36rhiyed7wu3ws7dmqj',
'description': r're:(?s)hearing people on twitter say that bluesky .{93}',
'tags': [],
'alt_title': 'md5:9b1ee1937fb3d1a81e932f9ec14d560e',
'uploader': 'T9',
... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
+
+
+class BlueskyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ ... | yt_dlp/extractor/bluesky.py | 26 | Python | 1 | security | 4,596 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
from .common import InfoExtractor
from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none
class BlueskyIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
_TESTS = [{
'url': 'https://bsk... | For my suggestions to work:
```suggestion
from ..utils import (
format_field,
int_or_none,
mimetype2ext,
parse_iso8601,
truncate_string,
update_url_query,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
``` | from .common import InfoExtractor
from ..utils import (
ExtractorError,
format_field,
int_or_none,
mimetype2ext,
orderedSet,
parse_iso8601,
truncate_string,
update_url_query,
url_basename,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(I... | @@ -0,0 +1,362 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none | yt_dlp/extractor/bluesky.py | 2 | Python | 0.929 | suggestion | 271 | 27 | 27 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
'uploader_url': 'https://bsky.app/profile/mary.my.id',
'channel_id': 'did:plc:ia76kvnndjutgedggx2ibrem',
'channel_url': 'https://bsky.app/profile/did:plc:ia76kvnndjutgedggx2ibrem',
'thumbnail': 'https://video.bsky.app/watch/did%3Aplc%3Aia76kvnndjutgedggx2ibrem/bafkreiasce... | Can be fatal inside of traversals
```suggestion
services, ('service', lambda _, x: x['type'] == 'AtprotoPersonalDataServer',
``` | 'like_count': int,
'repost_count': int,
'comment_count': int,
'tags': [],
},
}, {
'url': 'https://bsky.app/profile/purpleicetea.bsky.social/post/3l7gv55dc2o2w',
'info_dict': {
'id': '3l7gv55dc2o2w',
},
'playlist': [{... | @@ -0,0 +1,342 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | suggestion | 143 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
services, ('service', lambda _, x: x.get('type') == 'AtprotoPersonalDataServer',
'serviceEndpoint', {url_or_none}, any)) or 'https://bsky.social'
def _real_extract(self, url):
handle, video_id = self._match_valid_url(url).groups()
post = self._download_json(
... | Let's add one test with a playlist
```suggestion
}, {
'url': 'https://bsky.app/profile/purpleicetea.bsky.social/post/3l7gv55dc2o2w',
'info_dict': {
'id': '3l7gv55dc2o2w',
},
'playlist': [{
'info_dict': {
'id': '3l7gv55dc2o2w',
... | 'tags': [],
'uploader_id': 'purpleicetea.bsky.social',
'title': 'One of my favorite videos',
},
}, {
'info_dict': {
'id': '3l77u64l7le2e',
'ext': 'mp4',
'title': 'hearing people on twitter say... | @@ -0,0 +1,342 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | suggestion | 2,324 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
subtitles.setdefault(sub_data.get('lang') or 'und', []).append({
'url': update_url_query(self._BLOB_URL % endpoint, {'did': did, 'cid': sub_data['file']['ref']['$link']}),
'ext': traverse_obj(sub_data, ('file', 'mimeType', {mimetype2ext})),
})
... | After thinking on it, we should drop the language. This is supposed to be a format key specifying the language of the video/audio track. This is also used for `--embed-metadata`. Instead of overwriting the language, possibly incorrectly, I'd rather just not set it at all.
```suggestion
``` |
@staticmethod
def _build_profile_url(path):
return format_field(path, None, 'https://bsky.app/profile/%s', default=None)
def _extract_videos(self, root, video_id, embed_path='embed', record_path='record', record_subpath='embed'):
embed_path = variadic(embed_path, (str, bytes, dict, set))
... | @@ -0,0 +1,342 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | bug | 292 | 30 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | DrearyWillow |
services, ('service', lambda _, x: x['type'] == 'AtprotoPersonalDataServer',
'serviceEndpoint', {url_or_none}, any)) or 'https://bsky.social'
def _real_extract(self, url):
handle, video_id = self._match_valid_url(url).groups()
post = self._download_json(
... | `if not entries` should suffice. And since we're not returning any metadata, there's no point in allowing an `--ignore-no-formats-error` bypass here:
```suggestion
if not entries:
raise ExtractorError('No video could be found in this post', expected=True)
``` |
def _real_extract(self, url):
handle, video_id = self._match_valid_url(url).group('handle', 'id')
post = self._download_json(
'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
video_id, query={
'uri': f'at://{handle}/app.bsky.feed.post/{video_i... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 1 | refactor | 283 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
'channel_id': 'did:plc:6ttyq36rhiyed7wu3ws7dmqj',
'thumbnail': 'https://video.bsky.app/watch/did%3Aplc%3A6ttyq36rhiyed7wu3ws7dmqj/bafkreih4xf5k22urq5kytjbnlj2djnzmlrqnvotnglmoy35mkpobrwtota/thumbnail.jpg',
'timestamp': 1729731642,
'comment_count': int,
... | this isn't a POST request; is the `content-type` header necessary? what about `accept`?
```suggestion
video_id, query={
``` | 'comment_count': int,
'repost_count': int,
},
}],
}]
_BLOB_URL_TMPL = '{}/xrpc/com.atproto.sync.getBlob'
def _get_service_endpoint(self, did, video_id):
if did.startswith('did:web:'):
url = f'https://{did[8:]}/.well-known/did.json'
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | suggestion | 138 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
entries = []
# app.bsky.embed.video.view/app.bsky.embed.external.view
entries.extend(self._extract_videos(post, video_id))
# app.bsky.embed.recordWithMedia.view
entries.extend(self._extract_videos(
post, video_id, embed_path=('embed', 'media'), record_subpath=('embed'... | long line
```suggestion
if external_uri := traverse_obj(root, (
((*record_path, *record_subpath), embed_path), 'external', 'uri', {url_or_none}, any)):
``` | entries.extend(self._extract_videos(post, video_id))
# app.bsky.embed.recordWithMedia.view
entries.extend(self._extract_videos(
post, video_id, embed_path=('embed', 'media'), record_subpath=('embed', 'media')))
# app.bsky.embed.record.view
if nested_post := traverse_o... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 183 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
},
}, {
'info_dict': {
'id': '3l77u64l7le2e',
'ext': 'mp4',
'title': 'hearing people on twitter say that bluesky isn\'...',
'like_count': int,
'uploader_id': 'thafnine.net',
'uploader_url': 'h... | private method
```suggestion
def _get_service_endpoint(self, did, video_id):
``` | 'id': '3l77u64l7le2e',
'ext': 'mp4',
'title': 'hearing people on twitter say that bluesky isn\'...',
'like_count': int,
'uploader_id': 'thafnine.net',
'uploader_url': 'https://bsky.app/profile/thafnine.net',
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 87 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
'info_dict': {
'id': '3l77u64l7le2e',
'ext': 'mp4',
'title': 'hearing people on twitter say that bluesky isn\'...',
'like_count': int,
'uploader_id': 'thafnine.net',
'uploader_url': 'https://bsky.app/profile/thaf... | could we do this?
```suggestion
url = f'https://{did[8:]}/.well-known/did.json'
``` | 'title': 'hearing people on twitter say that bluesky isn\'...',
'like_count': int,
'uploader_id': 'thafnine.net',
'uploader_url': 'https://bsky.app/profile/thafnine.net',
'upload_date': '20241024',
'channel_url': 'https://bs... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.643 | suggestion | 98 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
'title': 'hearing people on twitter say that bluesky isn\'...',
'like_count': int,
'uploader_id': 'thafnine.net',
'uploader_url': 'https://bsky.app/profile/thafnine.net',
'upload_date': '20241024',
'channel_url': 'https://bs... | adding an errnote to this call might be nice
```suggestion
services = self._download_json(
url, video_id, 'Fetching service endpoint', 'Falling back to bsky.social', fatal=False)
``` | 'uploader_url': 'https://bsky.app/profile/thafnine.net',
'upload_date': '20241024',
'channel_url': 'https://bsky.app/profile/did:plc:6ttyq36rhiyed7wu3ws7dmqj',
'description': r're:(?s)hearing people on twitter say that bluesky .{93}',
'tags... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | suggestion | 206 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
'description': 'md5:dba7d54d6df7e5b79a24d7b287dafbe9',
'tags': [],
'alt_title': 'md5:9b1ee1937fb3d1a81e932f9ec14d560e',
'uploader': 'T9',
'channel_id': 'did:plc:6ttyq36rhiyed7wu3ws7dmqj',
'thumbnail': 'https://video.bsky.app... | ```suggestion
handle, video_id = self._match_valid_url(url).group('handle', 'id')
``` | 'uploader': 'T9',
'channel_id': 'did:plc:6ttyq36rhiyed7wu3ws7dmqj',
'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
'timestamp': 1729731642,
'comment_count': int,
'repost_count': int,
},
}],
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 95 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
from .common import InfoExtractor
from ..utils import (
format_field,
int_or_none,
mimetype2ext,
parse_iso8601,
truncate_string,
update_url_query,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(InfoExtractor):
_VALID_URL = [
r'https?://(... | can we be more strict with handle matching? (maybe the `-` is even unnecessary, i don't see it in any tests)
```suggestion
r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[\w.:%-]+)/post/(?P<id>\w+)',
```
or if not, then let's at least do this:
```suggestion
r'https?://(?:w... | from .common import InfoExtractor
from ..utils import (
ExtractorError,
format_field,
int_or_none,
mimetype2ext,
orderedSet,
parse_iso8601,
truncate_string,
update_url_query,
url_basename,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(I... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 17 | Python | 0.929 | question | 407 | 42 | 42 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
from .common import InfoExtractor
from ..utils import (
format_field,
int_or_none,
mimetype2ext,
parse_iso8601,
truncate_string,
update_url_query,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(InfoExtractor):
_VALID_URL = [
r'https?://(... | same question here, and escape the dots
```suggestion
r'at://(?P<handle>[\w.:%-]+)/app\.bsky\.feed\.post/(?P<id>\w+)',
```
| from .common import InfoExtractor
from ..utils import (
ExtractorError,
format_field,
int_or_none,
mimetype2ext,
orderedSet,
parse_iso8601,
truncate_string,
update_url_query,
url_basename,
url_or_none,
variadic,
)
from ..utils.traversal import traverse_obj
class BlueskyIE(I... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 18 | Python | 0.857 | security | 135 | 43 | 43 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
'uploader_id': 'purpleicetea.bsky.social',
'title': 'One of my favorite videos',
},
}, {
'info_dict': {
'id': '3l77u64l7le2e',
'ext': 'mp4',
'title': 'hearing people on twitter say that bluesky isn\'...',
... | ```suggestion
_BLOB_URL_TMPL = '%s/xrpc/com.atproto.sync.getBlob'
``` | }, {
'info_dict': {
'id': '3l77u64l7le2e',
'ext': 'mp4',
'title': 'hearing people on twitter say that bluesky isn\'...',
'like_count': int,
'uploader_id': 'thafnine.net',
'uploader_url': 'https://bsky.app... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 75 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
@staticmethod
def _build_profile_url(path):
return format_field(path, None, 'https://bsky.app/profile/%s', default=None)
def _extract_videos(self, root, video_id, embed_path='embed', record_path='record', record_subpath='embed'):
embed_path = variadic(embed_path, (str, bytes, dict, set))
... | ```suggestion
'url': update_url_query(
self._BLOB_URL_TMPL % endpoint, {'did': did, 'cid': video_cid}),
``` | @staticmethod
def _build_profile_url(path):
return format_field(path, None, 'https://bsky.app/profile/%s', default=None)
def _extract_videos(self, root, video_id, embed_path='embed', record_path='record', record_subpath='embed'):
embed_path = variadic(embed_path, (str, bytes, dict, set))
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | suggestion | 146 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
playlist, video_id, 'mp4', m3u8_id='hls', fatal=False)
else:
return entries
video_cid = traverse_obj(
root, (*embed_path, 'cid', {str}),
(*record_path, *record_subpath, 'video',... | line was too long before the `_BLOB_URL_TMPL` name change
```suggestion
'url': update_url_query(
self._BLOB_URL_TMPL % endpoint, {'did': did, 'cid': sub_data['file']['ref']['$link']}),
``` | if playlist := traverse_obj(root, (*embed_path, 'playlist', {url_or_none})):
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
playlist, video_id, 'mp4', m3u8_id='hls', fatal=False)
else:
return entries
video_cid = traverse_obj(
r... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.857 | refactor | 236 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
if did and video_cid:
endpoint = self.get_service_endpoint(did, video_id)
formats.append({
'format_id': 'blob',
'url': update_url_query(self._BLOB_URL % endpoint, {'did': did, 'cid': video_cid}),
**traverse_obj(root, (*embed_path, 'aspectRa... | ```suggestion
'id': ('uri', {lambda x: x.split('/')[-1]}, filter),
```
or maybe the `url_basename` util would be nice to use here? | (*record_path, *record_subpath, 'video', 'ref', '$link', {str}))
did = traverse_obj(root, ('author', 'did', {str}))
if did and video_cid:
endpoint = self._get_service_endpoint(did, video_id)
formats.append({
'format_id': 'blob',
'url'... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | question | 151 | 45 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
})),
})
for sub_data in traverse_obj(root, (
*record_path, *record_subpath, 'captions', lambda _, v: v['file']['ref']['$link'])):
subtitles.setdefault(sub_data.get('lang') or 'und', []).append({
'url': update_url_query(self.... | could use `orderedSet` from utils
```suggestion
'tags': ('labels', ..., 'val', {str}, all, {orderedSet}),
``` | 'height': ('height', {int_or_none}),
})),
**traverse_obj(root, (*record_path, *record_subpath, 'video', {
'filesize': ('size', {int_or_none}),
'ext': ('mimeType', {mimetype2ext}),
})),
})
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | suggestion | 128 | 33 | 42 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
*record_path, *record_subpath, 'captions', lambda _, v: v['file']['ref']['$link'])):
subtitles.setdefault(sub_data.get('lang') or 'und', []).append({
'url': update_url_query(self._BLOB_URL % endpoint, {'did': did, 'cid': sub_data['file']['ref']['$link']}),
... | note to self: `truncate_string` should have `partial_application`
```suggestion
'title': (*record_path, 'text', {truncate_string(left=50)}),
``` | 'filesize': ('size', {int_or_none}),
'ext': ('mimeType', {mimetype2ext}),
})),
})
for sub_data in traverse_obj(root, (
*record_path, *record_subpath, 'captions', lambda _, v: v['file']['ref']['$link'])):
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.786 | suggestion | 163 | 30 | 39 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
})
for sub_data in traverse_obj(root, (
*record_path, *record_subpath, 'captions', lambda _, v: v['file']['ref']['$link'])):
subtitles.setdefault(sub_data.get('lang') or 'und', []).append({
'url': update_url_query(self._BLOB_URL % endpoint,... | line too long
```suggestion
'age_limit': (
'labels', ..., 'val', {lambda x: 18 if x in ('sexual', 'porn', 'graphic-media') else None}, any),
``` | })),
**traverse_obj(root, (*record_path, *record_subpath, 'video', {
'filesize': ('size', {int_or_none}),
'ext': ('mimeType', {mimetype2ext}),
})),
})
for sub_data in traverse_obj(root, (
... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.714 | refactor | 184 | 32 | 41 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
if len(entries) == 1:
return entries[0]
return self.playlist_result(entries, video_id)
@staticmethod
def _build_profile_url(path):
return format_field(path, None, 'https://bsky.app/profile/%s', default=None)
def _extract_videos(self, root, video_id, embed_path='embed', ... | ```suggestion
endpoint = self._get_service_endpoint(did, video_id)
``` | return entries[0]
return self.playlist_result(entries, video_id)
@staticmethod
def _build_profile_url(path):
return format_field(path, None, 'https://bsky.app/profile/%s', default=None)
def _extract_videos(self, root, video_id, embed_path='embed', record_path='record', record_s... | @@ -0,0 +1,379 @@
+from .common import InfoExtractor
+from ..utils import (
+ format_field,
+ int_or_none,
+ mimetype2ext,
+ parse_iso8601,
+ truncate_string,
+ update_url_query,
+ url_or_none,
+ variadic,
+)
+from ..utils.traversal import traverse_obj
+
+
+class BlueskyIE(InfoExtractor):
+ _... | yt_dlp/extractor/bluesky.py | 26 | Python | 0.571 | suggestion | 84 | 51 | 51 | false | [ie/Bluesky] Add extractor | 11,055 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DrearyWillow |
'm4a': ('m4a', 'aac', ('-bsf:a', 'aac_adtstoasc')),
'opus': ('opus', 'libopus', ()),
'vorbis': ('ogg', 'libvorbis', ()),
'flac': ('flac', 'flac', ()),
'alac': ('m4a', None, ('-acodec', 'alac')),
'wav': ('wav', None, ('-f', 'wav')),
}
def create_mapping_re(supported):
return re.compile(r'{0... | This is not _strictly_ required as the logic in `convert_thumbnail` does the real work, but it does provide a nice message to the user so I thought I'd add it.
Just let me know if you'd like this handled differently 🤙 | 'm4a': ('m4a', 'aac', ('-bsf:a', 'aac_adtstoasc')),
'opus': ('opus', 'libopus', ()),
'vorbis': ('ogg', 'libvorbis', ()),
'flac': ('flac', 'flac', ()),
'alac': ('m4a', None, ('-acodec', 'alac')),
'wav': ('wav', None, ('-f', 'wav')),
}
def create_mapping_re(supported):
return re.compile(r'{0... | @@ -76,6 +76,8 @@ def resolve_mapping(source, mapping):
target = kv[-1].strip()
if target == source:
return target, f'already is in target format {source}'
+ if target == 'none':
+ return source, 'explicitly disabled' | yt_dlp/postprocessor/ffmpeg.py | 26 | Python | 0.786 | suggestion | 221 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | kieraneglin | kieraneglin |
else:
opts = ['-c', 'copy', '-bsf', 'setts=ts=TS-STARTPTS']
self._fixup('Fixing frame timestamp', info['filepath'], [*opts, *self.stream_copy_opts(False), '-ss', self.trim])
return [], info
class FFmpegCopyStreamPP(FFmpegFixupPostProcessor):
MESSAGE = 'Copying stream'
@Pos... | This is a slight deviation from convention since there were other modules using `FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS` (like you'll see in `ModifyChaptersPP`'s `_get_supported_subs` method below).
I didn't want to imply that `none` was a valid subtitle extension, so I split it out into two constants - one for ... | self._fixup('Fixing frame timestamp', info['filepath'], [*opts, *self.stream_copy_opts(False), '-ss', self.trim])
return [], info
class FFmpegCopyStreamPP(FFmpegFixupPostProcessor):
MESSAGE = 'Copying stream'
@PostProcessor._restrict_to(images=False)
def run(self, info):
self._fix... | @@ -947,7 +949,8 @@ class FFmpegFixupDuplicateMoovPP(FFmpegCopyStreamPP):
class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor):
- SUPPORTED_EXTS = MEDIA_EXTENSIONS.subtitles
+ SUBTITLE_EXTS = MEDIA_EXTENSIONS.subtitles
+ SUPPORTED_EXTS = (*SUBTITLE_EXTS, 'none') | yt_dlp/postprocessor/ffmpeg.py | 26 | Python | 0.571 | style | 366 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | kieraneglin | kieraneglin |
['-ss', str(chapter['start_time']),
'-t', str(chapter['end_time'] - chapter['start_time'])])
@PostProcessor._restrict_to(images=False)
def run(self, info):
self._fixup_chapters(info)
chapters = info.get('chapters') or []
if not chapters:
self.to_scre... | Same story here, except this isn't actually used anywhere else. I thought it'd still be best to mirror it anyway to keep things consistent | chapters = info.get('chapters') or []
if not chapters:
self.to_screen('Chapter information is unavailable')
return [], info
in_file = info['filepath']
if self._force_keyframes and len(chapters) > 1:
in_file = self.force_keyframes(in_file, (c['start_ti... | @@ -1070,7 +1076,8 @@ def run(self, info):
class FFmpegThumbnailsConvertorPP(FFmpegPostProcessor):
- SUPPORTED_EXTS = MEDIA_EXTENSIONS.thumbnails
+ THUMBNAIL_EXTS = MEDIA_EXTENSIONS.thumbnails
+ SUPPORTED_EXTS = (*THUMBNAIL_EXTS, 'none') | yt_dlp/postprocessor/ffmpeg.py | 26 | Python | 0.429 | suggestion | 138 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | kieraneglin | kieraneglin |
@classmethod
def is_webp(cls, path):
deprecation_warning(f'{cls.__module__}.{cls.__name__}.is_webp is deprecated')
return imghdr.what(path) == 'webp'
def fixup_webp(self, info, idx=-1):
thumbnail_filename = info['thumbnails'][idx]['filepath']
_, thumbnail_ext = os.path.split... | It's hard work but someone's gotta do it 😎 | _, thumbnail_ext = os.path.splitext(thumbnail_filename)
if thumbnail_ext:
if thumbnail_ext.lower() != '.webp' and imghdr.what(thumbnail_filename) == 'webp':
self.to_screen(f'Correcting thumbnail "{thumbnail_filename}" extension to webp')
webp_filename = replac... | @@ -1101,6 +1108,9 @@ def _options(target_ext):
yield from ('-bsf:v', 'mjpeg2jpeg')
def convert_thumbnail(self, thumbnail_filename, target_ext):
+ if target_ext == 'none':
+ return thumbnail_filename | yt_dlp/postprocessor/ffmpeg.py | 26 | Python | 0.071 | suggestion | 43 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | kieraneglin | kieraneglin |
warnings.append(
'Using allow-unsafe-ext opens you up to potential attacks. '
'Use with great care!')
_UnsafeExtensionError.sanitize_extension = lambda x, prepend=False: x
return warnings, deprecation_warnings
def get_postprocessors(opts):
yield from opts.add_postproce... | I could also approach this with something like:
```python
if opts.convertsubtitles == 'none':
opts.convertsubtitles = None
```
earlier in the file. This would also remove the need for my regex changes, but arguably it makes the code harder to follow. Let me know your preference! | if opts.ap_username is not None and opts.ap_password is None:
opts.ap_password = getpass.getpass('Type TV provider account password and press [Return]: ')
# compat option changes global state destructively; only allow from cli
if 'allow-unsafe-ext' in opts.compat_opts:
warnings.append(
... | @@ -621,13 +621,13 @@ def get_postprocessors(opts):
'api': opts.sponsorblock_api,
'when': 'after_filter',
}
- if opts.convertsubtitles:
+ if opts.convertsubtitles and opts.convertsubtitles != 'none': | yt_dlp/__init__.py | 26 | Python | 0.857 | suggestion | 290 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | kieraneglin | kieraneglin |
postproc.add_option(
'--no-exec',
action='store_const', dest='exec_cmd', const={},
help='Remove any previously defined --exec')
postproc.add_option(
'--exec-before-download', metavar='CMD',
action='append', dest='exec_before_dl_cmd',
help=optparse.SUPPRESS_HELP)
... | tacking `none` on to the end of the extension list is misleading here IMO, since the following line then implies you can use it like `--convert-thumb "jpg>png/webp>none"`
```suggestion
f'(currently supported: {", ".join(sorted(FFmpegThumbnailsConvertorPP.SUPPORTED_EXTS))}). '
'You can specify... | postproc.add_option(
'--no-exec',
action='store_const', dest='exec_cmd', const={},
help='Remove any previously defined --exec')
postproc.add_option(
'--exec-before-download', metavar='CMD',
action='append', dest='exec_before_dl_cmd',
help=optparse.SUPPRESS_HELP)
... | @@ -1725,14 +1725,15 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
'--convert-subs', '--convert-sub', '--convert-subtitles',
metavar='FORMAT', dest='convertsubtitles', default=None,
help=(
- 'Convert the subtitles to another format (currently supported: {}) '... | yt_dlp/options.py | 26 | Python | 0.857 | suggestion | 479 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kieraneglin |
metavar='[WHEN:]CMD', dest='exec_cmd', **when_prefix('after_move'),
help=(
'Execute a command, optionally prefixed with when to execute it, separated by a ":". '
'Supported values of "WHEN" are the same as that of --use-postprocessor (default: after_move). '
'Same syn... | ```suggestion
f'(currently supported: {", ".join(sorted(FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS))}). '
'Use "--convert-subs none" to disable conversion (default) (Alias: --convert-subtitles)'))
``` | metavar='[WHEN:]CMD', dest='exec_cmd', **when_prefix('after_move'),
help=(
'Execute a command, optionally prefixed with when to execute it, separated by a ":". '
'Supported values of "WHEN" are the same as that of --use-postprocessor (default: after_move). '
'Same syn... | @@ -1725,14 +1725,15 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
'--convert-subs', '--convert-sub', '--convert-subtitles',
metavar='FORMAT', dest='convertsubtitles', default=None,
help=(
- 'Convert the subtitles to another format (currently supported: {}) '... | yt_dlp/options.py | 26 | Python | 0.857 | suggestion | 226 | 51 | 51 | false | [option parser] Add conversion negation for thumbnails and subtitles | 11,066 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | kieraneglin |
import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
smuggle_url,
traverse_obj,
try_call,
unsmuggle_url,
)
class LiTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/]+/watch/|vod/[^/]+/content\.do\?content_id=)(?P... | do `/promo` URLs no longer exist?
```suggestion
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/[^/?#]+/content\.do\?content_id=)(?P<id>[\w-]+)'
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
join_nonempty,
smuggle_url,
traverse_obj,
try_call,
unsmuggle_url,
urljoin,
)
class LiTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/... | @@ -12,36 +13,37 @@
class LiTVIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:vod|promo)/[^/]+/(?:content\.do)?\?.*?\b(?:content_)?id=(?P<id>[^&]+)'
+ _VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/]+/watch/|vod/[^/]+/content\.do\?content_id=)(?P<id>[a-z\-A-Z0-9]+)' | yt_dlp/extractor/litv.py | 16 | Python | 0.714 | suggestion | 174 | 41 | 41 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
'ext': 'mp4',
'title': '芈月傳第1集 霸星芈月降世楚國',
'description': '楚威王二年,太史令唐昧夜觀星象,發現霸星即將現世。王后得知霸星的預言後,想盡辦法不讓孩子順利出生,幸得莒姬相護化解危機。沒想到眾人期待下出生的霸星卻是位公主,楚威王對此失望至極。楚王后命人將女嬰丟棄河中,居然奇蹟似的被少司命像攔下,楚威王認為此女非同凡響,為她取名芈月。',
},
'skip': 'No longer exists',
}]
def _extract_playlist(self, p... | use `self._search_nextjs_data()` | 'title': '芈月傳第1集 霸星芈月降世楚國',
'description': '楚威王二年,太史令唐昧夜觀星象,發現霸星即將現世。王后得知霸星的預言後,想盡辦法不讓孩子順利出生,幸得莒姬相護化解危機。沒想到眾人期待下出生的霸星卻是位公主,楚威王對此失望至極。楚王后命人將女嬰丟棄河中,居然奇蹟似的被少司命像攔下,楚威王認為此女非同凡響,為她取名芈月。',
},
'skip': 'No longer exists',
}]
def _extract_playlist(self, playlist_data, content_type... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.286 | suggestion | 32 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
}]
def _extract_playlist(self, playlist_data, content_type):
all_episodes = [
self.url_result(smuggle_url(
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in tra... | ```suggestion
program_info = traverse_obj(vod_data, ('props', 'pageProps', 'programInformation', {dict})) or {}
```
I would also maybe move `['props']['pageProps']` to the `_search_nextjs_data()` call above since every time we access `vod_data` we traverse that base path |
def _extract_playlist(self, playlist_data, content_type):
all_episodes = [
self.url_result(smuggle_url(
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_o... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.857 | suggestion | 284 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
all_episodes = [
self.url_result(smuggle_url(
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_obj(playlist_data, ('seasons', ..., 'episodes', lambda _, v: v['... | ```suggestion
playlist_data = traverse_obj(vod_data, ('props', 'pageProps', 'seriesTree'))
if playlist_data and self._yes_playlist(program_info.get('series_id'), video_id, smuggled_data):
``` | self.url_result(smuggle_url(
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_obj(playlist_data, ('seasons', ..., 'episodes', lambda _, v: v['content_id']))]
... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.786 | suggestion | 210 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_obj(playlist_data, ('seasons', ..., 'episodes', lambda _, v: v['content_id']))]
return self.playlist_result(all_episodes,... | ```suggestion
return self._extract_playlist(playlist_data, program_info.get('content_type'))
``` | {'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_obj(playlist_data, ('seasons', ..., 'episodes', lambda _, v: v['content_id']))]
return self.playlist_result(all_episodes, playlist_data['content_id'], playlist_data.get('title'))
def _real_ext... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.929 | refactor | 110 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
url, smuggled_data = unsmuggle_url(url, {})
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
vod_data = self._parse_json(self._search_regex(
r'<script\s+id="__NEXT_DATA__"[^>]*>(.+)</script>', webpage, 'VOD data', default='{}'),
vi... | I think it's more readable to reverse the if/else order and check `if asset_id:` first:
```suggestion
asset_id = traverse_obj(program_info, ('assets', 0, 'asset_id', {str}))
if asset_id: # This is a VOD
media_type = 'vod'
else: # This is a live stream
asset_id = p... | video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
vod_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']
program_info = traverse_obj(vod_data, ('programInformation', {dict})) or {}
playlist_data = traverse_obj(vod_data, ('series... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 1 | refactor | 513 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
vod_data = self._parse_json(self._search_regex(
r'<script\s+id="__NEXT_DATA__"[^>]*>(.+)</script>', webpage, 'VOD data', default='{}'),
video_id)
program_info = traverse_obj(
vod_data,
('props', 'pageProps', 'programInformation'),
default={}, ... | same thing here about `if/else` order
```suggestion
puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
if puid:
endpoint = 'get-urls'
else:
puid = str(uuid.uuid4())
endpoint = 'get-urls-no-auth'
``` | if playlist_data and self._yes_playlist(program_info.get('series_id'), video_id, smuggled_data):
return self._extract_playlist(playlist_data, program_info.get('content_type'))
asset_id = traverse_obj(program_info, ('assets', 0, 'asset_id', {str}))
if asset_id: # This is a VOD
... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.786 | security | 296 | 51 | 46 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
vod_data,
('props', 'pageProps', 'programInformation'),
default={}, expected_type=dict)
series_id = program_info.get('series_id')
playlist_data = traverse_obj(vod_data, ('props', 'pageProps', 'seriesTree'))
if playlist_data is not None and self._yes_playlist(s... | inline the payload in the request call
```suggestion
video_data = self._download_json(
f'https://www.litv.tv/api/{endpoint}', video_id,
data=json.dumps({'AssetId': asset_id, 'MediaType': media_type, 'puid': puid}).encode(),
headers={'Content-Type': 'application/json'})
... | media_type = 'vod'
else: # This is a live stream
asset_id = program_info['content_id']
media_type = program_info['content_type']
puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
if puid:
endpoint = 'get-urls'
... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.929 | suggestion | 323 | 51 | 41 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
default={}, expected_type=dict)
series_id = program_info.get('series_id')
playlist_data = traverse_obj(vod_data, ('props', 'pageProps', 'seriesTree'))
if playlist_data is not None and self._yes_playlist(series_id, video_id, smuggled_data):
content_type = program_info.get(... | I like to use `traverse_obj` for error handling since the response might not even be a dict
```suggestion
if error := traverse_obj(video_data, ('error', {dict})):
``` | asset_id = program_info['content_id']
media_type = program_info['content_type']
puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
if puid:
endpoint = 'get-urls'
else:
puid = str(uuid.uuid4())
endpoint = 'g... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.929 | suggestion | 177 | 51 | 39 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
series_id = program_info.get('series_id')
playlist_data = traverse_obj(vod_data, ('props', 'pageProps', 'seriesTree'))
if playlist_data is not None and self._yes_playlist(series_id, video_id, smuggled_data):
content_type = program_info.get('content_type')
return self._ext... | ```suggestion
error_msg = traverse_obj(error, ('message', {str}))
``` | media_type = program_info['content_type']
puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
if puid:
endpoint = 'get-urls'
else:
puid = str(uuid.uuid4())
endpoint = 'get-urls-no-auth'
video_data = self._downlo... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.714 | suggestion | 83 | 51 | 38 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
playlist_data = traverse_obj(vod_data, ('props', 'pageProps', 'seriesTree'))
if playlist_data is not None and self._yes_playlist(series_id, video_id, smuggled_data):
content_type = program_info.get('content_type')
return self._extract_playlist(playlist_data, content_type)
... | ```suggestion
if error_msg and 'OutsideRegionError' in error_msg:
``` | puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
if puid:
endpoint = 'get-urls'
else:
puid = str(uuid.uuid4())
endpoint = 'get-urls-no-auth'
video_data = self._download_json(
f'https://www.litv.tv/api/{endpoi... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.714 | suggestion | 83 | 51 | 37 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
content_type = program_info.get('content_type')
return self._extract_playlist(playlist_data, content_type)
asset_id = traverse_obj(program_info, ('assets', 0, 'asset_id'))
if asset_id is None: # live stream case
asset_id = program_info.get('content_id')
... | ```suggestion
elif error_msg:
``` | endpoint = 'get-urls'
else:
puid = str(uuid.uuid4())
endpoint = 'get-urls-no-auth'
video_data = self._download_json(
f'https://www.litv.tv/api/{endpoint}', video_id,
data=json.dumps({'AssetId': asset_id, 'MediaType': media_type, 'puid': puid}).... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.571 | suggestion | 47 | 51 | 35 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
else: # vod case
media_type = 'vod'
puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value)
if puid is None:
puid = str(uuid.uuid4())
endpoint = 'get-urls-no-auth'
else:
endpoint = 'get-urls'
payload = {'As... | we can remove this and have it be fatal below, since the request will fail anyway without it
```suggestion
``` | headers={'Content-Type': 'application/json'})
if error := traverse_obj(video_data, ('error', {dict})):
error_msg = traverse_obj(error, ('message', {str}))
if error_msg and 'OutsideRegionError' in error_msg:
self.raise_geo_restricted('This video is available i... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.786 | bug | 112 | 51 | 28 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
if puid is None:
puid = str(uuid.uuid4())
endpoint = 'get-urls-no-auth'
else:
endpoint = 'get-urls'
payload = {'AssetId': asset_id, 'MediaType': media_type, 'puid': puid}
video_data = self._download_json(
f'https://www.litv.tv/api/{endpoint... | inline the dict access here, and we can remove the `entry_protocol` param since `m3u8_native` is the default
```suggestion
video_data['result']['AssetURLs'][0], video_id, 'mp4', m3u8_id='hls')
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
join_nonempty,
smuggle_url,
traverse_obj,
try_call,
unsmuggle_url,
urljoin,
)
class LiTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.857 | suggestion | 211 | 48 | 118 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
if video_data.get('error'):
error_msg = traverse_obj(video_data, ('error', 'message'))
if error_msg == 'OutsideRegionError: ':
self.raise_geo_restricted('This video is available in Taiwan only')
if error_msg:
raise ExtractorError(f'{self.IE_NAM... | I would inline all this below in the return
import `functools`, and import `join_nonempty` and `urljoin` from `..utils`
```py
return {
'id': video_id,
'formats': formats,
'title': join_nonempty('title', 'secondary_mark', delim='', from_dict=program_info),
... | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
join_nonempty,
smuggle_url,
traverse_obj,
try_call,
unsmuggle_url,
urljoin,
)
class LiTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/... | @@ -68,73 +70,63 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.786 | style | 675 | 37 | 118 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
'description': '楚威王二年,太史令唐昧夜觀星象,發現霸星即將現世。王后得知霸星的預言後,想盡辦法不讓孩子順利出生,幸得莒姬相護化解危機。沒想到眾人期待下出生的霸星卻是位公主,楚威王對此失望至極。楚王后命人將女嬰丟棄河中,居然奇蹟似的被少司命像攔下,楚威王認為此女非同凡響,為她取名芈月。',
},
'skip': 'No longer exists',
}]
def _extract_playlist(self, playlist_data, content_type):
all_episodes = [
... | ```suggestion
vod_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']
program_info = traverse_obj(vod_data, ('programInformation', {dict})) or {}
playlist_data = traverse_obj(vod_data, ('seriesTree', {dict}))
if playlist_data and self._yes_playlist(program_info.g... |
def _extract_playlist(self, playlist_data, content_type):
all_episodes = [
self.url_result(smuggle_url(
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_o... | @@ -68,81 +73,52 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.786 | suggestion | 367 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
self._URL_TEMPLATE % (content_type, episode['content_id']),
{'force_noplaylist': True})) # To prevent infinite recursion
for episode in traverse_obj(playlist_data, ('seasons', ..., 'episodes', lambda _, v: v['content_id']))]
return self.playlist_result(all_episodes,... | aren't the comments wrong now? shouldn't it be:
```suggestion
if asset_id: # This is a VOD
media_type = 'vod'
else: # This is a live stream
asset_id = program_info['content_id']
media_type = program_info['content_type']
``` | return self.playlist_result(all_episodes, playlist_data['content_id'], playlist_data.get('title'))
def _real_extract(self, url):
url, smuggled_data = unsmuggle_url(url, {})
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
vod_data = self._search... | @@ -68,81 +73,52 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 1 | bug | 284 | 51 | 51 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
video_data = self._download_json(
f'https://www.litv.tv/api/{endpoint}', video_id,
data=json.dumps({'AssetId': asset_id, 'MediaType': media_type, 'puid': puid}).encode(),
headers={'Content-Type': 'application/json'})
if error := traverse_obj(video_data, ('error', {di... | since you merged master into this branch, we can now do this:
```suggestion
'thumbnail': ('picture', {urljoin('https://p-cdnstatic.svc.litv.tv/')}),
``` | import json
import uuid
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
join_nonempty,
smuggle_url,
traverse_obj,
try_call,
unsmuggle_url,
urljoin,
)
class LiTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/... | @@ -68,81 +73,52 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- if self._search_regex(
- r'(?i)<meta\s[^>]*http-equiv="refresh"\s[^>]*content="[0-9]+;\s*url=https://www\.litv\.tv/"',
- webpage, 'meta refresh redirect', default=False, ... | yt_dlp/extractor/litv.py | 26 | Python | 0.714 | suggestion | 171 | 31 | 118 | false | [ie/litv] Fix extractor + bypass georestriction | 11,071 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | jiru |
items = traverse_obj(data, (
'media', lambda _, v: v.get('type') == 'video' or v['metadata']['is_animated'],
'id', {lambda x: str_or_none(x) or None}))
# if a gallery with exactly one video, apply album metadata to video
media_id = None
i... | ```suggestion
_VALID_URL = r'https?://(?:i\.)?imgur\.com/(?:gallery|(?:t(?:opic)?|r)/[^/?#]+)/(?:[^/?#]+-)?(?P<id>[a-zA-Z0-9]+)'
``` | gallery_id = self._match_id(url)
data = self._call_api('albums', gallery_id, fatal=False, expected_status=404)
info = traverse_obj(data, {
'title': ('title', {lambda x: strip_or_none(x) or None}),
'description': ('description', {self.get_description}),
})
... | @@ -252,7 +259,7 @@ def _real_extract(self, url):
class ImgurGalleryIE(ImgurGalleryBaseIE):
IE_NAME = 'imgur:gallery'
- _VALID_URL = r'https?://(?:i\.)?imgur\.com/(?:gallery|(?:t(?:opic)?|r)/[^/?#]+)/(?P<id>[a-zA-Z0-9]+)'
+ _VALID_URL = r'https?://(?:i\.)?imgur\.com/(?:gallery|(?:t(?:opic)?|r)/(?:[^/?#]+-... | yt_dlp/extractor/imgur.py | 26 | Python | 0.714 | suggestion | 138 | 51 | 51 | false | [ie/imgur] Support new URL format | 11,075 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Deer-Spangle |
video_id = str(player_data['contentId'])
title = player_data.get('title') or self._og_search_title(webpage, fatal=False) or \
self._html_search_regex(r'<h\d+\b[^>]+\bclass="article_title">([^<]+)<', webpage, 'title')
upload_date = unified_strdate(
'{}-{}-{}'.format(mobj.... | As far as I can tell, the site no longer uses wowza. So let's just inline:
```py
'formats': self._extract_m3u8_formats(playlist_url, video_id),
```
Realistically, this whole extractor needs to be rewritten, but you don't need to do that as part of this PR. | 'upload_date': '20230909',
'thumbnail': 'https://petofilive.hu/wp-content/uploads/sites/4/2023/09/Clipboard11-2.jpg',
},
'skip': 'Webpage redirects to video list page',
}]
def _real_extract(self, url):
mobj = self._match_valid_url(url)
display_id = mobj.g... | @@ -144,7 +144,10 @@ def _real_extract(self, url):
raise ExtractorError('Unable to extract playlist url')
formats = self._extract_wowza_formats(
- playlist_url, video_id, skip_protocols=['f4m', 'smil', 'dash'])
+ playlist_url,
+ video_id,
+ m3u8_custom... | yt_dlp/extractor/mediaklikk.py | 26 | Python | 0.857 | refactor | 260 | 36 | 47 | false | [ie/mediaklikk] Fix extractor | 11,083 | yt-dlp/yt-dlp | 132,642 | Python | seproDev | szantnerb |
player_data_str = self._html_search_regex(
r'mtva_player_manager\.player\(document.getElementById\(.*\),\s?(\{.*\}).*\);', webpage, 'player data')
player_data = self._parse_json(player_data_str, display_id, urllib.parse.unquote)
video_id = str(player_data['contentId'])
title... | we could do this pre-emptively
```suggestion
formats, subtitles = self._extract_m3u8_formats_and_subtitles(playlist_url, video_id)
```
and then make sure to return `subtitles` below | 'id': '6713233',
'title': 'Futball Fesztivál a Margitszigeten',
'display_id': 'futball-fesztival-a-margitszigeten',
'ext': 'mp4',
'upload_date': '20230909',
'thumbnail': 'https://petofilive.hu/wp-content/uploads/sites/4/2023/09/Clipboard11-2.jpg',
... | @@ -143,8 +143,7 @@ def _real_extract(self, url):
if not playlist_url:
raise ExtractorError('Unable to extract playlist url')
- formats = self._extract_wowza_formats(
- playlist_url, video_id, skip_protocols=['f4m', 'smil', 'dash'])
+ formats = self._extract_m3u8_formats... | yt_dlp/extractor/mediaklikk.py | 26 | Python | 0.786 | refactor | 193 | 36 | 51 | false | [ie/mediaklikk] Fix extractor | 11,083 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | szantnerb |
]
def _extract_formats_and_subs(self, video_id):
media_info = self._call_api(video_id, codename=video_id)
formats, subtitles = [], {}
for media in traverse_obj(media_info, (
'MediaFiles', lambda _, v: v['RoleCodename'] == 'main',
'Formats', lambda _, v: u... | ```suggestion
return formats, subtitles
``` | ]
def _extract_formats_and_subs(self, video_id):
media_info = self._call_api(video_id, codename=video_id)
formats, subtitles = [], {}
for media in traverse_obj(media_info, (
'MediaFiles', lambda _, v: v['RoleCodename'] == 'main',
'Formats', lambda _, v: u... | @@ -74,27 +75,26 @@ class ERTFlixCodenameIE(ERTFlixBaseIE):
def _extract_formats_and_subs(self, video_id):
media_info = self._call_api(video_id, codename=video_id)
- formats, subs = [], {}
- for media_file in try_get(media_info, lambda x: x['MediaFiles'], list) or []:
- for medi... | yt_dlp/extractor/ertgr.py | 26 | Python | 0.571 | suggestion | 53 | 51 | 51 | false | [ie/ertgr] Fix video extraction | 11,091 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | seproDev |
from ..compat import compat_os_name
from ..utils import (
PostProcessingError,
XAttrMetadataError,
XAttrUnavailableError,
hyphenate_date,
write_xattr,
)
class XAttrMetadataPP(PostProcessor):
"""Set extended attributes on downloaded file (if xattr support is found)
More info about extended... | I know this is old/dead code but let's move this down to the end of the dict
```suggestion
``` | from ..compat import compat_os_name
from ..utils import (
PostProcessingError,
XAttrMetadataError,
XAttrUnavailableError,
hyphenate_date,
write_xattr,
)
class XAttrMetadataPP(PostProcessor):
"""Set extended attributes on downloaded file (if xattr support is found)
More info about extended... | @@ -29,35 +29,38 @@ class XAttrMetadataPP(PostProcessor):
# 'user.xdg.comment': 'description', | yt_dlp/postprocessor/xattrpp.py | 26 | Python | 0.643 | refactor | 96 | 51 | 51 | false | Make extended attribute writing more robust against filesystem limits. | 11,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | eric321 |
class XAttrMetadataPP(PostProcessor):
"""Set extended attributes on downloaded file (if xattr support is found)
More info about extended attributes for media:
http://freedesktop.org/wiki/CommonExtendedAttributes/
http://www.freedesktop.org/wiki/PhreedomDraft/
http://dublincore.org/doc... | ```suggestion
'user.dublincore.description': 'description',
# 'user.xdg.comment': 'description',
``` |
class XAttrMetadataPP(PostProcessor):
"""Set extended attributes on downloaded file (if xattr support is found)
More info about extended attributes for media:
http://freedesktop.org/wiki/CommonExtendedAttributes/
http://www.freedesktop.org/wiki/PhreedomDraft/
http://dublincore.org/doc... | @@ -29,35 +29,38 @@ class XAttrMetadataPP(PostProcessor):
# 'user.xdg.comment': 'description',
'user.dublincore.title': 'title',
'user.dublincore.date': 'upload_date',
- 'user.dublincore.description': 'description',
'user.dublincore.contributor': 'uploader',
'user.dub... | yt_dlp/postprocessor/xattrpp.py | 26 | Python | 0.786 | suggestion | 119 | 51 | 51 | false | Make extended attribute writing more robust against filesystem limits. | 11,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | eric321 |
'user.dublincore.contributor': 'uploader',
'user.dublincore.format': 'format',
# We do this last because it may get us close to the xattr limits
# (e.g., 4kB on ext4), and we don't want to have the other ones fail
# because of that.
'user.dublincore.description': 'descrip... | ```suggestion
f'Extended attribute "{xattrname}" was not written.')
``` | 'user.dublincore.format': 'format',
# We do this last because it may get us close to the xattr limits
# (e.g., 4kB on ext4), and we don't want to have the other ones fail
'user.dublincore.description': 'description',
# 'user.xdg.comment': 'description',
}
def run(self, i... | @@ -29,35 +29,38 @@ class XAttrMetadataPP(PostProcessor):
# 'user.xdg.comment': 'description',
'user.dublincore.title': 'title',
'user.dublincore.date': 'upload_date',
- 'user.dublincore.description': 'description',
'user.dublincore.contributor': 'uploader',
'user.dub... | yt_dlp/postprocessor/xattrpp.py | 26 | Python | 0.571 | suggestion | 97 | 36 | 35 | false | Make extended attribute writing more robust against filesystem limits. | 11,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | eric321 |
# We do this last because it may get us close to the xattr limits
# (e.g., 4kB on ext4), and we don't want to have the other ones fail
# because of that.
'user.dublincore.description': 'description',
}
def run(self, info):
mtime = os.stat(info['filepath']).st_mtime
... | ```suggestion
self.report_warning(f'Unable to write extended attribute "{xattrname}" due to too long values.')
``` | # (e.g., 4kB on ext4), and we don't want to have the other ones fail
'user.dublincore.description': 'description',
# 'user.xdg.comment': 'description',
}
def run(self, info):
mtime = os.stat(info['filepath']).st_mtime
self.to_screen('Writing metadata to file\'s xattrs')
... | @@ -29,35 +29,38 @@ class XAttrMetadataPP(PostProcessor):
# 'user.xdg.comment': 'description',
'user.dublincore.title': 'title',
'user.dublincore.date': 'upload_date',
- 'user.dublincore.description': 'description',
'user.dublincore.contributor': 'uploader',
'user.dub... | yt_dlp/postprocessor/xattrpp.py | 26 | Python | 0.714 | refactor | 136 | 34 | 33 | false | Make extended attribute writing more robust against filesystem limits. | 11,115 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | eric321 |
}))
# all-lowercase 'referer' so we can smuggle it to Generic, SproutVideo, Vimeo
headers = {'referer': 'https://patreon.com/'}
# handle Vimeo embeds
if traverse_obj(attributes, ('embed', 'provider')) == 'Vimeo':
v_url = urllib.parse.unquote(self._html_searc... | This check seems too lax. Maybe we can find another metric or match more of it? | }))
# all-lowercase 'referer' so we can smuggle it to Generic, SproutVideo, Vimeo
headers = {'referer': 'https://patreon.com/'}
# handle Vimeo embeds
if traverse_obj(attributes, ('embed', 'provider')) == 'Vimeo':
v_url = urllib.parse.unquote(self._html_searc... | @@ -326,8 +335,11 @@ def _real_extract(self, url):
if embed_url and (urlh := self._request_webpage(
embed_url, video_id, 'Checking embed URL', headers=headers,
fatal=False, errnote=False, expected_status=403)):
+ # Vimeo's Cloudflare anti-bot protection will return ... | yt_dlp/extractor/patreon.py | 26 | Python | 0.214 | question | 79 | 51 | 51 | false | [ie/patreon] Extract all m3u8 formats for locked posts | 11,138 | yt-dlp/yt-dlp | 132,642 | Python | Grub4K | bashonly |
def _parse_content(self, content, url):
video_id = content['dataMediaId']
config = self._download_json(
content['dataConfig'], video_id, 'Downloading config JSON')
title = config['info']['title']
services = config['services']
caronte = self._download_json(services... | we shouldn't return the geo verification headers in the info dict; this defeats the purpose of `--geo-verification-proxy` since the download itself will be using the proxy then too | 'duration': 662,
},
}],
'skip': 'HTTP Error 410 Gone',
}, {
'url': 'http://www.cuatro.com/deportes/futbol/barcelona/Leo_Messi-Champions-Roma_2_2052780128.html',
'md5': 'c86fe0d99e3bdb46b7950d38bf6ef12a',
'info_dict': {
'id': 'jn24Od1zGL... | @@ -89,25 +89,29 @@ def _parse_content(self, content, url):
services = config['services']
caronte = self._download_json(services['caronte'], video_id)
stream = caronte['dls'][0]['stream']
- headers = self.geo_verification_headers()
- headers.update({
- 'Content-Type':... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.571 | suggestion | 180 | 51 | 51 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
},
}, {
'url': 'http://www.telecinco.es/informativos/nacional/Pablo_Iglesias-Informativos_Telecinco-entrevista-Pedro_Piqueras_2_1945155182.html',
'only_matching': True,
}, {
'url': 'http://www.telecinco.es/espanasinirmaslejos/Espana-gran-destino-turistico_2_1240605043.html',
... | let's revert the `traverse_obj` usage here because we want `cdn` extraction to be fatal (since the next request will fatally fail without it)
```suggestion
cdn = self._download_json(
``` | 'url': 'http://www.telecinco.es/robinfood/temporada-01/t01xp14/Bacalao-cocochas-pil-pil_0_1876350223.html',
'info_dict': {
'id': '1876350223',
'title': 'Bacalao con kokotxas al pil-pil',
'description': 'md5:716caf5601e25c3c5ab6605b1ae71529',
},
'playli... | @@ -89,25 +89,29 @@ def _parse_content(self, content, url):
services = config['services']
caronte = self._download_json(services['caronte'], video_id)
stream = caronte['dls'][0]['stream']
- headers = self.geo_verification_headers()
- headers.update({
- 'Content-Type':... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.786 | bug | 197 | 51 | 51 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
}, {
'url': 'http://www.cuatro.com/chesterinlove/a-carta/chester-chester_in_love-chester_edu_2_2331030022.html',
'only_matching': True,
}]
def _parse_content(self, content, url):
video_id = content['dataMediaId']
config = self._download_json(
content['dataConfig'... | ```suggestion
})['tokens']['1']['cdn']
``` | 'md5': '7ee56d665cfd241c0e6d80fd175068b0',
'info_dict': {
'id': 'JEA5ijCnF6p5W08A1rNKn7',
'ext': 'mp4',
'title': 'Con Martín Berasategui, hacer un bacalao al pil-pil es fácil y divertido',
'duration': 662,
},
}],... | @@ -89,25 +89,29 @@ def _parse_content(self, content, url):
services = config['services']
caronte = self._download_json(services['caronte'], video_id)
stream = caronte['dls'][0]['stream']
- headers = self.geo_verification_headers()
- headers.update({
- 'Content-Type':... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.571 | suggestion | 56 | 51 | 51 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
'only_matching': True,
}]
def _parse_content(self, content, url):
video_id = content['dataMediaId']
config = self._download_json(
content['dataConfig'], video_id, 'Downloading config JSON')
title = config['info']['title']
services = config['services']
... | let's clean this up a bit: use `update_url` and remove `'m3u8_native'` (it's the default)
```suggestion
update_url(stream, query=cdn), video_id, 'mp4', m3u8_id='hls', headers=geo_headers)
``` | 'id': 'JEA5ijCnF6p5W08A1rNKn7',
'ext': 'mp4',
'title': 'Con Martín Berasategui, hacer un bacalao al pil-pil es fácil y divertido',
'duration': 662,
},
}],
'skip': 'HTTP Error 410 Gone',
}, {
'url': 'http://www.cuatro... | @@ -89,25 +89,29 @@ def _parse_content(self, content, url):
services = config['services']
caronte = self._download_json(services['caronte'], video_id)
stream = caronte['dls'][0]['stream']
- headers = self.geo_verification_headers()
- headers.update({
- 'Content-Type':... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.857 | suggestion | 206 | 51 | 51 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
import json
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
str_or_none,
traverse_obj,
)
class TelecincoIE(InfoExtractor):
IE_DESC = 'telecinco.es, cuatro.com and mediaset.es'
_VALID_URL = r'https?://(?:www\.)?(?:telecinco\.es|cuatro\.com|mediaset\.e... | needed for other suggestions
```suggestion
traverse_obj,
update_url,
url_or_none,
``` | import json
import re
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
ExtractorError,
clean_html,
int_or_none,
join_nonempty,
str_or_none,
traverse_obj,
update_url,
url_or_none,
)
class TelecincoBaseIE(InfoExtractor):
def _pars... | @@ -6,7 +6,7 @@
clean_html,
int_or_none,
str_or_none,
- try_get,
+ traverse_obj, | yt_dlp/extractor/telecinco.py | 12 | Python | 0.714 | suggestion | 102 | 37 | 37 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
stream + '?' + cdn, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', headers=geo_headers)
return {
'http_headers': headers,
'id': video_id,
'title': title,
'formats': formats,
'thumbnail': content.get('dataPoster') or traverse_obj(config, 'p... | `{list}` will not guarantee a list; it will return `None` if `'body'` is not a list. We can use branching (`...`) to guarantee a list result, and then expect `{dict}` to filter non-dict results out of the returned list:
```py
body.extend(traverse_obj(article, ('body', ..., {dict})))
for p in ... | 'duration': 50,
'thumbnail': 'https://album.mediaset.es/eimg/2017/11/02/1tlQLO5Q3mtKT24f3EaC24.jpg',
},
}, {
# video in opening's content
'url': 'https://www.telecinco.es/vivalavida/fiorella-sobrina-edmundo-arrocet-entrevista_18_2907195140.html',
'info_dict': ... | @@ -121,7 +125,7 @@ def _real_extract(self, url):
if article.get('editorialType') != 'VID':
entries = []
body = [article.get('opening')]
- body.extend(try_get(article, lambda x: x['body'], list) or [])
+ body.extend(traverse_obj(article, ('body', {list})))
... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.857 | refactor | 660 | 44 | 51 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
services = config['services']
caronte = self._download_json(services['caronte'], video_id)
stream = caronte['dls'][0]['stream']
headers = {
'Referer': url,
'Origin': re.match(r'https?://[^/]+', url).group(0),
}
geo_headers = {**headers, **self.geo_... | ```suggestion
'thumbnail': (traverse_obj(content, ('dataPoster', {url_or_none}))
or traverse_obj(config, 'poster', 'imageUrl', expected_type=url_or_none)),
'duration': traverse_obj(content, ('dataDuration', {int_or_none})),
'http_headers': headers,
``` | 'url': 'http://www.cuatro.com/deportes/futbol/barcelona/Leo_Messi-Champions-Roma_2_2052780128.html',
'md5': 'c86fe0d99e3bdb46b7950d38bf6ef12a',
'info_dict': {
'id': 'jn24Od1zGLG4XUZcnUnZB6',
'ext': 'mp4',
'title': '¿Quién es este ex futbolista con el que habla... | @@ -89,25 +89,29 @@ def _parse_content(self, content, url):
services = config['services']
caronte = self._download_json(services['caronte'], video_id)
stream = caronte['dls'][0]['stream']
- headers = self.geo_verification_headers()
- headers.update({
- 'Content-Type':... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.929 | suggestion | 319 | 51 | 51 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
import json
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
int_or_none,
str_or_none,
traverse_obj,
update_url,
url_or_none,
)
class TelecincoIE(InfoExtractor):
IE_DESC = 'telecinco.es, cuatro.com and mediaset.es'
_VALID_URL = r'https?://(?:www\.)?(?:tele... | ```suggestion
content = p['content']
type_ = p.get('type')
``` | },
}, {
'url': 'http://www.telecinco.es/informativos/nacional/Pablo_Iglesias-Informativos_Telecinco-entrevista-Pedro_Piqueras_2_1945155182.html',
'only_matching': True,
}, {
'url': 'http://www.telecinco.es/espanasinirmaslejos/Espana-gran-destino-turistico_2_1240605043.html',
... | @@ -120,14 +127,7 @@ def _real_extract(self, url):
description = clean_html(article.get('leadParagraph')) or ''
if article.get('editorialType') != 'VID':
entries = []
- body = [article.get('opening')]
- body.extend(try_get(article, lambda x: x['body'], list) or [])
-... | yt_dlp/extractor/telecinco.py | 26 | Python | 0.714 | suggestion | 97 | 145 | 39 | false | [ie/Telecinco] Fix extractor: Add headers | 11,142 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DarkZeros |
'duration': 903,
'view_count': int,
'like_count': int,
'description': 'Aria alexander manojob',
'tags': ['aria', 'alexander', 'manojob'],
'upload_date': '20190218',
'age_limit': 18,
},
}
def _real_extract(self, url):
... | ```suggestion
r'window\.playlist\s*=', webpage, video_id, 'playlist info')
``` | 'duration': 903,
'view_count': int,
'like_count': int,
'description': 'Aria alexander manojob',
'tags': ['aria', 'alexander', 'manojob'],
'upload_date': '20190218',
'age_limit': 18,
},
}
def _real_extract(self, url):
... | @@ -43,14 +43,8 @@ def _real_extract(self, url):
def build_url(url_or_path):
return urljoin('https://adult.noodlemagazine.com', url_or_path)
- headers = {'Referer': url}
- player_path = self._html_search_regex(
- r'<iframe[^>]+\bid="iplayer"[^>]+\bsrc="([^"]+)"', webpage... | yt_dlp/extractor/noodlemagazine.py | 26 | Python | 0.571 | suggestion | 92 | 51 | 51 | false | [NoodleMagazine] fix extractor | 11,144 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | shadisalman11 |
display_id = presumptive_id
if presumptive_id:
webpage = self._download_webpage(url, display_id)
description = strip_or_none(self._og_search_description(
webpage, default=None) or self._html_search_meta(
'description', webpage, default=None))
... | ```suggestion
r'\bclass="passportcoveplayer"[^>]+\bdata-media="(\d+)', # https://www.thirteen.org/programs/the-woodwrights-shop/who-wrote-the-book-of-sloyd-fggvvq/
``` | if cookie:
station = self._search_regex(r'#?s=\["([^"]+)"', cookie, 'station')
if station:
self._set_cookie('.pbs.org', 'pbsol.station', station)
def _extract_webpage(self, url):
mobj = self._match_valid_url(url)
description = None
presumpti... | @@ -477,6 +490,7 @@ def _extract_webpage(self, url):
r"div\s*:\s*'videoembed'\s*,\s*mediaid\s*:\s*'(\d+)'", # frontline video embed
r'class="coveplayerid">([^<]+)<', # coveplayer
r'<section[^>]+data-coveid="(\d+)"', # coveplaye... | yt_dlp/extractor/pbs.py | 26 | Python | 0.714 | suggestion | 186 | 51 | 51 | false | [ie/pbs] Support www.thirteen.org URLs | 11,191 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rohieb |
(r'video\.wcny\.org', 'WCNY/Channel 24 (WCNY)'), # http://www.wcny.org
(r'video\.wned\.org', 'WNED (WNED)'), # http://www.wned.org/
(r'watch\.wpbstv\.org', 'WPBS (WPBS)'), # http://www.wpbstv.org
(r'video\.wskg\.org', 'WSKG Public TV (WSKG)'), # http://wskg.org
(r'video\.wxxi... | make it a non-capturing group
```suggestion
(r'(?:www\.)?thirteen\.org', 'Thirteen (WNET'), # https://thirteen.org
```
| (r'video\.wcny\.org', 'WCNY/Channel 24 (WCNY)'), # http://www.wcny.org
(r'video\.wned\.org', 'WNED (WNED)'), # http://www.wned.org/
(r'watch\.wpbstv\.org', 'WPBS (WPBS)'), # http://www.wpbstv.org
(r'video\.wskg\.org', 'WSKG Public TV (WSKG)'), # http://wskg.org
(r'video\.wxxi... | @@ -178,6 +178,7 @@ class PBSIE(InfoExtractor):
(r'video\.wtjx\.org', 'WTJX Channel 12 (WTJX)'), # http://www.wtjx.org/
(r'video\.ideastations\.org', 'WCVE PBS (WCVE)'), # http://ideastations.org/
(r'video\.kbtc\.org', 'KBTC Public Television (KBTC)'), # http://kbtc.org
+ (r'(www\.)... | yt_dlp/extractor/pbs.py | 26 | Python | 0.714 | suggestion | 132 | 51 | 51 | false | [ie/pbs] Support www.thirteen.org URLs | 11,191 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rohieb |
_TESTS = [
{
'url': 'https://www.thirteen.org/programs/the-woodwrights-shop/carving-away-with-mary-may-tioglz/',
'info_dict': {
'id': '3004803331',
'ext': 'mp4',
'title': "The Woodwright's Shop - Carving Away with Mary May",
... | add this as a new test, don't replace the existing test. if the existing test's link is dead, then add a `skip` field to the test dict | {
'url': 'http://www.pbs.org/tpt/constitution-usa-peter-sagal/watch/a-more-perfect-union/',
'md5': '173dc391afd361fa72eab5d3d918968d',
'info_dict': {
'id': '2365006249',
'ext': 'mp4',
'title': 'Constitution USA with Peter Sagal ... | @@ -199,25 +200,37 @@ class PBSIE(InfoExtractor):
_TESTS = [
{
- 'url': 'http://www.pbs.org/tpt/constitution-usa-peter-sagal/watch/a-more-perfect-union/',
- 'md5': '173dc391afd361fa72eab5d3d918968d',
+ 'url': 'https://www.thirteen.org/programs/the-woodwrights-shop/carvin... | yt_dlp/extractor/pbs.py | 26 | Python | 0.571 | suggestion | 134 | 51 | 51 | false | [ie/pbs] Support www.thirteen.org URLs | 11,191 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | rohieb |
def _get_claims_token(self, email, password):
if not self.claims_token_valid():
self._claims_token = self._new_claims_token(email, password)
self.cache.store(self._NETRC_MACHINE, 'claims_token', self._claims_token)
return self._claims_token
def _real_initialize(self):
... | this line should be moved below the error handling
```suggestion
m3u8_url = update_url_query(m3u8_info['url'], {'manifestType': ''})
``` | return exp - time.time() < 10
def claims_token_valid(self):
return self._claims_token is not None and not self.claims_token_expired()
def _get_claims_token(self, email, password):
if not self.claims_token_valid():
self._claims_token = self._new_claims_token(email, password)... | @@ -676,7 +642,7 @@ def _real_extract(self, url):
else:
headers = {}
m3u8_info = self._download_json(video_info['playSession']['url'], video_id, headers=headers)
- m3u8_url = m3u8_info.get('url')
+ m3u8_url = re.sub(r'(manifestType=)[\w_-]+(&)', r'\1\2', m3u8_info.get('url')... | yt_dlp/extractor/cbc.py | 26 | Python | 0.929 | suggestion | 147 | 51 | 51 | false | [CBC Gem] Fix 1080p detection after URL format change | 11,196 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | DavidSkrundz |
'api_type': 'json',
}), note='Logging in', errnote='Login request failed')
errors = '; '.join(traverse_obj(login, ('json', 'errors', ..., 1)))
if errors:
raise ExtractorError(f'Unable to login, Reddit API says {errors}', expected=True)
elif not traverse_ob... | It's specifically a JSONDecodeError that occurs when auth is needed, right? We'd still want to raise the HTTPError if we get a 404 etc, no? | 'passwd': password,
'api_type': 'json',
}), note='Logging in', errnote='Login request failed')
errors = '; '.join(traverse_obj(login, ('json', 'errors', ..., 1)))
if errors:
raise ExtractorError(f'Unable to login, Reddit API says {errors}', expecte... | @@ -259,7 +259,9 @@ def _real_extract(self, url):
fallback_host = 'old.reddit.com' if host != 'old.reddit.com' else 'www.reddit.com'
self.to_screen(f'{host} request failed, retrying with {fallback_host}')
data = self._download_json(
- f'https://{fallback_host}/{slug... | yt_dlp/extractor/reddit.py | 26 | Python | 0.5 | security | 139 | 51 | 51 | false | [ie/reddit] Improve HTTP 403 error message | 11,202 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | pzhlkj6612 |
if default_search in ('error', 'fixup_error'):
raise ExtractorError(
f'{url!r} is not a valid URL. '
f'Set --default-search "ytsearch" (or run yt-dlp "ytsearch:{url}" ) to search YouTube', expected=True)
else:
if ':' not in... | this kinda duplicates what we are already doing in `InfoExtractor._request_webpage`. we could simplify it like this:
```suggestion
impersonate = self._configuration_arg('impersonate', [''])
if 'false' in impersonate or not self._downloader._impersonate_target_available(ImpersonateTarget()):
... | if default_search in ('error', 'fixup_error'):
raise ExtractorError(
f'{url!r} is not a valid URL. '
f'Set --default-search "ytsearch" (or run yt-dlp "ytsearch:{url}" ) to search YouTube', expected=True)
else:
if ':' not in... | @@ -2373,6 +2374,14 @@ def _real_extract(self, url):
else:
video_id = self._generic_id(url)
+ # Try to impersonate a web-browser by default if possible
+ # We test if impersonation is available at all to omit the warning if it isn't
+ impersonate = None
+ if self._dow... | yt_dlp/extractor/generic.py | 26 | Python | 0.857 | refactor | 347 | 51 | 51 | false | [ie/generic] Add `impersonate` extractor arg | 11,206 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | Grub4K |
join_nonempty(*get_package_info(m)) for m in available_dependencies.values()
})) or 'none'))
write_debug(f'Proxy map: {self.proxies}')
write_debug(f'Request Handlers: {", ".join(rh.RH_NAME for rh in self._request_director.handlers.values())}')
for plugin_type, plugins in {'E... | maybe also add the deprecation warning back?
```diff
diff --git a/README.md b/README.md
index fbf50072d..9810f264c 100644
--- a/README.md
+++ b/README.md
@@ -2359,7 +2359,7 @@ #### No longer supported
--prefer-avconv avconv is not officially supported by yt-dlp (Alias: --no-prefer-ffmpeg... | join_nonempty(*get_package_info(m)) for m in available_dependencies.values()
})) or 'none'))
write_debug(f'Proxy map: {self.proxies}')
write_debug(f'Request Handlers: {", ".join(rh.RH_NAME for rh in self._request_director.handlers.values())}')
if os.environ.get('YTDLP_NO_PLU... | @@ -4085,17 +4084,6 @@ def get_encoding(stream):
if plugin_dirs:
write_debug(f'Plugin directories: {plugin_dirs}')
- # Not implemented | yt_dlp/YoutubeDL.py | 26 | Python | 1 | bug | 2,200 | 51 | 51 | false | [cleanup] Misc | 11,216 | yt-dlp/yt-dlp | 132,642 | Python | grqz | Grub4K |
from .common import InfoExtractor
from ..utils import (
clean_html,
determine_ext,
int_or_none,
parse_duration,
parse_resolution,
try_get,
unified_timestamp,
url_or_none,
)
class CCMAIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?3cat\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?... | ```suggestion
_VALID_URL = r'https?://(?:www\.)?3cat\.cat/(?:3cat|tv3/sx3)/[^/?#]+/(?P<type>video|audio)/(?P<id>\d+)'
``` | from .common import InfoExtractor
from ..utils import (
clean_html,
determine_ext,
int_or_none,
parse_duration,
parse_resolution,
try_get,
unified_timestamp,
url_or_none,
)
class CCMAIE(InfoExtractor):
IE_DESC = '3Cat, TV3 and Catalunya Ràdio'
_VALID_URL = r'https?://(?:www\.)?... | @@ -12,9 +12,9 @@
class CCMAIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?ccma\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?P<id>\d+)'
+ _VALID_URL = r'https?://(?:www\.)?3cat\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?P<id>\d+)' | yt_dlp/extractor/ccma.py | 15 | Python | 0.857 | suggestion | 127 | 40 | 40 | false | [ie/ccma] Update ccma.cat domain to 3cat.cat | 11,222 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | JoseAngelB |
'id': '2458',
'ext': 'mp4',
'title': '첫 방송',
'channel': '강지',
'channel_id': 'b5ed5db484d04faf4d150aedd362f34b',
'channel_is_verified': True,
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 4433,
'timestamp': 1... | - let's move `video_status` to the bottom here / to the beginning of the next code block since it's only relevant to that block
- is `liveOpenDate` useful metadata? should we return it is `release_timestamp` or something? if not, let's condense this:
```suggestion
live_status = 'was_live' is video_meta.get... | 'id': '2458',
'ext': 'mp4',
'title': '첫 방송',
'channel': '강지',
'channel_id': 'b5ed5db484d04faf4d150aedd362f34b',
'channel_is_verified': True,
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 4433,
'timestamp': 1... | @@ -146,19 +146,39 @@ def _real_extract(self, url):
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
- formats, subtitles = self._extract_m... | yt_dlp/extractor/chzzk.py | 26 | Python | 0.857 | suggestion | 409 | 51 | 51 | false | [ie/chzzk] Fix video(fast replay) download | 11,228 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hui1601 |
'channel_is_verified': True,
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 4433,
'timestamp': 1703307460.214,
'upload_date': '20231223',
'view_count': int,
},
}]
def _real_extract(self, url):
video_id = self._match_id(... | since the `_extract_m3u8_formats` call is ultimately fatal, we don't need to use `.get()`/`traverse_obj` on the way there:
```suggestion
playback = self._parse_json(video_meta['liveRewindPlaybackJson'], video_id)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
... | 'channel_is_verified': True,
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 4433,
'timestamp': 1703307460.214,
'upload_date': '20231223',
'view_count': int,
},
}]
def _real_extract(self, url):
video_id = self._match_id(... | @@ -146,19 +146,39 @@ def _real_extract(self, url):
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
- formats, subtitles = self._extract_m... | yt_dlp/extractor/chzzk.py | 26 | Python | 0.857 | refactor | 387 | 51 | 51 | false | [ie/chzzk] Fix video(fast replay) download | 11,228 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hui1601 |
def _real_extract(self, url):
video_id = self._match_id(url)
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
video_status = vide... | same here
```suggestion
formats, subtitles = self._extract_mpd_formats_and_subtitles(
f'https://apis.naver.com/neonplayer/vodplay/v1/playback/{video_meta["videoId"]}',
video_id, query={
'key': video_meta['inKey'],
'env': 'real',
... | def _real_extract(self, url):
video_id = self._match_id(url)
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
live_status = 'was... | @@ -146,19 +146,39 @@ def _real_extract(self, url):
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
- formats, subtitles = self._extract_m... | yt_dlp/extractor/chzzk.py | 26 | Python | 0.857 | refactor | 416 | 50 | 44 | false | [ie/chzzk] Fix video(fast replay) download | 11,228 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hui1601 |
if video_live_date:
live_status = 'was_live'
else:
live_status = 'not_live'
if video_status == 'UPLOAD':
playback = self._parse_json(video_meta.get('liveRewindPlaybackJson'), video_id)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(... | just formatting/style nitpicks
```suggestion
self.raise_no_formats(
f'Unknown video status detected: "{video_status}"', expected=True, video_id=video_id)
formats, subtitles = [], {}
live_status = 'post_live' if live_status == 'was_live' else None
``` | video_status = video_meta.get('vodStatus')
if video_status == 'UPLOAD':
playback = self._parse_json(video_meta['liveRewindPlaybackJson'], video_id)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
playback['media'][0]['path'], video_id, 'mp4', m3u8_i... | @@ -146,19 +146,39 @@ def _real_extract(self, url):
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
- formats, subtitles = self._extract_m... | yt_dlp/extractor/chzzk.py | 26 | Python | 0.786 | suggestion | 308 | 43 | 37 | false | [ie/chzzk] Fix video(fast replay) download | 11,228 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hui1601 |
},
}, {
# Partner channel replay video
'url': 'https://chzzk.naver.com/video/2458',
'info_dict': {
'id': '2458',
'ext': 'mp4',
'title': '첫 방송',
'channel': '강지',
'channel_id': 'b5ed5db484d04faf4d150aedd362f34b',
'... | sorry, typo
```suggestion
live_status = 'was_live' if video_meta.get('liveOpenDate') else 'not_live'
``` | },
}, {
# Partner channel replay video
'url': 'https://chzzk.naver.com/video/2458',
'info_dict': {
'id': '2458',
'ext': 'mp4',
'title': '첫 방송',
'channel': '강지',
'channel_id': 'b5ed5db484d04faf4d150aedd362f34b',
'... | @@ -146,19 +146,33 @@ def _real_extract(self, url):
video_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v3/videos/{video_id}', video_id,
note='Downloading video info', errnote='Unable to download video info')['content']
- formats, subtitles = self._extract_m... | yt_dlp/extractor/chzzk.py | 26 | Python | 0.714 | suggestion | 115 | 51 | 51 | false | [ie/chzzk] Fix video(fast replay) download | 11,228 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | hui1601 |
class netrc_from_content(netrc.netrc):
def __init__(self, content):
self.hosts, self.macros = {}, {}
with io.StringIO(content) as stream:
self._parse('-', stream, False)
class Popen(subprocess.Popen):
if sys.platform == 'win32':
_startupinfo = subprocess.STARTUPINFO()
... | ```suggestion
# Ref: https://pyinstaller.org/en/v6.10.0/runtime-information.html#ld-library-path-libpath-considerations
``` |
class netrc_from_content(netrc.netrc):
def __init__(self, content):
self.hosts, self.macros = {}, {}
with io.StringIO(content) as stream:
self._parse('-', stream, False)
class Popen(subprocess.Popen):
if sys.platform == 'win32':
_startupinfo = subprocess.STARTUPINFO()
... | @@ -824,14 +824,17 @@ class Popen(subprocess.Popen):
_startupinfo = None
@staticmethod
- def _fix_pyinstaller_ld_path(env):
- """Restore LD_LIBRARY_PATH when using PyInstaller
- Ref: https://github.com/pyinstaller/pyinstaller/blob/develop/doc/runtime-information.rst#ld_library_path-... | yt_dlp/utils/_utils.py | 26 | Python | 0.786 | suggestion | 133 | 51 | 51 | false | [utils] `Popen`: Reset PyInstaller environment | 11,258 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bashonly |
.replace('"', '"')
.replace("'", ''')
)
class netrc_from_content(netrc.netrc):
def __init__(self, content):
self.hosts, self.macros = {}, {}
with io.StringIO(content) as stream:
self._parse('-', stream, False)
class Popen(subprocess.Popen):
if sys.pla... | ```suggestion
# Ref: https://pyinstaller.org/en/v6.10.0/CHANGES.html#incompatible-changes
# https://github.com/yt-dlp/yt-dlp/issues/11259
``` | .replace('"', '"')
.replace("'", ''')
)
class netrc_from_content(netrc.netrc):
def __init__(self, content):
self.hosts, self.macros = {}, {}
with io.StringIO(content) as stream:
self._parse('-', stream, False)
class Popen(subprocess.Popen):
if sys.pla... | @@ -824,14 +824,17 @@ class Popen(subprocess.Popen):
_startupinfo = None
@staticmethod
- def _fix_pyinstaller_ld_path(env):
- """Restore LD_LIBRARY_PATH when using PyInstaller
- Ref: https://github.com/pyinstaller/pyinstaller/blob/develop/doc/runtime-information.rst#ld_library_path-... | yt_dlp/utils/_utils.py | 26 | Python | 0.786 | suggestion | 165 | 51 | 51 | false | [utils] `Popen`: Reset PyInstaller environment | 11,258 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | bashonly |
result = int_or_none(response.get('RESULT'))
if result != 1:
error = _ERRORS.get(result, 'You have failed to log in.')
raise ExtractorError(
f'Unable to login: {self.IE_NAME} said: {error}',
expected=True)
def _call_api(self, endpoint, display... | do links like these even exist anymore? it seems like all VODs are on the `vod` subdomain now, no?
if we want to keep this part of the regex pattern for legacy reasons or something, we should turn back the clock on the domain name here too
```suggestion
(?:(?:live|afbbs|www)\.)?afreecat... | result = int_or_none(response.get('RESULT'))
if result != 1:
error = _ERRORS.get(result, 'You have failed to log in.')
raise ExtractorError(
f'Unable to login: {self.IE_NAME} said: {error}',
expected=True)
def _call_api(self, endpoint, display... | @@ -61,46 +61,46 @@ def _perform_login(self, username, password):
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
- f'https://api.m.afreecatv.com/{endpoint}',
+ f'https://api.m.sooplive.co.kr/{endpoint}',
... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.857 | suggestion | 553 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
if result != 1:
error = _ERRORS.get(result, 'You have failed to log in.')
raise ExtractorError(
f'Unable to login: {self.IE_NAME} said: {error}',
expected=True)
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
re... | support both domains here
```suggestion
vod\.(?:sooplive\.co\.kr|afreecatv\.com)/(?:PLAYER/STATION|player)/
``` | if result != 1:
error = _ERRORS.get(result, 'You have failed to log in.')
raise ExtractorError(
f'Unable to login: {self.IE_NAME} said: {error}',
expected=True)
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
re... | @@ -61,46 +61,46 @@ def _perform_login(self, username, password):
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
- f'https://api.m.afreecatv.com/{endpoint}',
+ f'https://api.m.sooplive.co.kr/{endpoint}',
... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.714 | suggestion | 142 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
f'https://api.m.sooplive.co.kr/{endpoint}',
data=data, headers=headers, query=query,
extensions={'legacy_ssl': True}), display_id,
'Downloading... | Revert; changing dead URLs to non-existent URLs doesn't make sense. If this type of URL doesn't exist anymore then we should just remove these tests entirely
```suggestion
'url': 'http://live.afreecatv.com:8079/app/index.cgi?szType=read_ucc_bbs&szBjId=dailyapril&nStationNo=16711924&nBbsNo=18605867&nTitleNo=... |
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
f'https://api.m.sooplive.co.kr/{endpoint}',
data=data, headers=headers, query=query,
extensions={'legacy_ssl': True}), display_id,
'Downloading... | @@ -61,46 +61,46 @@ def _perform_login(self, username, password):
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
- f'https://api.m.afreecatv.com/{endpoint}',
+ f'https://api.m.sooplive.co.kr/{endpoint}',
... | yt_dlp/extractor/afreecatv.py | 26 | Python | 1 | suggestion | 343 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
'Downloading API JSON', 'Unable to download API JSON')
class AfreecaTVIE(AfreecaTVBaseIE):
IE_NAME = 'soop'
IE_DESC = 'sooplive.co.kr'
_VALID_URL = r'''(?x)
https?://
(?:
(?:(?:live|afbbs|www)\.)?sooplive\.co\.kr(?::\d+)?
... | should not be changing dead tests
```suggestion
'thumbnail': 're:^https?://(?:video|st)img.afreecatv.com/.*$',
``` | 'Downloading API JSON', 'Unable to download API JSON')
class AfreecaTVIE(AfreecaTVBaseIE):
IE_NAME = 'soop'
IE_DESC = 'sooplive.co.kr'
_VALID_URL = r'https?://vod\.(?:sooplive\.co\.kr|afreecatv\.com)/(?:PLAYER/STATION|player)/(?P<id>\d+)/?(?:$|[?#&])'
_TESTS = [{
'url': 'https://vo... | @@ -61,46 +61,46 @@ def _perform_login(self, username, password):
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
- f'https://api.m.afreecatv.com/{endpoint}',
+ f'https://api.m.sooplive.co.kr/{endpoint}',
... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.786 | suggestion | 129 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
https?://
(?:
(?:(?:live|afbbs|www)\.)?sooplive\.co\.kr(?::\d+)?
(?:
/app/(?:index|read_ucc_bbs)\.cgi|
/player/[Pp]layer\.(?:swf|html)
... | same as above
```suggestion
'url': 'http://afbbs.afreecatv.com:8080/app/read_ucc_bbs.cgi?nStationNo=16711924&nTitleNo=36153164&szBjId=dailyapril&nBbsNo=18605867',
``` | _TESTS = [{
'url': 'https://vod.sooplive.co.kr/player/96753363',
'info_dict': {
'id': '20230108_9FF5BEE1_244432674_1',
'ext': 'mp4',
'uploader_id': 'rlantnghks',
'uploader': '페이즈으',
'duration': 10840,
'thumbnail': r're:https?://... | @@ -61,46 +61,46 @@ def _perform_login(self, username, password):
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
- f'https://api.m.afreecatv.com/{endpoint}',
+ f'https://api.m.sooplive.co.kr/{endpoint}',
... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.714 | suggestion | 177 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
/app/(?:index|read_ucc_bbs)\.cgi|
/player/[Pp]layer\.(?:swf|html)
)\?.*?\bnTitleNo=|
vod\.sooplive\.co\.kr/(PLAYER/STATION|player)/
)
(?P<id>\d+)/?(?:$|... | ```suggestion
'thumbnail': 're:^https?://(?:video|st)img.afreecatv.com/.*$',
``` | 'ext': 'mp4',
'uploader_id': 'rlantnghks',
'uploader': '페이즈으',
'duration': 10840,
'thumbnail': r're:https?://videoimg\.sooplive\.co/.kr/.+',
'upload_date': '20230108',
'timestamp': 1673218805,
'title': '젠지 페이즈',
},
... | @@ -61,46 +61,46 @@ def _perform_login(self, username, password):
def _call_api(self, endpoint, display_id, data=None, headers=None, query=None):
return self._download_json(Request(
- f'https://api.m.afreecatv.com/{endpoint}',
+ f'https://api.m.sooplive.co.kr/{endpoint}',
... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.571 | suggestion | 94 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
'upload_date': '20170411',
'timestamp': 1491929865,
'duration': 213,
},
'params': {
'skip_download': True,
},
}, {
# adult content
'url': 'https://vod.sooplive.co.kr/player/97267690',
'info_dict': {
'id': '20... | ```suggestion
'url': 'http://www.afreecatv.com/player/Player.swf?szType=szBjId=djleegoon&nStationNo=11273158&nBbsNo=13161095&nTitleNo=36327652',
``` | }]
def _real_extract(self, url):
video_id = self._match_id(url)
data = self._call_api(
'station/video/a/view', video_id, headers={'Referer': url},
data=urlencode_postdata({
'nTitleNo': video_id,
'nApiLevel': 10,
}))['data']
... | @@ -158,17 +158,17 @@ class AfreecaTVIE(AfreecaTVBaseIE):
},
'skip': 'The VOD does not exist',
}, {
- 'url': 'http://www.afreecatv.com/player/Player.swf?szType=szBjId=djleegoon&nStationNo=11273158&nBbsNo=13161095&nTitleNo=36327652',
+ 'url': 'http://www.sooplive.co.kr/player/Player.... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.857 | suggestion | 158 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
if not entries:
self.raise_login_required(
'Only users older than 19 are able to watch this video', method='password')
self.report_warning(
'In accordance with local laws and regulations, underage users are '
'restricted from wa... | support both domains
```suggestion
_VALID_URL = r'https?://vod\.(?:sooplive\.co\.kr|afreecatv\.com)/player/(?P<id>\d+)/catchstory'
``` | 'timestamp': ('write_timestamp', {int_or_none}),
}))
class AfreecaTVLiveIE(AfreecaTVBaseIE):
IE_NAME = 'soop:live'
IE_DESC = 'sooplive.co.kr livestreams'
_VALID_URL = r'https?://play\.(?:sooplive\.co\.kr|afreecatv\.com)/(?P<id>[^/?#]+)(?:/(?P<bno>\d+))?'
_TESTS = [{
... | @@ -262,11 +262,11 @@ def _real_extract(self, url):
class AfreecaTVCatchStoryIE(AfreecaTVBaseIE):
- IE_NAME = 'afreecatv:catchstory'
- IE_DESC = 'afreecatv.com catch story'
- _VALID_URL = r'https?://vod\.afreecatv\.com/player/(?P<id>\d+)/catchstory'
+ IE_NAME = 'soop:catchstory'
+ IE_DESC = 'soopliv... | yt_dlp/extractor/afreecatv.py | 26 | Python | 0.714 | suggestion | 141 | 51 | 51 | false | [ie/afreecatv] Adapt extractors to sooplive.co.kr domain | 11,266 | yt-dlp/yt-dlp | 132,642 | Python | bashonly | 63427083 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.