]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/webofstories.py
2037d9b3d57cd5876d85e9552ffcc9f387fcc975
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import int_or_none
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/'
17 'url': 'http://www.webofstories.com/play/hans.bethe/71',
18 'md5': '373e4dd915f60cfe3116322642ddf364',
22 'title': 'The temperature of the sun',
23 'thumbnail': 're:^https?://.*\.jpg$',
24 'description': 'Hans Bethe talks about calculating the temperature of the sun',
29 'url': 'http://www.webofstories.com/play/55908',
30 'md5': '2985a698e1fe3211022422c4b5ed962c',
34 'title': 'The story of Gemmata obscuriglobus',
35 'thumbnail': 're:^https?://.*\.jpg$',
36 'description': 'Planctomycete talks about The story of Gemmata obscuriglobus',
42 def _real_extract(self
, url
):
43 video_id
= self
._match
_id
(url
)
45 webpage
= self
._download
_webpage
(url
, video_id
)
46 title
= self
._og
_search
_title
(webpage
)
47 description
= self
._html
_search
_meta
('description', webpage
)
48 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
50 embed_params
= [s
.strip(" \r\n\t'") for s
in self
._search
_regex
(
51 r
'(?s)\$\("#embedCode"\).html\(getEmbedCode\((.*?)\)',
52 webpage
, 'embed params').split(',')]
55 _
, speaker_id
, story_id
, story_duration
,
56 speaker_type
, great_life
, _thumbnail
, _has_subtitles
,
57 story_filename
, _story_order
) = embed_params
59 is_great_life_series
= great_life
== 'true'
60 duration
= int_or_none(story_duration
)
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
,
105 class WebOfStoriesPlaylistIE(InfoExtractor
):
106 _VALID_URL
= r
'https?://(?:www\.)?webofstories\.com/playAll/(?P<id>[^/]+)'
108 'url': 'http://www.webofstories.com/playAll/donald.knuth',
110 'id': 'donald.knuth',
111 'title': 'Donald Knuth (Scientist)',
113 'playlist_mincount': 97,
116 def _real_extract(self
, url
):
117 playlist_id
= self
._match
_id
(url
)
119 webpage
= self
._download
_webpage
(url
, playlist_id
)
122 self
.url_result('http://www.webofstories.com/play/%s' % video_number
, 'WebOfStories')
123 for video_number
in set(re
.findall('href="/playAll/%s\?sId=(\d+)"' % playlist_id
, webpage
))
126 title
= self
._search
_regex
(
127 r
'<div id="speakerName">\s*<span>([^<]+)</span>',
128 webpage
, 'speaker', default
=None)
130 field
= self
._search
_regex
(
131 r
'<span id="primaryField">([^<]+)</span>',
132 webpage
, 'field', default
=None)
134 title
+= ' (%s)' % field
137 title
= self
._search
_regex
(
138 r
'<title>Play\s+all\s+stories\s*-\s*([^<]+)\s*-\s*Web\s+of\s+Stories</title>',
141 return self
.playlist_result(entries
, playlist_id
, title
)