|
|
@ -2,8 +2,7 @@
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
from ..compat import compat_str
|
|
|
|
from ..utils import js_to_json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TF1IE(InfoExtractor):
|
|
|
|
class TF1IE(InfoExtractor):
|
|
|
@ -62,23 +61,32 @@ class TF1IE(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
vids_data_string = self._html_search_regex(
|
|
|
|
|
|
|
|
r'<script>\s*window\.__APOLLO_STATE__\s*=\s*(?P<vids_data_string>\{.*?\})\s*;?\s*</script>',
|
|
|
|
wat_id = None
|
|
|
|
webpage, 'videos data string', group='vids_data_string', default=None)
|
|
|
|
|
|
|
|
|
|
|
|
data = self._parse_json(
|
|
|
|
|
|
|
|
self._search_regex(
|
|
|
|
|
|
|
|
r'__APOLLO_STATE__\s*=\s*({.+?})\s*(?:;|</script>)', webpage,
|
|
|
|
|
|
|
|
'data', default='{}'), video_id, fatal=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
wat_id = next(
|
|
|
|
|
|
|
|
video.get('streamId')
|
|
|
|
|
|
|
|
for key, video in data.items()
|
|
|
|
|
|
|
|
if isinstance(video, dict)
|
|
|
|
|
|
|
|
and video.get('slug') == video_id)
|
|
|
|
|
|
|
|
if not isinstance(wat_id, compat_str) or not wat_id.isdigit():
|
|
|
|
wat_id = None
|
|
|
|
wat_id = None
|
|
|
|
if vids_data_string is not None:
|
|
|
|
except StopIteration:
|
|
|
|
vids_data = self._parse_json(
|
|
|
|
pass
|
|
|
|
vids_data_string, video_id,
|
|
|
|
|
|
|
|
transform_source=js_to_json)
|
|
|
|
if not wat_id:
|
|
|
|
video_data = [v for v in vids_data.values()
|
|
|
|
|
|
|
|
if 'slug' in v and v['slug'] == video_id]
|
|
|
|
|
|
|
|
if len(video_data) > 0 and 'streamId' in video_data[0]:
|
|
|
|
|
|
|
|
wat_id = video_data[0]['streamId']
|
|
|
|
|
|
|
|
if wat_id is None:
|
|
|
|
|
|
|
|
wat_id = self._html_search_regex(
|
|
|
|
wat_id = self._html_search_regex(
|
|
|
|
[r'(["\'])(?:https?:)?//www\.wat\.tv/embedframe/.*?(?P<id>\d{8})\1',
|
|
|
|
(r'(["\'])(?:https?:)?//www\.wat\.tv/embedframe/.*?(?P<id>\d{8})\1',
|
|
|
|
r'(["\']?)streamId\1\s*:\s*(["\']?)(?P<id>\d+)\2'
|
|
|
|
r'(["\']?)streamId\1\s*:\s*(["\']?)(?P<id>\d+)\2'),
|
|
|
|
],
|
|
|
|
|
|
|
|
webpage, 'wat id', group='id')
|
|
|
|
webpage, 'wat id', group='id')
|
|
|
|
|
|
|
|
|
|
|
|
return self.url_result('wat:%s' % wat_id, 'Wat')
|
|
|
|
return self.url_result('wat:%s' % wat_id, 'Wat')
|
|
|
|