mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-04 18:09:36 +02:00
[ie/PicartoVod] Fix extractor (#7727)
Closes #2926 Authored by: Frankgoji
This commit is contained in:
parent
b9de629d78
commit
db97438940
@ -1,7 +1,10 @@
|
|||||||
|
import urllib.parse
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
js_to_json,
|
str_or_none,
|
||||||
|
traverse_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +87,7 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
|
|
||||||
class PicartoVodIE(InfoExtractor):
|
class PicartoVodIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www.)?picarto\.tv/videopopout/(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?://(?:www\.)?picarto\.tv/(?:videopopout|\w+/videos)/(?P<id>[^/?#&]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://picarto.tv/videopopout/ArtofZod_2017.12.12.00.13.23.flv',
|
'url': 'https://picarto.tv/videopopout/ArtofZod_2017.12.12.00.13.23.flv',
|
||||||
'md5': '3ab45ba4352c52ee841a28fb73f2d9ca',
|
'md5': '3ab45ba4352c52ee841a28fb73f2d9ca',
|
||||||
@ -94,6 +97,18 @@ class PicartoVodIE(InfoExtractor):
|
|||||||
'title': 'ArtofZod_2017.12.12.00.13.23.flv',
|
'title': 'ArtofZod_2017.12.12.00.13.23.flv',
|
||||||
'thumbnail': r're:^https?://.*\.jpg'
|
'thumbnail': r're:^https?://.*\.jpg'
|
||||||
},
|
},
|
||||||
|
'skip': 'The VOD does not exist',
|
||||||
|
}, {
|
||||||
|
'url': 'https://picarto.tv/ArtofZod/videos/772650',
|
||||||
|
'md5': '00067a0889f1f6869cc512e3e79c521b',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '772650',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Art of Zod - Drawing and Painting',
|
||||||
|
'thumbnail': r're:^https?://.*\.jpg',
|
||||||
|
'channel': 'ArtofZod',
|
||||||
|
'age_limit': 18,
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://picarto.tv/videopopout/Plague',
|
'url': 'https://picarto.tv/videopopout/Plague',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -102,21 +117,36 @@ class PicartoVodIE(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)
|
data = self._download_json(
|
||||||
|
'https://ptvintern.picarto.tv/ptvapi', video_id, query={
|
||||||
|
'query': f'''{{
|
||||||
|
video(id: "{video_id}") {{
|
||||||
|
id
|
||||||
|
title
|
||||||
|
adult
|
||||||
|
file_name
|
||||||
|
video_recording_image_url
|
||||||
|
channel {{
|
||||||
|
name
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}'''
|
||||||
|
})['data']['video']
|
||||||
|
|
||||||
vod_info = self._parse_json(
|
file_name = data['file_name']
|
||||||
self._search_regex(
|
netloc = urllib.parse.urlparse(data['video_recording_image_url']).netloc
|
||||||
r'(?s)#vod-player["\']\s*,\s*(\{.+?\})\s*\)', webpage,
|
|
||||||
'vod player'),
|
|
||||||
video_id, transform_source=js_to_json)
|
|
||||||
|
|
||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
vod_info['vod'], video_id, 'mp4', entry_protocol='m3u8_native',
|
f'https://{netloc}/stream/hls/{file_name}/index.m3u8', video_id, 'mp4', m3u8_id='hls')
|
||||||
m3u8_id='hls')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video_id,
|
**traverse_obj(data, {
|
||||||
'thumbnail': vod_info.get('vodThumb'),
|
'id': ('id', {str_or_none}),
|
||||||
|
'title': ('title', {str}),
|
||||||
|
'thumbnail': 'video_recording_image_url',
|
||||||
|
'channel': ('channel', 'name', {str}),
|
||||||
|
'age_limit': ('adult', {lambda x: 18 if x else 0}),
|
||||||
|
}),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user