logo

youtube-dl

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

mofosex.py (2758B)


  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. str_to_int,
  7. unified_strdate,
  8. )
  9. from .keezmovies import KeezMoviesIE
  10. class MofosexIE(KeezMoviesIE):
  11. _VALID_URL = r'https?://(?:www\.)?mofosex\.com/videos/(?P<id>\d+)/(?P<display_id>[^/?#&.]+)\.html'
  12. _TESTS = [{
  13. 'url': 'http://www.mofosex.com/videos/318131/amateur-teen-playing-and-masturbating-318131.html',
  14. 'md5': '558fcdafbb63a87c019218d6e49daf8a',
  15. 'info_dict': {
  16. 'id': '318131',
  17. 'display_id': 'amateur-teen-playing-and-masturbating-318131',
  18. 'ext': 'mp4',
  19. 'title': 'amateur teen playing and masturbating',
  20. 'thumbnail': r're:^https?://.*\.jpg$',
  21. 'upload_date': '20121114',
  22. 'view_count': int,
  23. 'like_count': int,
  24. 'dislike_count': int,
  25. 'age_limit': 18,
  26. }
  27. }, {
  28. # This video is no longer available
  29. 'url': 'http://www.mofosex.com/videos/5018/japanese-teen-music-video.html',
  30. 'only_matching': True,
  31. }]
  32. def _real_extract(self, url):
  33. webpage, info = self._extract_info(url)
  34. view_count = str_to_int(self._search_regex(
  35. r'VIEWS:</span>\s*([\d,.]+)', webpage, 'view count', fatal=False))
  36. like_count = int_or_none(self._search_regex(
  37. r'id=["\']amountLikes["\'][^>]*>(\d+)', webpage,
  38. 'like count', fatal=False))
  39. dislike_count = int_or_none(self._search_regex(
  40. r'id=["\']amountDislikes["\'][^>]*>(\d+)', webpage,
  41. 'like count', fatal=False))
  42. upload_date = unified_strdate(self._html_search_regex(
  43. r'Added:</span>([^<]+)', webpage, 'upload date', fatal=False))
  44. info.update({
  45. 'view_count': view_count,
  46. 'like_count': like_count,
  47. 'dislike_count': dislike_count,
  48. 'upload_date': upload_date,
  49. 'thumbnail': self._og_search_thumbnail(webpage),
  50. })
  51. return info
  52. class MofosexEmbedIE(InfoExtractor):
  53. _VALID_URL = r'https?://(?:www\.)?mofosex\.com/embed/?\?.*?\bvideoid=(?P<id>\d+)'
  54. _TESTS = [{
  55. 'url': 'https://www.mofosex.com/embed/?videoid=318131&referrer=KM',
  56. 'only_matching': True,
  57. }]
  58. @staticmethod
  59. def _extract_urls(webpage):
  60. return re.findall(
  61. r'<iframe[^>]+\bsrc=["\']((?:https?:)?//(?:www\.)?mofosex\.com/embed/?\?.*?\bvideoid=\d+)',
  62. webpage)
  63. def _real_extract(self, url):
  64. video_id = self._match_id(url)
  65. return self.url_result(
  66. 'http://www.mofosex.com/videos/{0}/{0}.html'.format(video_id),
  67. ie=MofosexIE.ie_key(), video_id=video_id)