]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/promptfile.py
23ac93d7e248bce034fcb221d26089d8be412ee2
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class PromptFileIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?promptfile\.com/l/(?P<id>[0-9A-Z\-]+)'
17 'url': 'http://www.promptfile.com/l/86D1CE8462-576CAAE416',
18 'md5': '5a7e285a26e0d66d9a263fae91bc92ce',
20 'id': '86D1CE8462-576CAAE416',
22 'title': 'oceans.mp4',
23 'thumbnail': r
're:^https?://.*\.jpg$',
27 def _real_extract(self
, url
):
28 video_id
= self
._match
_id
(url
)
29 webpage
= self
._download
_webpage
(url
, video_id
)
31 if re
.search(r
'<div.+id="not_found_msg".+>(?!We are).+</div>[^-]', webpage
) is not None:
32 raise ExtractorError('Video %s does not exist' % video_id
,
35 chash
= self
._search
_regex
(
36 r
'val\("([^"]*)"\s*\+\s*\$\("#chash"\)', webpage
, 'chash')
37 fields
= self
._hidden
_inputs
(webpage
)
38 keys
= list(fields
.keys())
39 chash_key
= keys
[0] if len(keys
) == 1 else next(
40 key
for key
in keys
if key
.startswith('cha'))
41 fields
[chash_key
] = chash
+ fields
[chash_key
]
43 webpage
= self
._download
_webpage
(
44 url
, video_id
, 'Downloading video page',
45 data
=urlencode_postdata(fields
),
46 headers
={'Content-type': 'application/x-www-form-urlencoded'})
48 video_url
= self
._search
_regex
(
49 (r
'<a[^>]+href=(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1[^
>]*>\s
*Download File
',
50 r'<a
[^
>]+href
=(["\'])(?P<url>https?://(?:www\.)?promptfile\.com/file/(?:(?!\1).)+)\1'),
51 webpage, 'video url', group='url')
52 title = self._html_search_regex(
53 r'<span.+title="([^
"]+)">', webpage, 'title
')
54 thumbnail = self._html_search_regex(
55 r'<div
id="player_overlay">.*button
>.*?
<img src
="([^"]+)"',
56 webpage, 'thumbnail', fatal=False, flags=re.DOTALL)
61 'ext': determine_ext(title),
63 self._sort_formats(formats)
68 'thumbnail': thumbnail,