mirror of https://github.com/yt-dlp/yt-dlp.git
Compare commits
10 Commits
3e2e0f2708
...
d771c64b5e
Author | SHA1 | Date |
---|---|---|
bashonly | d771c64b5e | |
Alexandre Huot | 6b54cccdcb | |
src-tinkerer | c4b87dd885 | |
fireattack | 2338827072 | |
fireattack | 06d52c8731 | |
sepro | df5c9e733a | |
Mozi | b38018b781 | |
Rasmus Antons | 145dc6f656 | |
bashonly | 8cc031f259 | |
bashonly | 9d37b9e298 |
|
@ -93,11 +93,11 @@ def extract_formats(self, play_info):
|
|||
|
||||
return formats
|
||||
|
||||
def _download_playinfo(self, video_id, cid):
|
||||
def _download_playinfo(self, video_id, cid, headers=None):
|
||||
return self._download_json(
|
||||
'https://api.bilibili.com/x/player/playurl', video_id,
|
||||
query={'bvid': video_id, 'cid': cid, 'fnval': 4048},
|
||||
note=f'Downloading video formats for cid {cid}')['data']
|
||||
note=f'Downloading video formats for cid {cid}', headers=headers)['data']
|
||||
|
||||
def json2srt(self, json_data):
|
||||
srt_data = ''
|
||||
|
@ -493,7 +493,8 @@ class BiliBiliIE(BilibiliBaseIE):
|
|||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
webpage, urlh = self._download_webpage_handle(url, video_id)
|
||||
headers = self.geo_verification_headers()
|
||||
webpage, urlh = self._download_webpage_handle(url, video_id, headers=headers)
|
||||
if not self._match_valid_url(urlh.url):
|
||||
return self.url_result(urlh.url)
|
||||
|
||||
|
@ -531,7 +532,7 @@ def _real_extract(self, url):
|
|||
self._download_json(
|
||||
'https://api.bilibili.com/x/player/pagelist', video_id,
|
||||
fatal=False, query={'bvid': video_id, 'jsonp': 'jsonp'},
|
||||
note='Extracting videos in anthology'),
|
||||
note='Extracting videos in anthology', headers=headers),
|
||||
'data', expected_type=list) or []
|
||||
is_anthology = len(page_list_json) > 1
|
||||
|
||||
|
@ -552,7 +553,7 @@ def _real_extract(self, url):
|
|||
|
||||
festival_info = {}
|
||||
if is_festival:
|
||||
play_info = self._download_playinfo(video_id, cid)
|
||||
play_info = self._download_playinfo(video_id, cid, headers=headers)
|
||||
|
||||
festival_info = traverse_obj(initial_state, {
|
||||
'uploader': ('videoInfo', 'upName'),
|
||||
|
@ -666,14 +667,15 @@ class BiliBiliBangumiIE(BilibiliBaseIE):
|
|||
|
||||
def _real_extract(self, url):
|
||||
episode_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, episode_id)
|
||||
headers = self.geo_verification_headers()
|
||||
webpage = self._download_webpage(url, episode_id, headers=headers)
|
||||
|
||||
if '您所在的地区无法观看本片' in webpage:
|
||||
raise GeoRestrictedError('This video is restricted')
|
||||
elif '正在观看预览,大会员免费看全片' in webpage:
|
||||
self.raise_login_required('This video is for premium members only')
|
||||
|
||||
headers = {'Referer': url, **self.geo_verification_headers()}
|
||||
headers['Referer'] = url
|
||||
play_info = self._download_json(
|
||||
'https://api.bilibili.com/pgc/player/web/v2/playurl', episode_id,
|
||||
'Extracting episode', query={'fnval': '4048', 'ep_id': episode_id},
|
||||
|
@ -724,7 +726,7 @@ def _real_extract(self, url):
|
|||
'duration': float_or_none(play_info.get('timelength'), scale=1000),
|
||||
'subtitles': self.extract_subtitles(episode_id, episode_info.get('cid'), aid=aid),
|
||||
'__post_extractor': self.extract_comments(aid),
|
||||
'http_headers': headers,
|
||||
'http_headers': {'Referer': url},
|
||||
}
|
||||
|
||||
|
||||
|
@ -1049,9 +1051,10 @@ def fetch_page(page_idx):
|
|||
raise ExtractorError(
|
||||
'Request is blocked by server (412), please add cookies, wait and try later.', expected=True)
|
||||
raise
|
||||
if response['code'] == -401:
|
||||
if response['code'] in (-352, -401):
|
||||
raise ExtractorError(
|
||||
'Request is blocked by server (401), please add cookies, wait and try later.', expected=True)
|
||||
f'Request is blocked by server ({-response["code"]}), '
|
||||
'please add cookies, wait and try later.', expected=True)
|
||||
return response['data']
|
||||
|
||||
def get_metadata(page_data):
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
import json
|
||||
import urllib.parse
|
||||
|
||||
from .common import InfoExtractor
|
||||
from .youtube import YoutubeIE
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
bug_reports_message,
|
||||
int_or_none,
|
||||
qualities,
|
||||
str_or_none,
|
||||
|
@ -162,9 +166,19 @@ def _extract_formats(self, player_urls, video_id):
|
|||
|
||||
def _real_extract(self, url):
|
||||
user, post_id = self._match_valid_url(url).group('user', 'post_id')
|
||||
|
||||
auth_headers = {}
|
||||
auth_cookie = self._get_cookies('https://boosty.to/').get('auth')
|
||||
if auth_cookie is not None:
|
||||
try:
|
||||
auth_data = json.loads(urllib.parse.unquote(auth_cookie.value))
|
||||
auth_headers['Authorization'] = f'Bearer {auth_data["accessToken"]}'
|
||||
except (json.JSONDecodeError, KeyError):
|
||||
self.report_warning(f'Failed to extract token from auth cookie{bug_reports_message()}')
|
||||
|
||||
post = self._download_json(
|
||||
f'https://api.boosty.to/v1/blog/{user}/post/{post_id}', post_id,
|
||||
note='Downloading post data', errnote='Unable to download post data')
|
||||
note='Downloading post data', errnote='Unable to download post data', headers=auth_headers)
|
||||
|
||||
post_title = post.get('title')
|
||||
if not post_title:
|
||||
|
@ -202,7 +216,9 @@ def _real_extract(self, url):
|
|||
'thumbnail': (('previewUrl', 'defaultPreview'), {url_or_none}),
|
||||
}, get_all=False)})
|
||||
|
||||
if not entries:
|
||||
if not entries and not post.get('hasAccess'):
|
||||
self.raise_login_required('This post requires a subscription', metadata_available=True)
|
||||
elif not entries:
|
||||
raise ExtractorError('No videos found', expected=True)
|
||||
if len(entries) == 1:
|
||||
return entries[0]
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
from .common import InfoExtractor
|
||||
from ..networking.exceptions import HTTPError
|
||||
from ..utils import ExtractorError, UserNotLive, int_or_none, url_or_none
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
UserNotLive,
|
||||
int_or_none,
|
||||
str_or_none,
|
||||
url_or_none,
|
||||
)
|
||||
from ..utils.traversal import traverse_obj
|
||||
|
||||
|
||||
|
@ -9,17 +15,20 @@ class MixchIE(InfoExtractor):
|
|||
_VALID_URL = r'https?://(?:www\.)?mixch\.tv/u/(?P<id>\d+)'
|
||||
|
||||
_TESTS = [{
|
||||
'url': 'https://mixch.tv/u/16236849/live',
|
||||
'url': 'https://mixch.tv/u/16943797/live',
|
||||
'skip': 'don\'t know if this live persists',
|
||||
'info_dict': {
|
||||
'id': '16236849',
|
||||
'title': '24配信シェア⭕️投票🙏💦',
|
||||
'comment_count': 13145,
|
||||
'view_count': 28348,
|
||||
'timestamp': 1636189377,
|
||||
'uploader': '🦥伊咲👶🏻#フレアワ',
|
||||
'uploader_id': '16236849',
|
||||
}
|
||||
'id': '16943797',
|
||||
'ext': 'mp4',
|
||||
'title': '#EntView #カリナ #セブチ 2024-05-05 06:58',
|
||||
'comment_count': int,
|
||||
'view_count': int,
|
||||
'timestamp': 1714726805,
|
||||
'uploader': 'Ent.View K-news🎶💕',
|
||||
'uploader_id': '16943797',
|
||||
'live_status': 'is_live',
|
||||
'upload_date': '20240503',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://mixch.tv/u/16137876/live',
|
||||
'only_matching': True,
|
||||
|
@ -48,8 +57,20 @@ def _real_extract(self, url):
|
|||
'protocol': 'm3u8',
|
||||
}],
|
||||
'is_live': True,
|
||||
'__post_extractor': self.extract_comments(video_id),
|
||||
}
|
||||
|
||||
def _get_comments(self, video_id):
|
||||
yield from traverse_obj(self._download_json(
|
||||
f'https://mixch.tv/api-web/lives/{video_id}/messages', video_id,
|
||||
note='Downloading comments', errnote='Failed to download comments'), (..., {
|
||||
'author': ('name', {str}),
|
||||
'author_id': ('user_id', {str_or_none}),
|
||||
'id': ('message_id', {str}, {lambda x: x or None}),
|
||||
'text': ('body', {str}),
|
||||
'timestamp': ('created', {int}),
|
||||
}))
|
||||
|
||||
|
||||
class MixchArchiveIE(InfoExtractor):
|
||||
IE_NAME = 'mixch:archive'
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
from ..networking import HEADRequest
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
LazyList,
|
||||
UnsupportedError,
|
||||
UserNotLive,
|
||||
determine_ext,
|
||||
|
@ -793,102 +792,150 @@ def _real_extract(self, url):
|
|||
|
||||
class TikTokUserIE(TikTokBaseIE):
|
||||
IE_NAME = 'tiktok:user'
|
||||
_VALID_URL = r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])'
|
||||
_WORKING = False
|
||||
_VALID_URL = [
|
||||
r'https?://(?:www\.)?tiktok\.com/@(?P<id>[\w\.-]+)/?(?:$|[#?])',
|
||||
r'tiktokuser:(?P<id>MS4wLjABAAAA[\w-]{64})',
|
||||
]
|
||||
_TESTS = [{
|
||||
'url': 'https://tiktok.com/@corgibobaa?lang=en',
|
||||
'playlist_mincount': 45,
|
||||
'info_dict': {
|
||||
'id': '6935371178089399301',
|
||||
'id': 'MS4wLjABAAAAepiJKgwWhulvCpSuUVsp7sgVVsFJbbNaLeQ6OQ0oAJERGDUIXhb2yxxHZedsItgT',
|
||||
'title': 'corgibobaa',
|
||||
'thumbnail': r're:https://.+_1080x1080\.webp'
|
||||
},
|
||||
'expected_warnings': ['Retrying']
|
||||
}, {
|
||||
'url': 'https://www.tiktok.com/@6820838815978423302',
|
||||
'playlist_mincount': 5,
|
||||
'info_dict': {
|
||||
'id': '6820838815978423302',
|
||||
'id': 'MS4wLjABAAAA0tF1nBwQVVMyrGu3CqttkNgM68Do1OXUFuCY0CRQk8fEtSVDj89HqoqvbSTmUP2W',
|
||||
'title': '6820838815978423302',
|
||||
'thumbnail': r're:https://.+_1080x1080\.webp'
|
||||
},
|
||||
'expected_warnings': ['Retrying']
|
||||
}, {
|
||||
'url': 'https://www.tiktok.com/@meme',
|
||||
'playlist_mincount': 593,
|
||||
'info_dict': {
|
||||
'id': '79005827461758976',
|
||||
'id': 'MS4wLjABAAAAiKfaDWeCsT3IHwY77zqWGtVRIy9v4ws1HbVi7auP1Vx7dJysU_hc5yRiGywojRD6',
|
||||
'title': 'meme',
|
||||
'thumbnail': r're:https://.+_1080x1080\.webp'
|
||||
},
|
||||
'expected_warnings': ['Retrying']
|
||||
}, {
|
||||
'url': 'tiktokuser:MS4wLjABAAAAM3R2BtjzVT-uAtstkl2iugMzC6AtnpkojJbjiOdDDrdsTiTR75-8lyWJCY5VvDrZ',
|
||||
'playlist_mincount': 31,
|
||||
'info_dict': {
|
||||
'id': 'MS4wLjABAAAAM3R2BtjzVT-uAtstkl2iugMzC6AtnpkojJbjiOdDDrdsTiTR75-8lyWJCY5VvDrZ',
|
||||
},
|
||||
}]
|
||||
_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0'
|
||||
_API_BASE_URL = 'https://www.tiktok.com/api/creator/item_list/'
|
||||
|
||||
r''' # TODO: Fix by adding _signature to api_url
|
||||
def _entries(self, webpage, user_id, username):
|
||||
secuid = self._search_regex(r'\"secUid\":\"(?P<secUid>[^\"]+)', webpage, username)
|
||||
verifyfp_cookie = self._get_cookies('https://www.tiktok.com').get('s_v_web_id')
|
||||
if not verifyfp_cookie:
|
||||
raise ExtractorError('Improper cookies (missing s_v_web_id).', expected=True)
|
||||
api_url = f'https://m.tiktok.com/api/post/item_list/?aid=1988&cookie_enabled=true&count=30&verifyFp={verifyfp_cookie.value}&secUid={secuid}&cursor='
|
||||
cursor = '0'
|
||||
for page in itertools.count():
|
||||
data_json = self._download_json(api_url + cursor, username, note='Downloading Page %d' % page)
|
||||
for video in data_json.get('itemList', []):
|
||||
video_id = video['id']
|
||||
video_url = f'https://www.tiktok.com/@{user_id}/video/{video_id}'
|
||||
yield self._url_result(video_url, 'TikTok', video_id, str_or_none(video.get('desc')))
|
||||
if not data_json.get('hasMore'):
|
||||
break
|
||||
cursor = data_json['cursor']
|
||||
'''
|
||||
|
||||
def _video_entries_api(self, webpage, user_id, username):
|
||||
query = {
|
||||
'user_id': user_id,
|
||||
'count': 21,
|
||||
'max_cursor': 0,
|
||||
'min_cursor': 0,
|
||||
'retry_type': 'no_retry',
|
||||
'device_id': ''.join(random.choices(string.digits, k=19)), # Some endpoints don't like randomized device_id, so it isn't directly set in _call_api.
|
||||
def _build_web_query(self, sec_uid, cursor):
|
||||
return {
|
||||
'aid': '1988',
|
||||
'app_language': 'en',
|
||||
'app_name': 'tiktok_web',
|
||||
'browser_language': 'en-US',
|
||||
'browser_name': 'Mozilla',
|
||||
'browser_online': 'true',
|
||||
'browser_platform': 'Win32',
|
||||
'browser_version': '5.0 (Windows)',
|
||||
'channel': 'tiktok_web',
|
||||
'cookie_enabled': 'true',
|
||||
'count': '15',
|
||||
'cursor': cursor,
|
||||
'device_id': ''.join(random.choices(string.digits, k=19)),
|
||||
'device_platform': 'web_pc',
|
||||
'focus_state': 'true',
|
||||
'from_page': 'user',
|
||||
'history_len': '2',
|
||||
'is_fullscreen': 'false',
|
||||
'is_page_visible': 'true',
|
||||
'language': 'en',
|
||||
'os': 'windows',
|
||||
'priority_region': '',
|
||||
'referer': '',
|
||||
'region': 'US',
|
||||
'screen_height': '1080',
|
||||
'screen_width': '1920',
|
||||
'secUid': sec_uid,
|
||||
'type': '1', # pagination type: 0 == oldest-to-newest, 1 == newest-to-oldest
|
||||
'tz_name': 'UTC',
|
||||
'verifyFp': 'verify_%s' % ''.join(random.choices(string.hexdigits, k=7)),
|
||||
'webcast_language': 'en',
|
||||
}
|
||||
|
||||
def _entries(self, sec_uid, user_name):
|
||||
cursor = int(time.time() * 1E3)
|
||||
for page in itertools.count(1):
|
||||
for retry in self.RetryManager():
|
||||
try:
|
||||
post_list = self._call_api(
|
||||
'aweme/post', query, username, note=f'Downloading user video list page {page}',
|
||||
errnote='Unable to download user video list')
|
||||
except ExtractorError as e:
|
||||
if isinstance(e.cause, json.JSONDecodeError) and e.cause.pos == 0:
|
||||
retry.error = e
|
||||
continue
|
||||
raise
|
||||
yield from post_list.get('aweme_list', [])
|
||||
if not post_list.get('has_more'):
|
||||
break
|
||||
query['max_cursor'] = post_list['max_cursor']
|
||||
response = self._download_json(
|
||||
self._API_BASE_URL, user_name or sec_uid, f'Downloading page {page}',
|
||||
query=self._build_web_query(sec_uid, cursor), headers={'User-Agent': self._USER_AGENT})
|
||||
|
||||
def _entries_api(self, user_id, videos):
|
||||
for video in videos:
|
||||
yield {
|
||||
**self._parse_aweme_video_app(video),
|
||||
'extractor_key': TikTokIE.ie_key(),
|
||||
'extractor': 'TikTok',
|
||||
'webpage_url': f'https://tiktok.com/@{user_id}/video/{video["aweme_id"]}',
|
||||
}
|
||||
for video in traverse_obj(response, ('itemList', lambda _, v: v['id'])):
|
||||
video_id = video['id']
|
||||
webpage_url = self._create_url(user_name, video_id)
|
||||
info = try_call(
|
||||
lambda: self._parse_aweme_video_web(video, webpage_url, video_id)) or {'id': video_id}
|
||||
info.pop('formats', None)
|
||||
yield self.url_result(webpage_url, TikTokIE, **info)
|
||||
|
||||
old_cursor = cursor
|
||||
cursor = traverse_obj(
|
||||
response, ('itemList', -1, 'createTime', {lambda x: x * 1E3}, {int_or_none}))
|
||||
if not cursor:
|
||||
cursor = old_cursor - 604800000 # jump 1 week back in time
|
||||
if cursor < 1472706000000 or not traverse_obj(response, 'hasMorePrevious'):
|
||||
break
|
||||
|
||||
def _get_sec_uid(self, user_url, user_name, msg):
|
||||
webpage = self._download_webpage(
|
||||
user_url, user_name, fatal=False, headers={'User-Agent': 'Mozilla/5.0'},
|
||||
note=f'Downloading {msg} webpage', errnote=f'Unable to download {msg} webpage') or ''
|
||||
return traverse_obj(
|
||||
self._get_universal_data(webpage, user_name),
|
||||
('webapp.user-detail', 'userInfo', 'user', 'secUid', {str})) or traverse_obj(
|
||||
self._get_sigi_state(webpage, user_name),
|
||||
('LiveRoom', 'liveRoomUserInfo', 'user', 'secUid'),
|
||||
('UserModule', 'users', ..., 'secUid'),
|
||||
get_all=False, expected_type=str)
|
||||
|
||||
def _real_extract(self, url):
|
||||
user_name = self._match_id(url)
|
||||
webpage = self._download_webpage(url, user_name, headers={
|
||||
'User-Agent': 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)'
|
||||
})
|
||||
user_id = self._html_search_regex(r'snssdk\d*://user/profile/(\d+)', webpage, 'user ID', default=None) or user_name
|
||||
user_name, sec_uid = None, None
|
||||
if url.startswith('tiktokuser:'):
|
||||
sec_uid = self._match_id(url)
|
||||
else:
|
||||
user_name = self._match_id(url)
|
||||
|
||||
videos = LazyList(self._video_entries_api(webpage, user_id, user_name))
|
||||
thumbnail = traverse_obj(videos, (0, 'author', 'avatar_larger', 'url_list', 0))
|
||||
if not sec_uid:
|
||||
for user_url, msg in (
|
||||
(self._UPLOADER_URL_FORMAT % user_name, 'user'),
|
||||
(self._UPLOADER_URL_FORMAT % f'{user_name}/live', 'live'),
|
||||
):
|
||||
sec_uid = self._get_sec_uid(user_url, user_name, msg)
|
||||
if sec_uid:
|
||||
break
|
||||
|
||||
return self.playlist_result(self._entries_api(user_id, videos), user_id, user_name, thumbnail=thumbnail)
|
||||
if not sec_uid:
|
||||
webpage = self._download_webpage(
|
||||
f'https://www.tiktok.com/embed/@{user_name}', user_name,
|
||||
note='Downloading user embed page', fatal=False) or ''
|
||||
data = traverse_obj(self._search_json(
|
||||
r'<script[^>]+\bid=[\'"]__FRONTITY_CONNECT_STATE__[\'"][^>]*>',
|
||||
webpage, 'data', user_name, default={}),
|
||||
('source', 'data', f'/embed/@{user_name}', {dict}))
|
||||
|
||||
for aweme_id in traverse_obj(data, ('videoList', ..., 'id')):
|
||||
try:
|
||||
sec_uid = self._extract_aweme_app(aweme_id).get('channel_id')
|
||||
except ExtractorError:
|
||||
continue
|
||||
if sec_uid:
|
||||
break
|
||||
|
||||
if not sec_uid:
|
||||
raise ExtractorError(
|
||||
'Unable to extract secondary user ID. Try using "tiktokuser:CHANNEL_ID" as the '
|
||||
'input URL, replacing "CHANNEL_ID" with the channel_id of the requested user')
|
||||
|
||||
return self.playlist_result(self._entries(sec_uid, user_name), sec_uid, user_name)
|
||||
|
||||
|
||||
class TikTokBaseListIE(TikTokBaseIE): # XXX: Conventionally, base classes should end with BaseIE/InfoExtractor
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import functools
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
float_or_none,
|
||||
int_or_none,
|
||||
smuggle_url,
|
||||
strip_or_none,
|
||||
)
|
||||
from ..utils import float_or_none, int_or_none, smuggle_url, strip_or_none
|
||||
from ..utils.traversal import traverse_obj
|
||||
|
||||
|
||||
class TVAIE(InfoExtractor):
|
||||
|
@ -49,11 +48,20 @@ class QubIE(InfoExtractor):
|
|||
'info_dict': {
|
||||
'id': '6084352463001',
|
||||
'ext': 'mp4',
|
||||
'title': 'Épisode 01',
|
||||
'title': 'Ép 01. Mon dernier jour',
|
||||
'uploader_id': '5481942443001',
|
||||
'upload_date': '20190907',
|
||||
'timestamp': 1567899756,
|
||||
'description': 'md5:9c0d7fbb90939420c651fd977df90145',
|
||||
'thumbnail': r're:https://.+\.jpg',
|
||||
'episode': 'Ép 01. Mon dernier jour',
|
||||
'episode_number': 1,
|
||||
'tags': ['alerte amber', 'alerte amber saison 1', 'surdemande'],
|
||||
'duration': 2625.963,
|
||||
'season': 'Season 1',
|
||||
'season_number': 1,
|
||||
'series': 'Alerte Amber',
|
||||
'channel': 'TVA',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
|
||||
|
@ -64,22 +72,24 @@ class QubIE(InfoExtractor):
|
|||
|
||||
def _real_extract(self, url):
|
||||
entity_id = self._match_id(url)
|
||||
entity = self._download_json(
|
||||
'https://www.qub.ca/proxy/pfu/content-delivery-service/v1/entities',
|
||||
entity_id, query={'id': entity_id})
|
||||
webpage = self._download_webpage(url, entity_id)
|
||||
entity = self._search_nextjs_data(webpage, entity_id)['props']['initialProps']['pageProps']['fallbackData']
|
||||
video_id = entity['videoId']
|
||||
episode = strip_or_none(entity.get('name'))
|
||||
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'url': f'https://videos.tva.ca/details/_{video_id}',
|
||||
'ie_key': TVAIE.ie_key(),
|
||||
'id': video_id,
|
||||
'title': episode,
|
||||
# 'url': self.BRIGHTCOVE_URL_TEMPLATE % entity['referenceId'],
|
||||
'url': 'https://videos.tva.ca/details/_' + video_id,
|
||||
'description': entity.get('longDescription'),
|
||||
'duration': float_or_none(entity.get('durationMillis'), 1000),
|
||||
'episode': episode,
|
||||
'episode_number': int_or_none(entity.get('episodeNumber')),
|
||||
# 'ie_key': 'BrightcoveNew',
|
||||
'ie_key': TVAIE.ie_key(),
|
||||
**traverse_obj(entity, {
|
||||
'description': ('longDescription', {str}),
|
||||
'duration': ('durationMillis', {functools.partial(float_or_none, scale=1000)}),
|
||||
'channel': ('knownEntities', 'channel', 'name', {str}),
|
||||
'series': ('knownEntities', 'videoShow', 'name', {str}),
|
||||
'season_number': ('slug', {lambda x: re.search(r'/s(?:ai|ea)son-(\d+)/', x)}, 1, {int_or_none}),
|
||||
'episode_number': ('episodeNumber', {int_or_none}),
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -451,6 +451,7 @@ def _real_extract(self, url):
|
|||
info_page, 'view count', default=None))
|
||||
|
||||
formats = []
|
||||
subtitles = {}
|
||||
for format_id, format_url in data.items():
|
||||
format_url = url_or_none(format_url)
|
||||
if not format_url or not format_url.startswith(('http', '//', 'rtmp')):
|
||||
|
@ -462,12 +463,21 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'format_id': format_id,
|
||||
'url': format_url,
|
||||
'ext': 'mp4',
|
||||
'source_preference': 1,
|
||||
'height': height,
|
||||
})
|
||||
elif format_id == 'hls':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||
format_url, video_id, 'mp4', 'm3u8_native',
|
||||
m3u8_id=format_id, fatal=False, live=is_live))
|
||||
m3u8_id=format_id, fatal=False, live=is_live)
|
||||
formats.extend(fmts)
|
||||
self._merge_subtitles(subs, target=subtitles)
|
||||
elif format_id.startswith('dash_'):
|
||||
fmts, subs = self._extract_mpd_formats_and_subtitles(
|
||||
format_url, video_id, mpd_id=format_id, fatal=False)
|
||||
formats.extend(fmts)
|
||||
self._merge_subtitles(subs, target=subtitles)
|
||||
elif format_id == 'rtmp':
|
||||
formats.append({
|
||||
'format_id': format_id,
|
||||
|
@ -475,7 +485,6 @@ def _real_extract(self, url):
|
|||
'ext': 'flv',
|
||||
})
|
||||
|
||||
subtitles = {}
|
||||
for sub in data.get('subs') or {}:
|
||||
subtitles.setdefault(sub.get('lang', 'en'), []).append({
|
||||
'ext': sub.get('title', '.srt').split('.')[-1],
|
||||
|
@ -496,6 +505,7 @@ def _real_extract(self, url):
|
|||
'comment_count': int_or_none(mv_data.get('commcount')),
|
||||
'is_live': is_live,
|
||||
'subtitles': subtitles,
|
||||
'_format_sort_fields': ('res', 'source'),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -259,15 +259,15 @@ def _real_extract(self, url):
|
|||
webpage = self._download_webpage(redirect, video_id, note='Redirecting')
|
||||
data_json = self._search_json(
|
||||
r'("data"\s*:|data\s*=)', webpage, 'metadata', video_id, contains_pattern=r'{["\']_*serverState_*video.+}')
|
||||
serverstate = self._search_regex(r'(_+serverState_+video-site_[^_]+_+)',
|
||||
webpage, 'server state').replace('State', 'Settings')
|
||||
serverstate = self._search_regex(r'(_+serverState_+video-site_[^_]+_+)', webpage, 'server state')
|
||||
uploader = self._search_regex(r'(<a\s*class=["\']card-channel-link[^"\']+["\'][^>]+>)',
|
||||
webpage, 'uploader', default='<a>')
|
||||
uploader_name = extract_attributes(uploader).get('aria-label')
|
||||
video_json = try_get(data_json, lambda x: x[serverstate]['exportData']['video'], dict)
|
||||
stream_urls = try_get(video_json, lambda x: x['video']['streams'])
|
||||
item_id = traverse_obj(data_json, (serverstate, 'videoViewer', 'openedItemId', {str}))
|
||||
video_json = traverse_obj(data_json, (serverstate, 'videoViewer', 'items', item_id, {dict})) or {}
|
||||
|
||||
formats, subtitles = [], {}
|
||||
for s_url in stream_urls:
|
||||
for s_url in traverse_obj(video_json, ('video', 'streams', ..., {url_or_none})):
|
||||
ext = determine_ext(s_url)
|
||||
if ext == 'mpd':
|
||||
fmts, subs = self._extract_mpd_formats_and_subtitles(s_url, video_id, mpd_id='dash')
|
||||
|
|
Loading…
Reference in New Issue