[promptfile] Improve and modernize
This commit is contained in:
parent
d3dbb46330
commit
72c3d02d29
|
@ -7,7 +7,6 @@ from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
sanitized_Request,
|
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,20 +32,23 @@ class PromptFileIE(InfoExtractor):
|
||||||
raise ExtractorError('Video %s does not exist' % video_id,
|
raise ExtractorError('Video %s does not exist' % video_id,
|
||||||
expected=True)
|
expected=True)
|
||||||
|
|
||||||
chash_pattern = r'\$\("#chash"\)\.val\("(.+)"\+\$\("#chash"\)'
|
chash = self._search_regex(
|
||||||
chash = self._html_search_regex(chash_pattern, webpage, "chash")
|
r'val\("([^"]*)"\s*\+\s*\$\("#chash"\)', webpage, 'chash')
|
||||||
fields = self._hidden_inputs(webpage)
|
fields = self._hidden_inputs(webpage)
|
||||||
k = list(fields)[0]
|
keys = list(fields.keys())
|
||||||
fields[k] = chash + fields[k]
|
chash_key = keys[0] if len(keys) == 1 else next(
|
||||||
|
key for key in keys if key.startswith('cha'))
|
||||||
|
fields[chash_key] = chash + fields[chash_key]
|
||||||
|
|
||||||
post = urlencode_postdata(fields)
|
|
||||||
req = sanitized_Request(url, post)
|
|
||||||
req.add_header('Content-type', 'application/x-www-form-urlencoded')
|
|
||||||
webpage = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
req, video_id, 'Downloading video page')
|
url, video_id, 'Downloading video page',
|
||||||
|
data=urlencode_postdata(fields),
|
||||||
|
headers={'Content-type': 'application/x-www-form-urlencoded'})
|
||||||
|
|
||||||
url_pattern = r'<a href="(http://www\.promptfile\.com/file/[^"]+)'
|
video_url = self._search_regex(
|
||||||
url = self._html_search_regex(url_pattern, webpage, 'URL')
|
(r'<a[^>]+href=(["\'])(?P<url>(?:(?!\1).)+)\1[^>]*>\s*Download File',
|
||||||
|
r'<a[^>]+href=(["\'])(?P<url>https?://(?:www\.)?promptfile\.com/file/(?:(?!\1).)+)\1'),
|
||||||
|
webpage, 'video url', group='url')
|
||||||
title = self._html_search_regex(
|
title = self._html_search_regex(
|
||||||
r'<span.+title="([^"]+)">', webpage, 'title')
|
r'<span.+title="([^"]+)">', webpage, 'title')
|
||||||
thumbnail = self._html_search_regex(
|
thumbnail = self._html_search_regex(
|
||||||
|
@ -55,7 +57,7 @@ class PromptFileIE(InfoExtractor):
|
||||||
|
|
||||||
formats = [{
|
formats = [{
|
||||||
'format_id': 'sd',
|
'format_id': 'sd',
|
||||||
'url': url,
|
'url': video_url,
|
||||||
'ext': determine_ext(title),
|
'ext': determine_ext(title),
|
||||||
}]
|
}]
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
Loading…
Reference in New Issue