*add links *fix infiniteBufferingForShoutcastBug by checkHttpOrHttps

This commit is contained in:
antonl05 2022-06-05 20:35:37 +05:30
parent c1a6e02cc2
commit dea2204d10
3 changed files with 30 additions and 14 deletions

View File

@ -4,11 +4,14 @@
"mp3channels.webradio.antenne.de:80/top-40",
"Yes! 91.2",
"46.4.65.194:8039",
"http://5.9.17.142:8024/;7stream.nsv",
"ChartHits FM",
"95.141.24.3:80",
"Al Arabiya 99 - العربية",
"stream.radiojar.com/s1mygd1frxquv",
"Dublins KISS",
"uk4.internet-radio.com:15476",
@ -18,10 +21,10 @@
"Megahit Radio",
"87.118.122.45:30710",
"Raute Music",
"193.34.51.67:80",
"Raute Musik",
"rautemusik-de-hz-fal-stream12.radiohost.de/charthits",
"Venus FM",
"s3.onweb.gr:8808"
"s3.onweb.gr:8808/;stream"
]
}

View File

@ -30,6 +30,9 @@
"WKSU News",
"66.225.205.8:8020",
"ΣΚΑΪ",
"https://skai.live24.gr/skai1003",
"detour TALK",
"arizona.thedetour.us:8000/;",

View File

@ -192,29 +192,39 @@ proc init(parm:string,ctx: ptr Handle) =
cE initialize ctx
cE ctx.cmd file
proc cleanLink(linke: string): string =
var link = linke
link.removePrefix "http://"
link.removePrefix "https://"
var findSlash = link.find "/"
if findSlash != -1:
link.delete(findSlash .. link.high)
else: discard
return link
proc httpOrHttps(https: bool): string =
if https: "https://" else: "http://"
proc checkHttpsOnly(link: var string): bool =
try:
var client = newHttpClient()
discard client.getContent(link & "/random")
link = cleanLink link
link = "http://" & link
discard client.getContent(link & "/currentsong")
except ProtocolError:
link.removePrefix "http://"
link = "https://" & link
return true
except: return false
return false
proc getCurrentSong(linke: string; https = false): string =
var
client = newHttpClient()
link = linke
httpOrHttps =
if not https:
"http://"
else:
"https://"
link.removePrefix httpOrHttps
var findSlash = link.find "/"
if findSlash != -1:
link.delete(findSlash .. link.high)
httpOrHttps = httpOrHttps https
link = cleanLink link
try: #shoutcast
link = httpOrHttps & link
return client.getContent(link & "/currentsong")