From a0d7ede350f13096f94a94f982925ba4ffac91e3 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 15 Dec 2015 21:37:47 +0100 Subject: [PATCH 1/2] Fix einthusan parser --- youtube_dl/extractor/einthusan.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/einthusan.py b/youtube_dl/extractor/einthusan.py index 5dfea0d39..bc6def65e 100644 --- a/youtube_dl/extractor/einthusan.py +++ b/youtube_dl/extractor/einthusan.py @@ -41,9 +41,12 @@ class EinthusanIE(InfoExtractor): video_title = self._html_search_regex( r'

(.*?)

', webpage, 'title') - video_url = self._html_search_regex( - r'''(?s)jwplayer\("mediaplayer"\)\.setup\({.*?'file': '([^']+)'.*?}\);''', - webpage, 'video url') + movieid = self._html_search_regex( + r'data-movieid="(.*?)"', webpage, 'movieid') + + location = 'Washington' + geturl = 'http://cdn.einthusan.com/geturl/%s/hd/%s' % (movieid, location) + video_url = self._download_webpage(geturl, video_id) description = self._html_search_meta('description', webpage) thumbnail = self._html_search_regex( From fec09bf15d632bc1694b32981d1468011e9d7da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Fri, 1 Jan 2016 02:39:00 +0600 Subject: [PATCH 2/2] [einthusan] Improve extraction (Closes #7877) --- youtube_dl/extractor/einthusan.py | 34 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/youtube_dl/extractor/einthusan.py b/youtube_dl/extractor/einthusan.py index bc6def65e..f7339702c 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): @@ -34,30 +37,33 @@ class EinthusanIE(InfoExtractor): ] 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) - video_title = self._html_search_regex( - r'

(.*?)

', webpage, 'title') + 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) - movieid = self._html_search_regex( - r'data-movieid="(.*?)"', webpage, 'movieid') + title = self._html_search_regex( + r'

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

', + webpage, 'title') - location = 'Washington' - geturl = 'http://cdn.einthusan.com/geturl/%s/hd/%s' % (movieid, location) - video_url = self._download_webpage(geturl, video_id) + video_id = self._search_regex( + r'data-movieid=["\'](\d+)', webpage, 'video id', default=video_id) + + video_url = self._download_webpage( + 'http://cdn.einthusan.com/geturl/%s/hd/London,Washington,Toronto,Dallas,San,Sydney/' + % video_id, video_id) 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, + 'title': title, 'url': video_url, 'thumbnail': thumbnail, 'description': description,