]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/einthusan.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
16 get_elements_by_class
,
21 class EinthusanIE(InfoExtractor
):
22 _VALID_URL
= r
'https?://(?P<host>einthusan\.(?:tv|com|ca))/movie/watch/(?P<id>[^/?#&]+)'
24 'url': 'https://einthusan.tv/movie/watch/9097/',
25 'md5': 'ff0f7f2065031b8a2cf13a933731c035',
29 'title': 'Ae Dil Hai Mushkil',
30 'description': 'md5:33ef934c82a671a94652a9b4e54d931b',
31 'thumbnail': r
're:^https?://.*\.jpg$',
34 'url': 'https://einthusan.tv/movie/watch/51MZ/?lang=hindi',
35 'only_matching': True,
37 'url': 'https://einthusan.com/movie/watch/9097/',
38 'only_matching': True,
40 'url': 'https://einthusan.ca/movie/watch/4E9n/?lang=hindi',
41 'only_matching': True,
44 # reversed from jsoncrypto.prototype.decrypt() in einthusan-PGMovieWatcher.js
45 def _decrypt(self
, encrypted_data
, video_id
):
46 return self
._parse
_json
(compat_b64decode((
47 encrypted_data
[:10] + encrypted_data
[-1] + encrypted_data
[12:-1]
48 )).decode('utf-8'), video_id
)
50 def _real_extract(self
, url
):
51 mobj
= re
.match(self
._VALID
_URL
, url
)
52 host
= mobj
.group('host')
53 video_id
= mobj
.group('id')
55 webpage
= self
._download
_webpage
(url
, video_id
)
57 title
= self
._html
_search
_regex
(r
'<h3>([^<]+)</h3>', webpage
, 'title')
59 player_params
= extract_attributes(self
._search
_regex
(
60 r
'(<section[^>]+id="UIVideoPlayer"[^>]+>)', webpage
, 'player parameters'))
62 page_id
= self
._html
_search
_regex
(
63 '<html[^>]+data-pageid="([^"]+)"', webpage
, 'page ID')
64 video_data
= self
._download
_json
(
65 'https://%s/ajax/movie/watch/%s/' % (host
, video_id
), video_id
,
66 data
=urlencode_postdata({
67 'xEvent': 'UIVideoPlayer.PingOutcome',
69 'EJOutcomes': player_params
['data-ejpingables'],
74 'gorilla.csrf.Token': page_id
,
77 if isinstance(video_data
, compat_str
) and video_data
.startswith('/ratelimited/'):
79 'Download rate reached. Please try again later.', expected
=True)
81 ej_links
= self
._decrypt
(video_data
['EJLinks'], video_id
)
85 m3u8_url
= ej_links
.get('HLSLink')
87 formats
.extend(self
._extract
_m
3u8_formats
(
88 m3u8_url
, video_id
, ext
='mp4', entry_protocol
='m3u8_native'))
90 mp4_url
= ej_links
.get('MP4Link')
96 self
._sort
_formats
(formats
)
98 description
= get_elements_by_class('synopsis', webpage
)[0]
99 thumbnail
= self
._html
_search
_regex
(
100 r
'''<img[^>]+src=(["'])(?P<url>(?!\1).+?/moviecovers/(?!\1).+?)\1''',
101 webpage
, 'thumbnail url', fatal
=False, group
='url')
102 if thumbnail
is not None:
103 thumbnail
= compat_urlparse
.urljoin(url
, thumbnail
)
109 'thumbnail': thumbnail
,
110 'description': description
,