2014-08-28 17:20:10 -04:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2014-12-13 06:24:42 -05:00
|
|
|
from ..utils import (
|
|
|
|
determine_ext,
|
|
|
|
ExtractorError,
|
2015-11-21 11:18:17 -05:00
|
|
|
sanitized_Request,
|
2016-03-25 16:19:24 -04:00
|
|
|
urlencode_postdata,
|
2014-12-13 06:24:42 -05:00
|
|
|
)
|
2014-08-28 17:20:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
class PromptFileIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?promptfile\.com/l/(?P<id>[0-9A-Z\-]+)'
|
|
|
|
_TEST = {
|
|
|
|
'url': 'http://www.promptfile.com/l/D21B4746E9-F01462F0FF',
|
|
|
|
'md5': 'd1451b6302da7215485837aaea882c4c',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'D21B4746E9-F01462F0FF',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Birds.mp4',
|
|
|
|
'thumbnail': 're:^https?://.*\.jpg$',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-10-26 19:50:22 -04:00
|
|
|
video_id = self._match_id(url)
|
2014-08-28 17:20:10 -04:00
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2014-10-26 19:50:22 -04:00
|
|
|
if re.search(r'<div.+id="not_found_msg".+>(?!We are).+</div>[^-]', webpage) is not None:
|
2014-08-28 17:20:10 -04:00
|
|
|
raise ExtractorError('Video %s does not exist' % video_id,
|
|
|
|
expected=True)
|
|
|
|
|
2015-07-14 12:36:30 -04:00
|
|
|
fields = self._hidden_inputs(webpage)
|
2016-03-25 16:19:24 -04:00
|
|
|
post = urlencode_postdata(fields)
|
2015-11-21 11:18:17 -05:00
|
|
|
req = sanitized_Request(url, post)
|
2014-08-28 17:20:10 -04:00
|
|
|
req.add_header('Content-type', 'application/x-www-form-urlencoded')
|
|
|
|
webpage = self._download_webpage(
|
|
|
|
req, video_id, 'Downloading video page')
|
|
|
|
|
|
|
|
url = self._html_search_regex(r'url:\s*\'([^\']+)\'', webpage, 'URL')
|
|
|
|
title = self._html_search_regex(
|
|
|
|
r'<span.+title="([^"]+)">', webpage, 'title')
|
|
|
|
thumbnail = self._html_search_regex(
|
|
|
|
r'<div id="player_overlay">.*button>.*?<img src="([^"]+)"',
|
|
|
|
webpage, 'thumbnail', fatal=False, flags=re.DOTALL)
|
|
|
|
|
|
|
|
formats = [{
|
|
|
|
'format_id': 'sd',
|
|
|
|
'url': url,
|
|
|
|
'ext': determine_ext(title),
|
|
|
|
}]
|
2014-08-28 19:07:18 -04:00
|
|
|
self._sort_formats(formats)
|
2014-08-28 17:20:10 -04:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'formats': formats,
|
|
|
|
}
|