Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #encoding=utf-8
- import requests
- import json
- import wget
- import os
- import time
- r = requests.get("https://api.radioparadise.com/api/get_block?bitrate=4&info=true&chan=1")
- #lee url
- data = json.loads(r.text)["url"]
- #lee lenght
- time_t =json.loads(r.text)["length"]
- time_t_seg = int(float(time_t))
- print (" ")
- print ("*****RADIOPARADISE MELLOW FLAC*****")
- print (" ")
- print (">Descargando block flac...")
- #borra block anterior flac
- dir = "/home/volumio/flac_in/"
- lista_ficheros = os.listdir(dir)
- for fichero in lista_ficheros:
- if fichero.endswith(".flac"):
- #print fichero
- #print lista_ficheros
- os.remove(dir + fichero)
- out_dir = "/home/volumio/flac_in/"
- block = wget.download(data, out=out_dir)
- #reproduce
- os.system ("mpc clear")
- os.system ("mpc add /home/volumio/flac_in/*.flac")
- os.system ("mpc play")
- #file = open("/home/volumio/RPBlock.txt","w")
- #file.write(data)m
- time.sleep(time_t_seg)
- print ">Reproduciendo block ", fichero, "Duración ", time_t_seg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement