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.

87 lines
3.3 KiB

  1. from __future__ import unicode_literals
  2. import datetime
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. unified_strdate,
  8. )
  9. class MotherlessIE(InfoExtractor):
  10. _VALID_URL = r'http://(?:www\.)?motherless\.com/(?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. def _real_extract(self,url):
  42. mobj = re.match(self._VALID_URL, url)
  43. video_id = mobj.group('id')
  44. webpage = self._download_webpage(url, video_id)
  45. title = self._html_search_regex(r'id="view-upload-title">\s+([^<]+)<', webpage, 'title')
  46. video_url = self._html_search_regex(r'setup\(\{\s+"file".+: "([^"]+)",', webpage, 'video_url')
  47. age_limit = self._rta_search(webpage)
  48. view_count = self._html_search_regex(r'<strong>Views</strong>\s+([^<]+)<', webpage, 'view_count')
  49. upload_date = self._html_search_regex(r'<strong>Uploaded</strong>\s+([^<]+)<', webpage, 'upload_date')
  50. if 'Ago' in upload_date:
  51. days = int(re.search(r'([0-9]+)', upload_date).group(1))
  52. upload_date = (datetime.datetime.now() - datetime.timedelta(days=days)).strftime('%Y%m%d')
  53. else:
  54. upload_date = unified_strdate(upload_date)
  55. like_count = self._html_search_regex(r'<strong>Favorited</strong>\s+([^<]+)<', webpage, 'like_count')
  56. comment_count = webpage.count('class="media-comment-contents"')
  57. uploader_id = self._html_search_regex(r'"thumb-member-username">\s+<a href="/m/([^"]+)"', webpage, 'uploader_id')
  58. categories = self._html_search_meta('keywords', webpage)
  59. if categories:
  60. categories = [cat.strip() for cat in categories.split(',')]
  61. return {
  62. 'id': video_id,
  63. 'title': title,
  64. 'upload_date': upload_date,
  65. 'uploader_id': uploader_id,
  66. 'thumbnail': self._og_search_thumbnail(webpage),
  67. 'categories': categories,
  68. 'view_count': int_or_none(view_count.replace(',', '')),
  69. 'like_count': int_or_none(like_count.replace(',', '')),
  70. 'comment_count': comment_count,
  71. 'age_limit': age_limit,
  72. 'url': video_url,
  73. }