Index: channels/shoutcast.py ================================================================== --- channels/shoutcast.py +++ channels/shoutcast.py @@ -3,14 +3,14 @@ # description: Primary list of shoutcast servers (now managed by radionomy). # type: channel # category: radio # author: Mario # original: Jean-Yves Lefort -# version: 1.6 +# version: 1.7 # url: http://directory.shoutcast.com/ # config: -# { name: shoutcast_format, type: select, select: pls|m3u|xspf, value: pls, description: "Shoutcast playlist format to retrieve" } +# { name: shoutcast_format, type: select, select: pls|m3u|xspf|json, value: pls, description: "Shoutcast playlist format to retrieve" } # priority: default # png: # iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAelJREFUOI2NU0toE2EYnM12t2wLkhSXSIgEJMHFQ2naQ+kpoPYQoaXH3gRFsegloUhRQTyU2oOgggQUzzlEQomIBzU+EHooBIol0cOGLqFFFiJ5SB5skvFU6ebRduA7/DAz # /PM9BJLoh3Q6zVQqBZfLhXq9jlAohHA4LHTzhvqJ2+02c7kcgsEgfD4fRFFEPp+HZVmUJEk41kAURcHv99Pj8cAwDGiaBkVR0C0GAJDsW7VajYVCgYlEguVymZZlsVKpcG1tlYd5fX8AAIqiCF6vF6VSibIsI5lMYvvDE1xymwDu/ec5BhkcIJPJIHJzFqf372P1cgMf # f46cLIKu61yJXufr5VO0voyzEZ/k8sI4s9ns0RFarRZjL56inIshekWGenYS6IzhR9PCntRBIBCw8XsiFItFNLMxPJgfwVjDi4Y8g2b9DILaMKZGd2Ca5tEGiqJg2xjF200H6J+AvKtjeG8T3998xW5nAk6n08bviSBJEqhewLlpN4bMHfwxfuH5J8J98SGerS/B4XDY @@ -131,21 +131,34 @@ Name:"AOLMRadio" StreamUrl:null """ entries = [] for e in json: + if self.listformat == "json": + url = "urn:shoutcast:" + str(e["ID"]) + else: + url = "http://yp.shoutcast.com/sbin/tunein-station.%s?id=%s" % (self.listformat, e.get("ID", "0")) entries.append({ "id": int(e.get("ID", 0)), "genre": str(e.get("Genre", "")), "title": str(e.get("Name", "")), "playing": str(e.get("CurrentTrack", "")), "bitrate": int(e.get("Bitrate", 0)), "listeners": int(e.get("Listeners", 0)), - "url": "http://yp.shoutcast.com/sbin/tunein-station.%s?id=%s" % (self.listformat, e.get("ID", "0")), + "url": url, "listformat": self.listformat, "homepage": "", "format": str(e.get("Format", "")) }) #log.DATA(entries) return entries + + # in case we're using AJAX lookups over tunein-station.pls + def resolve_urn(self, row): + if not row.get("id") or not row.get("url", "").startswith("urn:shoutcast:"): + return + url = ahttp.get("https://directory.shoutcast.com/Player/GetStreamUrl", {"station":row["id"]}, post=1) + row["url"] = url.strip('"') + return row["url"] +