1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-16 06:17:27 +00:00

Modify extractor according to suggestions

This commit is contained in:
01001110 2023-04-02 18:32:21 +08:00
parent a9a4d68364
commit 6a9848f94a

View File

@ -1,10 +1,13 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import json
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import unified_timestamp, parse_duration from ..utils import (
parse_duration,
traverse_obj,
unified_timestamp,
url_or_none,
)
class ChelseafcIE(InfoExtractor): class ChelseafcIE(InfoExtractor):
@ -56,25 +59,25 @@ class ChelseafcIE(InfoExtractor):
'data' 'data'
) )
data = json.loads(raw_data)['videoDetail'] data = self._parse_json(raw_data, video_id)
manifest_url = data['videoDetail']['signedUrl']
manifest_url = data['signedUrl'] data = data['videoDetail']
formats = self._extract_m3u8_formats(manifest_url, video_id, 'mp4')
title = data['title'] title = data['title']
descripiton = data['description']
timestamp = unified_timestamp(data['releaseDate']) formats = self._extract_m3u8_formats(manifest_url, video_id, 'mp4')
duration = parse_duration(data['duration']) self._sort_formats(formats)
tags = [tag['title'] for tag in data['tags']]
thumbnail = data['image']['file']['url'] txt_or_none = lambda x: x.strip() or None
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'description': descripiton, 'description': txt_or_none(data.get('description')),
'formats': formats, 'formats': formats,
'duration': duration, 'duration': parse_duration(data.get('duration')),
'timestamp': timestamp, 'timestamp': unified_timestamp(data.get('releaseDate')),
'tags': tags, 'tags': traverse_obj(data, ('tags', Ellipsis, 'title'), expected_type=txt_or_none),
'thumbnail': thumbnail 'thumbnail': traverse_obj(data, ('image', 'file', 'url'), expected_type=url_or_none),
} }