From 1be56a55009ef600b77559580637d091391ed1e1 Mon Sep 17 00:00:00 2001 From: Fran Hermoso Date: Thu, 14 May 2020 16:23:11 +0200 Subject: [PATCH] [SEXU] Improve patterns and conventions --- youtube_dl/extractor/sexu.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/sexu.py b/youtube_dl/extractor/sexu.py index 213c8c2c0..2891212f3 100644 --- a/youtube_dl/extractor/sexu.py +++ b/youtube_dl/extractor/sexu.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import re from .common import InfoExtractor -from ..utils import urlencode_postdata +from ..utils import urlencode_postdata, try_get class SexuIE(InfoExtractor): @@ -28,15 +28,15 @@ class SexuIE(InfoExtractor): apiresponse = self._download_json( 'https://sexu.com/api/video-info', - video_id, data=urlencode_postdata({'videoId': video_id}) - ) + video_id, data=urlencode_postdata({'videoId': video_id})) + formats = [{ 'url': source.get('src'), 'format_id': source.get('type'), 'height': int(self._search_regex( r'^(\d+)[pP]', source.get('quality', ''), 'height', default=None)), - } for source in apiresponse['sources']] + } for source in try_get(apiresponse, lambda x: x['sources'])] self._sort_formats(formats) title = self._og_search_property('title', webpage) @@ -47,8 +47,7 @@ class SexuIE(InfoExtractor): thumbnail = self._og_search_property('image', webpage) categories = re.findall( - r'(?s)]*>(.*?)', webpage - ) + r'(?s)]+class=[\'"]player-tags__item[^>]*>([^<]+)', webpage) return { 'id': video_id,