3 from .common
import InfoExtractor
10 class WebOfStoriesIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?webofstories\.com/play/(?:[^/]+/)?(?P<id>[0-9]+)'
12 _VIDEO_DOMAIN
= 'http://eu-mobile.webofstories.com/'
13 _GREAT_LIFE_STREAMER
= 'rtmp://eu-cdn1.webofstories.com/cfx/st/'
14 _USER_STREAMER
= 'rtmp://eu-users.webofstories.com/cfx/st/'
16 'url': 'http://www.webofstories.com/play/hans.bethe/71',
17 'md5': '373e4dd915f60cfe3116322642ddf364',
21 'title': 'The temperature of the sun',
22 'thumbnail': r
're:^https?://.*\.jpg$',
23 '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': r
're:^https?://.*\.jpg$',
34 'description': 'Planctomycete talks about The story of Gemmata obscuriglobus',
39 # malformed og:title meta
40 'url': 'http://www.webofstories.com/play/54215?o=MS',
44 'title': '"A Leg to Stand On"',
45 'thumbnail': r
're:^https?://.*\.jpg$',
46 'description': 'Oliver Sacks talks about the death and resurrection of a limb',
50 'skip_download': True,
54 def _real_extract(self
, url
):
55 video_id
= self
._match
_id
(url
)
57 webpage
= self
._download
_webpage
(url
, video_id
)
58 # Sometimes og:title meta is malformed
59 title
= self
._og
_search
_title
(webpage
, default
=None) or self
._html
_search
_regex
(
60 r
'(?s)<strong>Title:\s*</strong>(.+?)<', webpage
, 'title')
61 description
= self
._html
_search
_meta
('description', webpage
)
62 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
64 embed_params
= [s
.strip(" \r\n\t'") for s
in self
._search
_regex
(
65 r
'(?s)\$\("#embedCode"\).html\(getEmbedCode\((.*?)\)',
66 webpage
, 'embed params').split(',')]
69 _
, speaker_id
, story_id
, story_duration
,
70 speaker_type
, great_life
, _thumbnail
, _has_subtitles
,
71 story_filename
, _story_order
) = embed_params
73 is_great_life_series
= great_life
== 'true'
74 duration
= int_or_none(story_duration
)
76 # URL building, see: http://www.webofstories.com/scripts/player.js
78 if speaker_type
.lower() == 'ms':
79 ms_prefix
= 'mini_sites/'
81 if is_great_life_series
:
82 mp4_url
= f
'{self._VIDEO_DOMAIN}lives/{speaker_id}/{story_filename}.mp4'
84 streamer
= self
._GREAT
_LIFE
_STREAMER
85 play_path
= f
'stories/{speaker_id}/{story_filename}'
87 mp4_url
= f
'{self._VIDEO_DOMAIN}{ms_prefix}{speaker_id}/{story_filename}.mp4'
89 streamer
= self
._USER
_STREAMER
90 play_path
= f
'mp4:{ms_prefix}{speaker_id}/{story_filename}.mp4'
93 'format_id': 'mp4_sd',
96 'format_id': 'rtmp_sd',
100 'play_path': play_path
,
107 'thumbnail': thumbnail
,
108 'description': description
,
109 'duration': duration
,
113 class WebOfStoriesPlaylistIE(InfoExtractor
):
114 _VALID_URL
= r
'https?://(?:www\.)?webofstories\.com/playAll/(?P<id>[^/]+)'
116 'url': 'http://www.webofstories.com/playAll/donald.knuth',
118 'id': 'donald.knuth',
119 'title': 'Donald Knuth (Scientist)',
121 'playlist_mincount': 97,
124 def _real_extract(self
, url
):
125 playlist_id
= self
._match
_id
(url
)
127 webpage
= self
._download
_webpage
(url
, playlist_id
)
131 f
'http://www.webofstories.com/play/{video_id}',
132 'WebOfStories', video_id
=video_id
)
133 for video_id
in orderedSet(re
.findall(r
'\bid=["\']td_(\d
+)', webpage))
136 title = self._search_regex(
137 r'<div
id="speakerName">\s
*<span
>([^
<]+)</span
>',
138 webpage, 'speaker
', default=None)
140 field = self._search_regex(
141 r'<span
id="primaryField">([^
<]+)</span
>',
142 webpage, 'field
', default=None)
144 title += f' ({field}
)'
147 title = self._search_regex(
148 r'<title
>Play\s
+all\s
+stories\s
*-\s
*([^
<]+)\s
*-\s
*Web\s
+of\s
+Stories
</title
>',
151 return self.playlist_result(entries, playlist_id, title)