xanimu.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import int_or_none
  4. class XanimuIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?xanimu\.com/(?P<id>[^/]+)/?'
  6. _TESTS = [{
  7. 'url': 'https://xanimu.com/51944-the-princess-the-frog-hentai/',
  8. 'md5': '899b88091d753d92dad4cb63bbf357a7',
  9. 'info_dict': {
  10. 'id': '51944-the-princess-the-frog-hentai',
  11. 'ext': 'mp4',
  12. 'title': 'The Princess + The Frog Hentai',
  13. 'thumbnail': 'https://xanimu.com/storage/2020/09/the-princess-and-the-frog-hentai.jpg',
  14. 'description': r're:^Enjoy The Princess \+ The Frog Hentai',
  15. 'duration': 207.0,
  16. 'age_limit': 18,
  17. },
  18. }, {
  19. 'url': 'https://xanimu.com/huge-expansion/',
  20. 'only_matching': True,
  21. }]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. formats = []
  26. for format_id in ['videoHigh', 'videoLow']:
  27. format_url = self._search_json(
  28. rf'var\s+{re.escape(format_id)}\s*=', webpage, format_id,
  29. video_id, default=None, contains_pattern=r'[\'"]([^\'"]+)[\'"]')
  30. if format_url:
  31. formats.append({
  32. 'url': format_url,
  33. 'format_id': format_id,
  34. 'quality': -2 if format_id.endswith('Low') else None,
  35. })
  36. return {
  37. 'id': video_id,
  38. 'formats': formats,
  39. 'title': self._search_regex(r'[\'"]headline[\'"]:\s*[\'"]([^"]+)[\'"]', webpage,
  40. 'title', default=None) or self._html_extract_title(webpage),
  41. 'thumbnail': self._html_search_meta('thumbnailUrl', webpage, default=None),
  42. 'description': self._html_search_meta('description', webpage, default=None),
  43. 'duration': int_or_none(self._search_regex(r'duration:\s*[\'"]([^\'"]+?)[\'"]',
  44. webpage, 'duration', fatal=False)),
  45. 'age_limit': 18,
  46. }