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

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


Check-in [a906512c8d]

Overview
Comment:Update Dirble comments.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a906512c8daf340106127d9acd86e5b6e104c1e3
User & Date: mario on 2015-05-15 22:48:47
Other Links: manifest | tags
Context
2015-05-16
01:47
Use shorter domain names for homepage favicons again. check-in: 9931f4e0e5 user: mario tags: trunk
2015-05-15
22:48
Update Dirble comments. check-in: a906512c8d user: mario tags: trunk
21:52
Weighted selection of available stream urls from Dirble API. check-in: fe19fd3202 user: mario tags: trunk
Changes

Modified channels/dirble.py from [55aaf2e944] to [3714c6faa5].

21
22
23
24
25
26
27









28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
#    udJajRVDAI30TUQilG1qPry3I/Y9BThubmigb+R4x8L0m1fz5Ti3h0QE0ClcQCA+dflCz0VD
#    RKwUE5mgOvtu8u7z9wsVsyPPrBxfayqMjVtrMrmmI4f27swqkVS+GGMqy39nvy+W1uGxKL+h
#    u+uAt1KkwvVxAGJsEEWxEWzGm4iV8l1HM9K0BmEkrP8BlhoAUfmOxecAAAAASUVORK5CYII=
# priority: optional
# documentation: http://dirble.com/developer/api
#
#









# Server responses take a few seconds, and JSON
# decoding is surprisingly slow.


import json
from config import *
from channels import *
import ahttp


# Dirble
#
# Hmm ok, the new v2 API isn't so bad after all.
# It actually contains streaming urls, and even
# station homepages now.
#
#  ยท No idea what status: or timedout: mean,
#    just mapped to `deleted` and `status`
#  ยท Stream alternatives aren't yet sorted.

#  ยท Leave favicons to regular behaviour,
#    station banners are not accessible per CDN.
#
class dirble (ChannelPlugin):

    # control flags
    has_search = False







>
>
>
>
>
>
>
>
>
|
|
















|
>







21
22
23
24
25
26
27
28
29
30
31
32
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
#    udJajRVDAI30TUQilG1qPry3I/Y9BThubmigb+R4x8L0m1fz5Ti3h0QE0ClcQCA+dflCz0VD
#    RKwUE5mgOvtu8u7z9wsVsyPPrBxfayqMjVtrMrmmI4f27swqkVS+GGMqy39nvy+W1uGxKL+h
#    u+uAt1KkwvVxAGJsEEWxEWzGm4iV8l1HM9K0BmEkrP8BlhoAUfmOxecAAAAASUVORK5CYII=
# priority: optional
# documentation: http://dirble.com/developer/api
#
#
# Dirble is a user-contributed list of radio stations,
# auot-updating song titles and station information.
# Homepages are there now, and thus favicons readily
# available. Extra station banners aren't fetched.
#
# It provides a JSON API. Which in this newer version
# is actually speedier, as it doesn't strictly impose
# pagination roundtrips anymore.
#
# Response times are fixed now by overriding the HTTP
# encoding. (A python-requests issue mostly).


import json
from config import *
from channels import *
import ahttp


# Dirble
#
# Hmm ok, the new v2 API isn't so bad after all.
# It actually contains streaming urls, and even
# station homepages now.
#
#  ยท No idea what status: or timedout: mean,
#    just mapped to `deleted` and `status`
#  ยท Stream alternatives are meanwhile scanned
#    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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

125
126

127
128
129
130
131
132
133
        else:
            return {}

        # rename fields
        return dict(
            genre = " ".join(c["slug"] for c in r["categories"]),
            title = r["name"],
            playing = "{} {}".format(r.get("country"), r.get("description")),
            homepage = ahttp.fix_url(r["website"]),
            url = s["stream"],
            format = s["content_type"].strip(),
            bitrate = s["bitrate"],
           # img = r["image"]["image"]["thumb"]["url"], # CDN HTTPS trip up requests.get
            state = self.state_map[int(s["status"])] if s["status"] in [0,1,2] else "",
            deleted = s.get("timedout", False),
        )
        

    state_map = ["gtk-media-pause", "gtk-media-next", "gtk-media-rewind"]


    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, **params):
        params["token"] = conf.dirble_api_key or self.key
        try:







|


|


|


|
>
|

>







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
        else:
            return {}

        # rename fields
        return dict(
            genre = " ".join(c["slug"] for c in r["categories"]),
            title = r["name"],
            playing = "{} {}".format(r.get("country"), r.get("description", "")),
            homepage = ahttp.fix_url(r["website"]),
            url = s["stream"],
            format = s["content_type"].strip(),  # There's a "\r\n" in nearly every entry :?
            bitrate = s["bitrate"],
           # img = r["image"]["image"]["thumb"]["url"], # CDN HTTPS trip up requests.get
            state = self.state_map.get(int(s["status"]), ""),
            deleted = s.get("timedout", False),
        )

    # Streams contain a `status`, here mapped onto arbitrary Gtk icons        
    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, **params):
        params["token"] = conf.dirble_api_key or self.key
        try:

Modified help/channel_dirble.page from [a2c2f64962] to [2cc65a8e71].

16
17
18
19
20
21
22
23
24

	<p>It provides a JSON API, which as of v2 has a lot of unneeded meta
	information and internal ids. But it's actually nicer to scan, and
	contains even station homepages now.</p>

        <note><p>The config option for a custom API key is perhaps
        redundant. Should streamtuner2 -D however reveal an error, you
        can configure your own account there.</p></note>
</page>







|

16
17
18
19
20
21
22
23
24

	<p>It provides a JSON API, which as of v2 has a lot of unneeded meta
	information and internal ids. But it's actually nicer to scan, and
	contains even station homepages now.</p>

        <note><p>The config option for a custom API key is perhaps
        redundant. Should streamtuner2 -D however reveal an error, you
        can however configure your own account there.</p></note>
</page>