X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fprimesharetv.py;h=01cc3d9ea3ff845476a7f7b306c3bfee25078b96;hb=17941321ab0b3f9548d1f65e3f9d69e8cd01c0a3;hp=7c545761b157410bad2a032b373b924f14ec51e9;hpb=af69cab21d48da78ff7d2b54effb9dfd5fcfd1d8;p=youtube-dl diff --git a/youtube_dl/extractor/primesharetv.py b/youtube_dl/extractor/primesharetv.py index 7c545761b..01cc3d9ea 100644 --- a/youtube_dl/extractor/primesharetv.py +++ b/youtube_dl/extractor/primesharetv.py @@ -1,55 +1,65 @@ -# encoding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor -from ..utils import ( - 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) - - self._sleep(9, video_id) - - hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token') - 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,