thisav.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .jwplatform import JWPlatformBaseIE
  5. class ThisAVIE(JWPlatformBaseIE):
  6. _VALID_URL = r'https?://(?:www\.)?thisav\.com/video/(?P<id>[0-9]+)/.*'
  7. _TESTS = [{
  8. 'url': 'http://www.thisav.com/video/47734/%98%26sup1%3B%83%9E%83%82---just-fit.html',
  9. 'md5': '0480f1ef3932d901f0e0e719f188f19b',
  10. 'info_dict': {
  11. 'id': '47734',
  12. 'ext': 'flv',
  13. 'title': '高樹マリア - Just fit',
  14. 'uploader': 'dj7970',
  15. 'uploader_id': 'dj7970'
  16. }
  17. }, {
  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 = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. webpage = self._download_webpage(url, video_id)
  32. title = self._html_search_regex(r'<h1>([^<]*)</h1>', webpage, 'title')
  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. info_dict = self._extract_jwplayer_data(
  43. webpage, video_id, require_title=False)
  44. uploader = self._html_search_regex(
  45. r': <a href="http://www.thisav.com/user/[0-9]+/(?:[^"]+)">([^<]+)</a>',
  46. webpage, 'uploader name', fatal=False)
  47. uploader_id = self._html_search_regex(
  48. r': <a href="http://www.thisav.com/user/[0-9]+/([^"]+)">(?:[^<]+)</a>',
  49. webpage, 'uploader id', fatal=False)
  50. info_dict.update({
  51. 'id': video_id,
  52. 'uploader': uploader,
  53. 'uploader_id': uploader_id,
  54. 'title': title,
  55. })
  56. return info_dict