]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/thisav.py
[LnkIE] Add extractor (#2408)
[yt-dlp.git] / yt_dlp / extractor / thisav.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4
5 from .common import InfoExtractor
6 from ..utils import remove_end
7
8
9 class ThisAVIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?thisav\.com/video/(?P<id>[0-9]+)/.*'
11 _TESTS = [{
12 # jwplayer
13 'url': 'http://www.thisav.com/video/47734/%98%26sup1%3B%83%9E%83%82---just-fit.html',
14 'md5': '0480f1ef3932d901f0e0e719f188f19b',
15 'info_dict': {
16 'id': '47734',
17 'ext': 'flv',
18 'title': '高樹マリア - Just fit',
19 'uploader': 'dj7970',
20 'uploader_id': 'dj7970'
21 }
22 }, {
23 # html5 media
24 'url': 'http://www.thisav.com/video/242352/nerdy-18yo-big-ass-tattoos-and-glasses.html',
25 'md5': 'ba90c076bd0f80203679e5b60bf523ee',
26 'info_dict': {
27 'id': '242352',
28 'ext': 'mp4',
29 'title': 'Nerdy 18yo Big Ass Tattoos and Glasses',
30 'uploader': 'cybersluts',
31 'uploader_id': 'cybersluts',
32 },
33 }]
34
35 def _real_extract(self, url):
36 mobj = self._match_valid_url(url)
37
38 video_id = mobj.group('id')
39 webpage = self._download_webpage(url, video_id)
40 title = remove_end(self._html_search_regex(
41 r'<title>([^<]+)</title>', webpage, 'title'),
42 ' - 視頻 - ThisAV.com-世界第一中文成人娛樂網站')
43 video_url = self._html_search_regex(
44 r"addVariable\('file','([^']+)'\);", webpage, 'video url', default=None)
45 if video_url:
46 info_dict = {
47 'formats': [{
48 'url': video_url,
49 }],
50 }
51 else:
52 entries = self._parse_html5_media_entries(url, webpage, video_id)
53 if entries:
54 info_dict = entries[0]
55 else:
56 info_dict = self._extract_jwplayer_data(
57 webpage, video_id, require_title=False)
58 uploader = self._html_search_regex(
59 r': <a href="http://www\.thisav\.com/user/[0-9]+/(?:[^"]+)">([^<]+)</a>',
60 webpage, 'uploader name', fatal=False)
61 uploader_id = self._html_search_regex(
62 r': <a href="http://www\.thisav\.com/user/[0-9]+/([^"]+)">(?:[^<]+)</a>',
63 webpage, 'uploader id', fatal=False)
64
65 info_dict.update({
66 'id': video_id,
67 'uploader': uploader,
68 'uploader_id': uploader_id,
69 'title': title,
70 })
71
72 return info_dict