URL: https://linuxfr.org/forums/astucesdivers/posts/telecharger-arte-hd Title: Télécharger Arte HD Authors: VoixOff Date: 2013年09月28日T15:20:49+02:00 License: CC By-SA Tags: arte, python, rtmpdump et replay Score: 9 Salut tout le monde Je viens partager mon _grabber_ perso. Ajouter en ligne de commande les liens de [Arte+7](http://www.arte.tv/guide/fr/plus7), et hop ! Les émissions régulières (listées dans _show_names_) sont horodatées. (Nécessite BeautifulSoup 4 et rtmpdump, et il y a certainement à redire sur la qualité du code :) ```python #!/usr/bin/python3 # # Téléchargeur pour Arte # import sys import json import urllib.request import subprocess from bs4 import BeautifulSoup def call_rtmpdump(rtmpdump_opts): ''' Paramètres obtenus grâce à rtmpsuck : flashVer: LNX 11,2,202,297 swfUrl: http://www.arte.tv/player/v2//jwplayer6/mediaplayer.6.3.3242.swf pageUrl: http://www.arte.tv ''' opt_f = ['-f', 'LNX 11,2,202,297'] opt_W = ['-W', 'http://www.arte.tv/player/v2//jwplayer6/mediaplayer.6.3.3242.swf'] opt_p = ['-p', 'http://www.arte.tv'] cmd = ['/usr/bin/rtmpdump'] + opt_f + opt_W + opt_p + rtmpdump_opts try: subprocess.check_call(cmd) except subprocess.CalledProcessError: print("Téléchargement incomplet :(") return def find_video(plus7_url): video_name, video_excerpt, video_url = None, None, None tr_map = ''.maketrans('/', 'x', '"') show_names = ["360° - Géo","360° - GÉO", "Architectures", "Mystères d'archives", "Personne ne bouge !", "Tracks"] soup = BeautifulSoup(urllib.request.urlopen(plus7_url).read().decode()) divs = soup.findAll('div', {'class':'video-container'}) for a in divs: if 'arte_vp_url' in a.attrs: json_url = a.attrs['arte_vp_url'] if 'PLUS7' in json_url: break else: print("\nAucune vidéo trouvée dans {}".format(plus7_url)) return None jdic1 = json.loads(urllib.request.urlopen(json_url).read().decode()) vjp = jdic1['videoJsonPlayer'] vs5 = vjp['VST']['VS5'] video_date = '-'.join((vs5[4:], vs5[2:4], vs5[:2])) if 'V7T' in vjp: video_excerpt = vjp['V7T'] else: video_excerpt = "" vti = vjp['VTI'] title = vti.replace('"', '«', 1).replace('"', '»', 1) title = title.translate(tr_map).strip() if title in show_names: video_name = 'Arte - {} - {}.flv'.format(title, video_date) else: video_name = 'Arte - {}.flv'.format(title) print("\nVidéo trouvée : {}\n{}".format(video_name, video_excerpt)) sq1 = vjp['VSR']['RTMP_SQ_1'] opt_r = sq1['streamer'] split_result = urllib.parse.urlsplit(opt_r) opt_a = split_result.path.lstrip('/') opt_y = 'mp4:' + sq1['url'] rtmpdump_opts = ['-r', opt_r, '-a', opt_a, '-y', opt_y, '-o', video_name] return rtmpdump_opts for url in sys.argv[1:]: opts = find_video(url) if opts: call_rtmpdump(opts) ```

AltStyle によって変換されたページ (->オリジナル) /