motherless.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. import datetime as dt
  2. import re
  3. import urllib.parse
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. OnDemandPagedList,
  8. remove_end,
  9. str_to_int,
  10. unified_strdate,
  11. )
  12. class MotherlessIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:www\.)?motherless\.com/(?:g/[a-z0-9_]+/|G[VIG]?[A-F0-9]+/)?(?P<id>[A-F0-9]+)'
  14. _TESTS = [{
  15. 'url': 'http://motherless.com/EE97006',
  16. 'md5': 'cb5e7438f7a3c4e886b7bccc1292a3bc',
  17. 'info_dict': {
  18. 'id': 'EE97006',
  19. 'ext': 'mp4',
  20. 'title': 'Dogging blond Brit getting glazed (comp)',
  21. 'categories': ['UK', 'slag', 'whore', 'dogging', 'cunt', 'cumhound', 'big tits', 'Pearl Necklace'],
  22. 'upload_date': '20230519',
  23. 'uploader_id': 'deathbird',
  24. 'thumbnail': r're:https?://.*\.jpg',
  25. 'age_limit': 18,
  26. 'comment_count': int,
  27. 'view_count': int,
  28. 'like_count': int,
  29. },
  30. 'params': {
  31. # Incomplete cert chains
  32. 'nocheckcertificate': True,
  33. },
  34. }, {
  35. 'url': 'http://motherless.com/532291B',
  36. 'md5': 'bc59a6b47d1f958e61fbd38a4d31b131',
  37. 'info_dict': {
  38. 'id': '532291B',
  39. 'ext': 'mp4',
  40. 'title': 'Amazing girl playing the omegle game, PERFECT!',
  41. 'categories': ['Amateur', 'webcam', 'omegle', 'pink', 'young', 'masturbate', 'teen',
  42. 'game', 'hairy'],
  43. 'upload_date': '20140622',
  44. 'uploader_id': 'Sulivana7x',
  45. 'thumbnail': r're:https?://.*\.jpg',
  46. 'age_limit': 18,
  47. },
  48. 'skip': '404',
  49. }, {
  50. 'url': 'http://motherless.com/g/cosplay/633979F',
  51. 'md5': '0b2a43f447a49c3e649c93ad1fafa4a0',
  52. 'info_dict': {
  53. 'id': '633979F',
  54. 'ext': 'mp4',
  55. 'title': 'Turtlette',
  56. 'categories': ['superheroine heroine superher'],
  57. 'upload_date': '20140827',
  58. 'uploader_id': 'shade0230',
  59. 'thumbnail': r're:https?://.*\.jpg',
  60. 'age_limit': 18,
  61. 'like_count': int,
  62. 'comment_count': int,
  63. 'view_count': int,
  64. },
  65. 'params': {
  66. 'nocheckcertificate': True,
  67. },
  68. }, {
  69. 'url': 'http://motherless.com/8B4BBC1',
  70. 'info_dict': {
  71. 'id': '8B4BBC1',
  72. 'ext': 'mp4',
  73. 'title': 'VIDEO00441.mp4',
  74. 'categories': [],
  75. 'upload_date': '20160214',
  76. 'uploader_id': 'NMWildGirl',
  77. 'thumbnail': r're:https?://.*\.jpg',
  78. 'age_limit': 18,
  79. 'like_count': int,
  80. 'comment_count': int,
  81. 'view_count': int,
  82. },
  83. 'params': {
  84. 'nocheckcertificate': True,
  85. },
  86. }, {
  87. # see https://motherless.com/videos/recent for recent videos with
  88. # uploaded date in "ago" format
  89. 'url': 'https://motherless.com/3C3E2CF',
  90. 'info_dict': {
  91. 'id': '3C3E2CF',
  92. 'ext': 'mp4',
  93. 'title': 'a/ Hot Teens',
  94. 'categories': list,
  95. 'upload_date': '20210104',
  96. 'uploader_id': 'anonymous',
  97. 'thumbnail': r're:https?://.*\.jpg',
  98. 'age_limit': 18,
  99. 'like_count': int,
  100. 'comment_count': int,
  101. 'view_count': int,
  102. },
  103. 'params': {
  104. 'nocheckcertificate': True,
  105. },
  106. }]
  107. def _real_extract(self, url):
  108. video_id = self._match_id(url)
  109. webpage = self._download_webpage(url, video_id)
  110. if any(p in webpage for p in (
  111. '<title>404 - MOTHERLESS.COM<',
  112. ">The page you're looking for cannot be found.<")):
  113. raise ExtractorError(f'Video {video_id} does not exist', expected=True)
  114. if '>The content you are trying to view is for friends only.' in webpage:
  115. raise ExtractorError(f'Video {video_id} is for friends only', expected=True)
  116. title = self._html_search_regex(
  117. (r'(?s)<div[^>]+\bclass=["\']media-meta-title[^>]+>(.+?)</div>',
  118. r'id="view-upload-title">\s+([^<]+)<'), webpage, 'title')
  119. video_url = (self._html_search_regex(
  120. (r'setup\(\{\s*["\']file["\']\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1',
  121. r'fileurl\s*=\s*(["\'])(?P<url>(?:(?!\1).)+)\1'),
  122. webpage, 'video URL', default=None, group='url')
  123. or f'http://cdn4.videos.motherlessmedia.com/videos/{video_id}.mp4?fs=opencloud')
  124. age_limit = self._rta_search(webpage)
  125. view_count = str_to_int(self._html_search_regex(
  126. (r'>([\d,.]+)\s+Views<', r'<strong>Views</strong>\s+([^<]+)<'),
  127. webpage, 'view count', fatal=False))
  128. like_count = str_to_int(self._html_search_regex(
  129. (r'>([\d,.]+)\s+Favorites<',
  130. r'<strong>Favorited</strong>\s+([^<]+)<'),
  131. webpage, 'like count', fatal=False))
  132. upload_date = unified_strdate(self._search_regex(
  133. r'class=["\']count[^>]+>(\d+\s+[a-zA-Z]{3}\s+\d{4})<', webpage,
  134. 'upload date', default=None))
  135. if not upload_date:
  136. uploaded_ago = self._search_regex(
  137. r'>\s*(\d+[hd])\s+[aA]go\b', webpage, 'uploaded ago',
  138. default=None)
  139. if uploaded_ago:
  140. delta = int(uploaded_ago[:-1])
  141. _AGO_UNITS = {
  142. 'h': 'hours',
  143. 'd': 'days',
  144. }
  145. kwargs = {_AGO_UNITS.get(uploaded_ago[-1]): delta}
  146. upload_date = (dt.datetime.now(dt.timezone.utc) - dt.timedelta(**kwargs)).strftime('%Y%m%d')
  147. comment_count = len(re.findall(r'''class\s*=\s*['"]media-comment-contents\b''', webpage))
  148. uploader_id = self._html_search_regex(
  149. (r'''<span\b[^>]+\bclass\s*=\s*["']username\b[^>]*>([^<]+)</span>''',
  150. r'''(?s)['"](?:media-meta-member|thumb-member-username)\b[^>]+>\s*<a\b[^>]+\bhref\s*=\s*['"]/m/([^"']+)'''),
  151. webpage, 'uploader_id', fatal=False)
  152. categories = self._html_search_meta('keywords', webpage, default='')
  153. categories = [cat.strip() for cat in categories.split(',') if cat.strip()]
  154. return {
  155. 'id': video_id,
  156. 'title': title,
  157. 'upload_date': upload_date,
  158. 'uploader_id': uploader_id,
  159. 'thumbnail': self._og_search_thumbnail(webpage),
  160. 'categories': categories,
  161. 'view_count': view_count,
  162. 'like_count': like_count,
  163. 'comment_count': comment_count,
  164. 'age_limit': age_limit,
  165. 'url': video_url,
  166. }
  167. class MotherlessPaginatedIE(InfoExtractor):
  168. _EXTRA_QUERY = {}
  169. _PAGE_SIZE = 60
  170. def _correct_path(self, url, item_id):
  171. raise NotImplementedError('This method must be implemented by subclasses')
  172. def _extract_entries(self, webpage, base):
  173. for mobj in re.finditer(r'href="[^"]*(?P<href>/[A-F0-9]+)"\s+title="(?P<title>[^"]+)',
  174. webpage):
  175. video_url = urllib.parse.urljoin(base, mobj.group('href'))
  176. video_id = MotherlessIE.get_temp_id(video_url)
  177. if video_id:
  178. yield self.url_result(video_url, MotherlessIE, video_id, mobj.group('title'))
  179. def _real_extract(self, url):
  180. item_id = self._match_id(url)
  181. real_url = self._correct_path(url, item_id)
  182. webpage = self._download_webpage(real_url, item_id, 'Downloading page 1')
  183. def get_page(idx):
  184. page = idx + 1
  185. current_page = webpage if not idx else self._download_webpage(
  186. real_url, item_id, note=f'Downloading page {page}', query={'page': page, **self._EXTRA_QUERY})
  187. yield from self._extract_entries(current_page, real_url)
  188. return self.playlist_result(
  189. OnDemandPagedList(get_page, self._PAGE_SIZE), item_id,
  190. remove_end(self._html_extract_title(webpage), ' | MOTHERLESS.COM ™'))
  191. class MotherlessGroupIE(MotherlessPaginatedIE):
  192. _VALID_URL = r'https?://(?:www\.)?motherless\.com/g[vifm]?/(?P<id>[a-z0-9_]+)/?(?:$|[#?])'
  193. _TESTS = [{
  194. 'url': 'http://motherless.com/gv/movie_scenes',
  195. 'info_dict': {
  196. 'id': 'movie_scenes',
  197. 'title': 'Movie Scenes - Videos - Hot and sexy scenes from "regular" movies... Beautiful actresses fully',
  198. },
  199. 'playlist_mincount': 540,
  200. }, {
  201. 'url': 'http://motherless.com/g/sex_must_be_funny',
  202. 'info_dict': {
  203. 'id': 'sex_must_be_funny',
  204. 'title': 'Sex must be funny',
  205. },
  206. 'playlist_count': 0,
  207. }, {
  208. 'url': 'https://motherless.com/gv/beautiful_cock',
  209. 'info_dict': {
  210. 'id': 'beautiful_cock',
  211. 'title': 'Beautiful Cock',
  212. },
  213. 'playlist_mincount': 2040,
  214. }]
  215. def _correct_path(self, url, item_id):
  216. return urllib.parse.urljoin(url, f'/gv/{item_id}')
  217. class MotherlessGalleryIE(MotherlessPaginatedIE):
  218. _VALID_URL = r'https?://(?:www\.)?motherless\.com/G[VIG]?(?P<id>[A-F0-9]+)/?(?:$|[#?])'
  219. _TESTS = [{
  220. 'url': 'https://motherless.com/GV338999F',
  221. 'info_dict': {
  222. 'id': '338999F',
  223. 'title': 'Random',
  224. },
  225. 'playlist_mincount': 171,
  226. }, {
  227. 'url': 'https://motherless.com/GVABD6213',
  228. 'info_dict': {
  229. 'id': 'ABD6213',
  230. 'title': 'Cuties',
  231. },
  232. 'playlist_mincount': 2,
  233. }, {
  234. 'url': 'https://motherless.com/GVBCF7622',
  235. 'info_dict': {
  236. 'id': 'BCF7622',
  237. 'title': 'Vintage',
  238. },
  239. 'playlist_count': 0,
  240. }, {
  241. 'url': 'https://motherless.com/G035DE2F',
  242. 'info_dict': {
  243. 'id': '035DE2F',
  244. 'title': 'General',
  245. },
  246. 'playlist_mincount': 420,
  247. }]
  248. def _correct_path(self, url, item_id):
  249. return urllib.parse.urljoin(url, f'/GV{item_id}')
  250. class MotherlessUploaderIE(MotherlessPaginatedIE):
  251. _VALID_URL = r'https?://(?:www\.)?motherless\.com/u/(?P<id>\w+)/?(?:$|[?#])'
  252. _TESTS = [{
  253. 'url': 'https://motherless.com/u/Mrgo4hrs2023',
  254. 'info_dict': {
  255. 'id': 'Mrgo4hrs2023',
  256. 'title': "Mrgo4hrs2023's Uploads - Videos",
  257. },
  258. 'playlist_mincount': 32,
  259. }, {
  260. 'url': 'https://motherless.com/u/Happy_couple?t=v',
  261. 'info_dict': {
  262. 'id': 'Happy_couple',
  263. 'title': "Happy_couple's Uploads - Videos",
  264. },
  265. 'playlist_mincount': 8,
  266. }]
  267. _EXTRA_QUERY = {'t': 'v'}
  268. def _correct_path(self, url, item_id):
  269. return urllib.parse.urljoin(url, f'/u/{item_id}?t=v')