You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB

  1. # coding=utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. unified_strdate,
  8. )
  9. class JpopsukiIE(InfoExtractor):
  10. IE_NAME = 'jpopsuki.tv'
  11. _VALID_URL = r'https?://(?:www\.)?jpopsuki\.tv/video/(.*?)/(?P<id>\S+)'
  12. _TEST = {
  13. 'url': 'http://www.jpopsuki.tv/video/ayumi-hamasaki---evolution/00be659d23b0b40508169cdee4545771',
  14. 'md5': '88018c0c1a9b1387940e90ec9e7e198e',
  15. 'file': '00be659d23b0b40508169cdee4545771.mp4',
  16. 'info_dict': {
  17. 'id': '00be659d23b0b40508169cdee4545771',
  18. 'title': 'ayumi hamasaki - evolution',
  19. 'description': 'Release date: 2001.01.31\r\n浜崎あゆみ - evolution',
  20. 'thumbnail': 'http://www.jpopsuki.tv/cache/89722c74d2a2ebe58bcac65321c115b2.jpg',
  21. 'uploader': 'plama_chan',
  22. 'uploader_id': '404',
  23. 'upload_date': '20121101'
  24. }
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. webpage = self._download_webpage(url, video_id)
  30. video_url = 'http://www.jpopsuki.tv' + self._html_search_regex(
  31. r'<source src="(.*?)" type', webpage, 'video url')
  32. video_title = self._og_search_title(webpage)
  33. description = self._og_search_description(webpage)
  34. thumbnail = self._og_search_thumbnail(webpage)
  35. uploader = self._html_search_regex(
  36. r'<li>from: <a href="/user/view/user/(.*?)/uid/',
  37. webpage, 'video uploader', fatal=False)
  38. uploader_id = self._html_search_regex(
  39. r'<li>from: <a href="/user/view/user/\S*?/uid/(\d*)',
  40. webpage, 'video uploader_id', fatal=False)
  41. upload_date = self._html_search_regex(
  42. r'<li>uploaded: (.*?)</li>', webpage, 'video upload_date',
  43. fatal=False)
  44. if upload_date is not None:
  45. upload_date = unified_strdate(upload_date)
  46. view_count_str = self._html_search_regex(
  47. r'<li>Hits: ([0-9]+?)</li>', webpage, 'video view_count',
  48. fatal=False)
  49. comment_count_str = self._html_search_regex(
  50. r'<h2>([0-9]+?) comments</h2>', webpage, 'video comment_count',
  51. fatal=False)
  52. return {
  53. 'id': video_id,
  54. 'url': video_url,
  55. 'title': video_title,
  56. 'description': description,
  57. 'thumbnail': thumbnail,
  58. 'uploader': uploader,
  59. 'uploader_id': uploader_id,
  60. 'upload_date': upload_date,
  61. 'view_count': int_or_none(view_count_str),
  62. 'comment_count': int_or_none(comment_count_str),
  63. }