]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/einthusan.py
Fix "invalid escape sequences" error on Python 3.6
[yt-dlp.git] / youtube_dl / extractor / einthusan.py
CommitLineData
98703c7f
HP
1# coding: utf-8
2from __future__ import unicode_literals
3
98703c7f 4from .common import InfoExtractor
b26afec8
S
5from ..compat import compat_urlparse
6from ..utils import (
7 remove_start,
8 sanitized_Request,
9)
98703c7f
HP
10
11
12class EinthusanIE(InfoExtractor):
e2037b3f 13 _VALID_URL = r'https?://(?:www\.)?einthusan\.com/movies/watch.php\?([^#]*?)id=(?P<id>[0-9]+)'
98703c7f
HP
14 _TESTS = [
15 {
54190339 16 'url': 'http://www.einthusan.com/movies/watch.php?id=2447',
d75d9e34 17 'md5': 'd71379996ff5b7f217eca034c34e3461',
98703c7f
HP
18 'info_dict': {
19 'id': '2447',
20 'ext': 'mp4',
21 'title': 'Ek Villain',
ec85ded8 22 'thumbnail': r're:^https?://.*\.jpg$',
e2037b3f 23 'description': 'md5:9d29fc91a7abadd4591fb862fa560d93',
98703c7f
HP
24 }
25 },
26 {
27 'url': 'http://www.einthusan.com/movies/watch.php?id=1671',
d75d9e34 28 'md5': 'b16a6fd3c67c06eb7c79c8a8615f4213',
98703c7f
HP
29 'info_dict': {
30 'id': '1671',
31 'ext': 'mp4',
32 'title': 'Soodhu Kavvuum',
ec85ded8 33 'thumbnail': r're:^https?://.*\.jpg$',
d75d9e34 34 'description': 'md5:b40f2bf7320b4f9414f3780817b2af8c',
98703c7f
HP
35 }
36 },
37 ]
38
39 def _real_extract(self, url):
b26afec8
S
40 video_id = self._match_id(url)
41
42 request = sanitized_Request(url)
43 request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 5.2; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0')
44 webpage = self._download_webpage(request, video_id)
98703c7f 45
b26afec8
S
46 title = self._html_search_regex(
47 r'<h1><a[^>]+class=["\']movie-title["\'][^>]*>(.+?)</a></h1>',
48 webpage, 'title')
98703c7f 49
b26afec8
S
50 video_id = self._search_regex(
51 r'data-movieid=["\'](\d+)', webpage, 'video id', default=video_id)
0416006a 52
d75d9e34 53 m3u8_url = self._download_webpage(
b26afec8 54 'http://cdn.einthusan.com/geturl/%s/hd/London,Washington,Toronto,Dallas,San,Sydney/'
d75d9e34
YCH
55 % video_id, video_id, headers={'Referer': url})
56 formats = self._extract_m3u8_formats(
57 m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native')
98703c7f 58
e2037b3f
PH
59 description = self._html_search_meta('description', webpage)
60 thumbnail = self._html_search_regex(
61 r'''<a class="movie-cover-wrapper".*?><img src=["'](.*?)["'].*?/></a>''',
62 webpage, "thumbnail url", fatal=False)
63 if thumbnail is not None:
b26afec8 64 thumbnail = compat_urlparse.urljoin(url, remove_start(thumbnail, '..'))
98703c7f
HP
65
66 return {
67 'id': video_id,
b26afec8 68 'title': title,
d75d9e34 69 'formats': formats,
e2037b3f
PH
70 'thumbnail': thumbnail,
71 'description': description,
98703c7f 72 }