]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/einthusan.py
3 from .common
import InfoExtractor
12 get_elements_by_class
,
17 class EinthusanIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?P<host>einthusan\.(?:tv|com|ca))/movie/watch/(?P<id>[^/?#&]+)'
20 'url': 'https://einthusan.tv/movie/watch/9097/',
21 'md5': 'ff0f7f2065031b8a2cf13a933731c035',
25 'title': 'Ae Dil Hai Mushkil',
26 'description': 'md5:33ef934c82a671a94652a9b4e54d931b',
27 'thumbnail': r
're:^https?://.*\.jpg$',
30 'url': 'https://einthusan.tv/movie/watch/51MZ/?lang=hindi',
31 'only_matching': True,
33 'url': 'https://einthusan.com/movie/watch/9097/',
34 'only_matching': True,
36 'url': 'https://einthusan.ca/movie/watch/4E9n/?lang=hindi',
37 'only_matching': True,
40 # reversed from jsoncrypto.prototype.decrypt() in einthusan-PGMovieWatcher.js
41 def _decrypt(self
, encrypted_data
, video_id
):
42 return self
._parse
_json
(compat_b64decode((
43 encrypted_data
[:10] + encrypted_data
[-1] + encrypted_data
[12:-1]
44 )).decode('utf-8'), video_id
)
46 def _real_extract(self
, url
):
47 mobj
= self
._match
_valid
_url
(url
)
48 host
= mobj
.group('host')
49 video_id
= mobj
.group('id')
51 webpage
= self
._download
_webpage
(url
, video_id
)
53 title
= self
._html
_search
_regex
(r
'<h3>([^<]+)</h3>', webpage
, 'title')
55 player_params
= extract_attributes(self
._search
_regex
(
56 r
'(<section[^>]+id="UIVideoPlayer"[^>]+>)', webpage
, 'player parameters'))
58 page_id
= self
._html
_search
_regex
(
59 '<html[^>]+data-pageid="([^"]+)"', webpage
, 'page ID')
60 video_data
= self
._download
_json
(
61 'https://%s/ajax/movie/watch/%s/' % (host
, video_id
), video_id
,
62 data
=urlencode_postdata({
63 'xEvent': 'UIVideoPlayer.PingOutcome',
65 'EJOutcomes': player_params
['data-ejpingables'],
70 'gorilla.csrf.Token': page_id
,
73 if isinstance(video_data
, compat_str
) and video_data
.startswith('/ratelimited/'):
75 'Download rate reached. Please try again later.', expected
=True)
77 ej_links
= self
._decrypt
(video_data
['EJLinks'], video_id
)
81 m3u8_url
= ej_links
.get('HLSLink')
83 formats
.extend(self
._extract
_m
3u8_formats
(
84 m3u8_url
, video_id
, ext
='mp4', entry_protocol
='m3u8_native'))
86 mp4_url
= ej_links
.get('MP4Link')
92 description
= get_elements_by_class('synopsis', webpage
)[0]
93 thumbnail
= self
._html
_search
_regex
(
94 r
'''<img[^>]+src=(["'])(?P<url>(?!\1).+?/moviecovers/(?!\1).+?)\1''',
95 webpage
, 'thumbnail url', fatal
=False, group
='url')
96 if thumbnail
is not None:
97 thumbnail
= compat_urlparse
.urljoin(url
, thumbnail
)
103 'thumbnail': thumbnail
,
104 'description': description
,