From d9658562350f6aaf9f6deb037734d1cd691a64ce Mon Sep 17 00:00:00 2001 From: Audrey <45548254+tntmod54321@users.noreply.github.com> Date: Fri, 11 Nov 2022 12:58:54 -0500 Subject: [extractor/Veoh] Add user extractor (#5242) Authored by: tntmod54321 --- yt_dlp/extractor/veoh.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'yt_dlp/extractor/veoh.py') diff --git a/yt_dlp/extractor/veoh.py b/yt_dlp/extractor/veoh.py index 70280ae85..a32c2fccb 100644 --- a/yt_dlp/extractor/veoh.py +++ b/yt_dlp/extractor/veoh.py @@ -1,9 +1,14 @@ +import functools +import json + from .common import InfoExtractor from ..utils import ( + ExtractorError, + OnDemandPagedList, int_or_none, parse_duration, qualities, - try_get + try_get, ) @@ -123,3 +128,62 @@ class VeohIE(InfoExtractor): 'categories': categories, 'tags': tags.split(', ') if tags else None, } + + +class VeohUserIE(VeohIE): + _VALID_URL = r'https?://(?:www\.)?veoh\.com/users/(?P[\w-]+)' + IE_NAME = 'veoh:user' + + _TESTS = [ + { + 'url': 'https://www.veoh.com/users/valentinazoe', + 'info_dict': { + 'id': 'valentinazoe', + 'title': 'valentinazoe (Uploads)' + }, + 'playlist_mincount': 75 + }, + { + 'url': 'https://www.veoh.com/users/PiensaLibre', + 'info_dict': { + 'id': 'PiensaLibre', + 'title': 'PiensaLibre (Uploads)' + }, + 'playlist_mincount': 2 + }] + + _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, + 'content-type': 'application/json;charset=UTF-8' + }, + data=json.dumps({ + 'username': uploader, + 'maxResults': self._PAGE_SIZE, + 'page': page + 1, + 'requestName': 'userPage' + }).encode('utf-8')) + 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[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)') -- cgit v1.2.3 From 6368e2e639bca7e66609911d2672b6a9dc65b052 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Wed, 16 Nov 2022 06:27:43 +0530 Subject: [cleanup] Misc Closes #5541 --- yt_dlp/extractor/veoh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yt_dlp/extractor/veoh.py') diff --git a/yt_dlp/extractor/veoh.py b/yt_dlp/extractor/veoh.py index a32c2fccb..d9b3ab115 100644 --- a/yt_dlp/extractor/veoh.py +++ b/yt_dlp/extractor/veoh.py @@ -130,7 +130,7 @@ class VeohIE(InfoExtractor): } -class VeohUserIE(VeohIE): +class VeohUserIE(VeohIE): # XXX: Do not subclass from concrete IE _VALID_URL = r'https?://(?:www\.)?veoh\.com/users/(?P[\w-]+)' IE_NAME = 'veoh:user' -- cgit v1.2.3 From 9f14daf22b4080ae1531a772ee7574959af4e2fa Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 17 Nov 2022 10:40:03 +0530 Subject: [extractor] Deprecate `_sort_formats` --- yt_dlp/extractor/veoh.py | 1 - 1 file changed, 1 deletion(-) (limited to 'yt_dlp/extractor/veoh.py') diff --git a/yt_dlp/extractor/veoh.py b/yt_dlp/extractor/veoh.py index d9b3ab115..92ff86521 100644 --- a/yt_dlp/extractor/veoh.py +++ b/yt_dlp/extractor/veoh.py @@ -105,7 +105,6 @@ class VeohIE(InfoExtractor): 'quality': q(f_id), 'url': f_url, }) - self._sort_formats(formats) categories = metadata.get('categoryPath') if not categories: -- cgit v1.2.3