3 from .common
import InfoExtractor
4 from ..compat
import compat_HTTPError
13 class ViewLiftBaseIE(InfoExtractor
):
14 _API_BASE
= 'https://prod-api.viewlift.com/'
15 _DOMAINS_REGEX
= r
'(?:(?:main\.)?snagfilms|snagxtreme|funnyforfree|kiddovid|winnersview|(?:monumental|lax)sportsnetwork|vayafilm|failarmy|ftfnext|lnppass\.legapallacanestro|moviespree|app\.myoutdoortv|neoufitness|pflmma|theidentitytb)\.com|(?:hoichoi|app\.horseandcountry|kronon|marquee|supercrosslive)\.tv'
18 'funnyforfree': 'snagfilms',
19 'hoichoi': 'hoichoitv',
20 'kiddovid': 'snagfilms',
21 'laxsportsnetwork': 'lax',
22 'legapallacanestro': 'lnp',
23 'marquee': 'marquee-tv',
24 'monumentalsportsnetwork': 'monumental-network',
25 'moviespree': 'bingeflix',
27 'snagxtreme': 'snagfilms',
28 'theidentitytb': 'tampabay',
29 'vayafilm': 'snagfilms',
33 def _fetch_token(self
, site
, url
):
34 if self
._TOKENS
.get(site
):
37 cookies
= self
._get
_cookies
(url
)
38 if cookies
and cookies
.get('token'):
39 self
._TOKENS
[site
] = self
._search
_regex
(r
'22authorizationToken\%22:\%22([^\%]+)\%22', cookies
['token'].value
, 'token')
40 if not self
._TOKENS
.get(site
):
41 self
.raise_login_required('Cookies (not necessarily logged in) are needed to download from this website', method
='cookies')
43 def _call_api(self
, site
, path
, video_id
, url
, query
):
44 self
._fetch
_token
(site
, url
)
46 return self
._download
_json
(
47 self
._API
_BASE
+ path
, video_id
, headers
={'Authorization': self._TOKENS.get(site)}
, query
=query
)
48 except ExtractorError
as e
:
49 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
50 webpage
= e
.cause
.read().decode()
52 error_message
= traverse_obj(json
.loads(webpage
), 'errorMessage', 'message')
53 except json
.JSONDecodeError
:
54 raise ExtractorError(f
'{site} said: {webpage}', cause
=e
.cause
)
56 if 'has not purchased' in error_message
:
57 self
.raise_login_required(method
='cookies')
58 raise ExtractorError(error_message
, expected
=True)
62 class ViewLiftEmbedIE(ViewLiftBaseIE
):
63 IE_NAME
= 'viewlift:embed'
64 _VALID_URL
= r
'https?://(?:(?:www|embed)\.)?(?P<domain>%s)/embed/player\?.*\bfilmId=(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})' % ViewLiftBaseIE
._DOMAINS
_REGEX
65 _EMBED_REGEX
= [r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:embed\
.)?
(?
:%s)/embed
/player
.+?
)\
1' % ViewLiftBaseIE._DOMAINS_REGEX]
67 'url
': 'http
://embed
.snagfilms
.com
/embed
/player?filmId
=74849a00
-85a9
-11e1
-9660-123139220831&w
=500',
68 'md5
': '2924e9215c6eff7a55ed35b72276bd93
',
70 'id': '74849a00
-85a9
-11e1
-9660-123139220831',
72 'title
': '#whilewewatch',
73 'description': 'md5:b542bef32a6f657dadd0df06e26fb0c8',
74 'timestamp': 1334350096,
75 'upload_date': '20120413',
78 # invalid labels, 360p is better that 480p
79 'url': 'http://www.snagfilms.com/embed/player?filmId=17ca0950-a74a-11e0-a92a-0026bb61d036',
80 'md5': '882fca19b9eb27ef865efeeaed376a48',
82 'id': '17ca0950-a74a-11e0-a92a-0026bb61d036',
84 'title': 'Life in Limbo',
86 'skip': 'The video does not exist',
88 'url': 'http://www.snagfilms.com/embed/player?filmId=0000014c-de2f-d5d6-abcf-ffef58af0017',
89 'only_matching': True,
92 def _real_extract(self
, url
):
93 domain
, film_id
= self
._match
_valid
_url
(url
).groups()
94 site
= domain
.split('.')[-2]
95 if site
in self
._SITE
_MAP
:
96 site
= self
._SITE
_MAP
[site
]
98 content_data
= self
._call
_api
(
99 site
, 'entitlement/video/status', film_id
, url
, {
102 gist
= content_data
['gist']
103 title
= gist
['title']
104 video_assets
= content_data
['streamingInfo']['videoAssets']
106 hls_url
= video_assets
.get('hls')
107 formats
, subtitles
= [], {}
109 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
110 hls_url
, film_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False)
112 for video_asset
in video_assets
.get('mpeg') or []:
113 video_asset_url
= video_asset
.get('url')
114 if not video_asset_url
:
116 bitrate
= int_or_none(video_asset
.get('bitrate'))
117 height
= int_or_none(self
._search
_regex
(
118 r
'^_?(\d+)[pP]$', video_asset
.get('renditionValue'),
119 'height', default
=None))
121 'url': video_asset_url
,
122 'format_id': 'http%s' % ('-%d' % bitrate
if bitrate
else ''),
125 'vcodec': video_asset
.get('codec'),
129 for sub
in traverse_obj(content_data
, ('contentDetails', 'closedCaptions')) or []:
130 sub_url
= sub
.get('url')
133 subs
.setdefault(sub
.get('language', 'English'), []).append({
137 self
._sort
_formats
(formats
)
141 'description': gist
.get('description'),
142 'thumbnail': gist
.get('videoImageUrl'),
143 'duration': int_or_none(gist
.get('runtime')),
144 'age_limit': parse_age_limit(content_data
.get('parentalRating')),
145 'timestamp': int_or_none(gist
.get('publishDate'), 1000),
147 'subtitles': self
._merge
_subtitles
(subs
, subtitles
),
148 'categories': traverse_obj(content_data
, ('categories', ..., 'title')),
149 'tags': traverse_obj(content_data
, ('tags', ..., 'title')),
153 class ViewLiftIE(ViewLiftBaseIE
):
155 _API_BASE
= 'https://prod-api-cached-2.viewlift.com/'
156 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>%s)(?P<path>(?:/(?:films/title|show|(?:news/)?videos?|watch))?/(?P<id>[^?#]+))' % ViewLiftBaseIE
._DOMAINS
_REGEX
158 'url': 'http://www.snagfilms.com/films/title/lost_for_life',
159 'md5': '19844f897b35af219773fd63bdec2942',
161 'id': '0000014c-de2f-d5d6-abcf-ffef58af0017',
162 'display_id': 'lost_for_life',
164 'title': 'Lost for Life',
165 'description': 'md5:ea10b5a50405ae1f7b5269a6ec594102',
166 'thumbnail': r
're:^https?://.*\.jpg',
168 'categories': 'mincount:3',
170 'upload_date': '20150421',
171 'timestamp': 1429656820,
174 'url': 'http://www.snagfilms.com/show/the_world_cut_project/india',
175 'md5': 'e6292e5b837642bbda82d7f8bf3fbdfd',
177 'id': '00000145-d75c-d96e-a9c7-ff5c67b20000',
178 'display_id': 'the_world_cut_project/india',
181 'description': 'md5:5c168c5a8f4719c146aad2e0dfac6f5f',
182 'thumbnail': r
're:^https?://.*\.jpg',
184 'timestamp': 1399478279,
185 'upload_date': '20140507',
188 'url': 'http://main.snagfilms.com/augie_alone/s_2_ep_12_love',
190 'id': '00000148-7b53-de26-a9fb-fbf306f70020',
191 'display_id': 'augie_alone/s_2_ep_12_love',
193 'title': 'S. 2 Ep. 12 - Love',
194 'description': 'Augie finds love.',
195 'thumbnail': r
're:^https?://.*\.jpg',
197 'upload_date': '20141012',
198 'timestamp': 1413129540,
202 'skip_download': True,
205 'url': 'http://main.snagfilms.com/films/title/the_freebie',
206 'only_matching': True,
208 # Film is not playable in your area.
209 'url': 'http://www.snagfilms.com/films/title/inside_mecca',
210 'only_matching': True,
212 # Film is not available.
213 'url': 'http://www.snagfilms.com/show/augie_alone/flirting',
214 'only_matching': True,
216 'url': 'http://www.winnersview.com/videos/the-good-son',
217 'only_matching': True,
219 # Was once Kaltura embed
220 'url': 'https://www.monumentalsportsnetwork.com/videos/john-carlson-postgame-2-25-15',
221 'only_matching': True,
223 'url': 'https://www.marquee.tv/watch/sadlerswells-sacredmonsters',
224 'only_matching': True,
225 }, { # Free film with langauge code
226 'url': 'https://www.hoichoi.tv/bn/films/title/shuyopoka',
228 'id': '7a7a9d33-1f4c-4771-9173-ee4fb6dbf196',
230 'title': 'Shuyopoka',
231 'description': 'md5:e28f2fb8680096a69c944d37c1fa5ffc',
232 'thumbnail': r
're:^https?://.*\.jpg$',
233 'upload_date': '20211006',
236 'params': {'skip_download': True}
,
238 'url': 'https://www.hoichoi.tv/films/title/dadu-no1',
240 'id': '0000015b-b009-d126-a1db-b81ff3780000',
242 'title': 'Dadu No.1',
243 'description': 'md5:605cba408e51a79dafcb824bdeded51e',
244 'thumbnail': r
're:^https?://.*\.jpg$',
245 'upload_date': '20210827',
248 'params': {'skip_download': True}
,
250 'url': 'https://www.hoichoi.tv/webseries/case-jaundice-s01-e01',
252 'id': 'f779e07c-30c8-459c-8612-5a834ab5e5ba',
254 'title': 'Humans Vs. Corona',
255 'description': 'md5:ca30a682b4528d02a3eb6d0427dd0f87',
256 'thumbnail': r
're:^https?://.*\.jpg$',
257 'upload_date': '20210830',
258 'series': 'Case Jaundice'
260 'params': {'skip_download': True}
,
262 'url': 'https://www.hoichoi.tv/videos/1549072415320-six-episode-02-hindi',
264 'id': 'b41fa1ce-aca6-47b6-b208-283ff0a2de30',
266 'title': 'Woman in red - Hindi',
267 'description': 'md5:9d21edc1827d32f8633eb67c2054fc31',
268 'thumbnail': r
're:^https?://.*\.jpg$',
269 'upload_date': '20211006',
270 'series': 'Six (Hindi)'
272 'params': {'skip_download': True}
,
274 'url': 'https://www.hoichoi.tv/shows/watch-asian-paints-moner-thikana-online-season-1-episode-1',
276 'id': '1f45d185-8500-455c-b88d-13252307c3eb',
278 'title': 'Jisshu Sengupta',
279 'description': 'md5:ef6ffae01a3d83438597367400f824ed',
280 'thumbnail': r
're:^https?://.*\.jpg$',
281 'upload_date': '20211004',
282 'series': 'Asian Paints Moner Thikana'
284 'params': {'skip_download': True}
,
286 'url': 'https://www.hoichoi.tv/shows/watch-moner-thikana-bengali-web-series-online',
287 'playlist_mincount': 5,
289 'id': 'watch-moner-thikana-bengali-web-series-online',
291 }, { # Premium series
292 'url': 'https://www.hoichoi.tv/shows/watch-byomkesh-bengali-web-series-online',
293 'playlist_mincount': 14,
295 'id': 'watch-byomkesh-bengali-web-series-online',
298 'url': 'https://www.hoichoi.tv/movies/detective-2020',
299 'only_matching': True
303 def suitable(cls
, url
):
304 return False if ViewLiftEmbedIE
.suitable(url
) else super(ViewLiftIE
, cls
).suitable(url
)
306 def _show_entries(self
, domain
, seasons
):
307 for season
in seasons
:
308 for episode
in season
.get('episodes') or []:
309 path
= traverse_obj(episode
, ('gist', 'permalink'))
311 yield self
.url_result(f
'https://www.{domain}{path}', ie
=self
.ie_key())
313 def _real_extract(self
, url
):
314 domain
, path
, display_id
= self
._match
_valid
_url
(url
).groups()
315 site
= domain
.split('.')[-2]
316 if site
in self
._SITE
_MAP
:
317 site
= self
._SITE
_MAP
[site
]
318 modules
= self
._call
_api
(
319 site
, 'content/pages', display_id
, url
, {
320 'includeContent': 'true',
326 seasons
= next((m
['contentData'][0]['seasons'] for m
in modules
if m
.get('moduleType') == 'ShowDetailModule'), None)
328 return self
.playlist_result(self
._show
_entries
(domain
, seasons
), display_id
)
330 film_id
= next(m
['contentData'][0]['gist']['id'] for m
in modules
if m
.get('moduleType') == 'VideoDetailModule')
332 '_type': 'url_transparent',
333 'url': 'http://%s/embed/player?filmId=%s' % (domain
, film_id
),
335 'display_id': display_id
,
336 'ie_key': 'ViewLiftEmbed',