prettify, fix red playing issue, remove curl
This commit is contained in:
parent
e447c6e34f
commit
1b574eeeaa
9 changed files with 76 additions and 93 deletions
|
@ -1,32 +1,32 @@
|
|||
{
|
||||
"Name01": "bollywood radio & beyond",
|
||||
//"Name01": "bollywood radio & beyond",
|
||||
"Name02": "Bombay Beats India Radio",
|
||||
"Name03": "Desi Music Mix",
|
||||
"Name04": "Hungama-Bollywood-Hits",
|
||||
"Name05": "Hungama-Bollywood-Retro",
|
||||
"Name06": "Indo-Caribbean Radio",
|
||||
"Name07": "Radio Afsana",
|
||||
"Name08": "Radio DJ-Gaurav",
|
||||
"Name09": "Hindi Desi Bollywood",
|
||||
"Name10": "Mast Radio",
|
||||
"Name11": "Radio Gabbar",
|
||||
"Name12": "Radio HSL",
|
||||
"Name13": "Radio Teen Taal",
|
||||
"Name14": "The Voice Asia",
|
||||
//"Name04": "Hungama-Bollywood-Hits",
|
||||
//"Name05": "Hungama-Bollywood-Retro",
|
||||
//"Name06": "Indo-Caribbean Radio",
|
||||
//"Name07": "Radio Afsana",
|
||||
//"Name08": "Radio DJ-Gaurav",
|
||||
//"Name09": "Hindi Desi Bollywood",
|
||||
//"Name10": "Mast Radio",
|
||||
//"Name11": "Radio Gabbar",
|
||||
//"Name12": "Radio HSL",
|
||||
//"Name13": "Radio Teen Taal",
|
||||
//"Name14": "The Voice Asia",
|
||||
"Name15": "",
|
||||
"link01": "http://96.31.83.86:8084",
|
||||
//"link01": "http://96.31.83.86:8084",
|
||||
"link02": "http://205.164.62.15:8017",
|
||||
"link03": "http://desimusicmix.com:8000/HQ",
|
||||
"link04": "http://123.176.41.8:8056",
|
||||
"link05": "http://123.176.41.8:8132",
|
||||
"link06": "http://208.43.9.96:8652",
|
||||
"link07": "http://174.36.206.197:8198",
|
||||
"link08": "http://radio.dj-gaurav.com:8035",
|
||||
"link09": "http://50.7.77.114:8296",
|
||||
"link10": "http://stream.mastradio.net:8000",
|
||||
"link11": "http://viadj.viastreaming.net:7090",
|
||||
"link12": "http://50.7.70.66:8485",
|
||||
"link13": "http://195.154.176.33:8000",
|
||||
"link14": "http://uk2.internet-radio.com:8043/live",
|
||||
//"link04": "http://123.176.41.8:8056",
|
||||
//"link05": "http://123.176.41.8:8132",
|
||||
//"link06": "http://208.43.9.96:8652",
|
||||
//"link07": "http://174.36.206.197:8198",
|
||||
//"link08": "http://radio.dj-gaurav.com:8035",
|
||||
//"link09": "http://50.7.77.114:8296",
|
||||
//"link10": "http://stream.mastradio.net:8000",
|
||||
//"link11": "http://viadj.viastreaming.net:7090",
|
||||
//"link12": "http://50.7.70.66:8485",
|
||||
//"link13": "http://195.154.176.33:8000",
|
||||
//"link14": "http://uk2.internet-radio.com:8043/live",
|
||||
"link15": ""
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
"link03": "http://64.95.243.43:8002",
|
||||
"link04": "http://www.bigblueswing.com:8002",
|
||||
"link05": "http://relay.publicdomainradio.org:80/classical.mp3",
|
||||
"link06": "https://smoothjazz.cdnstream1.com/2585_128.mp3"
|
||||
"link06": "https://smoothjazz.cdnstream1.com/2585_128.mp3",
|
||||
"link07": "",
|
||||
"lino08": "",
|
||||
"link09": "",
|
||||
"link10": "",
|
||||
"link10": ""
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ from terminal import showCursor,hideCursor
|
|||
proc checkFileIter*(x:seq[string]):bool =
|
||||
var i:uint8 = 0
|
||||
for f in x:
|
||||
if fileExists(fmt"pnimrp.d/{x[i]}.json"): inc i
|
||||
if fileExists fmt"pnimrp.d/{x[i]}.json": inc i
|
||||
else: return false
|
||||
return true
|
||||
|
||||
|
@ -17,7 +17,4 @@ proc init* =
|
|||
echo "data and config files dont exist"
|
||||
quit QuitFailure
|
||||
|
||||
if findExe("curl") == "":
|
||||
echo "please get curl installed"
|
||||
quit QuitFailure
|
||||
hideCursor()
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
from osproc import startProcess,waitForExit,poUsePath,poParentStreams,kill,suspend,resume
|
||||
from strutils import contains,repeat,splitLines
|
||||
from os import findExe,sleep,getCurrentDir,removeFile
|
||||
from termbase import warn,say,sayPos,inv,clear,exitEcho,drawMenuSect
|
||||
from terminal import terminalWidth,setCursorXPos,setCursorPos,getch,cursorUp,eraseLine
|
||||
from strutils import contains,repeat
|
||||
from os import findExe,sleep,getCurrentDir
|
||||
from termbase import warn,say,sayPos,inv,clear,exitEcho
|
||||
from terminal import terminalWidth,setCursorXPos,getch,cursorUp,eraseLine
|
||||
from strformat import fmt
|
||||
|
||||
proc exec*(x:string,args:openArray[string],strm:uint8) =
|
||||
if strm == 1: discard waitForExit(startProcess(x,args=args,options={poUsePath,poParentStreams}))
|
||||
if strm == 0: discard waitForExit(startProcess(x,args=args,options={poUsePath}))
|
||||
proc exec*(x:string,args:openArray[string]; stream = false) =
|
||||
if stream: discard waitForExit(startProcess(x,args=args,options={poUsePath,poParentStreams}))
|
||||
elif stream == false: discard waitForExit(startProcess(x,args=args,options={poUsePath}))
|
||||
|
||||
proc execPolled(q,x:string,args:openArray[string]):bool =
|
||||
var curl = startProcess(q,args=["-s",args[0],"-o","temp"])
|
||||
var app = startProcess(x ,args=args)
|
||||
proc execPolled(args:string):bool =
|
||||
var PLAYER = getCurrentDir() & "/player"
|
||||
var app = startProcess(PLAYER,args=[args])
|
||||
sayPos 4,"Playing.."
|
||||
var j = false
|
||||
while true:
|
||||
sleep 50
|
||||
case getch():
|
||||
of '/':
|
||||
when not defined macos:
|
||||
when defined linux: exec "amixer",["--quiet","set","PCM","7%+"],0
|
||||
when defined windows: exec "nircmd",["changesysvolume","5000"],0
|
||||
when defined linux: exec "amixer",["--quiet","set","PCM","7%+"]
|
||||
when defined windows: exec "nircmd",["changesysvolume","5000"]
|
||||
warn "Volume+"
|
||||
sleep 500
|
||||
cursorUp()
|
||||
eraseLine()
|
||||
else: discard
|
||||
|
||||
of 'P','p':
|
||||
cursorUp()
|
||||
setCursorXPos 4
|
||||
warn "Paused.."
|
||||
warn "Paused..."
|
||||
suspend app
|
||||
while true:
|
||||
sleep 300
|
||||
|
@ -37,31 +37,21 @@ proc execPolled(q,x:string,args:openArray[string]):bool =
|
|||
of 'P','p':
|
||||
resume app
|
||||
cursorUp()
|
||||
setCursorXPos 4
|
||||
warn "Playing.."
|
||||
sleep 400
|
||||
sayPos 4,"Playing.."
|
||||
sleep 200
|
||||
break
|
||||
of 'R','r': kill app; discard waitForExit app; kill curl; discard waitForExit curl; removeFile "temp"; break
|
||||
of 'Q','q': kill app; discard waitForExit app; kill curl; discard waitForExit curl; removeFile "temp"; exitEcho()
|
||||
of 'R','r': kill app; discard waitForExit app; j = true; break
|
||||
of 'Q','q': kill app; discard waitForExit app; exitEcho()
|
||||
else: inv()
|
||||
of 'Q','q': kill app; discard waitForExit app; kill curl; discard waitForExit curl; removeFile "temp"; exitEcho()
|
||||
of 'R','r':
|
||||
kill app
|
||||
discard waitForExit app
|
||||
kill curl
|
||||
discard waitForExit curl
|
||||
removeFile "temp"
|
||||
break
|
||||
of 'R','r': kill app; discard waitForExit app; break
|
||||
of 'Q','q': kill app; discard waitForExit app; exitEcho()
|
||||
else: inv()
|
||||
if j: break
|
||||
|
||||
proc call*(sub,sect,stat,link:string) =
|
||||
if link == "" or link.contains " ":
|
||||
warn "link dont exist or is invalid"
|
||||
sleep 750
|
||||
if link == "" or link.contains " ": warn "link dont exist or is invalid"; sleep 750
|
||||
else:
|
||||
clear()
|
||||
say fmt"PNimRP > {sub} > {sect} > {stat}"
|
||||
sayPos 0,'-'.repeat((terminalWidth()/8).int) & '>'.repeat(int(terminalWidth()/12))
|
||||
var curl = findExe "curl"
|
||||
var PLAYER = getCurrentDir() & "/player"
|
||||
discard execPolled(curl,PLAYER,[link])
|
||||
sayPos 0,'-'.repeat(int terminalWidth() / 8) & '>'.repeat int terminalWidth() / 12
|
||||
discard execPolled link
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from strformat import fmt
|
||||
import terminal
|
||||
from os import sleep
|
||||
from strutils import contains,repeat,splitLines
|
||||
from strutils import repeat,splitLines
|
||||
|
||||
proc clear* =
|
||||
eraseScreen()
|
||||
|
|
|
@ -10,7 +10,7 @@ proc notes* =
|
|||
const sub = "Notes"
|
||||
clear()
|
||||
say fmt"PNimRP > {sub}"
|
||||
sayPos 0,'-'.repeat((terminalWidth()/8).int) & '>'.repeat(int(terminalWidth()/12))
|
||||
sayPos 0, ('-'.repeat int terminalWidth() / 8) & ('>'.repeat int terminalWidth() / 12)
|
||||
sayIter """PNimRP Copyright (C) 2021 antonl05
|
||||
This program comes with ABSOLUTELY NO WARRANTY
|
||||
This is free software, and you are welcome to redistribute
|
||||
|
@ -27,8 +27,8 @@ under certain conditions. press `t` for details"""
|
|||
say "Please wait..."
|
||||
sleep 750
|
||||
showCursor()
|
||||
when not defined android: exec "vi",["TERMS"],1
|
||||
else: exec "editor",["TERMS"],1
|
||||
when not defined android: exec "vi",["TERMS"], stream = true
|
||||
else: exec "editor",["TERMS"], stream = true
|
||||
hideCursor()
|
||||
break
|
||||
else: showCursor(); echo "please open TERMS file"; quit QuitSuccess
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
when defined posix: {.push dynlib: "libmpv.so".}
|
||||
when defined windows: {.push dynlib: "mpv-1.dll".}
|
||||
|
||||
template MPV_MAKE_VERSION*(major, minor: untyped): untyped = (((major) shl 16) or (minor) or 0'u32)
|
||||
template MPV_MAKE_VERSION*(major, minor: untyped): untyped = major shl 16 or minor or 0'u32
|
||||
|
||||
const MPV_CLIENT_API_VERSION* = MPV_MAKE_VERSION(1, 107)
|
||||
|
||||
|
@ -13,8 +13,7 @@ type
|
|||
|
||||
INNER_C_UNION_client_1* {.bycopy, union.} = object
|
||||
string*: cstring
|
||||
flag*: cint
|
||||
int64*: cint
|
||||
flag*, int64*: cint
|
||||
double*: cdouble
|
||||
list*: ptr mpv_node_list
|
||||
ba*: ptr mpv_byte_array
|
||||
|
@ -118,14 +117,11 @@ type
|
|||
MPV_LOG_LEVEL_TRACE = 70
|
||||
|
||||
mpv_event_log_message* {.bycopy.} = object
|
||||
prefix*: cstring
|
||||
level*: cstring
|
||||
text*: cstring
|
||||
prefix*, level*, text*: cstring
|
||||
log_level*: mpv_log_level
|
||||
|
||||
mpv_event_end_file* {.bycopy.} = object
|
||||
reason*: cint
|
||||
error*: cint
|
||||
reason*, error*: cint
|
||||
|
||||
mpv_event_client_message* {.bycopy.} = object
|
||||
num_args*: cint
|
||||
|
@ -140,8 +136,7 @@ type
|
|||
|
||||
mpv_event* {.bycopy.} = object
|
||||
event_id*: mpv_event_id
|
||||
error*: cint
|
||||
reply_userdata*: cint
|
||||
error*, reply_userdata*: cint
|
||||
data*: pointer
|
||||
|
||||
mpv_event_script_input_dispatch* {.bycopy.} = object
|
||||
|
@ -170,7 +165,7 @@ proc mpv_client_name*(ctx: ptr mpv_handle): cstring
|
|||
proc mpv_create*(): ptr mpv_handle
|
||||
{.importc: "mpv_create".}
|
||||
|
||||
proc mpv_initialize*(ctx: ptr mpv_handle): cint
|
||||
proc mpv_initialize*(ctx: ptr mpv_handle) #: cint
|
||||
{.importc: "mpv_initialize".}
|
||||
|
||||
proc mpv_destroy*(ctx: ptr mpv_handle)
|
||||
|
@ -194,13 +189,13 @@ proc mpv_get_time_us*(ctx: ptr mpv_handle): cint
|
|||
proc mpv_free_node_contents*(node: ptr mpv_node)
|
||||
{.importc: "mpv_free_node_contents".}
|
||||
|
||||
proc mpv_set_option*(ctx: ptr mpv_handle; name: cstring; format: mpv_format; data: pointer): cint
|
||||
proc mpv_set_option*(ctx: ptr mpv_handle; name: cstring; format: mpv_format; data: pointer) #: cint
|
||||
{.importc: "mpv_set_option".}
|
||||
|
||||
proc mpv_set_option_string*(ctx: ptr mpv_handle; name: cstring; data: cstring): cint
|
||||
{.importc: "mpv_set_option_string".}
|
||||
|
||||
proc mpv_command*(ctx: ptr mpv_handle; args: cstringArray): cint
|
||||
proc mpv_command*(ctx: ptr mpv_handle; args: cstringArray) #: cint
|
||||
{.importc: "mpv_command".}
|
||||
|
||||
proc mpv_command_node*(ctx: ptr mpv_handle; args: ptr mpv_node; result: ptr mpv_node): cint
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
from os import commandLineParams,sleep
|
||||
from os import commandLineParams
|
||||
import client
|
||||
|
||||
proc main() =
|
||||
let parm = commandLineParams()
|
||||
let ctx = mpv_create()
|
||||
var val: cint = 1
|
||||
discard mpv_set_option(ctx, "", MPV_FORMAT_FLAG, addr(val))
|
||||
discard mpv_initialize ctx
|
||||
let file = allocCStringArray ["loadfile", parm[0]]
|
||||
discard mpv_command(ctx, file)
|
||||
while true:
|
||||
discard mpv_wait_event(ctx, 1)
|
||||
let
|
||||
parm = commandLineParams()
|
||||
ctx = mpv_create()
|
||||
file = allocCStringArray ["loadfile", parm[0]] #couldbe file,link,playlistfile
|
||||
var val: cint = 1
|
||||
|
||||
main()
|
||||
mpv_set_option(ctx, "", MPV_FORMAT_FLAG, addr val)
|
||||
mpv_initialize ctx
|
||||
mpv_command(ctx, file)
|
||||
|
||||
while true:
|
||||
discard mpv_wait_event(ctx, 1000)
|
||||
|
|
|
@ -5,6 +5,7 @@ import base/[termbase,initbase,menu], notes, fm181, soma, listener
|
|||
|
||||
init()
|
||||
|
||||
#1,3,4,5,6,7
|
||||
while true:
|
||||
clear()
|
||||
say "Poor Mans Radio Player in Nim-lang " & '-'.repeat int terminalWidth() / 8
|
||||
|
|
Loading…
Reference in a new issue