diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-11-13 15:59:22 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-11-13 15:59:22 +0100 |
commit | 3deed1e91ad4ede72ab0eb222dfd6c54fe963413 (patch) | |
tree | de70b3f300d6fa47177ce62f044e824524301177 | |
parent | 11b28e93d3a5496916e55a717c362fe7a6a1c7e7 (diff) |
[freevideo] Simplify and raise error for foreigners (Fixes #4131)
-rw-r--r-- | youtube_dl/extractor/freevideo.py | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/youtube_dl/extractor/freevideo.py b/youtube_dl/extractor/freevideo.py index f9716c4c8..f755e3c4a 100644 --- a/youtube_dl/extractor/freevideo.py +++ b/youtube_dl/extractor/freevideo.py @@ -1,49 +1,38 @@ from __future__ import unicode_literals -import re - from .common import InfoExtractor -from ..utils import ( - ExtractorError, -) +from ..utils import ExtractorError class FreeVideoIE(InfoExtractor): - _VALID_URL = r'^http://www.freevideo.cz/vase-videa/(?P<videoid>[^.]+)\.html$' + _VALID_URL = r'^http://www.freevideo.cz/vase-videa/(?P<id>[^.]+)\.html(?:$|[?#])' _TEST = { 'url': 'http://www.freevideo.cz/vase-videa/vysukany-zadecek-22033.html', - 'file': 'vysukany-zadecek-22033.mp4', 'info_dict': { + 'id': 'vysukany-zadecek-22033', + 'ext': 'mp4', "title": "vysukany-zadecek-22033", "age_limit": 18, - } + }, + 'skip': 'Blocked outside .cz', } def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - if mobj is None: - raise ExtractorError('Invalid search query "%s"' % query) - - video_id = mobj.group('videoid') - - # Get webpage content - webpage = self._download_webpage(url, video_id) - - age_limit = self._rta_search(webpage) - if age_limit == 0: - # interpret 0 as mis-detection since this site is adult-content only. - # However, if we get non-0, assume the rtalabel started giving proper - # results - age_limit = 18 + video_id = self._match_id(url) + webpage, handle = self._download_webpage_handle(url, video_id) + if '//www.czechav.com/' in handle.geturl(): + raise ExtractorError( + 'Access to freevideo is blocked from your location', + expected=True) - url = re.search(r'\s+url: "(http://[a-z0-9-]+.cdn.freevideo.cz/stream/.*/video.mp4)"', webpage) - if url is None: - raise ExtractorError('ERROR: unable to extract video url') + video_url = self._search_regex( + r'\s+url: "(http://[a-z0-9-]+.cdn.freevideo.cz/stream/.*?/video.mp4)"', + webpage, 'video URL') return { 'id': video_id, - 'url': url.groups()[0], + 'url': video_url, 'title': video_id, - 'age_limit': age_limit, + 'age_limit': 18, } |