mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-02 20:22:52 +08:00
Make all formats available
This commit is contained in:
parent
a6dee7433c
commit
99166c1e7b
@ -4,15 +4,23 @@ import re
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
|
||||||
|
from ..utils import (
|
||||||
|
remove_end,
|
||||||
|
int_or_none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class WeltIE(InfoExtractor):
|
class WeltIE(InfoExtractor):
|
||||||
IE_NAME = 'welt.de'
|
IE_NAME = 'welt.de'
|
||||||
_VALID_URL = r'''https?://(?:www\.)?welt\.de/mediathek/dokumentation/.*sendung(?P<id>\d+)/.*'''
|
_VALID_URL = r'''https?://(?:www\.)?welt\.de/[^\.]+/(?P<id>[a-z]+\d+)(?:/.*)?'''
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
{
|
{
|
||||||
'url': 'https://www.welt.de/mediathek/dokumentation/space/sendung170058475/ISS-Leben-auf-der-Weltraumstation.html',
|
# All videos have a predefined lifetime, usually just 30-45 days
|
||||||
|
'url': 'https://www.welt.de/mediathek/dokumentation/natur-und-wildlife/sendung157940018/Mega-Croc-vs-Superschlange.html',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
'id': 'sendung157940018',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'ISS - Leben auf der Weltraumstation',
|
'title': 'Mega Croc vs. Superschlange',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -20,12 +28,29 @@ class WeltIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'title')
|
title = remove_end(self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'title')
|
||||||
video_url = self._html_search_regex(r'<source data-content="Video.source" src="(https://weltn24.+?_2000.mp4)"', webpage, 'video_url')
|
.strip(), ' - Video - WELT')
|
||||||
|
|
||||||
return [{
|
sources = self._search_regex(r'(["\'])?sources\1\s*:\s*\[({\s*\1file\1\s*:\s*\1([^\1,])+\1\s*}\s*,?)+', webpage, 'sources', group=0)
|
||||||
'id': video_id,
|
files = re.findall(r'http[^\'"]+', sources)
|
||||||
'url': video_url,
|
|
||||||
'ext': 'mp4',
|
formats = []
|
||||||
|
for url in files:
|
||||||
|
number = re.search(r'_(\d+)\.mp4', url).group(1)
|
||||||
|
formats.append({
|
||||||
|
'url': url,
|
||||||
|
'quality_key': int_or_none(number)
|
||||||
|
})
|
||||||
|
self._remove_duplicate_formats(formats)
|
||||||
|
formats = sorted(formats, key=lambda x: x['quality_key'])
|
||||||
|
quality_counter = -1
|
||||||
|
for i in range(len(formats) - 1, 0, -1):
|
||||||
|
formats[i] = {'url': formats[i]['url'], 'quality': quality_counter}
|
||||||
|
quality_counter -= 1
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': video_id,
|
||||||
|
'ext': 'mp4',
|
||||||
'title': title,
|
'title': title,
|
||||||
}]
|
'formats': formats
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user