]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/thisav.py
debian/control: Annotate with bug numbers closed by this release.
[youtubedl] / youtube_dl / extractor / thisav.py
1 #coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import determine_ext
8
9
10 class ThisAVIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?thisav\.com/video/(?P<id>[0-9]+)/.*'
12 _TEST = {
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
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26
27 video_id = mobj.group('id')
28 webpage = self._download_webpage(url, video_id)
29 title = self._html_search_regex(r'<h1>([^<]*)</h1>', webpage, 'title')
30 video_url = self._html_search_regex(
31 r"addVariable\('file','([^']+)'\);", webpage, 'video url')
32 uploader = self._html_search_regex(
33 r': <a href="http://www.thisav.com/user/[0-9]+/(?:[^"]+)">([^<]+)</a>',
34 webpage, 'uploader name', fatal=False)
35 uploader_id = self._html_search_regex(
36 r': <a href="http://www.thisav.com/user/[0-9]+/([^"]+)">(?:[^<]+)</a>',
37 webpage, 'uploader id', fatal=False)
38 ext = determine_ext(video_url)
39
40 return {
41 'id': video_id,
42 'url': video_url,
43 'uploader': uploader,
44 'uploader_id': uploader_id,
45 'title': title,
46 'ext': ext,
47 }