mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 14:52:38 +00:00
[megavideozeu] Simplify (Closes #5454)
This commit is contained in:
parent
f32cb5cb14
commit
31f224008e
@ -1,51 +1,52 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
float_or_none,
|
||||||
parse_filesize,
|
xpath_text,
|
||||||
unified_strdate,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MegavideozeuIE(InfoExtractor):
|
class MegavideozeuIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?megavideoz\.eu/video/(?P<id>.*)(?:.*)'
|
_VALID_URL = r'https?://(?:www\.)?megavideoz\.eu/video/(?P<id>[^/]+)(?:/(?P<display_id>[^/]+))?'
|
||||||
_TESTS = [
|
_TEST = {
|
||||||
{
|
'url': 'http://megavideoz.eu/video/WM6UB919XMXH/SMPTE-Universal-Film-Leader',
|
||||||
'url': 'http://megavideoz.eu/video/WM6UB919XMXH/SMPTE-Universal-Film-Leader',
|
'info_dict': {
|
||||||
'info_dict': {
|
'id': '48723',
|
||||||
'id': '48723',
|
'display_id': 'SMPTE-Universal-Film-Leader',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'duration': '10',
|
'title': 'SMPTE Universal Film Leader',
|
||||||
'title': 'SMPTE Universal Film Leader',
|
'thumbnail': 're:https?://.*?\.jpg',
|
||||||
}
|
'duration': 10.93,
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
tmp_video_id = self._match_id(url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
video_id = mobj.group('id')
|
||||||
|
display_id = mobj.group('display_id') or video_id
|
||||||
|
|
||||||
webpage = self._download_webpage(url, tmp_video_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
config_php = self._html_search_regex(
|
config = self._download_xml(
|
||||||
r'var cnf = \'([^\']+)\'', webpage, 'config.php url')
|
self._search_regex(
|
||||||
|
r"var\s+cnf\s*=\s*'([^']+)'", webpage, 'cnf url'),
|
||||||
|
display_id)
|
||||||
|
|
||||||
configpage = self._download_webpage(config_php, tmp_video_id)
|
video_url = xpath_text(config, './file', 'video url', fatal=True)
|
||||||
|
title = xpath_text(config, './title', 'title', fatal=True)
|
||||||
video_id = self._html_search_regex(
|
thumbnail = xpath_text(config, './image', 'thumbnail')
|
||||||
r'<mediaid>([^<]+)', configpage, 'video id')
|
duration = float_or_none(xpath_text(config, './duration', 'duration'))
|
||||||
video_url = self._html_search_regex(
|
video_id = xpath_text(config, './mediaid', 'video id') or video_id
|
||||||
r'<file>([^<]+)', configpage, 'video URL')
|
|
||||||
title = self._html_search_regex(
|
|
||||||
r'<title><!\[CDATA\[([^\]]+)', configpage, 'title')
|
|
||||||
duration = int_or_none(self._html_search_regex(
|
|
||||||
r'<duration>([0-9\.]+)', configpage, 'duration', fatal=False))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
'display_id': display_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'title': title,
|
'title': title,
|
||||||
|
'thumbnail': thumbnail,
|
||||||
'duration': duration
|
'duration': duration
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user