2021-02-19 15:44:36 -05:00
|
|
|
import functools
|
|
|
|
|
2020-08-16 20:07:14 -04:00
|
|
|
from .common import InfoExtractor
|
2021-02-19 15:44:36 -05:00
|
|
|
from ..utils import (
|
2022-01-21 02:57:40 -05:00
|
|
|
format_field,
|
2021-02-19 15:44:36 -05:00
|
|
|
int_or_none,
|
|
|
|
OnDemandPagedList,
|
|
|
|
smuggle_url,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class StoryFireBaseIE(InfoExtractor):
|
|
|
|
_VALID_URL_BASE = r'https?://(?:www\.)?storyfire\.com/'
|
|
|
|
|
|
|
|
def _call_api(self, path, video_id, resource, query=None):
|
|
|
|
return self._download_json(
|
|
|
|
'https://storyfire.com/app/%s/%s' % (path, video_id), video_id,
|
|
|
|
'Downloading %s JSON metadata' % resource, query=query)
|
|
|
|
|
|
|
|
def _parse_video(self, video):
|
|
|
|
title = video['title']
|
|
|
|
vimeo_id = self._search_regex(
|
|
|
|
r'https?://player\.vimeo\.com/external/(\d+)',
|
|
|
|
video['vimeoVideoURL'], 'vimeo id')
|
|
|
|
|
|
|
|
uploader_id = video.get('hostID')
|
2020-08-16 20:07:14 -04:00
|
|
|
|
2021-02-19 15:44:36 -05:00
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
'id': vimeo_id,
|
|
|
|
'title': title,
|
|
|
|
'description': video.get('description'),
|
|
|
|
'url': smuggle_url(
|
|
|
|
'https://player.vimeo.com/video/' + vimeo_id, {
|
|
|
|
'http_headers': {
|
|
|
|
'Referer': 'https://storyfire.com/',
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
'thumbnail': video.get('storyImage'),
|
|
|
|
'view_count': int_or_none(video.get('views')),
|
|
|
|
'like_count': int_or_none(video.get('likesCount')),
|
|
|
|
'comment_count': int_or_none(video.get('commentsCount')),
|
|
|
|
'duration': int_or_none(video.get('videoDuration')),
|
|
|
|
'timestamp': int_or_none(video.get('publishDate')),
|
|
|
|
'uploader': video.get('username'),
|
|
|
|
'uploader_id': uploader_id,
|
2022-06-17 22:00:12 -04:00
|
|
|
'uploader_url': format_field(uploader_id, None, 'https://storyfire.com/user/%s/video'),
|
2021-02-19 15:44:36 -05:00
|
|
|
'episode_number': int_or_none(video.get('episodeNumber') or video.get('episode_number')),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class StoryFireIE(StoryFireBaseIE):
|
|
|
|
_VALID_URL = StoryFireBaseIE._VALID_URL_BASE + r'video-details/(?P<id>[0-9a-f]{24})'
|
|
|
|
_TEST = {
|
2020-08-16 20:07:14 -04:00
|
|
|
'url': 'https://storyfire.com/video-details/5df1d132b6378700117f9181',
|
2021-02-19 15:44:36 -05:00
|
|
|
'md5': 'caec54b9e4621186d6079c7ec100c1eb',
|
2020-08-16 20:07:14 -04:00
|
|
|
'info_dict': {
|
2021-02-19 15:44:36 -05:00
|
|
|
'id': '378954662',
|
2020-08-16 20:07:14 -04:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Buzzfeed Teaches You About Memes',
|
|
|
|
'uploader_id': 'ntZAJFECERSgqHSxzonV5K2E89s1',
|
|
|
|
'timestamp': 1576129028,
|
2021-02-19 15:44:36 -05:00
|
|
|
'description': 'md5:0b4e28021548e144bed69bb7539e62ea',
|
2020-08-16 20:07:14 -04:00
|
|
|
'uploader': 'whang!',
|
|
|
|
'upload_date': '20191212',
|
2021-02-19 15:44:36 -05:00
|
|
|
'duration': 418,
|
|
|
|
'view_count': int,
|
|
|
|
'like_count': int,
|
|
|
|
'comment_count': int,
|
2020-08-16 20:07:14 -04:00
|
|
|
},
|
2021-02-19 15:44:36 -05:00
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
2020-08-16 20:07:14 -04:00
|
|
|
},
|
2021-02-19 15:44:36 -05:00
|
|
|
'expected_warnings': ['Unable to download JSON metadata']
|
2020-08-16 20:07:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
2021-02-19 15:44:36 -05:00
|
|
|
video = self._call_api(
|
|
|
|
'generic/video-detail', video_id, 'video')['video']
|
|
|
|
return self._parse_video(video)
|
2020-08-16 20:07:14 -04:00
|
|
|
|
|
|
|
|
2021-02-19 15:44:36 -05:00
|
|
|
class StoryFireUserIE(StoryFireBaseIE):
|
|
|
|
_VALID_URL = StoryFireBaseIE._VALID_URL_BASE + r'user/(?P<id>[^/]+)/video'
|
|
|
|
_TEST = {
|
2020-08-16 20:07:14 -04:00
|
|
|
'url': 'https://storyfire.com/user/UQ986nFxmAWIgnkZQ0ftVhq4nOk2/video',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'UQ986nFxmAWIgnkZQ0ftVhq4nOk2',
|
|
|
|
},
|
2021-02-19 15:44:36 -05:00
|
|
|
'playlist_mincount': 151,
|
|
|
|
}
|
|
|
|
_PAGE_SIZE = 20
|
2020-08-16 20:07:14 -04:00
|
|
|
|
2021-02-19 15:44:36 -05:00
|
|
|
def _fetch_page(self, user_id, page):
|
|
|
|
videos = self._call_api(
|
|
|
|
'publicVideos', user_id, 'page %d' % (page + 1), {
|
|
|
|
'skip': page * self._PAGE_SIZE,
|
|
|
|
})['videos']
|
|
|
|
for video in videos:
|
|
|
|
yield self._parse_video(video)
|
2020-08-16 20:07:14 -04:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
user_id = self._match_id(url)
|
2021-02-19 15:44:36 -05:00
|
|
|
entries = OnDemandPagedList(functools.partial(
|
|
|
|
self._fetch_page, user_id), self._PAGE_SIZE)
|
|
|
|
return self.playlist_result(entries, user_id)
|
2020-08-16 20:07:14 -04:00
|
|
|
|
|
|
|
|
2021-02-19 15:44:36 -05:00
|
|
|
class StoryFireSeriesIE(StoryFireBaseIE):
|
|
|
|
_VALID_URL = StoryFireBaseIE._VALID_URL_BASE + r'write/series/stories/(?P<id>[^/?&#]+)'
|
2020-08-16 20:07:14 -04:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://storyfire.com/write/series/stories/-Lq6MsuIHLODO6d2dDkr/',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '-Lq6MsuIHLODO6d2dDkr',
|
|
|
|
},
|
2021-02-19 15:44:36 -05:00
|
|
|
'playlist_mincount': 13,
|
2020-08-16 20:07:14 -04:00
|
|
|
}, {
|
|
|
|
'url': 'https://storyfire.com/write/series/stories/the_mortal_one/',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'the_mortal_one',
|
|
|
|
},
|
2021-02-19 15:44:36 -05:00
|
|
|
'playlist_count': 0,
|
2020-08-16 20:07:14 -04:00
|
|
|
}]
|
|
|
|
|
2021-02-19 15:44:36 -05:00
|
|
|
def _extract_videos(self, stories):
|
|
|
|
for story in stories.values():
|
|
|
|
if story.get('hasVideo'):
|
|
|
|
yield self._parse_video(story)
|
2020-08-16 20:07:14 -04:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-02-19 15:44:36 -05:00
|
|
|
series_id = self._match_id(url)
|
|
|
|
stories = self._call_api(
|
|
|
|
'seriesStories', series_id, 'series stories')
|
|
|
|
return self.playlist_result(self._extract_videos(stories), series_id)
|