mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-22 02:01:50 +00:00
[hitrecord] Improve (closes #11626)
This commit is contained in:
parent
553c68bbd9
commit
364131584b
1 changed files with 37 additions and 17 deletions
|
@ -1,17 +1,17 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
unified_strdate,
|
try_get,
|
||||||
)
|
)
|
||||||
from ..compat import compat_str
|
|
||||||
|
|
||||||
|
|
||||||
class HitRecordIE(InfoExtractor):
|
class HitRecordIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?hitrecord\.org/records/(?P<id>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?hitrecord\.org/records/(?P<id>\d+)'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://hitrecord.org/records/2954362',
|
'url': 'https://hitrecord.org/records/2954362',
|
||||||
'md5': 'fe1cdc2023bce0bbb95c39c57426aa71',
|
'md5': 'fe1cdc2023bce0bbb95c39c57426aa71',
|
||||||
|
@ -20,29 +20,49 @@ class HitRecordIE(InfoExtractor):
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'A Very Different World (HITRECORD x ACLU)',
|
'title': 'A Very Different World (HITRECORD x ACLU)',
|
||||||
'description': 'md5:e62defaffab5075a5277736bead95a3d',
|
'description': 'md5:e62defaffab5075a5277736bead95a3d',
|
||||||
'release_date': '20160818',
|
'duration': 139.327,
|
||||||
'timestamp': 1471557582,
|
'timestamp': 1471557582,
|
||||||
|
'upload_date': '20160818',
|
||||||
'uploader': 'Zuzi.C12',
|
'uploader': 'Zuzi.C12',
|
||||||
'uploader_id': '362811',
|
'uploader_id': '362811',
|
||||||
|
'view_count': int,
|
||||||
|
'like_count': int,
|
||||||
|
'comment_count': int,
|
||||||
|
'tags': list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
video_info = self._download_json('https://hitrecord.org/api/web/records/' + video_id, video_id)
|
|
||||||
user_info = video_info.get('user', {})
|
video = self._download_json(
|
||||||
|
'https://hitrecord.org/api/web/records/%s' % video_id, video_id)
|
||||||
|
|
||||||
|
title = video['title']
|
||||||
|
video_url = video['source_url']['mp4_url']
|
||||||
|
|
||||||
|
tags = None
|
||||||
|
tags_list = try_get(video, lambda x: x['tags'], list)
|
||||||
|
if tags_list:
|
||||||
|
tags = [
|
||||||
|
t['text']
|
||||||
|
for t in tags_list
|
||||||
|
if isinstance(t, dict) and t.get('text') and
|
||||||
|
isinstance(t['text'], compat_str)]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video_info['title'],
|
'url': video_url,
|
||||||
'url': video_info['source_url']['mp4_url'],
|
'title': title,
|
||||||
'description': clean_html(video_info.get('body')),
|
'description': clean_html(video.get('body')),
|
||||||
'uploader': user_info.get('username'),
|
'duration': float_or_none(video.get('duration'), 1000),
|
||||||
'uploader_id': compat_str(user_info.get('id')),
|
'timestamp': int_or_none(video.get('created_at_i')),
|
||||||
'release_date': unified_strdate(video_info.get('created_at')),
|
'uploader': try_get(
|
||||||
'timestamp': video_info.get('created_at_i'),
|
video, lambda x: x['user']['username'], compat_str),
|
||||||
'view_count': int_or_none(video_info.get('total_views_count')),
|
'uploader_id': try_get(
|
||||||
'like_count': int_or_none(video_info.get('hearts_count')),
|
video, lambda x: compat_str(x['user']['id'])),
|
||||||
'comment_count': int_or_none(video_info.get('comments_count')),
|
'view_count': int_or_none(video.get('total_views_count')),
|
||||||
'tags': [tag.get('text') for tag in video_info.get('tags', [])],
|
'like_count': int_or_none(video.get('hearts_count')),
|
||||||
|
'comment_count': int_or_none(video.get('comments_count')),
|
||||||
|
'tags': tags,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue