mirror of https://github.com/yt-dlp/yt-dlp.git
[Fancode] fix video extraction, regex
This commit is contained in:
parent
576faf00b2
commit
2559d457d7
|
@ -12,7 +12,7 @@ from ..utils import (
|
|||
class FancodeVodIE(InfoExtractor):
|
||||
IE_NAME = 'fancode:vod'
|
||||
|
||||
_VALID_URL = r'https?://(?:www\.)?fancode\.com/video/(?P<id>[0-9]+)\b'
|
||||
_VALID_URL = r'https?://(?:www\.)?fancode\.com(?:/[a-zA-Z0-9].*)?/videos?/(?:(?:[^/])*?/)?(?P<id>[0-9]+)\b'
|
||||
|
||||
_TESTS = [{
|
||||
'url': 'https://fancode.com/video/15043/match-preview-pbks-vs-mi',
|
||||
|
@ -33,6 +33,21 @@ class FancodeVodIE(InfoExtractor):
|
|||
}, {
|
||||
'url': 'https://fancode.com/video/15043',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
'url': 'https://www.fancode.com/cricket/videos/thriller-india-fightback-to-clinch-2wicket-win/35441',
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
},
|
||||
'info_dict': {
|
||||
'id': '35441',
|
||||
'ext': 'mp4',
|
||||
'title': 'Thriller! India fightback to clinch 2-wicket win',
|
||||
'thumbnail': r're:^https?://.*\.jpg$',
|
||||
"timestamp": 1619081590,
|
||||
'view_count': int,
|
||||
'like_count': int,
|
||||
'release_timestamp': 1658702382
|
||||
}
|
||||
}]
|
||||
|
||||
_ACCESS_TOKEN = None
|
||||
|
@ -89,7 +104,7 @@ class FancodeVodIE(InfoExtractor):
|
|||
|
||||
brightcove_user_id = '6008340455001'
|
||||
data = '''{
|
||||
"query":"query Video($id: Int\\u0021, $filter: SegmentFilter) { media(id: $id, filter: $filter) { id contentId title contentId publishedTime totalViews totalUpvotes provider thumbnail { src } mediaSource {brightcove } duration isPremium isUserEntitled tags duration }}",
|
||||
"query":"query Video($id: Int\\u0021, $filter: SegmentFilter) { media(id: $id, filter: $filter) { id contentId title contentId publishedTime totalViews totalUpvotes provider thumbnail { src } mediaSource {brightcove } duration isPremium source {url} isUserEntitled tags duration }}",
|
||||
"variables":{
|
||||
"id":%s,
|
||||
"filter":{
|
||||
|
@ -102,19 +117,17 @@ class FancodeVodIE(InfoExtractor):
|
|||
metadata_json = self.download_gql(video_id, data, note='Downloading metadata')
|
||||
|
||||
media = try_get(metadata_json, lambda x: x['data']['media'], dict) or {}
|
||||
source_url = try_get(media, lambda x: x['source']['url'])
|
||||
brightcove_video_id = try_get(media, lambda x: x['mediaSource']['brightcove'], compat_str)
|
||||
|
||||
if brightcove_video_id is None:
|
||||
raise ExtractorError('Unable to extract brightcove Video ID')
|
||||
if not brightcove_video_id and not source_url:
|
||||
raise ExtractorError('Unable to extract Video URL')
|
||||
|
||||
is_premium = media.get('isPremium')
|
||||
|
||||
self._check_login_required(media.get('isUserEntitled'), is_premium)
|
||||
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'url': BRIGHTCOVE_URL_TEMPLATE % (brightcove_user_id, brightcove_video_id),
|
||||
'ie_key': 'BrightcoveNew',
|
||||
result = {
|
||||
'id': video_id,
|
||||
'title': media['title'],
|
||||
'like_count': media.get('totalUpvotes'),
|
||||
|
@ -124,6 +137,18 @@ class FancodeVodIE(InfoExtractor):
|
|||
'availability': self._availability(needs_premium=is_premium),
|
||||
}
|
||||
|
||||
if brightcove_video_id:
|
||||
result.update({
|
||||
'_type': 'url_transparent',
|
||||
'url': BRIGHTCOVE_URL_TEMPLATE % (brightcove_user_id, brightcove_video_id),
|
||||
'ie_key': 'BrightcoveNew'
|
||||
})
|
||||
|
||||
else:
|
||||
result['formats'] = self._extract_m3u8_formats(source_url, video_id)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class FancodeLiveIE(FancodeVodIE):
|
||||
IE_NAME = 'fancode:live'
|
||||
|
|
Loading…
Reference in New Issue