mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-26 18:34:32 +01:00
[gaskrank] Fix extraction
This commit is contained in:
parent
703751add4
commit
5a6d1da442
@ -6,7 +6,6 @@ from .common import InfoExtractor
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
js_to_json,
|
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,19 +48,12 @@ class GaskrankIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
"""extract information from gaskrank.tv"""
|
"""extract information from gaskrank.tv"""
|
||||||
def fix_json(code):
|
|
||||||
"""Removes trailing comma in json: {{},} --> {{}}"""
|
|
||||||
return re.sub(r',\s*}', r'}', js_to_json(code))
|
|
||||||
|
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
categories = [re.match(self._VALID_URL, url).group('categories')]
|
categories = [re.match(self._VALID_URL, url).group('categories')]
|
||||||
title = self._search_regex(
|
title = self._og_search_title(webpage, default=None) or self._html_search_meta(
|
||||||
r'movieName\s*:\s*\'([^\']*)\'',
|
'title', webpage, fatal=True)
|
||||||
webpage, 'title')
|
|
||||||
thumbnail = self._search_regex(
|
|
||||||
r'poster\s*:\s*\'([^\']*)\'',
|
|
||||||
webpage, 'thumbnail', default=None)
|
|
||||||
|
|
||||||
mobj = re.search(
|
mobj = re.search(
|
||||||
r'Video von:\s*(?P<uploader_id>[^|]*?)\s*\|\s*vom:\s*(?P<upload_date>[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9])',
|
r'Video von:\s*(?P<uploader_id>[^|]*?)\s*\|\s*vom:\s*(?P<upload_date>[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9])',
|
||||||
@ -89,29 +81,14 @@ class GaskrankIE(InfoExtractor):
|
|||||||
if average_rating:
|
if average_rating:
|
||||||
average_rating = float_or_none(average_rating.replace(',', '.'))
|
average_rating = float_or_none(average_rating.replace(',', '.'))
|
||||||
|
|
||||||
playlist = self._parse_json(
|
|
||||||
self._search_regex(
|
|
||||||
r'playlist\s*:\s*\[([^\]]*)\]',
|
|
||||||
webpage, 'playlist', default='{}'),
|
|
||||||
display_id, transform_source=fix_json, fatal=False)
|
|
||||||
|
|
||||||
video_id = self._search_regex(
|
video_id = self._search_regex(
|
||||||
r'https?://movies\.gaskrank\.tv/([^-]*?)(-[^\.]*)?\.mp4',
|
r'https?://movies\.gaskrank\.tv/([^-]*?)(-[^\.]*)?\.mp4',
|
||||||
playlist.get('0').get('src'), 'video id')
|
webpage, 'video id')
|
||||||
|
|
||||||
formats = []
|
entry = self._parse_html5_media_entries(url, webpage, video_id)[0]
|
||||||
for key in playlist:
|
entry.update({
|
||||||
formats.append({
|
|
||||||
'url': playlist[key]['src'],
|
|
||||||
'format_id': key,
|
|
||||||
'quality': playlist[key].get('quality')})
|
|
||||||
self._sort_formats(formats, field_preference=['format_id'])
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'formats': formats,
|
|
||||||
'thumbnail': thumbnail,
|
|
||||||
'categories': categories,
|
'categories': categories,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'uploader_id': uploader_id,
|
'uploader_id': uploader_id,
|
||||||
@ -120,4 +97,7 @@ class GaskrankIE(InfoExtractor):
|
|||||||
'tags': tags,
|
'tags': tags,
|
||||||
'view_count': view_count,
|
'view_count': view_count,
|
||||||
'average_rating': average_rating,
|
'average_rating': average_rating,
|
||||||
}
|
})
|
||||||
|
self._sort_formats(entry['formats'])
|
||||||
|
|
||||||
|
return entry
|
||||||
|
Loading…
Reference in New Issue
Block a user