internazionale.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from .common import InfoExtractor
  2. from ..utils import unified_timestamp
  3. class InternazionaleIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?internazionale\.it/video/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  5. _TESTS = [{
  6. 'url': 'https://www.internazionale.it/video/2015/02/19/richard-linklater-racconta-una-scena-di-boyhood',
  7. 'md5': '3e39d32b66882c1218e305acbf8348ca',
  8. 'info_dict': {
  9. 'id': '265968',
  10. 'display_id': 'richard-linklater-racconta-una-scena-di-boyhood',
  11. 'ext': 'mp4',
  12. 'title': 'Richard Linklater racconta una scena di Boyhood',
  13. 'description': 'md5:efb7e5bbfb1a54ae2ed5a4a015f0e665',
  14. 'timestamp': 1424354635,
  15. 'upload_date': '20150219',
  16. 'thumbnail': r're:^https?://.*\.jpg$',
  17. },
  18. }, {
  19. 'url': 'https://www.internazionale.it/video/2018/08/29/telefono-stare-con-noi-stessi',
  20. 'md5': '9db8663704cab73eb972d1cee0082c79',
  21. 'info_dict': {
  22. 'id': '761344',
  23. 'display_id': 'telefono-stare-con-noi-stessi',
  24. 'ext': 'mp4',
  25. 'title': 'Usiamo il telefono per evitare di stare con noi stessi',
  26. 'description': 'md5:75ccfb0d6bcefc6e7428c68b4aa1fe44',
  27. 'timestamp': 1535528954,
  28. 'upload_date': '20180829',
  29. 'thumbnail': r're:^https?://.*\.jpg$',
  30. },
  31. }]
  32. def _real_extract(self, url):
  33. display_id = self._match_id(url)
  34. webpage = self._download_webpage(url, display_id)
  35. DATA_RE = r'data-%s=(["\'])(?P<value>(?:(?!\1).)+)\1'
  36. title = self._search_regex(
  37. DATA_RE % 'video-title', webpage, 'title', default=None,
  38. group='value') or self._og_search_title(webpage)
  39. video_id = self._search_regex(
  40. DATA_RE % 'job-id', webpage, 'video id', group='value')
  41. video_path = self._search_regex(
  42. DATA_RE % 'video-path', webpage, 'video path', group='value')
  43. video_available_abroad = self._search_regex(
  44. DATA_RE % 'video-available_abroad', webpage,
  45. 'video available aboard', default='1', group='value')
  46. video_available_abroad = video_available_abroad == '1'
  47. video_base = 'https://video{}.internazionale.it/{}/{}.'.format(
  48. '' if video_available_abroad else '-ita', video_path, video_id)
  49. formats = self._extract_m3u8_formats(
  50. video_base + 'm3u8', display_id, 'mp4',
  51. entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
  52. formats.extend(self._extract_mpd_formats(
  53. video_base + 'mpd', display_id, mpd_id='dash', fatal=False))
  54. timestamp = unified_timestamp(self._html_search_meta(
  55. 'article:published_time', webpage, 'timestamp'))
  56. return {
  57. 'id': video_id,
  58. 'display_id': display_id,
  59. 'title': title,
  60. 'thumbnail': self._og_search_thumbnail(webpage),
  61. 'description': self._og_search_description(webpage),
  62. 'timestamp': timestamp,
  63. 'formats': formats,
  64. }