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.

80 lines
2.8 KiB

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