]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/storyfire.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class StoryFireBaseIE(InfoExtractor
):
16 _VALID_URL_BASE
= r
'https?://(?:www\.)?storyfire\.com/'
18 def _call_api(self
, path
, video_id
, resource
, query
=None):
19 return self
._download
_json
(
20 'https://storyfire.com/app/%s/%s' % (path
, video_id
), video_id
,
21 'Downloading %s JSON metadata' % resource
, query
=query
)
23 def _parse_video(self
, video
):
24 title
= video
['title']
25 vimeo_id
= self
._search
_regex
(
26 r
'https?://player\.vimeo\.com/external/(\d+)',
27 video
['vimeoVideoURL'], 'vimeo id')
29 # video_url = self._request_webpage(
30 # HEADRequest(video['vimeoVideoURL']), video_id).geturl()
32 # for v_url, suffix in [(video_url, '_sep'), (video_url.replace('/sep/video/', '/video/'), '')]:
33 # formats.extend(self._extract_m3u8_formats(
34 # v_url, video_id, 'mp4', 'm3u8_native',
35 # m3u8_id='hls' + suffix, fatal=False))
36 # formats.extend(self._extract_mpd_formats(
37 # v_url.replace('.m3u8', '.mpd'), video_id,
38 # mpd_id='dash' + suffix, fatal=False))
39 # self._sort_formats(formats)
41 uploader_id
= video
.get('hostID')
44 '_type': 'url_transparent',
47 'description': video
.get('description'),
49 'https://player.vimeo.com/video/' + vimeo_id
, {
51 'Referer': 'https://storyfire.com/',
55 'thumbnail': video
.get('storyImage'),
56 'view_count': int_or_none(video
.get('views')),
57 'like_count': int_or_none(video
.get('likesCount')),
58 'comment_count': int_or_none(video
.get('commentsCount')),
59 'duration': int_or_none(video
.get('videoDuration')),
60 'timestamp': int_or_none(video
.get('publishDate')),
61 'uploader': video
.get('username'),
62 'uploader_id': uploader_id
,
63 'uploader_url': 'https://storyfire.com/user/%s/video' % uploader_id
if uploader_id
else None,
64 'episode_number': int_or_none(video
.get('episodeNumber') or video
.get('episode_number')),
68 class StoryFireIE(StoryFireBaseIE
):
69 _VALID_URL
= StoryFireBaseIE
._VALID
_URL
_BASE
+ r
'video-details/(?P<id>[0-9a-f]{24})'
71 'url': 'https://storyfire.com/video-details/5df1d132b6378700117f9181',
72 'md5': 'caec54b9e4621186d6079c7ec100c1eb',
76 'title': 'Buzzfeed Teaches You About Memes',
77 'uploader_id': 'ntZAJFECERSgqHSxzonV5K2E89s1',
78 'timestamp': 1576129028,
79 'description': 'md5:0b4e28021548e144bed69bb7539e62ea',
81 'upload_date': '20191212',
88 'skip_download': True,
90 'expected_warnings': ['Unable to download JSON metadata']
93 def _real_extract(self
, url
):
94 video_id
= self
._match
_id
(url
)
95 video
= self
._call
_api
(
96 'generic/video-detail', video_id
, 'video')['video']
97 return self
._parse
_video
(video
)
100 class StoryFireUserIE(StoryFireBaseIE
):
101 _VALID_URL
= StoryFireBaseIE
._VALID
_URL
_BASE
+ r
'user/(?P<id>[^/]+)/video'
103 'url': 'https://storyfire.com/user/UQ986nFxmAWIgnkZQ0ftVhq4nOk2/video',
105 'id': 'UQ986nFxmAWIgnkZQ0ftVhq4nOk2',
107 'playlist_mincount': 151,
111 def _fetch_page(self
, user_id
, page
):
112 videos
= self
._call
_api
(
113 'publicVideos', user_id
, 'page %d' % (page
+ 1), {
114 'skip': page
* self
._PAGE
_SIZE
,
117 yield self
._parse
_video
(video
)
119 def _real_extract(self
, url
):
120 user_id
= self
._match
_id
(url
)
121 entries
= OnDemandPagedList(functools
.partial(
122 self
._fetch
_page
, user_id
), self
._PAGE
_SIZE
)
123 return self
.playlist_result(entries
, user_id
)
126 class StoryFireSeriesIE(StoryFireBaseIE
):
127 _VALID_URL
= StoryFireBaseIE
._VALID
_URL
_BASE
+ r
'write/series/stories/(?P<id>[^/?&#]+)'
129 'url': 'https://storyfire.com/write/series/stories/-Lq6MsuIHLODO6d2dDkr/',
131 'id': '-Lq6MsuIHLODO6d2dDkr',
133 'playlist_mincount': 13,
135 'url': 'https://storyfire.com/write/series/stories/the_mortal_one/',
137 'id': 'the_mortal_one',
142 def _extract_videos(self
, stories
):
143 for story
in stories
.values():
144 if story
.get('hasVideo'):
145 yield self
._parse
_video
(story
)
147 def _real_extract(self
, url
):
148 series_id
= self
._match
_id
(url
)
149 stories
= self
._call
_api
(
150 'seriesStories', series_id
, 'series stories')
151 return self
.playlist_result(self
._extract
_videos
(stories
), series_id
)