2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..utils import int_or_none
8 class WebOfStoriesIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?webofstories\.com/play/(?:[^/]+/)?(?P<id>[0-9]+)'
10 _VIDEO_DOMAIN = 'http://eu-mobile.webofstories.com/'
11 _GREAT_LIFE_STREAMER = 'rtmp://eu-cdn1.webofstories.com/cfx/st/'
12 _USER_STREAMER = 'rtmp://eu-users.webofstories.com/cfx/st/'
15 'url': 'http://www.webofstories.com/play/hans.bethe/71',
16 'md5': '373e4dd915f60cfe3116322642ddf364',
20 'title': 'The temperature of the sun',
21 'thumbnail': 're:^https?://.*\.jpg$',
22 'description': 'Hans Bethe talks about calculating the temperature of the sun',
27 'url': 'http://www.webofstories.com/play/55908',
28 'md5': '2985a698e1fe3211022422c4b5ed962c',
32 'title': 'The story of Gemmata obscuriglobus',
33 'thumbnail': 're:^https?://.*\.jpg$',
34 'description': 'Planctomycete talks about The story of Gemmata obscuriglobus',
40 def _real_extract(self, url):
41 video_id = self._match_id(url)
43 webpage = self._download_webpage(url, video_id)
44 title = self._og_search_title(webpage)
45 description = self._html_search_meta('description', webpage)
46 thumbnail = self._og_search_thumbnail(webpage)
48 story_filename = self._search_regex(
49 r'\.storyFileName\("([^"]+)"\)', webpage, 'story filename')
50 speaker_id = self._search_regex(
51 r'\.speakerId\("([^"]+)"\)', webpage, 'speaker ID')
52 story_id = self._search_regex(
53 r'\.storyId\((\d+)\)', webpage, 'story ID')
54 speaker_type = self._search_regex(
55 r'\.speakerType\("([^"]+)"\)', webpage, 'speaker type')
56 great_life = self._search_regex(
57 r'isGreatLifeStory\s*=\s*(true|false)', webpage, 'great life story')
58 is_great_life_series = great_life == 'true'
59 duration = int_or_none(self._search_regex(
60 r'\.duration\((\d+)\)', webpage, 'duration', fatal=False))
62 # URL building, see: http://www.webofstories.com/scripts/player.js
64 if speaker_type.lower() == 'ms':
65 ms_prefix = 'mini_sites/'
67 if is_great_life_series:
68 mp4_url = '{0:}lives/{1:}/{2:}.mp4'.format(
69 self._VIDEO_DOMAIN, speaker_id, story_filename)
71 streamer = self._GREAT_LIFE_STREAMER
72 play_path = 'stories/{0:}/{1:}'.format(
73 speaker_id, story_filename)
75 mp4_url = '{0:}{1:}{2:}/{3:}.mp4'.format(
76 self._VIDEO_DOMAIN, ms_prefix, speaker_id, story_filename)
78 streamer = self._USER_STREAMER
79 play_path = 'mp4:{0:}{1:}/{2}.mp4'.format(
80 ms_prefix, speaker_id, story_filename)
83 'format_id': 'mp4_sd',
86 'format_id': 'rtmp_sd',
90 'play_path': play_path,
93 self._sort_formats(formats)
99 'thumbnail': thumbnail,
100 'description': description,
101 'duration': duration,