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