diff options
author | Yen Chi Hsuan <[email protected]> | 2016-09-08 00:28:33 +0800 |
---|---|---|
committer | Yen Chi Hsuan <[email protected]> | 2016-09-08 00:28:33 +0800 |
commit | f87feb4b688f7b6e02714f8405c8343e27956400 (patch) | |
tree | 6d50ba74b81466403e5878138aad7f6c7c071194 /youtube_dl/extractor/miaopai.py | |
parent | 2841bdcebb308cab2a6af6b970459889392faa40 (diff) | |
download | youtube-dl-f87feb4b688f7b6e02714f8405c8343e27956400.tar.gz youtube-dl-f87feb4b688f7b6e02714f8405c8343e27956400.zip |
[miaopai] Coding style (#10556)
Diffstat (limited to 'youtube_dl/extractor/miaopai.py')
-rw-r--r-- | youtube_dl/extractor/miaopai.py | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/youtube_dl/extractor/miaopai.py b/youtube_dl/extractor/miaopai.py index 2477d1009..f9e35ac7f 100644 --- a/youtube_dl/extractor/miaopai.py +++ b/youtube_dl/extractor/miaopai.py @@ -2,11 +2,10 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..utils import sanitized_Request class MiaoPaiIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?miaopai\.com/show/(?P<id>[-A-Za-z0-9~_]+).htm' + _VALID_URL = r'https?://(?:www\.)?miaopai\.com/show/(?P<id>[-A-Za-z0-9~_]+)' _TEST = { 'url': 'http://www.miaopai.com/show/n~0hO7sfV1nBEw4Y29-Hqg__.htm', 'md5': '095ed3f1cd96b821add957bdc29f845b', @@ -18,27 +17,24 @@ class MiaoPaiIE(InfoExtractor): } } - _USER_AGENT_IPAD = 'User-Agent:Mozilla/5.0 ' \ - '(iPad; CPU OS 9_1 like Mac OS X) ' \ - 'AppleWebKit/601.1.46 (KHTML, like Gecko) ' \ - 'Version/9.0 Mobile/13B143 Safari/601.1' + _USER_AGENT_IPAD = 'Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1' def _real_extract(self, url): video_id = self._match_id(url) - request = sanitized_Request(url) - request.add_header('User-Agent', self._USER_AGENT_IPAD) - webpage = self._download_webpage(request, video_id) + webpage = self._download_webpage( + url, video_id, headers={'User-Agent': self._USER_AGENT_IPAD}) - title = self._html_search_regex(r'<title>([^<]*)</title>', - webpage, - 'title') - regex = r"""<div *class=['"]video_img[^>]*data-url=['"]([^'"]*\.jpg)['"]""" - thumbnail = self._html_search_regex(regex, webpage, '') + title = self._html_search_regex( + r'<title>([^<]+)</title>', webpage, 'title') + thumbnail = self._html_search_regex( + r'<div[^>]+class=(?P<q1>[\'"]).*\bvideo_img\b.*(?P=q1)[^>]+data-url=(?P<q2>[\'"])(?P<url>[^\'"]+)(?P=q2)', + webpage, 'thumbnail', fatal=False, group='url') videos = self._parse_html5_media_entries(url, webpage, video_id) info = videos[0] - info.update({'id': video_id, - 'title': title, - 'thumbnail': thumbnail, - }) + info.update({ + 'id': video_id, + 'title': title, + 'thumbnail': thumbnail, + }) return info |