2022-11-11 18:58:54 +01:00
|
|
|
import functools
|
|
|
|
import json
|
|
|
|
|
2013-07-08 22:02:23 +02:00
|
|
|
from .common import InfoExtractor
|
2014-12-13 12:24:42 +01:00
|
|
|
from ..utils import (
|
2022-11-11 18:58:54 +01:00
|
|
|
ExtractorError,
|
|
|
|
OnDemandPagedList,
|
2014-03-24 14:53:03 +01:00
|
|
|
int_or_none,
|
2019-03-11 09:04:06 +01:00
|
|
|
parse_duration,
|
|
|
|
qualities,
|
[cleanup] Misc (#11216)
- Add Python 3.13 to CI, finalize 3.13 support
- Remove Python 3.8 from CI in preparation for removing 3.8 support
- Document that PyPy3.8 and PyPy3.9 are no longer supported
- Usual documentation fixes and code cleanup
Closes #8248, Closes #11146, Closes #11149, Closes #11211
Authored by: Grub4K, grqz, DTrombett, KarboniteKream, bashonly, mikkovedru, seproDev
Co-authored-by: N/Ame <173015200+grqz@users.noreply.github.com>
Co-authored-by: DTrombett <d@trombett.org>
Co-authored-by: =?UTF-8?q?Klemen=20Ko=C5=A1ir?= <klemen.kosir@kream.io>
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
Co-authored-by: Mikko Vedru <mikko.vedru@gmail.com>
Co-authored-by: sepro <sepro@sepr0.com>
2024-10-22 06:50:35 +02:00
|
|
|
remove_start,
|
|
|
|
strip_or_none,
|
2014-03-24 14:53:03 +01:00
|
|
|
)
|
2014-01-05 05:48:12 +01:00
|
|
|
|
2013-07-08 22:02:23 +02:00
|
|
|
|
|
|
|
class VeohIE(InfoExtractor):
|
2022-01-09 19:20:26 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|videos|embed|iphone/#_Watch)/(?P<id>(?:v|e|yapi-)[\da-zA-Z]+)'
|
2014-03-24 14:53:03 +01:00
|
|
|
|
2017-07-09 09:54:52 +02:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
|
2022-01-09 19:20:26 +01:00
|
|
|
'md5': '620e68e6a3cff80086df3348426c9ca3',
|
2017-07-09 09:54:52 +02:00
|
|
|
'info_dict': {
|
2019-03-11 09:04:06 +01:00
|
|
|
'id': 'v56314296nk7Zdmz3',
|
2017-07-09 09:54:52 +02:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Straight Backs Are Stronger',
|
2022-01-09 19:20:26 +01:00
|
|
|
'description': 'md5:203f976279939a6dc664d4001e13f5f4',
|
|
|
|
'thumbnail': 're:https://fcache\\.veoh\\.com/file/f/th56314296\\.jpg(\\?.*)?',
|
2017-07-09 09:54:52 +02:00
|
|
|
'uploader': 'LUMOback',
|
2022-01-09 19:20:26 +01:00
|
|
|
'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'],
|
2014-03-24 14:53:03 +01:00
|
|
|
},
|
2018-02-11 00:51:10 +01:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.veoh.com/embed/v56314296nk7Zdmz3',
|
|
|
|
'only_matching': True,
|
2017-07-09 09:54:52 +02:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage',
|
|
|
|
'md5': '4a6ff84b87d536a6a71e6aa6c0ad07fa',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '27701988',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Chile workers cover up to avoid skin damage',
|
|
|
|
'description': 'md5:2bd151625a60a32822873efc246ba20d',
|
|
|
|
'uploader': 'afp-news',
|
|
|
|
'duration': 123,
|
2014-03-24 14:53:03 +01:00
|
|
|
},
|
2017-07-09 09:54:52 +02:00
|
|
|
'skip': 'This video has been deleted.',
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.veoh.com/watch/v69525809F6Nc4frX',
|
|
|
|
'md5': '4fde7b9e33577bab2f2f8f260e30e979',
|
|
|
|
'note': 'Embedded ooyala video',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '69525809',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Doctors Alter Plan For Preteen\'s Weight Loss Surgery',
|
|
|
|
'description': 'md5:f5a11c51f8fb51d2315bca0937526891',
|
|
|
|
'uploader': 'newsy-videos',
|
2014-03-24 14:53:03 +01:00
|
|
|
},
|
2017-07-09 09:54:52 +02:00
|
|
|
'skip': 'This video has been deleted.',
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.veoh.com/watch/e152215AJxZktGS',
|
|
|
|
'only_matching': True,
|
2022-01-09 19:20:26 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.veoh.com/videos/v16374379WA437rMH',
|
|
|
|
'md5': 'cceb73f3909063d64f4b93d4defca1b3',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'v16374379WA437rMH',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Phantasmagoria 2, pt. 1-3',
|
|
|
|
'description': 'Phantasmagoria: a Puzzle of Flesh',
|
|
|
|
'thumbnail': 're:https://fcache\\.veoh\\.com/file/f/th16374379\\.jpg(\\?.*)?',
|
|
|
|
'uploader': 'davidspackage',
|
|
|
|
'duration': 968,
|
|
|
|
'view_count': int,
|
|
|
|
'average_rating': int,
|
|
|
|
'comment_count': int,
|
|
|
|
'age_limit': 18,
|
|
|
|
'categories': ['technology_and_gaming', 'gaming'],
|
|
|
|
'tags': ['puzzle', 'of', 'flesh'],
|
2024-06-12 01:09:58 +02:00
|
|
|
},
|
2022-01-09 19:20:26 +01:00
|
|
|
}]
|
2013-07-08 22:02:23 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2019-03-11 09:04:06 +01:00
|
|
|
video_id = self._match_id(url)
|
2022-01-09 19:20:26 +01:00
|
|
|
metadata = self._download_json(
|
2019-03-11 09:04:06 +01:00
|
|
|
'https://www.veoh.com/watch/getVideo/' + video_id,
|
2022-01-09 19:20:26 +01:00
|
|
|
video_id)
|
|
|
|
video = metadata['video']
|
2019-03-11 09:04:06 +01:00
|
|
|
title = video['title']
|
2013-07-08 22:02:23 +02:00
|
|
|
|
2019-03-11 09:04:06 +01:00
|
|
|
thumbnail_url = None
|
2022-01-09 19:20:26 +01:00
|
|
|
q = qualities(['Regular', 'HQ'])
|
2019-03-11 09:04:06 +01:00
|
|
|
formats = []
|
|
|
|
for f_id, f_url in video.get('src', {}).items():
|
|
|
|
if not f_url:
|
|
|
|
continue
|
|
|
|
if f_id == 'poster':
|
|
|
|
thumbnail_url = f_url
|
|
|
|
else:
|
|
|
|
formats.append({
|
|
|
|
'format_id': f_id,
|
|
|
|
'quality': q(f_id),
|
|
|
|
'url': f_url,
|
|
|
|
})
|
2014-03-24 14:53:03 +01:00
|
|
|
|
2022-01-09 19:20:26 +01:00
|
|
|
categories = metadata.get('categoryPath')
|
|
|
|
if not categories:
|
[cleanup] Misc (#11216)
- Add Python 3.13 to CI, finalize 3.13 support
- Remove Python 3.8 from CI in preparation for removing 3.8 support
- Document that PyPy3.8 and PyPy3.9 are no longer supported
- Usual documentation fixes and code cleanup
Closes #8248, Closes #11146, Closes #11149, Closes #11211
Authored by: Grub4K, grqz, DTrombett, KarboniteKream, bashonly, mikkovedru, seproDev
Co-authored-by: N/Ame <173015200+grqz@users.noreply.github.com>
Co-authored-by: DTrombett <d@trombett.org>
Co-authored-by: =?UTF-8?q?Klemen=20Ko=C5=A1ir?= <klemen.kosir@kream.io>
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
Co-authored-by: Mikko Vedru <mikko.vedru@gmail.com>
Co-authored-by: sepro <sepro@sepr0.com>
2024-10-22 06:50:35 +02:00
|
|
|
category = remove_start(strip_or_none(video.get('category')), 'category_')
|
2022-01-09 19:20:26 +01:00
|
|
|
categories = [category] if category else None
|
|
|
|
tags = video.get('tags')
|
|
|
|
|
2019-03-11 09:04:06 +01:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'description': video.get('description'),
|
|
|
|
'thumbnail': thumbnail_url,
|
|
|
|
'uploader': video.get('author', {}).get('nickname'),
|
|
|
|
'duration': int_or_none(video.get('lengthBySec')) or parse_duration(video.get('length')),
|
|
|
|
'view_count': int_or_none(video.get('views')),
|
|
|
|
'formats': formats,
|
|
|
|
'average_rating': int_or_none(video.get('rating')),
|
|
|
|
'comment_count': int_or_none(video.get('numOfComments')),
|
2022-01-09 19:20:26 +01:00
|
|
|
'age_limit': 18 if video.get('contentRatingId') == 2 else 0,
|
|
|
|
'categories': categories,
|
|
|
|
'tags': tags.split(', ') if tags else None,
|
2019-03-11 09:04:06 +01:00
|
|
|
}
|
2022-11-11 18:58:54 +01:00
|
|
|
|
|
|
|
|
2022-11-16 01:57:43 +01:00
|
|
|
class VeohUserIE(VeohIE): # XXX: Do not subclass from concrete IE
|
2022-11-11 18:58:54 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?veoh\.com/users/(?P<id>[\w-]+)'
|
|
|
|
IE_NAME = 'veoh:user'
|
|
|
|
|
|
|
|
_TESTS = [
|
|
|
|
{
|
|
|
|
'url': 'https://www.veoh.com/users/valentinazoe',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'valentinazoe',
|
2024-06-12 01:09:58 +02:00
|
|
|
'title': 'valentinazoe (Uploads)',
|
2022-11-11 18:58:54 +01:00
|
|
|
},
|
2024-06-12 01:09:58 +02:00
|
|
|
'playlist_mincount': 75,
|
2022-11-11 18:58:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'url': 'https://www.veoh.com/users/PiensaLibre',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'PiensaLibre',
|
2024-06-12 01:09:58 +02:00
|
|
|
'title': 'PiensaLibre (Uploads)',
|
2022-11-11 18:58:54 +01:00
|
|
|
},
|
2024-06-12 01:09:58 +02:00
|
|
|
'playlist_mincount': 2,
|
2022-11-11 18:58:54 +01:00
|
|
|
}]
|
|
|
|
|
|
|
|
_PAGE_SIZE = 16
|
|
|
|
|
|
|
|
def _fetch_page(self, uploader, page):
|
|
|
|
response = self._download_json(
|
|
|
|
'https://www.veoh.com/users/published/videos', uploader,
|
|
|
|
note=f'Downloading videos page {page + 1}',
|
|
|
|
headers={
|
|
|
|
'x-csrf-token': self._TOKEN,
|
2024-06-12 01:09:58 +02:00
|
|
|
'content-type': 'application/json;charset=UTF-8',
|
2022-11-11 18:58:54 +01:00
|
|
|
},
|
|
|
|
data=json.dumps({
|
|
|
|
'username': uploader,
|
|
|
|
'maxResults': self._PAGE_SIZE,
|
|
|
|
'page': page + 1,
|
2024-06-12 01:09:58 +02:00
|
|
|
'requestName': 'userPage',
|
|
|
|
}).encode())
|
2022-11-11 18:58:54 +01:00
|
|
|
if not response.get('success'):
|
|
|
|
raise ExtractorError(response['message'])
|
|
|
|
|
|
|
|
for video in response['videos']:
|
|
|
|
yield self.url_result(f'https://www.veoh.com/watch/{video["permalinkId"]}', VeohIE,
|
|
|
|
video['permalinkId'], video.get('title'))
|
|
|
|
|
|
|
|
def _real_initialize(self):
|
|
|
|
webpage = self._download_webpage(
|
|
|
|
'https://www.veoh.com', None, note='Downloading authorization token')
|
|
|
|
self._TOKEN = self._search_regex(
|
|
|
|
r'csrfToken:\s*(["\'])(?P<token>[0-9a-zA-Z]{40})\1', webpage,
|
|
|
|
'request token', group='token')
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
uploader = self._match_id(url)
|
|
|
|
return self.playlist_result(OnDemandPagedList(
|
|
|
|
functools.partial(self._fetch_page, uploader),
|
|
|
|
self._PAGE_SIZE), uploader, f'{uploader} (Uploads)')
|