2014-08-28 15:20:10 -06:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2014-12-13 04:24:42 -07:00
|
|
|
from ..utils import (
|
|
|
|
determine_ext,
|
|
|
|
ExtractorError,
|
2015-11-21 09:18:17 -07:00
|
|
|
sanitized_Request,
|
2016-03-25 14:19:24 -06:00
|
|
|
urlencode_postdata,
|
2014-12-13 04:24:42 -07:00
|
|
|
)
|
2014-08-28 15:20:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
class PromptFileIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?promptfile\.com/l/(?P<id>[0-9A-Z\-]+)'
|
|
|
|
_TEST = {
|
2016-09-25 04:44:46 -06:00
|
|
|
'url': 'http://www.promptfile.com/l/86D1CE8462-576CAAE416',
|
|
|
|
'md5': '5a7e285a26e0d66d9a263fae91bc92ce',
|
2014-08-28 15:20:10 -06:00
|
|
|
'info_dict': {
|
2016-09-25 04:44:46 -06:00
|
|
|
'id': '86D1CE8462-576CAAE416',
|
2014-08-28 15:20:10 -06:00
|
|
|
'ext': 'mp4',
|
2016-09-25 04:44:46 -06:00
|
|
|
'title': 'oceans.mp4',
|
2014-08-28 15:20:10 -06:00
|
|
|
'thumbnail': 're:^https?://.*\.jpg$',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-10-26 17:50:22 -06:00
|
|
|
video_id = self._match_id(url)
|
2014-08-28 15:20:10 -06:00
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2014-10-26 17:50:22 -06:00
|
|
|
if re.search(r'<div.+id="not_found_msg".+>(?!We are).+</div>[^-]', webpage) is not None:
|
2014-08-28 15:20:10 -06:00
|
|
|
raise ExtractorError('Video %s does not exist' % video_id,
|
|
|
|
expected=True)
|
|
|
|
|
2016-09-25 04:44:46 -06:00
|
|
|
chash_pattern = r'\$\("#chash"\)\.val\("(.+)"\+\$\("#chash"\)'
|
|
|
|
chash = self._html_search_regex(chash_pattern, webpage, "chash")
|
2015-07-14 10:36:30 -06:00
|
|
|
fields = self._hidden_inputs(webpage)
|
2016-09-25 04:44:46 -06:00
|
|
|
k = list(fields)[0]
|
|
|
|
fields[k] = chash + fields[k]
|
|
|
|
|
2016-03-25 14:19:24 -06:00
|
|
|
post = urlencode_postdata(fields)
|
2015-11-21 09:18:17 -07:00
|
|
|
req = sanitized_Request(url, post)
|
2014-08-28 15:20:10 -06:00
|
|
|
req.add_header('Content-type', 'application/x-www-form-urlencoded')
|
|
|
|
webpage = self._download_webpage(
|
|
|
|
req, video_id, 'Downloading video page')
|
|
|
|
|
2016-09-25 04:44:46 -06:00
|
|
|
url_pattern = r'<a href="(http://www\.promptfile\.com/file/[^"]+)'
|
|
|
|
url = self._html_search_regex(url_pattern, webpage, 'URL')
|
2014-08-28 15:20:10 -06:00
|
|
|
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 17:07:18 -06:00
|
|
|
self._sort_formats(formats)
|
2014-08-28 15:20:10 -06:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'formats': formats,
|
|
|
|
}
|