1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 03:32:05 +00:00

[miaopai] Coding style (#10556)

This commit is contained in:
Yen Chi Hsuan 2016-09-08 00:28:33 +08:00
parent 2841bdcebb
commit f87feb4b68
No known key found for this signature in database
GPG key ID: 3FDDD575826C5C30

View file

@ -2,11 +2,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import sanitized_Request
class MiaoPaiIE(InfoExtractor): 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 = { _TEST = {
'url': 'http://www.miaopai.com/show/n~0hO7sfV1nBEw4Y29-Hqg__.htm', 'url': 'http://www.miaopai.com/show/n~0hO7sfV1nBEw4Y29-Hqg__.htm',
'md5': '095ed3f1cd96b821add957bdc29f845b', 'md5': '095ed3f1cd96b821add957bdc29f845b',
@ -18,27 +17,24 @@ class MiaoPaiIE(InfoExtractor):
} }
} }
_USER_AGENT_IPAD = 'User-Agent:Mozilla/5.0 ' \ _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'
'(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): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
request = sanitized_Request(url) webpage = self._download_webpage(
request.add_header('User-Agent', self._USER_AGENT_IPAD) url, video_id, headers={'User-Agent': self._USER_AGENT_IPAD})
webpage = self._download_webpage(request, video_id)
title = self._html_search_regex(r'<title>([^<]*)</title>', title = self._html_search_regex(
webpage, r'<title>([^<]+)</title>', webpage, 'title')
'title') thumbnail = self._html_search_regex(
regex = r"""<div *class=['"]video_img[^>]*data-url=['"]([^'"]*\.jpg)['"]""" r'<div[^>]+class=(?P<q1>[\'"]).*\bvideo_img\b.*(?P=q1)[^>]+data-url=(?P<q2>[\'"])(?P<url>[^\'"]+)(?P=q2)',
thumbnail = self._html_search_regex(regex, webpage, '') webpage, 'thumbnail', fatal=False, group='url')
videos = self._parse_html5_media_entries(url, webpage, video_id) videos = self._parse_html5_media_entries(url, webpage, video_id)
info = videos[0] info = videos[0]
info.update({'id': video_id, info.update({
'title': title, 'id': video_id,
'thumbnail': thumbnail, 'title': title,
}) 'thumbnail': thumbnail,
})
return info return info