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.5 KiB

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