]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/einthusan.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 get_elements_by_class
,
20 class EinthusanIE(InfoExtractor
):
21 _VALID_URL
= r
'https?://einthusan\.tv/movie/watch/(?P<id>[^/?#&]+)'
23 'url': 'https://einthusan.tv/movie/watch/9097/',
24 'md5': 'ff0f7f2065031b8a2cf13a933731c035',
28 'title': 'Ae Dil Hai Mushkil',
29 'description': 'md5:33ef934c82a671a94652a9b4e54d931b',
30 'thumbnail': r
're:^https?://.*\.jpg$',
33 'url': 'https://einthusan.tv/movie/watch/51MZ/?lang=hindi',
34 'only_matching': True,
37 # reversed from jsoncrypto.prototype.decrypt() in einthusan-PGMovieWatcher.js
38 def _decrypt(self
, encrypted_data
, video_id
):
39 return self
._parse
_json
(compat_b64decode((
40 encrypted_data
[:10] + encrypted_data
[-1] + encrypted_data
[12:-1]
41 )).decode('utf-8'), video_id
)
43 def _real_extract(self
, url
):
44 video_id
= self
._match
_id
(url
)
46 webpage
= self
._download
_webpage
(url
, video_id
)
48 title
= self
._html
_search
_regex
(r
'<h3>([^<]+)</h3>', webpage
, 'title')
50 player_params
= extract_attributes(self
._search
_regex
(
51 r
'(<section[^>]+id="UIVideoPlayer"[^>]+>)', webpage
, 'player parameters'))
53 page_id
= self
._html
_search
_regex
(
54 '<html[^>]+data-pageid="([^"]+)"', webpage
, 'page ID')
55 video_data
= self
._download
_json
(
56 'https://einthusan.tv/ajax/movie/watch/%s/' % video_id
, video_id
,
57 data
=urlencode_postdata({
58 'xEvent': 'UIVideoPlayer.PingOutcome',
60 'EJOutcomes': player_params
['data-ejpingables'],
65 'gorilla.csrf.Token': page_id
,
68 if isinstance(video_data
, compat_str
) and video_data
.startswith('/ratelimited/'):
70 'Download rate reached. Please try again later.', expected
=True)
72 ej_links
= self
._decrypt
(video_data
['EJLinks'], video_id
)
76 m3u8_url
= ej_links
.get('HLSLink')
78 formats
.extend(self
._extract
_m
3u8_formats
(
79 m3u8_url
, video_id
, ext
='mp4', entry_protocol
='m3u8_native'))
81 mp4_url
= ej_links
.get('MP4Link')
87 self
._sort
_formats
(formats
)
89 description
= get_elements_by_class('synopsis', webpage
)[0]
90 thumbnail
= self
._html
_search
_regex
(
91 r
'''<img[^>]+src=(["'])(?P<url>(?!\1).+?/moviecovers/(?!\1).+?)\1''',
92 webpage
, 'thumbnail url', fatal
=False, group
='url')
93 if thumbnail
is not None:
94 thumbnail
= compat_urlparse
.urljoin(url
, thumbnail
)
100 'thumbnail': thumbnail
,
101 'description': description
,