]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/einthusan.py
Imported Upstream version 2016.02.22
[youtubedl] / youtube_dl / extractor / einthusan.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urlparse
6 from ..utils import (
7 remove_start,
8 sanitized_Request,
9 )
10
11
12 class EinthusanIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?einthusan\.com/movies/watch.php\?([^#]*?)id=(?P<id>[0-9]+)'
14 _TESTS = [
15 {
16 'url': 'http://www.einthusan.com/movies/watch.php?id=2447',
17 'md5': 'af244f4458cd667205e513d75da5b8b1',
18 'info_dict': {
19 'id': '2447',
20 'ext': 'mp4',
21 'title': 'Ek Villain',
22 'thumbnail': 're:^https?://.*\.jpg$',
23 'description': 'md5:9d29fc91a7abadd4591fb862fa560d93',
24 }
25 },
26 {
27 'url': 'http://www.einthusan.com/movies/watch.php?id=1671',
28 'md5': 'ef63c7a803e22315880ed182c10d1c5c',
29 'info_dict': {
30 'id': '1671',
31 'ext': 'mp4',
32 'title': 'Soodhu Kavvuum',
33 'thumbnail': 're:^https?://.*\.jpg$',
34 'description': 'md5:05d8a0c0281a4240d86d76e14f2f4d51',
35 }
36 },
37 ]
38
39 def _real_extract(self, url):
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)
45
46 title = self._html_search_regex(
47 r'<h1><a[^>]+class=["\']movie-title["\'][^>]*>(.+?)</a></h1>',
48 webpage, 'title')
49
50 video_id = self._search_regex(
51 r'data-movieid=["\'](\d+)', webpage, 'video id', default=video_id)
52
53 video_url = self._download_webpage(
54 'http://cdn.einthusan.com/geturl/%s/hd/London,Washington,Toronto,Dallas,San,Sydney/'
55 % video_id, video_id)
56
57 description = self._html_search_meta('description', webpage)
58 thumbnail = self._html_search_regex(
59 r'''<a class="movie-cover-wrapper".*?><img src=["'](.*?)["'].*?/></a>''',
60 webpage, "thumbnail url", fatal=False)
61 if thumbnail is not None:
62 thumbnail = compat_urlparse.urljoin(url, remove_start(thumbnail, '..'))
63
64 return {
65 'id': video_id,
66 'title': title,
67 'url': video_url,
68 'thumbnail': thumbnail,
69 'description': description,
70 }