0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-04 23:35:04 +00:00
yt-dlp/youtube_dl/extractor/jpopsukitv.py

74 lines
2.7 KiB
Python
Raw Normal View History

# coding=utf-8
2014-01-03 11:51:37 +00:00
from __future__ import unicode_literals
2014-01-01 13:59:54 +00:00
import re
2014-01-03 11:51:37 +00:00
2014-01-01 13:59:54 +00:00
from .common import InfoExtractor
2014-01-03 11:51:37 +00:00
from ..utils import (
int_or_none,
unified_strdate,
)
2014-01-01 13:59:54 +00:00
class JpopsukiIE(InfoExtractor):
2014-01-03 11:51:37 +00:00
IE_NAME = 'jpopsuki.tv'
2014-01-01 13:59:54 +00:00
_VALID_URL = r'https?://(?:www\.)?jpopsuki\.tv/video/(.*?)/(?P<id>\S+)'
_TEST = {
2014-01-03 11:51:37 +00:00
'url': 'http://www.jpopsuki.tv/video/ayumi-hamasaki---evolution/00be659d23b0b40508169cdee4545771',
'md5': '88018c0c1a9b1387940e90ec9e7e198e',
'file': '00be659d23b0b40508169cdee4545771.mp4',
'info_dict': {
'id': '00be659d23b0b40508169cdee4545771',
'title': 'ayumi hamasaki - evolution',
'description': 'Release date: 2001.01.31\r\n浜崎あゆみ - evolution',
'thumbnail': 'http://www.jpopsuki.tv/cache/89722c74d2a2ebe58bcac65321c115b2.jpg',
'uploader': 'plama_chan',
'uploader_id': '404',
'upload_date': '20121101'
2014-01-01 13:59:54 +00:00
}
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)
video_url = 'http://www.jpopsuki.tv' + self._html_search_regex(
2014-01-03 11:51:37 +00:00
r'<source src="(.*?)" type', webpage, 'video url')
2014-01-01 13:59:54 +00:00
2014-01-03 11:51:37 +00:00
video_title = self._og_search_title(webpage)
description = self._og_search_description(webpage)
thumbnail = self._og_search_thumbnail(webpage)
2014-01-01 13:59:54 +00:00
uploader = self._html_search_regex(
2014-01-03 11:51:37 +00:00
r'<li>from: <a href="/user/view/user/(.*?)/uid/',
webpage, 'video uploader', fatal=False)
2014-01-01 13:59:54 +00:00
uploader_id = self._html_search_regex(
2014-01-03 11:51:37 +00:00
r'<li>from: <a href="/user/view/user/\S*?/uid/(\d*)',
webpage, 'video uploader_id', fatal=False)
2014-01-01 13:59:54 +00:00
upload_date = self._html_search_regex(
2014-01-03 11:51:37 +00:00
r'<li>uploaded: (.*?)</li>', webpage, 'video upload_date',
fatal=False)
2014-01-01 13:59:54 +00:00
if upload_date is not None:
upload_date = unified_strdate(upload_date)
2014-01-03 11:51:37 +00:00
view_count_str = self._html_search_regex(
r'<li>Hits: ([0-9]+?)</li>', webpage, 'video view_count',
fatal=False)
comment_count_str = self._html_search_regex(
r'<h2>([0-9]+?) comments</h2>', webpage, 'video comment_count',
fatal=False)
2014-01-01 13:59:54 +00:00
return {
'id': video_id,
'url': video_url,
'title': video_title,
'description': description,
'thumbnail': thumbnail,
'uploader': uploader,
'uploader_id': uploader_id,
'upload_date': upload_date,
2014-01-03 11:51:37 +00:00
'view_count': int_or_none(view_count_str),
'comment_count': int_or_none(comment_count_str),
}