mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 12:40:11 +09:00
[joj] Fixed extractor
This commit is contained in:
parent
4cf557e765
commit
e9cb2c9f71
@ -2,6 +2,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
@ -21,7 +22,8 @@ class JojIE(InfoExtractor):
|
|||||||
(?P<id>[^/?#^]+)
|
(?P<id>[^/?#^]+)
|
||||||
'''
|
'''
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://media.joj.sk/embed/a388ec4c-6019-4a4a-9312-b1bee194e932',
|
'url':
|
||||||
|
'https://media.joj.sk/embed/a388ec4c-6019-4a4a-9312-b1bee194e932',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'a388ec4c-6019-4a4a-9312-b1bee194e932',
|
'id': 'a388ec4c-6019-4a4a-9312-b1bee194e932',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
@ -64,16 +66,20 @@ class JojIE(InfoExtractor):
|
|||||||
r'(?s)(?:src|bitrates)\s*=\s*({.+?});', webpage, 'bitrates',
|
r'(?s)(?:src|bitrates)\s*=\s*({.+?});', webpage, 'bitrates',
|
||||||
default='{}'),
|
default='{}'),
|
||||||
video_id, transform_source=js_to_json, fatal=False)
|
video_id, transform_source=js_to_json, fatal=False)
|
||||||
|
quality = self._search_regex(
|
||||||
|
r'var qualityLabels = ({.*?});', webpage, 'quality', default=None)
|
||||||
|
quality = json.loads(quality)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for format_url in try_get(bitrates, lambda x: x['mp4'], list) or []:
|
for format_url in try_get(bitrates, lambda x: x['mp4'], list) or []:
|
||||||
if isinstance(format_url, compat_str):
|
if isinstance(format_url, compat_str):
|
||||||
height = self._search_regex(
|
height = self._search_regex(
|
||||||
r'(\d+)[pP]\.', format_url, 'height', default=None)
|
r'\-(\d+)(p|)\.', format_url, 'height', default=None)
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': format_url,
|
'url': format_url,
|
||||||
'format_id': '%sp' % height if height else None,
|
'format_id': '%sp' % height if height else None,
|
||||||
'height': int(height),
|
'height': int(height),
|
||||||
|
'resolution': quality.get(str(height)+'p')
|
||||||
})
|
})
|
||||||
if not formats:
|
if not formats:
|
||||||
playlist = self._download_xml(
|
playlist = self._download_xml(
|
||||||
@ -104,5 +110,5 @@ class JojIE(InfoExtractor):
|
|||||||
'title': title,
|
'title': title,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'formats': formats,
|
'formats': formats
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user