thisav.py 2.3 KB

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