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