+import random
+import re
+import urllib.parse
+
from .common import InfoExtractor
-from ..compat import compat_urlparse
from ..utils import (
+ determine_ext,
parse_count,
- unified_timestamp,
remove_end,
- determine_ext,
+ unified_timestamp,
)
-import re
-import random
class NitterIE(InfoExtractor):
'like_count': int,
'repost_count': int,
'comment_count': int,
- }
- }
+ },
+ }, { # no OpenGraph title
+ 'url': f'https://{current_instance}/LocalBateman/status/1678455464038735895#m',
+ 'info_dict': {
+ 'id': '1678455464038735895',
+ 'ext': 'mp4',
+ 'title': 'Your Typical Local Man - Local man, what did Romanians ever do to you?',
+ 'description': 'Local man, what did Romanians ever do to you?',
+ 'thumbnail': r're:^https?://.*\.jpg$',
+ 'uploader': 'Your Typical Local Man',
+ 'uploader_id': 'LocalBateman',
+ 'uploader_url': f'https://{current_instance}/LocalBateman',
+ 'upload_date': '20230710',
+ 'timestamp': 1689009900,
+ 'view_count': int,
+ 'like_count': int,
+ 'repost_count': int,
+ 'comment_count': int,
+ },
+ 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
+ 'params': {'skip_download': 'm3u8'},
+ },
]
def _real_extract(self, url):
video_id, uploader_id = self._match_valid_url(url).group('id', 'uploader_id')
- parsed_url = compat_urlparse.urlparse(url)
+ parsed_url = urllib.parse.urlparse(url)
base_url = f'{parsed_url.scheme}://{parsed_url.netloc}'
self._set_cookie(parsed_url.netloc, 'hlsPlayback', 'on')
if main_tweet_start > 0:
webpage = full_webpage[main_tweet_start:]
- video_url = '%s%s' % (base_url, self._html_search_regex(
+ video_url = '{}{}'.format(base_url, self._html_search_regex(
r'(?:<video[^>]+data-url|<source[^>]+src)="([^"]+)"', webpage, 'video url'))
ext = determine_ext(video_url)
else:
formats = [{
'url': video_url,
- 'ext': ext
+ 'ext': ext,
}]
- title = description = self._og_search_description(full_webpage) or self._html_search_regex(
+ title = description = self._og_search_description(full_webpage, default=None) or self._html_search_regex(
r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title', fatal=False)
uploader_id = self._html_search_regex(
thumbnail = (
self._html_search_meta('og:image', full_webpage, 'thumbnail url')
- or remove_end('%s%s' % (base_url, self._html_search_regex(
+ or remove_end('{}{}'.format(base_url, self._html_search_regex(
r'<video[^>]+poster="([^"]+)"', webpage, 'thumbnail url', fatal=False)), '%3Asmall'))
thumbnails = [
- {'id': id, 'url': f'{thumbnail}%3A{id}'}
- for id in ('thumb', 'small', 'large', 'medium', 'orig')
+ {'id': id_, 'url': f'{thumbnail}%3A{id_}'}
+ for id_ in ('thumb', 'small', 'large', 'medium', 'orig')
]
date = self._html_search_regex(