X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Feinthusan.py;h=6ca07a13d736b3909269aa1314d6e868150f8aa0;hb=12afdc2ad617dedfd7d60654b8c57b99604332ed;hp=bc6def65e1b153e06730f1c2d82b467d94329d0e;hpb=0416006a3051b15e4bebbb096960ca4fb8ffd0a9;p=youtube-dl diff --git a/youtube_dl/extractor/einthusan.py b/youtube_dl/extractor/einthusan.py index bc6def65e..6ca07a13d 100644 --- a/youtube_dl/extractor/einthusan.py +++ b/youtube_dl/extractor/einthusan.py @@ -1,9 +1,12 @@ # coding: utf-8 from __future__ import unicode_literals -import re - from .common import InfoExtractor +from ..compat import compat_urlparse +from ..utils import ( + remove_start, + sanitized_Request, +) class EinthusanIE(InfoExtractor): @@ -11,54 +14,59 @@ class EinthusanIE(InfoExtractor): _TESTS = [ { 'url': 'http://www.einthusan.com/movies/watch.php?id=2447', - 'md5': 'af244f4458cd667205e513d75da5b8b1', + 'md5': 'd71379996ff5b7f217eca034c34e3461', 'info_dict': { 'id': '2447', 'ext': 'mp4', 'title': 'Ek Villain', - 'thumbnail': 're:^https?://.*\.jpg$', + 'thumbnail': r're:^https?://.*\.jpg$', 'description': 'md5:9d29fc91a7abadd4591fb862fa560d93', } }, { 'url': 'http://www.einthusan.com/movies/watch.php?id=1671', - 'md5': 'ef63c7a803e22315880ed182c10d1c5c', + 'md5': 'b16a6fd3c67c06eb7c79c8a8615f4213', 'info_dict': { 'id': '1671', 'ext': 'mp4', 'title': 'Soodhu Kavvuum', - 'thumbnail': 're:^https?://.*\.jpg$', - 'description': 'md5:05d8a0c0281a4240d86d76e14f2f4d51', + 'thumbnail': r're:^https?://.*\.jpg$', + 'description': 'md5:b40f2bf7320b4f9414f3780817b2af8c', } }, ] def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') - webpage = self._download_webpage(url, video_id) + video_id = self._match_id(url) + + request = sanitized_Request(url) + request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 5.2; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0') + webpage = self._download_webpage(request, video_id) - video_title = self._html_search_regex( - r'

(.*?)

', webpage, 'title') + title = self._html_search_regex( + r'

]+class=["\']movie-title["\'][^>]*>(.+?)

', + webpage, 'title') - movieid = self._html_search_regex( - r'data-movieid="(.*?)"', webpage, 'movieid') + video_id = self._search_regex( + r'data-movieid=["\'](\d+)', webpage, 'video id', default=video_id) - location = 'Washington' - geturl = 'http://cdn.einthusan.com/geturl/%s/hd/%s' % (movieid, location) - video_url = self._download_webpage(geturl, video_id) + m3u8_url = self._download_webpage( + 'http://cdn.einthusan.com/geturl/%s/hd/London,Washington,Toronto,Dallas,San,Sydney/' + % video_id, video_id, headers={'Referer': url}) + formats = self._extract_m3u8_formats( + m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native') description = self._html_search_meta('description', webpage) thumbnail = self._html_search_regex( r'''''', webpage, "thumbnail url", fatal=False) if thumbnail is not None: - thumbnail = thumbnail.replace('..', 'http://www.einthusan.com') + thumbnail = compat_urlparse.urljoin(url, remove_start(thumbnail, '..')) return { 'id': video_id, - 'title': video_title, - 'url': video_url, + 'title': title, + 'formats': formats, 'thumbnail': thumbnail, 'description': description, }