logo

youtube-dl

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

gedidigital.py (7100B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. determine_ext,
  7. int_or_none,
  8. )
  9. class GediDigitalIE(InfoExtractor):
  10. _VALID_URL = r'''(?x)https?://video\.
  11. (?:
  12. (?:
  13. (?:espresso\.)?repubblica
  14. |lastampa
  15. |ilsecoloxix
  16. )|
  17. (?:
  18. iltirreno
  19. |messaggeroveneto
  20. |ilpiccolo
  21. |gazzettadimantova
  22. |mattinopadova
  23. |laprovinciapavese
  24. |tribunatreviso
  25. |nuovavenezia
  26. |gazzettadimodena
  27. |lanuovaferrara
  28. |corrierealpi
  29. |lasentinella
  30. )\.gelocal
  31. )\.it(?:/[^/]+){2,3}?/(?P<id>\d+)(?:[/?&#]|$)'''
  32. _TESTS = [{
  33. 'url': 'https://video.lastampa.it/politica/il-paradosso-delle-regionali-la-lega-vince-ma-sembra-aver-perso/121559/121683',
  34. 'md5': '84658d7fb9e55a6e57ecc77b73137494',
  35. 'info_dict': {
  36. 'id': '121559',
  37. 'ext': 'mp4',
  38. 'title': 'Il paradosso delle Regionali: ecco perché la Lega vince ma sembra aver perso',
  39. 'description': 'md5:de7f4d6eaaaf36c153b599b10f8ce7ca',
  40. 'thumbnail': r're:^https://www\.repstatic\.it/video/photo/.+?-thumb-full-.+?\.jpg$',
  41. 'duration': 125,
  42. },
  43. }, {
  44. 'url': 'https://video.espresso.repubblica.it/embed/tutti-i-video/01-ted-villa/14772/14870&width=640&height=360',
  45. 'only_matching': True,
  46. }, {
  47. 'url': 'https://video.repubblica.it/motori/record-della-pista-a-spa-francorchamps-la-pagani-huayra-roadster-bc-stupisce/367415/367963',
  48. 'only_matching': True,
  49. }, {
  50. 'url': 'https://video.ilsecoloxix.it/sport/cassani-e-i-brividi-azzurri-ai-mondiali-di-imola-qui-mi-sono-innamorato-del-ciclismo-da-ragazzino-incredibile-tornarci-da-ct/66184/66267',
  51. 'only_matching': True,
  52. }, {
  53. 'url': 'https://video.iltirreno.gelocal.it/sport/dentro-la-notizia-ferrari-cosa-succede-a-maranello/141059/142723',
  54. 'only_matching': True,
  55. }, {
  56. 'url': 'https://video.messaggeroveneto.gelocal.it/locale/maria-giovanna-elmi-covid-vaccino/138155/139268',
  57. 'only_matching': True,
  58. }, {
  59. 'url': 'https://video.ilpiccolo.gelocal.it/dossier/big-john/dinosauro-big-john-al-via-le-visite-guidate-a-trieste/135226/135751',
  60. 'only_matching': True,
  61. }, {
  62. 'url': 'https://video.gazzettadimantova.gelocal.it/locale/dal-ponte-visconteo-di-valeggio-l-and-8217sos-dei-ristoratori-aprire-anche-a-cena/137310/137818',
  63. 'only_matching': True,
  64. }, {
  65. 'url': 'https://video.mattinopadova.gelocal.it/dossier/coronavirus-in-veneto/covid-a-vo-un-anno-dopo-un-cuore-tricolore-per-non-dimenticare/138402/138964',
  66. 'only_matching': True,
  67. }, {
  68. 'url': 'https://video.laprovinciapavese.gelocal.it/locale/mede-zona-rossa-via-alle-vaccinazioni-per-gli-over-80/137545/138120',
  69. 'only_matching': True,
  70. }, {
  71. 'url': 'https://video.tribunatreviso.gelocal.it/dossier/coronavirus-in-veneto/ecco-le-prima-vaccinazioni-di-massa-nella-marca/134485/135024',
  72. 'only_matching': True,
  73. }, {
  74. 'url': 'https://video.nuovavenezia.gelocal.it/locale/camion-troppo-alto-per-il-ponte-ferroviario-perde-il-carico/135734/136266',
  75. 'only_matching': True,
  76. }, {
  77. 'url': 'https://video.gazzettadimodena.gelocal.it/locale/modena-scoperta-la-proteina-che-predice-il-livello-di-gravita-del-covid/139109/139796',
  78. 'only_matching': True,
  79. }, {
  80. 'url': 'https://video.lanuovaferrara.gelocal.it/locale/due-bombole-di-gpl-aperte-e-abbandonate-i-vigili-bruciano-il-gas/134391/134957',
  81. 'only_matching': True,
  82. }, {
  83. 'url': 'https://video.corrierealpi.gelocal.it/dossier/cortina-2021-i-mondiali-di-sci-alpino/mondiali-di-sci-il-timelapse-sulla-splendida-olympia/133760/134331',
  84. 'only_matching': True,
  85. }, {
  86. 'url': 'https://video.lasentinella.gelocal.it/locale/vestigne-centra-un-auto-e-si-ribalta/138931/139466',
  87. 'only_matching': True,
  88. }, {
  89. 'url': 'https://video.espresso.repubblica.it/tutti-i-video/01-ted-villa/14772',
  90. 'only_matching': True,
  91. }]
  92. def _real_extract(self, url):
  93. video_id = self._match_id(url)
  94. webpage = self._download_webpage(url, video_id)
  95. title = self._html_search_meta(
  96. ['twitter:title', 'og:title'], webpage, fatal=True)
  97. player_data = re.findall(
  98. r"PlayerFactory\.setParam\('(?P<type>format|param)',\s*'(?P<name>[^']+)',\s*'(?P<val>[^']+)'\);",
  99. webpage)
  100. formats = []
  101. duration = thumb = None
  102. for t, n, v in player_data:
  103. if t == 'format':
  104. if n in ('video-hds-vod-ec', 'video-hls-vod-ec', 'video-viralize', 'video-youtube-pfp'):
  105. continue
  106. elif n.endswith('-vod-ak'):
  107. formats.extend(self._extract_akamai_formats(
  108. v, video_id, {'http': 'media.gedidigital.it'}))
  109. else:
  110. ext = determine_ext(v)
  111. if ext == 'm3u8':
  112. formats.extend(self._extract_m3u8_formats(
  113. v, video_id, 'mp4', 'm3u8_native', m3u8_id=n, fatal=False))
  114. continue
  115. f = {
  116. 'format_id': n,
  117. 'url': v,
  118. }
  119. if ext == 'mp3':
  120. abr = int_or_none(self._search_regex(
  121. r'-mp3-audio-(\d+)', v, 'abr', default=None))
  122. f.update({
  123. 'abr': abr,
  124. 'tbr': abr,
  125. 'vcodec': 'none'
  126. })
  127. else:
  128. mobj = re.match(r'^video-rrtv-(\d+)(?:-(\d+))?$', n)
  129. if mobj:
  130. f.update({
  131. 'height': int(mobj.group(1)),
  132. 'vbr': int_or_none(mobj.group(2)),
  133. })
  134. if not f.get('vbr'):
  135. f['vbr'] = int_or_none(self._search_regex(
  136. r'-video-rrtv-(\d+)', v, 'abr', default=None))
  137. formats.append(f)
  138. elif t == 'param':
  139. if n in ['image_full', 'image']:
  140. thumb = v
  141. elif n == 'videoDuration':
  142. duration = int_or_none(v)
  143. self._sort_formats(formats)
  144. return {
  145. 'id': video_id,
  146. 'title': title,
  147. 'description': self._html_search_meta(
  148. ['twitter:description', 'og:description', 'description'], webpage),
  149. 'thumbnail': thumb or self._og_search_thumbnail(webpage),
  150. 'formats': formats,
  151. 'duration': duration,
  152. }