]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/webofstories.py
73077a312549f6b883fdf549a2b364f6de35db9f
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 embed_params
= [s
.strip(" \r\n\t'") for s
in self
._search
_regex
(
49 r
'(?s)\$\("#embedCode"\).html\(getEmbedCode\((.*?)\)',
50 webpage
, 'embed params').split(',')]
53 _
, speaker_id
, story_id
, story_duration
,
54 speaker_type
, great_life
, _thumbnail
, _has_subtitles
,
55 story_filename
, _story_order
) = embed_params
57 is_great_life_series
= great_life
== 'true'
58 duration
= int_or_none(story_duration
)
60 # URL building, see: http://www.webofstories.com/scripts/player.js
62 if speaker_type
.lower() == 'ms':
63 ms_prefix
= 'mini_sites/'
65 if is_great_life_series
:
66 mp4_url
= '{0:}lives/{1:}/{2:}.mp4'.format(
67 self
._VIDEO
_DOMAIN
, speaker_id
, story_filename
)
69 streamer
= self
._GREAT
_LIFE
_STREAMER
70 play_path
= 'stories/{0:}/{1:}'.format(
71 speaker_id
, story_filename
)
73 mp4_url
= '{0:}{1:}{2:}/{3:}.mp4'.format(
74 self
._VIDEO
_DOMAIN
, ms_prefix
, speaker_id
, story_filename
)
76 streamer
= self
._USER
_STREAMER
77 play_path
= 'mp4:{0:}{1:}/{2}.mp4'.format(
78 ms_prefix
, speaker_id
, story_filename
)
81 'format_id': 'mp4_sd',
84 'format_id': 'rtmp_sd',
88 'play_path': play_path
,
91 self
._sort
_formats
(formats
)
97 'thumbnail': thumbnail
,
98 'description': description
,