logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

tube8.py (3087B)


  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. @staticmethod
  30. def _extract_urls(webpage):
  31. return re.findall(
  32. r'<iframe[^>]+\bsrc=["\']((?:https?:)?//(?:www\.)?tube8\.com/embed/(?:[^/]+/)+\d+)',
  33. webpage)
  34. def _real_extract(self, url):
  35. webpage, info = self._extract_info(url)
  36. if not info['title']:
  37. info['title'] = self._html_search_regex(
  38. r'videoTitle\s*=\s*"([^"]+)', webpage, 'title')
  39. description = self._html_search_regex(
  40. r'(?s)Description:</dt>\s*<dd>(.+?)</dd>', webpage, 'description', fatal=False)
  41. uploader = self._html_search_regex(
  42. r'<span class="username">\s*(.+?)\s*<',
  43. webpage, 'uploader', fatal=False)
  44. like_count = int_or_none(self._search_regex(
  45. r'rupVar\s*=\s*"(\d+)"', webpage, 'like count', fatal=False))
  46. dislike_count = int_or_none(self._search_regex(
  47. r'rdownVar\s*=\s*"(\d+)"', webpage, 'dislike count', fatal=False))
  48. view_count = str_to_int(self._search_regex(
  49. r'Views:\s*</dt>\s*<dd>([\d,\.]+)',
  50. webpage, 'view count', fatal=False))
  51. comment_count = str_to_int(self._search_regex(
  52. r'<span id="allCommentsCount">(\d+)</span>',
  53. webpage, 'comment count', fatal=False))
  54. category = self._search_regex(
  55. r'Category:\s*</dt>\s*<dd>\s*<a[^>]+href=[^>]+>([^<]+)',
  56. webpage, 'category', fatal=False)
  57. categories = [category] if category else None
  58. tags_str = self._search_regex(
  59. r'(?s)Tags:\s*</dt>\s*<dd>(.+?)</(?!a)',
  60. webpage, 'tags', fatal=False)
  61. tags = [t for t in re.findall(
  62. r'<a[^>]+href=[^>]+>([^<]+)', tags_str)] if tags_str else None
  63. info.update({
  64. 'description': description,
  65. 'uploader': uploader,
  66. 'view_count': view_count,
  67. 'like_count': like_count,
  68. 'dislike_count': dislike_count,
  69. 'comment_count': comment_count,
  70. 'categories': categories,
  71. 'tags': tags,
  72. })
  73. return info