Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #encoding=utf-8
  2. import requests
  3. import json
  4. import wget
  5. import os
  6. import time
  7.  
  8.  
  9. r = requests.get("https://api.radioparadise.com/api/get_block?bitrate=4&info=true&chan=1")
  10.  
  11.  
  12. #lee url
  13. data = json.loads(r.text)["url"]
  14.  
  15. #lee lenght
  16. time_t =json.loads(r.text)["length"]
  17. time_t_seg = int(float(time_t))
  18.  
  19.  
  20. print (" ")
  21. print ("*****RADIOPARADISE MELLOW FLAC*****")
  22. print (" ")
  23. print (">Descargando block flac...")
  24.  
  25. #borra block anterior flac
  26. dir = "/home/volumio/flac_in/"
  27. lista_ficheros = os.listdir(dir)
  28. for fichero in lista_ficheros:
  29. if fichero.endswith(".flac"):
  30. #print fichero
  31. #print lista_ficheros
  32. os.remove(dir + fichero)
  33.  
  34. out_dir = "/home/volumio/flac_in/"
  35.  
  36. block = wget.download(data, out=out_dir)
  37.  
  38.  
  39. #reproduce
  40. os.system ("mpc clear")
  41. os.system ("mpc add /home/volumio/flac_in/*.flac")
  42. os.system ("mpc play")
  43. #file = open("/home/volumio/RPBlock.txt","w")
  44. #file.write(data)m
  45.  
  46. time.sleep(time_t_seg)
  47.  
  48. print ">Reproduciendo block ", fichero, "Duración ", time_t_seg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement