[powerwatch] Add new extractor

This commit is contained in:
Yurifag 2016-02-21 17:22:01 +01:00
parent 7efc1c2b49
commit bdc660277d
2 changed files with 64 additions and 0 deletions

View File

@ -560,6 +560,7 @@ from .pornhub import (
from .pornotube import PornotubeIE
from .pornovoisines import PornoVoisinesIE
from .pornoxo import PornoXOIE
from .powerwatch import PowerwatchIE
from .primesharetv import PrimeShareTVIE
from .promptfile import PromptFileIE
from .prosiebensat1 import ProSiebenSat1IE

View File

@ -0,0 +1,63 @@
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..compat import compat_urllib_parse
from ..utils import (
ExtractorError,
sanitized_Request,
)
class PowerwatchIE(InfoExtractor):
_VALID_URL = r'http://powerwatch\.pw/(?P<id>\w+)'
_TEST = {
'url': 'http://powerwatch.pw/duecjibvicbu',
'md5': 'bf7965f70675be5e1a1749be3b8d20ba',
'info_dict': {
'id': 'duecjibvicbu',
'ext': 'mp4',
'title': 'Big Buck Bunny trailer',
},
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
if '>File Not Found<' in webpage:
raise ExtractorError('Video %s was not found' % video_id, expected=True)
self._sleep(5, video_id)
download_form = self._hidden_inputs(webpage)
request = sanitized_Request(url, compat_urllib_parse.urlencode(download_form))
request.add_header('Content-Type', 'application/x-www-form-urlencoded')
video_page = self._download_webpage(request, video_id, 'Downloading video page')
self.report_extraction(video_id)
title = self._html_search_regex(
r'h4-fine[^>]*>([^<]+)<', video_page, 'title')
thumbnail = self._search_regex(
r'image:\s*"([^"]+)"', video_page, 'thumbnail URL', fatal=False)
video_urls = list(re.findall(
r'file:\s*"([^"]+)"', video_page))
formats = []
for video_url in video_urls:
formats.append({
'url': video_url,
'ext': 'mp4',
})
self._sort_formats(formats)
return {
'formats': formats,
'id': video_id,
'title': title,
'thumbnail': thumbnail,
}