float_or_none,
int_or_none,
parse_iso8601,
- sanitized_Request,
+ strip_or_none,
)
class ToggleIE(InfoExtractor):
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 = [{
'url': 'http://www.mewatch.sg/en/series/lion-moms-tif/trailers/lion-moms-premier/343115',
'info_dict': {
'only_matching': True,
}]
- _FORMAT_PREFERENCES = {
- 'wvm-STBMain': -10,
- 'wvm-iPadMain': -20,
- 'wvm-iPhoneMain': -30,
- 'wvm-Android': -40,
- }
_API_USER = 'tvpapi_147'
_API_PASS = '11111'
def _real_extract(self, 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 = {
'initObj': {
'Locale': {
'SiteGuid': 0,
'DomainID': '0',
'UDID': '',
- 'ApiUser': api_user,
- 'ApiPass': api_pass
+ 'ApiUser': self._API_USER,
+ 'ApiPass': self._API_PASS
},
'MediaID': video_id,
'mediaType': 0,
}
- req = sanitized_Request(
+ info = self._download_json(
'http://tvpapi.as.tvinci.com/v2_9/gateways/jsonpostgw.aspx?m=GetMediaInfo',
- json.dumps(params).encode('utf-8'))
- info = self._download_json(req, video_id, 'Downloading video info json')
+ video_id, 'Downloading video info json', data=json.dumps(params).encode('utf-8'))
title = info['MediaName']
vid_format = vid_format.replace(' ', '')
# if geo-restricted, m3u8 is inaccessible, but mp4 is okay
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,
note='Downloading %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':
formats.extend(self._extract_mpd_formats(
video_url, video_id, mpd_id=vid_format,
note='Downloading %s ISM manifest' % vid_format,
errnote='Failed to download %s ISM manifest' % vid_format,
fatal=False))
- elif ext in ('mp4', 'wvm'):
- # wvm are drm-protected files
+ elif ext == 'mp4':
formats.append({
'ext': ext,
'url': video_url,
'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:
+ 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
raise ExtractorError('No downloadable videos found', expected=True)
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 = []
for picture in info.get('Pictures', []):
if not isinstance(picture, dict):
})
thumbnails.append(thumbnail)
+ def counter(prefix):
+ return int_or_none(
+ info.get(prefix + 'Counter') or info.get(prefix.lower() + '_counter'))
+
return {
'id': video_id,
'title': title,
- 'description': description,
- 'duration': duration,
- 'timestamp': created_at,
- 'average_rating': average_rating,
- 'view_count': view_count,
- 'like_count': like_count,
+ 'description': strip_or_none(info.get('Description')),
+ 'duration': int_or_none(info.get('Duration')),
+ 'timestamp': parse_iso8601(info.get('CreationDate') or None),
+ 'average_rating': float_or_none(info.get('Rating')),
+ 'view_count': counter('View'),
+ 'like_count': counter('Like'),
'thumbnails': thumbnails,
'formats': formats,
}
+
+
+class MeWatchIE(InfoExtractor):
+ IE_NAME = 'mewatch'
+ _VALID_URL = r'https?://(?:(?:www|live)\.)?mewatch\.sg/watch/[^/?#&]+-(?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',
+ },
+ }, {
+ 'url': 'https://www.mewatch.sg/watch/Little-Red-Dot-Detectives-S2-搜密。打卡。小红点-S2-E1-176232',
+ 'only_matching': True,
+ }, {
+ 'url': 'https://www.mewatch.sg/watch/Little-Red-Dot-Detectives-S2-%E6%90%9C%E5%AF%86%E3%80%82%E6%89%93%E5%8D%A1%E3%80%82%E5%B0%8F%E7%BA%A2%E7%82%B9-S2-E1-176232',
+ 'only_matching': True,
+ }, {
+ 'url': 'https://live.mewatch.sg/watch/Recipe-Of-Life-E41-189759',
+ 'only_matching': True,
+ }]
+
+ 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)