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.

93 lines
3.9 KiB

  1. from __future__ import unicode_literals
  2. import datetime
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import str_to_int
  6. class MotherlessIE(InfoExtractor):
  7. """Information Extractor for Motherless"""
  8. _VALID_URL = r'http://(?:www\.)?motherless\.com/(?P<id>[A-Z0-9]+)'
  9. _TESTS = [
  10. {
  11. 'url': 'http://motherless.com/AC3FFE1',
  12. 'md5': '5527fef81d2e529215dad3c2d744a7d9',
  13. 'info_dict': {
  14. 'id': 'AC3FFE1',
  15. 'ext': 'flv',
  16. 'title': 'Fucked in the ass while playing PS3',
  17. 'categories': ['Gaming', 'anal', 'reluctant', 'rough', 'Wife'],
  18. 'upload_date': '20100913',
  19. 'uploader_id': 'famouslyfuckedup',
  20. 'thumbnail': 'http://thumbs.motherlessmedia.com/thumbs/AC3FFE1.jpg',
  21. 'age_limit': 18,
  22. }
  23. },
  24. {
  25. 'url': 'http://motherless.com/532291B',
  26. 'md5': 'bc59a6b47d1f958e61fbd38a4d31b131',
  27. 'info_dict': {
  28. 'id': '532291B',
  29. 'ext': 'mp4',
  30. 'title': 'Amazing girl playing the omegle game, PERFECT!',
  31. 'categories': ['Amateur', 'webcam', 'omegle', 'pink', 'young', 'masturbate', 'teen', 'game', 'hairy'],
  32. 'upload_date': '20140622',
  33. 'uploader_id': 'Sulivana7x',
  34. 'thumbnail': 'http://thumbs.motherlessmedia.com/thumbs/532291B.jpg',
  35. 'age_limit': 18,
  36. }
  37. }
  38. ]
  39. def _real_extract(self,url):
  40. mobj = re.match(self._VALID_URL, url)
  41. video_id = mobj.group('id')
  42. webpage = self._download_webpage(url, video_id)
  43. title = self._html_search_regex(r'<title>(?P<title>.+?) - MOTHERLESS.COM</title>', webpage, 'title')
  44. video_url = self._search_regex(r"__fileurl = '(?P<video_url>[^']+)'", webpage, 'video_url')
  45. thumbnail = self._og_search_thumbnail(webpage)
  46. age_limit = self._rta_search(webpage) # Hint: it's 18 ;)
  47. view_count = str_to_int(self._html_search_regex(r'<strong>Views</strong>(.+?)</h2>', webpage,
  48. 'view_count', flags=re.DOTALL))
  49. like_count = str_to_int(self._html_search_regex(r'<strong>Favorited</strong>(.+?)</h2>', webpage,
  50. 'like_count', flags=re.DOTALL))
  51. comment_count = webpage.count('class="media-comment-contents"')
  52. uploader_id = self._html_search_regex(r'<div class="thumb-member-username">.*?<a [^>]*>(.+?)</a>',
  53. webpage, 'uploader_id', flags=re.DOTALL)
  54. categories = self._html_search_meta('keywords', webpage)
  55. if categories is not None:
  56. categories = [cat.strip() for cat in categories.split(',')]
  57. upload_date = self._html_search_regex(r'<strong>Uploaded</strong>(.+?)</h2>', webpage,
  58. 'upload_date', flags=re.DOTALL)
  59. mobj = re.search(r'(\d+) days? ago', upload_date, re.I)
  60. if mobj is not None:
  61. upload_date = datetime.datetime.now() - datetime.timedelta(days=int(mobj.group(1)))
  62. else:
  63. mobj = re.search(r'(\w+) (\d+)\w* (\d+)', upload_date, re.I)
  64. if mobj is not None:
  65. upload_date = datetime.datetime.strptime('%s %s %s' % mobj.groups(), '%b %d %Y').date()
  66. else:
  67. upload_date = None
  68. if upload_date is not None:
  69. upload_date = upload_date.strftime('%Y%m%d')
  70. return {
  71. 'id': video_id,
  72. 'title': title,
  73. 'upload_date': upload_date,
  74. 'uploader_id': uploader_id,
  75. 'thumbnail': thumbnail,
  76. 'categories': categories,
  77. 'view_count': view_count,
  78. 'like_count': like_count,
  79. 'comment_count': comment_count,
  80. 'age_limit': age_limit,
  81. 'url': video_url,
  82. }