Internet radio browser GUI for music/video streams from various directory services.

โŒˆโŒ‹ โŽ‡ branch:  streamtuner2


Diff

Differences From Artifact [8ed175109e]:

To Artifact [5db6fb7163]:


1
2
3
4
5
6
7
8
9
10
11
12
13
# encoding: UTF-8
# api: streamtuner2
# title: Dirble
# description: Song history tracker for Internet radio stations.
# url: http://dirble.com/
# version: 2.3
# type: channel
# category: radio
# config:
#    { name: dirble_api_key,  value: "",  type: text,  description: Alternative API access key., hidden: 1 }
# png:
#    iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAA3NCSVQICAjb4U/gAAACP0lE
#    QVQokVVSO0+UURA9M/d+jyWbBVcQFSQhPqJSYBRFA5pVoFGURApjYYWtvYUNP8FKOwsttDFq





|







1
2
3
4
5
6
7
8
9
10
11
12
13
# encoding: UTF-8
# api: streamtuner2
# title: Dirble
# description: Song history tracker for Internet radio stations.
# url: http://dirble.com/
# version: 2.4
# type: channel
# category: radio
# config:
#    { name: dirble_api_key,  value: "",  type: text,  description: Alternative API access key., hidden: 1 }
# png:
#    iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAA3NCSVQICAjb4U/gAAACP0lE
#    QVQokVVSO0+UURA9M/d+jyWbBVcQFSQhPqJSYBRFA5pVoFGURApjYYWtvYUNP8FKOwsttDFq
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#    for "best" format+bitrate combinations.
#  ยท Leave favicons to regular behaviour,
#    station banners are not accessible per CDN.
#
class dirble (ChannelPlugin):

    # control flags
    has_search = False
    listformat = "srv"
    titles = dict(playing="Location")
    base = "http://api.dirble.com/v2/{}"
    key = "a0bdd7b8efc2f5d1ebdf1728b65a07ece4c73de5"


    # Retrieve cat list and map







|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#    for "best" format+bitrate combinations.
#  ยท Leave favicons to regular behaviour,
#    station banners are not accessible per CDN.
#
class dirble (ChannelPlugin):

    # control flags
    has_search = True
    listformat = "srv"
    titles = dict(playing="Location")
    base = "http://api.dirble.com/v2/{}"
    key = "a0bdd7b8efc2f5d1ebdf1728b65a07ece4c73de5"


    # Retrieve cat list and map
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
        self.categories = ["Popular", "Recent"] + cats


    # Fetch entries
    def update_streams(self, cat, search=None):
        self.progress(1)
        if search:
            r = self.api("search", query=search, page=0, pages=1)
        elif cat in ("Popular", "Recent"):
            r = self.api("stations/{}".format(cat.lower()), pages=15)
        else:
            r = self.api("category/{}/stations".format(self.catmap.get(cat, 0)), pages=10)
        return [self.unpack(row) for row in r]

    
    # Extract rows
    def unpack(self, r):
        listeners = 0








|

|

|







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
        self.categories = ["Popular", "Recent"] + cats


    # Fetch entries
    def update_streams(self, cat, search=None):
        self.progress(1)
        if search:
            r = self.api("search", query=search, page=0, pages=1, post=1)
        elif cat in ("Popular", "Recent"):
            r = self.api("stations/{}".format(cat.lower()), pages=5)
        else:
            r = self.api("category/{}/stations".format(self.catmap.get(cat, 0)), pages=5)
        return [self.unpack(row) for row in r]

    
    # Extract rows
    def unpack(self, r):
        listeners = 0

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172



173
174
175
176
177
178
179
180
    state_map = {0:"gtk-media-pause", 1:"gtk-media-next", 2:"gtk-media-rewind"}

    # Weighting bitrate and audio format for alternative stream URLs
    format_q = {"?":0.75, "audio/mpeg":1.0, "audio/aac":1.25, "audio/aacp":1.35, "audio/ogg":1.50}


    # Patch API url together, send request, decode JSON list
    def api(self, method, pages=1, **params):
        # pagination parameters
        if pages > 1:
            params["page"] = 0
            params["per_page"] = 30
            params["offset"] = 0
        params["token"] = conf.dirble_api_key or self.key
        try:
            r = []
            # paginate results
            for params["page"] in range(0, pages):
                self.progress(pages)
                # send HTTP request and extract JSON



                add = ahttp.get(self.base.format(method), params, encoding="utf-8")
                add = json.loads(add)
                # check for errors
                if isinstance(add, dict) and add.get("error"):
                    if r:
                        log.WARN(add["error"])
                        break
                    else:







|












>
>
>
|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
    state_map = {0:"gtk-media-pause", 1:"gtk-media-next", 2:"gtk-media-rewind"}

    # Weighting bitrate and audio format for alternative stream URLs
    format_q = {"?":0.75, "audio/mpeg":1.0, "audio/aac":1.25, "audio/aacp":1.35, "audio/ogg":1.50}


    # Patch API url together, send request, decode JSON list
    def api(self, method, pages=1, post=0, **params):
        # pagination parameters
        if pages > 1:
            params["page"] = 0
            params["per_page"] = 30
            params["offset"] = 0
        params["token"] = conf.dirble_api_key or self.key
        try:
            r = []
            # paginate results
            for params["page"] in range(0, pages):
                self.progress(pages)
                # send HTTP request and extract JSON
                if post:
                    method += "?token=" + params["token"]
                    del params["token"]
                add = ahttp.get(self.base.format(method), params, post=post, json=post, encoding="utf-8")
                add = json.loads(add)
                # check for errors
                if isinstance(add, dict) and add.get("error"):
                    if r:
                        log.WARN(add["error"])
                        break
                    else: