mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 21:23:05 +00:00
[extractor/JdItemVideo] Add Extractor. fix some problems
This commit is contained in:
parent
b7f94ef67a
commit
48e821ab16
@ -4,7 +4,7 @@ import random
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import determine_ext, ExtractorError
|
from ..utils import determine_ext, ExtractorError, traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class JdItemVideoIE(InfoExtractor):
|
class JdItemVideoIE(InfoExtractor):
|
||||||
@ -52,8 +52,7 @@ class JdItemVideoIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
item_id = self._match_id(url=url)
|
item_id = self._match_id(url=url)
|
||||||
resp = self._download_webpage(url_or_request=url, video_id=item_id)
|
resp = self._download_webpage(url_or_request=url, video_id=item_id)
|
||||||
pattern_data = self._html_search_regex(pattern=r'"mainVideoId":"(\d+?)"', string=resp, name='videoId',
|
pattern_data = self._html_search_regex(pattern=r'"mainVideoId":"(\d+?)"', string=resp, name='videoId')
|
||||||
default=None)
|
|
||||||
if pattern_data is None:
|
if pattern_data is None:
|
||||||
raise ExtractorError("There are no any video. %s" % url)
|
raise ExtractorError("There are no any video. %s" % url)
|
||||||
|
|
||||||
@ -75,11 +74,11 @@ class JdItemVideoIE(InfoExtractor):
|
|||||||
info_dict = {
|
info_dict = {
|
||||||
'id': item_id,
|
'id': item_id,
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
'title': detailRespJson.get("extInfo", {}).get("videoName") or "unknown_video_title",
|
'title': traverse_obj(detailRespJson, ('extInfo', 'videoName'), default="unknown_video_title"),
|
||||||
'description': description,
|
'description': description,
|
||||||
'size': detailRespJson.get("extInfo", {}).get("size"),
|
'size': traverse_obj(detailRespJson, ("extInfo","size")),
|
||||||
'width': detailRespJson.get("extInfo", {}).get("vwidth"),
|
'width': traverse_obj(detailRespJson, ("extInfo", "vwidth")),
|
||||||
'height': detailRespJson.get("extInfo", {}).get("vheight"),
|
'height': traverse_obj(detailRespJson, ("extInfo", "vheight")),
|
||||||
'duration': detailRespJson.get("duration"),
|
'duration': detailRespJson.get("duration"),
|
||||||
'thumbnail': detailRespJson.get("imageUrl"),
|
'thumbnail': detailRespJson.get("imageUrl"),
|
||||||
'url': detailRespJson.get("playUrl")
|
'url': detailRespJson.get("playUrl")
|
||||||
|
Loading…
Reference in New Issue
Block a user