I have written this script just “for fun”. The main prerequesite is to install the command-line program : youtube-dl. To do this, simply this the following command :
pip install youtube-dl
Youtube-dl is used to download the videos. My script just offers a command-line menu to browse the available videos in the pluzz tv service.
Preview :
# python jsonpluzz.py ------------------------------ SELECTION ------------------------------ 0. france2 1. france3 2. france4 3. france5 4. franceo 5. la_1ere ------------------------------ Enter your choice [0-5] : 0 ------------------------------ SELECTION ------------------------------ 0. 2015-01-05 1. 2015-01-11 2. 2015-01-20 3. 2015-01-21 4. 2015-01-22 5. 2015-01-23 6. 2015-01-24 7. 2015-01-25 8. 2015-01-26 9. 2015-01-27 ------------------------------ Enter your choice [0-9] : 6 ------------------------------ SELECTION ------------------------------ 0. 13h15, le samedi... 1. Faites entrer l'accusé 2. Journal 3. Le plus grand cabaret du monde 4. Les Z'amours 5. Mon Envoyé spécial 6. Mot de passe 7. Motus 8. Météo 2 9. Météo des neiges 10. On n'est pas couché 11. Point route 12. Pyramide 13. Thé ou café 14. Tout le monde veut prendre sa place 15. Télématin 16. Un jour, un destin ------------------------------ Enter your choice [0-16] : 10 http://pluzz.francetv.fr/videos/on_nest_pas_couche_,116605696.html [pluzz.francetv.fr] on_nest_pas_couche_,116605696: Downloading webpage [pluzz.francetv.fr] 116605696: Downloading video JSON [pluzz.francetv.fr] 116605696: Downloading geo restriction info [pluzz.francetv.fr] 116605696: Downloading m3u8 information [download] Destination: On n'est pas couché-116605696.mp4 Input #0, hls,applehttp, from 'http://ftvodhdsecz-f.akamaihd.net/i/streaming-adaptatif_france-dom-tom/2015/S04/J6/116605696-20150124-,398k,632k,934k,.mp4.csmil/index_2_av.m3u8?null=': Duration: 03:29:20.00, start: 0.100667, bitrate: N/A Stream #0.0: Video: h264 (Main), yuv420p, 704x396 [PAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0.1: Audio: aac, 48000 Hz, stereo, fltp Output #0, mp4, to 'On n'est pas couché-116605696.mp4.part': Metadata: encoder : Lavf54.20.4 Stream #0.0: Video: libx264, yuv420p, 704x396 [PAR 1:1 DAR 16:9], q=2-31, 90k tbn, 90k tbc Stream #0.1: Audio: aac, 48000 Hz, stereo Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press ctrl-c to stop encoding Non-monotonous DTS in output stream 0:1; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file. frame=309500 fps=1414 q=-1.0 size= 1261792kB time=12379.96 bitrate= 834.9kbits/s video:1188347kB audio:102155kB global headers:0kB muxing overhead 0.423275% [avconv] 1327067607 bytes
The source :
#!/usr/bin/env python # -*- coding: utf8 -*- import urllib2 import json from subprocess import call response = urllib2.urlopen('http://pluzz.webservices.francetelevisions.fr/pluzz/liste/type/replay/nb/9999/debut/0') data = json.load(response) def get_channel_name(jsondata): return sorted(list(set([channel_name['chaine_id'] for channel_name in jsondata]))) def get_avail_date(channel, jsondata): return sorted(list(set([date["date_diffusion"].split('T')[0] for date in jsondata if date['chaine_id'] == channel]))) def get_tvshow(date, channel, jsondata): return sorted(list(set([tvshow["titre"] for tvshow in jsondata if tvshow['chaine_id'] == channel and tvshow["date_diffusion"].split('T')[0] == date]))) def dl_video(title, date, channel, jsondata): return [dl_link["url"] for dl_link in jsondata if dl_link["titre"] == title and dl_link['chaine_id'] == channel and dl_link["date_diffusion"].split('T')[0] == date] def print_menu(result): print (30 * '-') print ("SELECTION") print (30 * '-') for entry in result: print str(result.index(entry)) + ". " + entry print (30 * '-') choice = raw_input('Enter your choice [0-'+str(len(result)-1)+'] : ') choice = int(choice) return choice result = get_channel_name(data["reponse"]["emissions"]); choice_channel = print_menu(result) #for texte in data["reponse"]["emissions"]: # print texte['chaine_id']+' - '+texte["date_diffusion"]+' : \t'+texte["titre"]+" ("+texte['url']+")" dateresult = get_avail_date(result[choice_channel], data["reponse"]["emissions"]); choice_date = print_menu(dateresult) tvshowresult = get_tvshow(dateresult[choice_date], result[choice_channel], data["reponse"]["emissions"]); choice_tvshow = print_menu(tvshowresult) urldl = dl_video(tvshowresult[choice_tvshow], dateresult[choice_date], result[choice_channel], data["reponse"]["emissions"]); for entry in urldl: print ("http://pluzz.francetv.fr"+str(entry)) call(["youtube-dl", "http://pluzz.francetv.fr"+str(entry)])
This script can be easily updated with your favorite tv on-demand service if you know the url to get the json data.
My Powershell script categories
- Active Directory
- Cluster
- Database
- Exchange
- Files and folders
- Hardware
- Network
- Operating System
- PKI
- SCCM
- Service and process
- Tips
- VMWare
References
Download Pluzz videos with Python