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.

105 lines
3.8 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. import datetime
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. str_to_int,
  7. unified_strdate,
  8. )
  9. class MotherlessIE(InfoExtractor):
  10. _VALID_URL = r'http://(?:www\.)?motherless\.com/(?:g/[a-z0-9_]+/)?(?P<id>[A-Z0-9]+)'
  11. _TESTS = [
  12. {
  13. 'url': 'http://motherless.com/AC3FFE1',
  14. 'md5': '310f62e325a9fafe64f68c0bccb6e75f',
  15. 'info_dict': {
  16. 'id': 'AC3FFE1',
  17. 'ext': 'mp4',
  18. 'title': 'Fucked in the ass while playing PS3',
  19. 'categories': ['Gaming', 'anal', 'reluctant', 'rough', 'Wife'],
  20. 'upload_date': '20100913',
  21. 'uploader_id': 'famouslyfuckedup',
  22. 'thumbnail': 're:http://.*\.jpg',
  23. 'age_limit': 18,
  24. }
  25. },
  26. {
  27. 'url': 'http://motherless.com/532291B',
  28. 'md5': 'bc59a6b47d1f958e61fbd38a4d31b131',
  29. 'info_dict': {
  30. 'id': '532291B',
  31. 'ext': 'mp4',
  32. 'title': 'Amazing girl playing the omegle game, PERFECT!',
  33. 'categories': ['Amateur', 'webcam', 'omegle', 'pink', 'young', 'masturbate', 'teen', 'game', 'hairy'],
  34. 'upload_date': '20140622',
  35. 'uploader_id': 'Sulivana7x',
  36. 'thumbnail': 're:http://.*\.jpg',
  37. 'age_limit': 18,
  38. }
  39. },
  40. {
  41. 'url': 'http://motherless.com/g/cosplay/633979F',
  42. 'md5': '0b2a43f447a49c3e649c93ad1fafa4a0',
  43. 'info_dict': {
  44. 'id': '633979F',
  45. 'ext': 'mp4',
  46. 'title': 'Turtlette',
  47. 'categories': ['superheroine heroine superher'],
  48. 'upload_date': '20140827',
  49. 'uploader_id': 'shade0230',
  50. 'thumbnail': 're:http://.*\.jpg',
  51. 'age_limit': 18,
  52. }
  53. }
  54. ]
  55. def _real_extract(self, url):
  56. video_id = self._match_id(url)
  57. webpage = self._download_webpage(url, video_id)
  58. title = self._html_search_regex(
  59. r'id="view-upload-title">\s+([^<]+)<', webpage, 'title')
  60. video_url = self._html_search_regex(
  61. r'setup\(\{\s+"file".+: "([^"]+)",', webpage, 'video URL')
  62. age_limit = self._rta_search(webpage)
  63. view_count = str_to_int(self._html_search_regex(
  64. r'<strong>Views</strong>\s+([^<]+)<',
  65. webpage, 'view count', fatal=False))
  66. like_count = str_to_int(self._html_search_regex(
  67. r'<strong>Favorited</strong>\s+([^<]+)<',
  68. webpage, 'like count', fatal=False))
  69. upload_date = self._html_search_regex(
  70. r'<strong>Uploaded</strong>\s+([^<]+)<', webpage, 'upload date')
  71. if 'Ago' in upload_date:
  72. days = int(re.search(r'([0-9]+)', upload_date).group(1))
  73. upload_date = (datetime.datetime.now() - datetime.timedelta(days=days)).strftime('%Y%m%d')
  74. else:
  75. upload_date = unified_strdate(upload_date)
  76. comment_count = webpage.count('class="media-comment-contents"')
  77. uploader_id = self._html_search_regex(
  78. r'"thumb-member-username">\s+<a href="/m/([^"]+)"',
  79. webpage, 'uploader_id')
  80. categories = self._html_search_meta('keywords', webpage)
  81. if categories:
  82. categories = [cat.strip() for cat in categories.split(',')]
  83. return {
  84. 'id': video_id,
  85. 'title': title,
  86. 'upload_date': upload_date,
  87. 'uploader_id': uploader_id,
  88. 'thumbnail': self._og_search_thumbnail(webpage),
  89. 'categories': categories,
  90. 'view_count': view_count,
  91. 'like_count': like_count,
  92. 'comment_count': comment_count,
  93. 'age_limit': age_limit,
  94. 'url': video_url,
  95. }