]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jpopsukitv.py
debian/changelog: Initiate new release.
[youtubedl] / youtube_dl / extractor / jpopsukitv.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 (
8 int_or_none,
9 unified_strdate,
10 )
11
12
13 class JpopsukiIE(InfoExtractor):
14 IE_NAME = 'jpopsuki.tv'
15 _VALID_URL = r'https?://(?:www\.)?jpopsuki\.tv/video/(.*?)/(?P<id>\S+)'
16
17 _TEST = {
18 'url': 'http://www.jpopsuki.tv/video/ayumi-hamasaki---evolution/00be659d23b0b40508169cdee4545771',
19 'md5': '88018c0c1a9b1387940e90ec9e7e198e',
20 'file': '00be659d23b0b40508169cdee4545771.mp4',
21 'info_dict': {
22 'id': '00be659d23b0b40508169cdee4545771',
23 'title': 'ayumi hamasaki - evolution',
24 'description': 'Release date: 2001.01.31\r\n浜崎あゆみ - evolution',
25 'thumbnail': 'http://www.jpopsuki.tv/cache/89722c74d2a2ebe58bcac65321c115b2.jpg',
26 'uploader': 'plama_chan',
27 'uploader_id': '404',
28 'upload_date': '20121101'
29 }
30 }
31
32 def _real_extract(self, url):
33 mobj = re.match(self._VALID_URL, url)
34 video_id = mobj.group('id')
35
36 webpage = self._download_webpage(url, video_id)
37
38 video_url = 'http://www.jpopsuki.tv' + self._html_search_regex(
39 r'<source src="(.*?)" type', webpage, 'video url')
40
41 video_title = self._og_search_title(webpage)
42 description = self._og_search_description(webpage)
43 thumbnail = self._og_search_thumbnail(webpage)
44 uploader = self._html_search_regex(
45 r'<li>from: <a href="/user/view/user/(.*?)/uid/',
46 webpage, 'video uploader', fatal=False)
47 uploader_id = self._html_search_regex(
48 r'<li>from: <a href="/user/view/user/\S*?/uid/(\d*)',
49 webpage, 'video uploader_id', fatal=False)
50 upload_date = self._html_search_regex(
51 r'<li>uploaded: (.*?)</li>', webpage, 'video upload_date',
52 fatal=False)
53 if upload_date is not None:
54 upload_date = unified_strdate(upload_date)
55 view_count_str = self._html_search_regex(
56 r'<li>Hits: ([0-9]+?)</li>', webpage, 'video view_count',
57 fatal=False)
58 comment_count_str = self._html_search_regex(
59 r'<h2>([0-9]+?) comments</h2>', webpage, 'video comment_count',
60 fatal=False)
61
62 return {
63 'id': video_id,
64 'url': video_url,
65 'title': video_title,
66 'description': description,
67 'thumbnail': thumbnail,
68 'uploader': uploader,
69 'uploader_id': uploader_id,
70 'upload_date': upload_date,
71 'view_count': int_or_none(view_count_str),
72 'comment_count': int_or_none(comment_count_str),
73 }