[feat] add station select for chill-player
This commit is contained in:
parent
7918ef0b3a
commit
8c25e4163f
1 changed files with 19 additions and 5 deletions
|
@ -1,10 +1,24 @@
|
|||
#!/usr/bin/env hy
|
||||
|
||||
(import json)
|
||||
(import requests)
|
||||
(import subprocess)
|
||||
(import argparse)
|
||||
|
||||
(defn live-play [live-id]
|
||||
(while True
|
||||
(for [item (.json (requests.get "https://stream.chillhop.com/live/12355"))]
|
||||
(for [item (.json (requests.get f"https://stream.chillhop.com/live/{live-id}"))]
|
||||
(print f"Now playing: {(:title item)} - {(:artists item)} - {(:fileId item)}")
|
||||
(subprocess.run f"mpv --no-video https://stream.chillhop.com/mp3/{(:fileId item)}" :shell True :capture_output True)))
|
||||
(subprocess.run f"mpv --no-video https://stream.chillhop.com/mp3/{(:fileId item)}"
|
||||
:shell True
|
||||
:capture_output True))))
|
||||
|
||||
(setv parser (argparse.ArgumentParser))
|
||||
(parser.add_argument "-s" :action "store" :dest "station" :metavar "station" :required False)
|
||||
(setv args (parser.parse_args))
|
||||
(when args.station (live-play args.station))
|
||||
|
||||
(let [presets (:presets (.json (requests.get "https://stream.chillhop.com/presets")))]
|
||||
(print "Now streaming...")
|
||||
(for [item presets]
|
||||
(print f"Name: {(:name item)} station Id: {(:stationId item)}"))
|
||||
(live-play (input "Input station ID: ")))
|
||||
|
|
Loading…
Reference in a new issue