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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [590edd0877]

Overview
Comment:Support /get2/ URLs for albums and playlists now. Genres are queried for /tracks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 590edd08776deec65882bc6f1e19e194d7105dc9
User & Date: mario on 2014-05-09 00:01:49
Other Links: manifest | tags
Context
2014-05-10
21:40
Skip new_streams with undefined title or url check-in: 3c94abea16 user: mario tags: trunk
2014-05-09
00:01
Support /get2/ URLs for albums and playlists now. Genres are queried for /tracks. check-in: 590edd0877 user: mario tags: trunk
2014-05-08
20:02
Introduce channel.has_search flag check-in: 08de3d2f45 user: mario tags: trunk
Changes

Modified channels/jamendo.py from [c6330abad1] to [4a00f6a5de].

1
2
3


4



5





6
7
8
9


10








11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

# api: streamtuner2
# title: jamendo browser


#



# For now this is really just a browser, doesn't utilizt the jamendo API yet.





# Requires more rework of streamtuner2 list display to show album covers.
#
# Recently required an API key as well. Thus probably will remain a stub.
#


#










import re
import ahttp as http
from config import conf, __print__, dbg
from channels import *
from xml.sax.saxutils import unescape
import json













# jamendo CC music sharing site



>
>

>
>
>
|
>
>
>
>
>
|

<

>
>

>
>
>
>
>
>
>
>






<

<
<
<
<
<
<
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

36







37
38
39
40
41
42
43

# api: streamtuner2
# title: jamendo browser
# description: Jamendo is a license-free music collection and artist hub
# depends: json
#
# Now utilizes the Jamendo /v3.0/ API.
#
# Radio station lists are fixed for now. Querying the API twice per station
# doesn't seem overly sensible.
#
# Albums and Playlists are limited to 200 entries. Adding a cursor is
# feasible however.
#
# Tracks are queried by genre, where currently there's just a small built-in
# tag list in ST2.
#

#
# The v3.0 streaming URLs don't seem to work. Therefore some /get2 URLs will
# be used.
#
#  [x]  http://api.jamendo.com/v3.0/playlists/file?client_id=&id=
#  [+]  http://storage-new.newjamendo.com/?trackid=792843&format=ogg2&u=0
#  [+]  http://api.jamendo.com/get2/stream/track/xspf/?playlist_id=171574&n=all&order=random
#  [+]  http://api.jamendo.com/get2/stream/track/xspf/?album_id=%s&streamencoding=ogg2&n=all
#
# Seem to resolve to OGG Vorbis each.
#



import re
import ahttp as http
from config import conf, __print__, dbg
from channels import *

import json













# jamendo CC music sharing site
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
65
66
67
68
69
70
71
72
73
74
75
76
77
    has_search = True

    base = "http://www.jamendo.com/en/"
    listformat = "url/http"
    api = "http://api.jamendo.com/v3.0/"
    cid = "49daa4f5"

    categories = ["radios"]






    titles = dict( title="Title", playing="Album/Artist/User", bitrate=False, listeners=False )
 
    config = [
        {"name":"jamendo_stream_format", "value":"ogg2", "type":"text", "description":"streaming format, 'ogg2' or 'mp31'"}
    ]    
    



    # refresh category list
    def update_categories(self):

        self.categories = [
           "radios",
           "playlists",
           "albums",
           "tracks",
             ["pop", "rock", "dance", "classical", "jazz", "instrumental"]
        ]
        


    # download links from dmoz listing
    def update_streams(self, cat, search="", force=0):

        entries = []
        
        # return a static list for now
        if cat == "radios":
        







|
>
>
>
>
>
>








<



<
|
<
<
<
<
<



|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75

76





77
78
79
80
81
82
83
84
85
86
87
    has_search = True

    base = "http://www.jamendo.com/en/"
    listformat = "url/http"
    api = "http://api.jamendo.com/v3.0/"
    cid = "49daa4f5"

    categories = [
        "radios",
        "playlists",
        "albums",
        "tracks",
            ["pop", "rock", "dance", "classical", "jazz", "instrumental"]
    ]
    titles = dict( title="Title", playing="Album/Artist/User", bitrate=False, listeners=False )
 
    config = [
        {"name":"jamendo_stream_format", "value":"ogg2", "type":"text", "description":"streaming format, 'ogg2' or 'mp31'"}
    ]    
    



    # refresh category list
    def update_categories(self):


        pass





        


    # retrieve category or search
    def update_streams(self, cat, search="", force=0):

        entries = []
        
        # return a static list for now
        if cat == "radios":
        
