mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 08:19:57 +01:00
[vube] Consider optional fields and modernize
This commit is contained in:
parent
b5368acee8
commit
5f0f8013ac
@ -3,6 +3,7 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import int_or_none
|
||||||
|
|
||||||
|
|
||||||
class VubeIE(InfoExtractor):
|
class VubeIE(InfoExtractor):
|
||||||
@ -49,17 +50,20 @@ def _real_extract(self, url):
|
|||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
|
|
||||||
video = self._download_json('http://vube.com/api/v2/video/%s' % video_id,
|
video = self._download_json(
|
||||||
video_id, 'Downloading video JSON')
|
'http://vube.com/api/v2/video/%s' % video_id, video_id, 'Downloading video JSON')
|
||||||
|
|
||||||
public_id = video['public_id']
|
public_id = video['public_id']
|
||||||
|
|
||||||
formats = [{'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id),
|
formats = [
|
||||||
'height': int(fmt['height']),
|
{
|
||||||
'abr': int(fmt['audio_bitrate']),
|
'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id),
|
||||||
'vbr': int(fmt['video_bitrate']),
|
'height': int(fmt['height']),
|
||||||
'format_id': fmt['media_resolution_id']
|
'abr': int(fmt['audio_bitrate']),
|
||||||
} for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed']
|
'vbr': int(fmt['video_bitrate']),
|
||||||
|
'format_id': fmt['media_resolution_id']
|
||||||
|
} for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed'
|
||||||
|
]
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
@ -72,14 +76,14 @@ def _real_extract(self, url):
|
|||||||
uploader_id = video['user_url_id']
|
uploader_id = video['user_url_id']
|
||||||
timestamp = int(video['upload_time'])
|
timestamp = int(video['upload_time'])
|
||||||
duration = video['duration']
|
duration = video['duration']
|
||||||
view_count = video['raw_view_count']
|
view_count = video.get('raw_view_count')
|
||||||
like_count = video['total_likes']
|
like_count = video.get('total_likes')
|
||||||
dislike_count= video['total_hates']
|
dislike_count= video.get('total_hates')
|
||||||
|
|
||||||
comment = self._download_json('http://vube.com/api/video/%s/comment' % video_id,
|
comment = self._download_json(
|
||||||
video_id, 'Downloading video comment JSON')
|
'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON')
|
||||||
|
|
||||||
comment_count = comment['total']
|
comment_count = int_or_none(comment.get('total'))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user