From: Sergey M․ Date: Tue, 17 Mar 2015 15:06:38 +0000 (+0600) Subject: [primesharetv] Clean up X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=0499cd866e7e746658f33e6c2f44f7e1e699ad1b;p=youtube-dl [primesharetv] Clean up --- diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index b02812365..3c5401145 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -381,7 +381,7 @@ from .pornhub import ( ) from .pornotube import PornotubeIE from .pornoxo import PornoXOIE -from .primesharetv import PrimesharetvIE +from .primesharetv import PrimeShareTVIE from .promptfile import PromptFileIE from .prosiebensat1 import ProSiebenSat1IE from .puls4 import Puls4IE diff --git a/youtube_dl/extractor/primesharetv.py b/youtube_dl/extractor/primesharetv.py index 570fd2210..01cc3d9ea 100644 --- a/youtube_dl/extractor/primesharetv.py +++ b/youtube_dl/extractor/primesharetv.py @@ -1,59 +1,65 @@ -# encoding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor -from ..utils import ( - ExtractorError, - int_or_none, - parse_filesize, - unified_strdate, - urlencode_postdata, -) from ..compat import ( + compat_urllib_parse, compat_urllib_request, ) +from ..utils import ExtractorError -class PrimesharetvIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P.*)(?:.*)' - _TESTS = [ - { - 'url': 'http://primeshare.tv/download/238790B611', - 'md5': 'bb41f9f6c0dd434c729f04ce5b677192', - 'info_dict': { - 'id': '238790B611', - 'ext': 'mp4', - "title": "Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona [...]", - "duration": 10, - }, - } - ] +class PrimeShareTVIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P[\da-zA-Z]+)' + + _TEST = { + 'url': 'http://primeshare.tv/download/238790B611', + 'md5': 'b92d9bf5461137c36228009f31533fbc', + 'info_dict': { + 'id': '238790B611', + 'ext': 'mp4', + 'title': 'Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona', + }, + } def _real_extract(self, url): video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) - if re.search(r'

File not exist

', webpage) is not None: - raise ExtractorError('The file does not exist', expected=True) - hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token') - - self._sleep(9, video_id) - - data = urlencode_postdata({ - 'hash': hashtoken, - }) + + if '>File not exist<' in webpage: + raise ExtractorError('Video %s does not exist' % video_id, expected=True) + + fields = dict(re.findall(r'''(?x)Watch [^\(]+\(([^/)]+)\) ', video_page, 'title') + r'

Watch\s*(?: )?\s*\((.+?)(?:\s*\[\.\.\.\])?\)\s*(?: )?\s*', + video_page, 'title') return { 'id': video_id, @@ -61,8 +67,3 @@ class PrimesharetvIE(InfoExtractor): 'title': title, 'ext': 'mp4', } - - def _debug_print(self, txt): - if self._downloader.params.get('verbose'): - self.to_screen('[debug] %s' % txt) -