logo

youtube-dl

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

pornovoisines.py (4003B)


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