[ie/threads] Lint

This commit is contained in:
Renan D. 2024-08-09 15:35:53 -03:00
parent e0eefb2c5a
commit 9989f2ab3b
2 changed files with 14 additions and 14 deletions

View File

@ -2081,7 +2081,7 @@ from .thisvid import (
) )
from .threads import ( from .threads import (
ThreadsIE, ThreadsIE,
ThreadsIOSIE ThreadsIOSIE,
) )
from .threeqsdn import ThreeQSDNIE from .threeqsdn import ThreeQSDNIE
from .threespeak import ( from .threespeak import (

View File

@ -1,10 +1,10 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
strftime_or_none,
traverse_obj,
remove_end, remove_end,
strip_or_none strftime_or_none,
strip_or_none,
) )
from ..utils.traversal import traverse_obj
class ThreadsIE(InfoExtractor): class ThreadsIE(InfoExtractor):
@ -26,8 +26,8 @@ class ThreadsIE(InfoExtractor):
'upload_date': '20240502', 'upload_date': '20240502',
'like_count': int, 'like_count': int,
'channel_is_verified': bool, 'channel_is_verified': bool,
'thumbnail': r're:^https?://.*\.jpg' 'thumbnail': r're:^https?://.*\.jpg',
} },
}, { }, {
'url': 'https://www.threads.net/@felipebecari/post/C6cM_yNPHCF', 'url': 'https://www.threads.net/@felipebecari/post/C6cM_yNPHCF',
'info_dict': { 'info_dict': {
@ -44,8 +44,8 @@ class ThreadsIE(InfoExtractor):
'upload_date': '20240501', 'upload_date': '20240501',
'like_count': int, 'like_count': int,
'channel_is_verified': bool, 'channel_is_verified': bool,
'thumbnail': r're:^https?://.*\.jpg' 'thumbnail': r're:^https?://.*\.jpg',
} },
}] }]
def _real_extract(self, url): def _real_extract(self, url):
@ -55,7 +55,7 @@ class ThreadsIE(InfoExtractor):
# Try getting videos from json # Try getting videos from json
json_data = self._search_regex( json_data = self._search_regex(
r'<script[^>]+>(.*"code":"%s".*)</script>' % video_id, rf'<script[^>]+>(.*"code":"{video_id}".*)</script>',
webpage, 'main json', fatal=True) webpage, 'main json', fatal=True)
result = self._search_json( result = self._search_json(
@ -86,7 +86,7 @@ class ThreadsIE(InfoExtractor):
if videos: if videos:
for video in videos: for video in videos:
formats.append({ formats.append({
'format_id': '%s-%s' % (media.get('pk'), video['type']), # id-type 'format_id': '{}-{}'.format(media.get('pk'), video['type']), # id-type
'url': video['url'], 'url': video['url'],
'width': media.get('original_width'), 'width': media.get('original_width'),
'height': media.get('original_height'), 'height': media.get('original_height'),
@ -105,7 +105,7 @@ class ThreadsIE(InfoExtractor):
# Metadata # Metadata
metadata.setdefault('uploader_id', traverse_obj(post, ('user', 'username'))) metadata.setdefault('uploader_id', traverse_obj(post, ('user', 'username')))
metadata.setdefault('channel_is_verified', traverse_obj(post, ('user', 'is_verified'))) metadata.setdefault('channel_is_verified', traverse_obj(post, ('user', 'is_verified')))
metadata.setdefault('uploader_url', 'https://www.threads.net/@%s' % traverse_obj(post, ('user', 'username'))) metadata.setdefault('uploader_url', 'https://www.threads.net/@{}'.format(traverse_obj(post, ('user', 'username'))))
metadata.setdefault('timestamp', post.get('taken_at')) metadata.setdefault('timestamp', post.get('taken_at'))
metadata.setdefault('like_count', post.get('like_count')) metadata.setdefault('like_count', post.get('like_count'))
@ -122,7 +122,7 @@ class ThreadsIE(InfoExtractor):
return { return {
**metadata, **metadata,
'formats': formats, 'formats': formats,
'thumbnails': thumbnails 'thumbnails': thumbnails,
} }
@ -145,9 +145,9 @@ class ThreadsIOSIE(InfoExtractor):
'upload_date': '20240502', 'upload_date': '20240502',
'like_count': int, 'like_count': int,
'channel_is_verified': bool, 'channel_is_verified': bool,
'thumbnail': r're:^https?://.*\.jpg' 'thumbnail': r're:^https?://.*\.jpg',
}, },
'add_ie': ['Threads'] 'add_ie': ['Threads'],
}] }]
def _real_extract(self, url): def _real_extract(self, url):