mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-22 20:20:09 +09:00
Compare commits
3 Commits
132aece1ed
...
37d979ad33
Author | SHA1 | Date | |
---|---|---|---|
|
37d979ad33 | ||
|
95ac4de229 | ||
|
d3e142b3fa |
@ -1185,7 +1185,10 @@ from .tnaflix import (
|
|||||||
EMPFlixIE,
|
EMPFlixIE,
|
||||||
MovieFapIE,
|
MovieFapIE,
|
||||||
)
|
)
|
||||||
from .toggle import ToggleIE
|
from .toggle import (
|
||||||
|
ToggleIE,
|
||||||
|
MeWatchIE,
|
||||||
|
)
|
||||||
from .tonline import TOnlineIE
|
from .tonline import TOnlineIE
|
||||||
from .toongoggles import ToonGogglesIE
|
from .toongoggles import ToonGogglesIE
|
||||||
from .toutv import TouTvIE
|
from .toutv import TouTvIE
|
||||||
|
@ -11,13 +11,13 @@ from ..utils import (
|
|||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
sanitized_Request,
|
strip_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ToggleIE(InfoExtractor):
|
class ToggleIE(InfoExtractor):
|
||||||
IE_NAME = 'toggle'
|
IE_NAME = 'toggle'
|
||||||
_VALID_URL = r'https?://(?:(?:www\.)?mewatch|video\.toggle)\.sg/(?:en|zh)/(?:[^/]+/){2,}(?P<id>[0-9]+)'
|
_VALID_URL = r'(?:https?://(?:(?:www\.)?mewatch|video\.toggle)\.sg/(?:en|zh)/(?:[^/]+/){2,}|toggle:)(?P<id>[0-9]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.mewatch.sg/en/series/lion-moms-tif/trailers/lion-moms-premier/343115',
|
'url': 'http://www.mewatch.sg/en/series/lion-moms-tif/trailers/lion-moms-premier/343115',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -84,28 +84,12 @@ class ToggleIE(InfoExtractor):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_FORMAT_PREFERENCES = {
|
|
||||||
'wvm-STBMain': -10,
|
|
||||||
'wvm-iPadMain': -20,
|
|
||||||
'wvm-iPhoneMain': -30,
|
|
||||||
'wvm-Android': -40,
|
|
||||||
}
|
|
||||||
_API_USER = 'tvpapi_147'
|
_API_USER = 'tvpapi_147'
|
||||||
_API_PASS = '11111'
|
_API_PASS = '11111'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(
|
|
||||||
url, video_id, note='Downloading video page')
|
|
||||||
|
|
||||||
api_user = self._search_regex(
|
|
||||||
r'apiUser\s*:\s*(["\'])(?P<user>.+?)\1', webpage, 'apiUser',
|
|
||||||
default=self._API_USER, group='user')
|
|
||||||
api_pass = self._search_regex(
|
|
||||||
r'apiPass\s*:\s*(["\'])(?P<pass>.+?)\1', webpage, 'apiPass',
|
|
||||||
default=self._API_PASS, group='pass')
|
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'initObj': {
|
'initObj': {
|
||||||
'Locale': {
|
'Locale': {
|
||||||
@ -118,17 +102,16 @@ class ToggleIE(InfoExtractor):
|
|||||||
'SiteGuid': 0,
|
'SiteGuid': 0,
|
||||||
'DomainID': '0',
|
'DomainID': '0',
|
||||||
'UDID': '',
|
'UDID': '',
|
||||||
'ApiUser': api_user,
|
'ApiUser': self._API_USER,
|
||||||
'ApiPass': api_pass
|
'ApiPass': self._API_PASS
|
||||||
},
|
},
|
||||||
'MediaID': video_id,
|
'MediaID': video_id,
|
||||||
'mediaType': 0,
|
'mediaType': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
req = sanitized_Request(
|
info = self._download_json(
|
||||||
'http://tvpapi.as.tvinci.com/v2_9/gateways/jsonpostgw.aspx?m=GetMediaInfo',
|
'http://tvpapi.as.tvinci.com/v2_9/gateways/jsonpostgw.aspx?m=GetMediaInfo',
|
||||||
json.dumps(params).encode('utf-8'))
|
video_id, 'Downloading video info json', data=json.dumps(params).encode('utf-8'))
|
||||||
info = self._download_json(req, video_id, 'Downloading video info json')
|
|
||||||
|
|
||||||
title = info['MediaName']
|
title = info['MediaName']
|
||||||
|
|
||||||
@ -141,11 +124,16 @@ class ToggleIE(InfoExtractor):
|
|||||||
vid_format = vid_format.replace(' ', '')
|
vid_format = vid_format.replace(' ', '')
|
||||||
# if geo-restricted, m3u8 is inaccessible, but mp4 is okay
|
# if geo-restricted, m3u8 is inaccessible, but mp4 is okay
|
||||||
if ext == 'm3u8':
|
if ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
video_url, video_id, ext='mp4', m3u8_id=vid_format,
|
video_url, video_id, ext='mp4', m3u8_id=vid_format,
|
||||||
note='Downloading %s m3u8 information' % vid_format,
|
note='Downloading %s m3u8 information' % vid_format,
|
||||||
errnote='Failed to download %s m3u8 information' % vid_format,
|
errnote='Failed to download %s m3u8 information' % vid_format,
|
||||||
fatal=False))
|
fatal=False)
|
||||||
|
for f in m3u8_formats:
|
||||||
|
# Apple FairPlay Streaming
|
||||||
|
if '/fpshls/' in f['url']:
|
||||||
|
continue
|
||||||
|
formats.append(f)
|
||||||
elif ext == 'mpd':
|
elif ext == 'mpd':
|
||||||
formats.extend(self._extract_mpd_formats(
|
formats.extend(self._extract_mpd_formats(
|
||||||
video_url, video_id, mpd_id=vid_format,
|
video_url, video_id, mpd_id=vid_format,
|
||||||
@ -158,28 +146,21 @@ class ToggleIE(InfoExtractor):
|
|||||||
note='Downloading %s ISM manifest' % vid_format,
|
note='Downloading %s ISM manifest' % vid_format,
|
||||||
errnote='Failed to download %s ISM manifest' % vid_format,
|
errnote='Failed to download %s ISM manifest' % vid_format,
|
||||||
fatal=False))
|
fatal=False))
|
||||||
elif ext in ('mp4', 'wvm'):
|
elif ext == 'mp4':
|
||||||
# wvm are drm-protected files
|
|
||||||
formats.append({
|
formats.append({
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'format_id': vid_format,
|
'format_id': vid_format,
|
||||||
'preference': self._FORMAT_PREFERENCES.get(ext + '-' + vid_format) or -1,
|
|
||||||
'format_note': 'DRM-protected video' if ext == 'wvm' else None
|
|
||||||
})
|
})
|
||||||
if not formats:
|
if not formats:
|
||||||
|
for meta in (info.get('Metas') or []):
|
||||||
|
if meta.get('Key') == 'Encryption' and meta.get('Value') == '1':
|
||||||
|
raise ExtractorError(
|
||||||
|
'This video is DRM protected.', expected=True)
|
||||||
# Most likely because geo-blocked
|
# Most likely because geo-blocked
|
||||||
raise ExtractorError('No downloadable videos found', expected=True)
|
raise ExtractorError('No downloadable videos found', expected=True)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
duration = int_or_none(info.get('Duration'))
|
|
||||||
description = info.get('Description')
|
|
||||||
created_at = parse_iso8601(info.get('CreationDate') or None)
|
|
||||||
|
|
||||||
average_rating = float_or_none(info.get('Rating'))
|
|
||||||
view_count = int_or_none(info.get('ViewCounter') or info.get('view_counter'))
|
|
||||||
like_count = int_or_none(info.get('LikeCounter') or info.get('like_counter'))
|
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
for picture in info.get('Pictures', []):
|
for picture in info.get('Pictures', []):
|
||||||
if not isinstance(picture, dict):
|
if not isinstance(picture, dict):
|
||||||
@ -199,15 +180,46 @@ class ToggleIE(InfoExtractor):
|
|||||||
})
|
})
|
||||||
thumbnails.append(thumbnail)
|
thumbnails.append(thumbnail)
|
||||||
|
|
||||||
|
def counter(prefix):
|
||||||
|
return int_or_none(
|
||||||
|
info.get(prefix + 'Counter') or info.get(prefix.lower() + '_counter'))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': description,
|
'description': strip_or_none(info.get('Description')),
|
||||||
'duration': duration,
|
'duration': int_or_none(info.get('Duration')),
|
||||||
'timestamp': created_at,
|
'timestamp': parse_iso8601(info.get('CreationDate') or None),
|
||||||
'average_rating': average_rating,
|
'average_rating': float_or_none(info.get('Rating')),
|
||||||
'view_count': view_count,
|
'view_count': counter('View'),
|
||||||
'like_count': like_count,
|
'like_count': counter('Like'),
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class MeWatchIE(InfoExtractor):
|
||||||
|
IE_NAME = 'mewatch'
|
||||||
|
_VALID_URL = r'https?://(?:www\.)?mewatch\.sg/watch/[0-9a-zA-Z-]+-(?P<id>[0-9]+)'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.mewatch.sg/watch/Recipe-Of-Life-E1-179371',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '1008625',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Recipe Of Life 味之道',
|
||||||
|
'timestamp': 1603306526,
|
||||||
|
'description': 'md5:6e88cde8af2068444fc8e1bc3ebf257c',
|
||||||
|
'upload_date': '20201021',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': 'm3u8 download',
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
item_id = self._match_id(url)
|
||||||
|
custom_id = self._download_json(
|
||||||
|
'https://cdn.mewatch.sg/api/items/' + item_id,
|
||||||
|
item_id, query={'segments': 'all'})['customId']
|
||||||
|
return self.url_result(
|
||||||
|
'toggle:' + custom_id, ToggleIE.ie_key(), custom_id)
|
||||||
|
@ -4,7 +4,9 @@ from __future__ import unicode_literals
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
float_or_none,
|
||||||
|
int_or_none,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
|
strip_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +25,8 @@ class TVAIE(InfoExtractor):
|
|||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
}
|
},
|
||||||
|
'skip': 'HTTP Error 404: Not Found',
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://video.tva.ca/details/_5596811470001',
|
'url': 'https://video.tva.ca/details/_5596811470001',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -32,26 +35,54 @@ class TVAIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
video_data = self._download_json(
|
|
||||||
'https://videos.tva.ca/proxy/item/_' + video_id, video_id, headers={
|
|
||||||
'Accept': 'application/json',
|
|
||||||
}, query={
|
|
||||||
'appId': '5955fc5f23eec60006c951f1',
|
|
||||||
})
|
|
||||||
|
|
||||||
def get_attribute(key):
|
|
||||||
for attribute in video_data.get('attributes', []):
|
|
||||||
if attribute.get('key') == key:
|
|
||||||
return attribute.get('value')
|
|
||||||
return None
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': get_attribute('title'),
|
|
||||||
'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
|
'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
|
||||||
'description': get_attribute('description'),
|
|
||||||
'thumbnail': get_attribute('image-background') or get_attribute('image-landscape'),
|
|
||||||
'duration': float_or_none(get_attribute('video-duration'), 1000),
|
|
||||||
'ie_key': 'BrightcoveNew',
|
'ie_key': 'BrightcoveNew',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class QubIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'https?://(?:www\.)?qub\.ca/(?:[^/]+/)*[0-9a-z-]+-(?P<id>\d+)'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.qub.ca/tvaplus/tva/alerte-amber/saison-1/episode-01-1000036619',
|
||||||
|
'md5': '949490fd0e7aee11d0543777611fbd53',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '6084352463001',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Épisode 01',
|
||||||
|
'uploader_id': '5481942443001',
|
||||||
|
'upload_date': '20190907',
|
||||||
|
'timestamp': 1567899756,
|
||||||
|
'description': 'md5:9c0d7fbb90939420c651fd977df90145',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
# reference_id also works with old account_id(5481942443001)
|
||||||
|
# BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5813221784001/default_default/index.html?videoId=ref:%s'
|
||||||
|
|
||||||
|
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})
|
||||||
|
video_id = entity['videoId']
|
||||||
|
episode = strip_or_none(entity.get('name'))
|
||||||
|
|
||||||
|
return {
|
||||||
|
'_type': 'url_transparent',
|
||||||
|
'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(),
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user