mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.7 KiB
Python
81 lines
2.7 KiB
Python
8 years ago
|
# coding: utf-8
|
||
11 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
|
from .common import InfoExtractor
|
||
9 years ago
|
from ..utils import (
|
||
|
ExtractorError,
|
||
9 years ago
|
NO_DEFAULT,
|
||
9 years ago
|
sanitized_Request,
|
||
9 years ago
|
urlencode_postdata,
|
||
9 years ago
|
)
|
||
11 years ago
|
|
||
|
|
||
|
class VodlockerIE(InfoExtractor):
|
||
9 years ago
|
_VALID_URL = r'https?://(?:www\.)?vodlocker\.(?:com|city)/(?:embed-)?(?P<id>[0-9a-zA-Z]+)(?:\..*?)?'
|
||
11 years ago
|
|
||
|
_TESTS = [{
|
||
|
'url': 'http://vodlocker.com/e8wvyzz4sl42',
|
||
|
'md5': 'ce0c2d18fa0735f1bd91b69b0e54aacf',
|
||
|
'info_dict': {
|
||
|
'id': 'e8wvyzz4sl42',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Germany vs Brazil',
|
||
8 years ago
|
'thumbnail': r're:http://.*\.jpg',
|
||
11 years ago
|
},
|
||
|
}]
|
||
|
|
||
|
def _real_extract(self, url):
|
||
10 years ago
|
video_id = self._match_id(url)
|
||
11 years ago
|
webpage = self._download_webpage(url, video_id)
|
||
|
|
||
9 years ago
|
if any(p in webpage for p in (
|
||
|
'>THIS FILE WAS DELETED<',
|
||
|
'>File Not Found<',
|
||
8 years ago
|
'The file you were looking for could not be found, sorry for any inconvenience.<',
|
||
|
'>The file was removed')):
|
||
9 years ago
|
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
||
|
|
||
10 years ago
|
fields = self._hidden_inputs(webpage)
|
||
11 years ago
|
|
||
|
if fields['op'] == 'download1':
|
||
11 years ago
|
self._sleep(3, video_id) # they do detect when requests happen too fast!
|
||
9 years ago
|
post = urlencode_postdata(fields)
|
||
9 years ago
|
req = sanitized_Request(url, post)
|
||
11 years ago
|
req.add_header('Content-type', 'application/x-www-form-urlencoded')
|
||
11 years ago
|
webpage = self._download_webpage(
|
||
|
req, video_id, 'Downloading video page')
|
||
11 years ago
|
|
||
9 years ago
|
def extract_file_url(html, default=NO_DEFAULT):
|
||
|
return self._search_regex(
|
||
|
r'file:\s*"(http[^\"]+)",', html, 'file url', default=default)
|
||
|
|
||
|
video_url = extract_file_url(webpage, default=None)
|
||
|
|
||
|
if not video_url:
|
||
|
embed_url = self._search_regex(
|
||
|
r'<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?vodlocker\.(?:com|city)/embed-.+?)\1',
|
||
|
webpage, 'embed url', group='url')
|
||
|
embed_webpage = self._download_webpage(
|
||
|
embed_url, video_id, 'Downloading embed webpage')
|
||
|
video_url = extract_file_url(embed_webpage)
|
||
|
thumbnail_webpage = embed_webpage
|
||
|
else:
|
||
|
thumbnail_webpage = webpage
|
||
|
|
||
11 years ago
|
title = self._search_regex(
|
||
10 years ago
|
r'id="file_title".*?>\s*(.*?)\s*<(?:br|span)', webpage, 'title')
|
||
11 years ago
|
thumbnail = self._search_regex(
|
||
9 years ago
|
r'image:\s*"(http[^\"]+)",', thumbnail_webpage, 'thumbnail', fatal=False)
|
||
11 years ago
|
|
||
|
formats = [{
|
||
|
'format_id': 'sd',
|
||
9 years ago
|
'url': video_url,
|
||
11 years ago
|
}]
|
||
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
|
'title': title,
|
||
|
'thumbnail': thumbnail,
|
||
|
'formats': formats,
|
||
|
}
|