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.

63 lines
2.2 KiB

9 years ago
  1. from __future__ import unicode_literals
  2. from ..utils import (
  3. int_or_none,
  4. str_to_int,
  5. )
  6. from .keezmovies import KeezMoviesIE
  7. class Tube8IE(KeezMoviesIE):
  8. _VALID_URL = r'https?://(?:www\.)?tube8\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/(?P<id>\d+)'
  9. _TESTS = [{
  10. 'url': 'http://www.tube8.com/teen/kasia-music-video/229795/',
  11. 'md5': '65e20c48e6abff62ed0c3965fff13a39',
  12. 'info_dict': {
  13. 'id': '229795',
  14. 'display_id': 'kasia-music-video',
  15. 'ext': 'mp4',
  16. 'description': 'hot teen Kasia grinding',
  17. 'uploader': 'unknown',
  18. 'title': 'Kasia music video',
  19. 'age_limit': 18,
  20. 'duration': 230,
  21. }
  22. }, {
  23. 'url': 'http://www.tube8.com/shemale/teen/blonde-cd-gets-kidnapped-by-two-blacks-and-punished-for-being-a-slutty-girl/19569151/',
  24. 'only_matching': True,
  25. }]
  26. def _real_extract(self, url):
  27. webpage, info = self._extract_info(url)
  28. if not info['title']:
  29. info['title'] = self._html_search_regex(
  30. r'videoTitle\s*=\s*"([^"]+)', webpage, 'title')
  31. description = self._html_search_regex(
  32. r'>Description:</strong>\s*(.+?)\s*<', webpage, 'description', fatal=False)
  33. uploader = self._html_search_regex(
  34. r'<span class="username">\s*(.+?)\s*<',
  35. webpage, 'uploader', fatal=False)
  36. like_count = int_or_none(self._search_regex(
  37. r'rupVar\s*=\s*"(\d+)"', webpage, 'like count', fatal=False))
  38. dislike_count = int_or_none(self._search_regex(
  39. r'rdownVar\s*=\s*"(\d+)"', webpage, 'dislike count', fatal=False))
  40. view_count = str_to_int(self._search_regex(
  41. r'<strong>Views: </strong>([\d,\.]+)\s*</li>',
  42. webpage, 'view count', fatal=False))
  43. comment_count = str_to_int(self._search_regex(
  44. r'<span id="allCommentsCount">(\d+)</span>',
  45. webpage, 'comment count', fatal=False))
  46. info.update({
  47. 'description': description,
  48. 'uploader': uploader,
  49. 'view_count': view_count,
  50. 'like_count': like_count,
  51. 'dislike_count': dislike_count,
  52. 'comment_count': comment_count,
  53. })
  54. return info