33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# collect 200 station entries (see main options).
import re
import json
from config import *
from channels import *
import ahttp as http
# Surfmusik sharing site
class icast (ChannelPlugin):
# control attributes
has_search = True
listformat = "pls"
titles = dict(listeners=False, bitrate=False, playing=False)
categories = []
base = "http://api.icast.io/1/"
# Categories require little post-processing, just dict into list conversion
def update_categories(self):
self.categories = []
for genre,cats in json.loads(http.get(self.base + "genres"))["genres"].items():
self.categories.append(genre.title())
self.categories.append([c.title() for c in cats])
# Just copy over stream URLs and station titles
def update_streams(self, cat, search=None):
if cat:
|
|
|
|
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# collect 200 station entries (see main options).
import re
import json
from config import *
from channels import *
import ahttp
# iCast.io API
class icast (ChannelPlugin):
# control attributes
has_search = True
listformat = "pls"
titles = dict(listeners=False, bitrate=False, playing=False)
categories = []
base = "http://api.icast.io/1/"
# Categories require little post-processing, just dict into list conversion
def update_categories(self):
self.categories = []
for genre,cats in json.loads(ahttp.get(self.base + "genres"))["genres"].items():
self.categories.append(genre.title())
self.categories.append([c.title() for c in cats])
# Just copy over stream URLs and station titles
def update_streams(self, cat, search=None):
if cat:
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
return r
# fetch multiple pages
def api(self, method, path, params):
r = []
while len(r) < int(conf.max_streams):
data = json.loads(http.get( self.base + method + path, params))
r += data["stations"]
if len(r) >= data["meta"]["total_count"] or len(data["stations"]) < 10:
break
else:
params["page"] = int(data["meta"]["current_page"]) + 1
self.parent.status(params["page"] * 9.5 / float(conf.max_streams))
#log.DATA(data)
return r
|
|
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
return r
# fetch multiple pages
def api(self, method, path, params):
r = []
while len(r) < int(conf.max_streams):
data = json.loads(ahttp.get( self.base + method + path, params))
r += data["stations"]
if len(r) >= data["meta"]["total_count"] or len(data["stations"]) < 10:
break
else:
params["page"] = int(data["meta"]["current_page"]) + 1
self.parent.status(params["page"] * 9.5 / float(conf.max_streams))
#log.DATA(data)
return r
|