]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/webofstories.py
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
,