[SEXU] Improve patterns and conventions

This commit is contained in:
Fran Hermoso 2020-05-14 16:23:11 +02:00
parent 987fbde7da
commit 1be56a5500

View File

@ -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)<a class=[\'"]player-tags__item[\'"][^>]*>(.*?)</a>', webpage
)
r'(?s)<a[^>]+class=[\'"]player-tags__item[^>]*>([^<]+)</a>', webpage)
return {
'id': video_id,