pornovoisines.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. float_or_none,
  4. int_or_none,
  5. unified_strdate,
  6. )
  7. class PornoVoisinesIE(InfoExtractor):
  8. _WORKING = False
  9. _VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/videos/show/(?P<id>\d+)/(?P<display_id>[^/.]+)'
  10. _TEST = {
  11. 'url': 'http://www.pornovoisines.com/videos/show/919/recherche-appartement.html',
  12. 'md5': '6f8aca6a058592ab49fe701c8ba8317b',
  13. 'info_dict': {
  14. 'id': '919',
  15. 'display_id': 'recherche-appartement',
  16. 'ext': 'mp4',
  17. 'title': 'Recherche appartement',
  18. 'description': 'md5:fe10cb92ae2dd3ed94bb4080d11ff493',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'upload_date': '20140925',
  21. 'duration': 120,
  22. 'view_count': int,
  23. 'average_rating': float,
  24. 'categories': ['Débutante', 'Débutantes', 'Scénario', 'Sodomie'],
  25. 'age_limit': 18,
  26. 'subtitles': {
  27. 'fr': [{
  28. 'ext': 'vtt',
  29. }],
  30. },
  31. },
  32. }
  33. def _real_extract(self, url):
  34. mobj = self._match_valid_url(url)
  35. video_id = mobj.group('id')
  36. display_id = mobj.group('display_id')
  37. settings_url = self._download_json(
  38. f'http://www.pornovoisines.com/api/video/{video_id}/getsettingsurl/',
  39. video_id, note='Getting settings URL')['video_settings_url']
  40. settings = self._download_json(settings_url, video_id)['data']
  41. formats = []
  42. for kind, data in settings['variants'].items():
  43. if kind == 'HLS':
  44. formats.extend(self._extract_m3u8_formats(
  45. data, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls'))
  46. elif kind == 'MP4':
  47. for item in data:
  48. formats.append({
  49. 'url': item['url'],
  50. 'height': item.get('height'),
  51. 'bitrate': item.get('bitrate'),
  52. })
  53. webpage = self._download_webpage(url, video_id)
  54. title = self._og_search_title(webpage)
  55. description = self._og_search_description(webpage)
  56. # The webpage has a bug - there's no space between "thumb" and src=
  57. thumbnail = self._html_search_regex(
  58. r'<img[^>]+class=([\'"])thumb\1[^>]*src=([\'"])(?P<url>[^"]+)\2',
  59. webpage, 'thumbnail', fatal=False, group='url')
  60. upload_date = unified_strdate(self._search_regex(
  61. r'Le\s*<b>([\d/]+)', webpage, 'upload date', fatal=False))
  62. duration = settings.get('main', {}).get('duration')
  63. view_count = int_or_none(self._search_regex(
  64. r'(\d+) vues', webpage, 'view count', fatal=False))
  65. average_rating = self._search_regex(
  66. r'Note\s*:\s*(\d+(?:,\d+)?)', webpage, 'average rating', fatal=False)
  67. if average_rating:
  68. average_rating = float_or_none(average_rating.replace(',', '.'))
  69. categories = self._html_search_regex(
  70. r'(?s)Catégories\s*:\s*<b>(.+?)</b>', webpage, 'categories', fatal=False)
  71. if categories:
  72. categories = [category.strip() for category in categories.split(',')]
  73. subtitles = {'fr': [{
  74. 'url': subtitle,
  75. } for subtitle in settings.get('main', {}).get('vtt_tracks', {}).values()]}
  76. return {
  77. 'id': video_id,
  78. 'display_id': display_id,
  79. 'formats': formats,
  80. 'title': title,
  81. 'description': description,
  82. 'thumbnail': thumbnail,
  83. 'upload_date': upload_date,
  84. 'duration': duration,
  85. 'view_count': view_count,
  86. 'average_rating': average_rating,
  87. 'categories': categories,
  88. 'age_limit': 18,
  89. 'subtitles': subtitles,
  90. }