[veoh] Improve extractor (#2251)

* [veoh] Remove old _extract_video
* [veoh] Extend _VALID_URL to accept '/videos/'
* [veoh] Prefer high quality
* [veoh] Extract more metadata

Authored by: foghawk
This commit is contained in:
foghawk 2022-01-09 12:20:26 -06:00 committed by GitHub
parent 0254f16274
commit 62c955efc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,21 +5,30 @@
int_or_none, int_or_none,
parse_duration, parse_duration,
qualities, qualities,
try_get
) )
class VeohIE(InfoExtractor): class VeohIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|embed|iphone/#_Watch)/(?P<id>(?:v|e|yapi-)[\da-zA-Z]+)' _VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|videos|embed|iphone/#_Watch)/(?P<id>(?:v|e|yapi-)[\da-zA-Z]+)'
_TESTS = [{ _TESTS = [{
'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3', 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
'md5': '9e7ecc0fd8bbee7a69fe38953aeebd30', 'md5': '620e68e6a3cff80086df3348426c9ca3',
'info_dict': { 'info_dict': {
'id': 'v56314296nk7Zdmz3', 'id': 'v56314296nk7Zdmz3',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Straight Backs Are Stronger', 'title': 'Straight Backs Are Stronger',
'description': 'md5:203f976279939a6dc664d4001e13f5f4',
'thumbnail': 're:https://fcache\\.veoh\\.com/file/f/th56314296\\.jpg(\\?.*)?',
'uploader': 'LUMOback', 'uploader': 'LUMOback',
'description': 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ', 'duration': 46,
'view_count': int,
'average_rating': int,
'comment_count': int,
'age_limit': 0,
'categories': ['technology_and_gaming'],
'tags': ['posture', 'posture', 'sensor', 'back', 'pain', 'wearable', 'tech', 'lumo'],
}, },
}, { }, {
'url': 'http://www.veoh.com/embed/v56314296nk7Zdmz3', 'url': 'http://www.veoh.com/embed/v56314296nk7Zdmz3',
@ -51,30 +60,36 @@ class VeohIE(InfoExtractor):
}, { }, {
'url': 'http://www.veoh.com/watch/e152215AJxZktGS', 'url': 'http://www.veoh.com/watch/e152215AJxZktGS',
'only_matching': True, 'only_matching': True,
}] }, {
'url': 'https://www.veoh.com/videos/v16374379WA437rMH',
def _extract_video(self, source): 'md5': 'cceb73f3909063d64f4b93d4defca1b3',
return { 'info_dict': {
'id': source.get('videoId'), 'id': 'v16374379WA437rMH',
'title': source.get('title'), 'ext': 'mp4',
'description': source.get('description'), 'title': 'Phantasmagoria 2, pt. 1-3',
'thumbnail': source.get('highResImage') or source.get('medResImage'), 'description': 'Phantasmagoria: a Puzzle of Flesh',
'uploader': source.get('username'), 'thumbnail': 're:https://fcache\\.veoh\\.com/file/f/th16374379\\.jpg(\\?.*)?',
'duration': int_or_none(source.get('length')), 'uploader': 'davidspackage',
'view_count': int_or_none(source.get('views')), 'duration': 968,
'age_limit': 18 if source.get('isMature') == 'true' or source.get('isSexy') == 'true' else 0, 'view_count': int,
'formats': self._extract_formats(source), 'average_rating': int,
'comment_count': int,
'age_limit': 18,
'categories': ['technology_and_gaming', 'gaming'],
'tags': ['puzzle', 'of', 'flesh'],
} }
}]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
video = self._download_json( metadata = self._download_json(
'https://www.veoh.com/watch/getVideo/' + video_id, 'https://www.veoh.com/watch/getVideo/' + video_id,
video_id)['video'] video_id)
video = metadata['video']
title = video['title'] title = video['title']
thumbnail_url = None thumbnail_url = None
q = qualities(['HQ', 'Regular']) q = qualities(['Regular', 'HQ'])
formats = [] formats = []
for f_id, f_url in video.get('src', {}).items(): for f_id, f_url in video.get('src', {}).items():
if not f_url: if not f_url:
@ -89,6 +104,12 @@ def _real_extract(self, url):
}) })
self._sort_formats(formats) self._sort_formats(formats)
categories = metadata.get('categoryPath')
if not categories:
category = try_get(video, lambda x: x['category'].strip().removeprefix('category_'))
categories = [category] if category else None
tags = video.get('tags')
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
@ -100,4 +121,7 @@ def _real_extract(self, url):
'formats': formats, 'formats': formats,
'average_rating': int_or_none(video.get('rating')), 'average_rating': int_or_none(video.get('rating')),
'comment_count': int_or_none(video.get('numOfComments')), 'comment_count': int_or_none(video.get('numOfComments')),
'age_limit': 18 if video.get('contentRatingId') == 2 else 0,
'categories': categories,
'tags': tags.split(', ') if tags else None,
} }