From 987fbde7da0e1cf6e543c5dd90688e75be78cdf1 Mon Sep 17 00:00:00 2001 From: Fran Hermoso Date: Thu, 14 May 2020 13:51:40 +0200 Subject: [PATCH] [SEXU] Moved to API requests (closes #25270) --- youtube_dl/extractor/sexu.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/youtube_dl/extractor/sexu.py b/youtube_dl/extractor/sexu.py index 3df51520b..213c8c2c0 100644 --- a/youtube_dl/extractor/sexu.py +++ b/youtube_dl/extractor/sexu.py @@ -1,6 +1,9 @@ from __future__ import unicode_literals +import re + from .common import InfoExtractor +from ..utils import urlencode_postdata class SexuIE(InfoExtractor): @@ -12,7 +15,7 @@ class SexuIE(InfoExtractor): 'id': '961791', 'ext': 'mp4', 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b', - 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403', + 'description': 'md5:6c7e471f9ac9bc326a9ad27be409f617', 'categories': list, # NSFW 'thumbnail': r're:https?://.*\.jpg$', 'age_limit': 18, @@ -23,34 +26,29 @@ class SexuIE(InfoExtractor): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - jwvideo = self._parse_json( - self._search_regex(r'\.setup\(\s*({.+?})\s*\);', webpage, 'jwvideo'), - video_id) - - sources = jwvideo['sources'] - + apiresponse = self._download_json( + 'https://sexu.com/api/video-info', + video_id, data=urlencode_postdata({'videoId': video_id}) + ) formats = [{ - 'url': source['file'].replace('\\', ''), - 'format_id': source.get('label'), + 'url': source.get('src'), + 'format_id': source.get('type'), 'height': int(self._search_regex( - r'^(\d+)[pP]', source.get('label', ''), 'height', + r'^(\d+)[pP]', source.get('quality', ''), 'height', default=None)), - } for source in sources if source.get('file')] + } for source in apiresponse['sources']] self._sort_formats(formats) - title = self._html_search_regex( - r'([^<]+)\s*-\s*Sexu\.Com', webpage, 'title') + title = self._og_search_property('title', webpage) description = self._html_search_meta( 'description', webpage, 'description') - thumbnail = jwvideo.get('image') + thumbnail = self._og_search_property('image', webpage) - categories_str = self._html_search_meta( - 'keywords', webpage, 'categories') - categories = ( - None if categories_str is None - else categories_str.split(',')) + categories = re.findall( + r'(?s)]*>(.*?)', webpage + ) return { 'id': video_id,