98
99
100
101
102
103
104
105


106
107
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
134

135
136
137



138
139
140
141
142


143
144
145
146
147
148
149
                "limit": "200"
            })
            for e in json.loads(data)["results"]:
                entries.append({
                    "title": e["name"],
                    "playing": e["user_name"],
                    "homepage": e["shareurl"],
                    "url": "http://api.jamendo.com/v3.0/playlists/file?client_id="+self.cid+"&id="+e["id"]


                })

        # albums
        if cat == "albums":
            data = http.get(self.api + cat, params = {
                "client_id": self.cid,
                "format": "json",
                "limit": "200",
                "imagesize": "50"
            })
            for e in json.loads(data)["results"]:
                entries.append({
                    "title": e["name"],
                    "playing": e["artist_name"],
                    "favicon": e["image"],
                    "homepage": e["shareurl"],
                    "url": "http://api.jamendo.com/v3.0/playlists/file?client_id="+self.cid+"&id="+e["id"]


                })
		
        # genre list            
        else:
            data = http.get(self.api + "tracks", params={
                "client_id": self.cid,
                ("fuzzytags" if cat else "search"): (search if search else cat),
                "format": "json",
                "audioformat":"mp31",
                "limit": "200",

                "imagesize": "50",
                "order": "popularity_week",

            })
            for e in json.loads(data)["results"]:
                entries.append({



                    "title": e["name"],
                    "playing": e["album_name"] + " / " + e["artist_name"],
                    "favicon": e["album_image"],
                    "homepage": e["shareurl"],
                    "url": e["audio"]


                })
 
        # done    
        return entries
        
        
    # smaller album link







|
>
>
















|
>
>


|





|

>


>



>
>
>




|
>
>







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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
                "limit": "200"
            })
            for e in json.loads(data)["results"]:
                entries.append({
                    "title": e["name"],
                    "playing": e["user_name"],
                    "homepage": e["shareurl"],
                    #"url": "http://api.jamendo.com/v3.0/playlists/file?client_id=%s&id=%s" % (self.cid, e["id"]),
                    "url": "http://api.jamendo.com/get2/stream/track/xspf/?playlist_id=%s&n=all&order=random&from=app-%s" % (e["id"], self.cid),
                    "format": "application/xspf+xml",
                })

        # albums
        if cat == "albums":
            data = http.get(self.api + cat, params = {
                "client_id": self.cid,
                "format": "json",
                "limit": "200",
                "imagesize": "50"
            })
            for e in json.loads(data)["results"]:
                entries.append({
                    "title": e["name"],
                    "playing": e["artist_name"],
                    "favicon": e["image"],
                    "homepage": e["shareurl"],
                    #"url": "http://api.jamendo.com/v3.0/playlists/file?client_id=%s&id=%s" % (self.cid, e["id"]),
                    "url": "http://api.jamendo.com/get2/stream/track/xspf/?album_id=%s&streamencoding=ogg2&n=all&from=app-%s" % (e["id"], self.cid),
                    "format": "application/xspf+xml",
                })
		
        # genre list
        else:
            data = http.get(self.api + "tracks", params={
                "client_id": self.cid,
                ("fuzzytags" if cat else "search"): (search if search else cat),
                "format": "json",
                "audioformat":"ogg",
                "limit": "200",
                "offset": 200,
                "imagesize": "50",
                "order": "popularity_week",
                "include": "musicinfo",
            })
            for e in json.loads(data)["results"]:
                entries.append({
                    "lang": e["musicinfo"]["lang"],
                    "genre": " ".join(e["musicinfo"]["tags"]["genres"]),
                    "description": ", ".join(e["musicinfo"]["tags"]["vartags"]),
                    "title": e["name"],
                    "playing": e["album_name"] + " / " + e["artist_name"],
                    "favicon": e["album_image"],
                    "homepage": e["shareurl"],
                    #"url": e["audio"],
                    "url": "http://storage-new.newjamendo.com/?trackid=%s&format=ogg2&u=0&from=app-%s" % (e["id"], self.cid),
                    "format": "audio/ogg",
                })
 
        # done    
        return entries
        
        
    # smaller album link