Skip to content

Commit 2212347

Browse files
author
David Norman
committed
Adding hyperlinks for most fields
search retains location in URL added track browser (non functional) adjusted the return value from the proxy to only have the result
1 parent c8c76c0 commit 2212347

14 files changed

+103
-67
lines changed

controller/deploy.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cp src/squeezed /usr/local/bin
2+
echo "Squeezebox server proxy installed"

controller/src/squeezed

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_ip_address():
1818

1919
def squeeze_request(params):
2020
js = {"id":1,"method":"slim.request","params":[squeeze_player,params]}
21-
return requests.post('http://192.168.0.101:9001/jsonrpc.js', data=json.dumps(js)).json()
21+
return requests.post('http://192.168.0.101:9001/jsonrpc.js', data=json.dumps(js)).json()['result']
2222

2323
class SqueezeServerService(object):
2424
exposed = True
@@ -47,12 +47,12 @@ if __name__ == '__main__':
4747

4848
# Establish our player id
4949
r = squeeze_request(["players"])
50-
player_count = r["result"]["count"]
50+
player_count = r["count"]
5151
if player_count == 0:
5252
sys.exit(0)
5353

5454
r = squeeze_request(["players",0,player_count])
55-
for p in r["result"]["players_loop"]:
55+
for p in r["players_loop"]:
5656
if p["ip"].startswith(ip):
5757
squeeze_player = p["playerid"]
5858

deploy.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#!/bin/bash
2+
13
# Web site
2-
pushd web
4+
pushd web >/dev/null
35
source ./deploy.sh
4-
popd
6+
popd >/dev/null
57

68
# Controller
7-
pushd ./controller
9+
pushd ./controller >/dev/null
810
source ./deploy.sh
9-
popd
11+
popd >/dev/null

web/src/html/browse_album.html

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
<div ng-init="init()" />
22

3-
<div>
4-
<form novalidate class="simple-form" ng-submit="submitSearch()">
5-
<input type="text" ng-model="searchText" placeholder="Search" />
6-
</form>
7-
</div>
8-
9-
<p>Album: {{album_title}}</p>
10-
<p>Artist: {{album_artist}}</p>
3+
<p>Album: {{album_info.album}}</p>
4+
<p>Artist: <a href="#/local/artist/{{album_info.artist_id}}">{{album_info.artist}}</a></p>
115

126
<table class="table table-striped">
137
<thead>
148
<tr>
159
<th class="col-xs-1"></th>
10+
<th class="col-xs-1">Number</th>
1611
<th class="col-xs-5">Track</th>
12+
<th class="col-xs-5">Artist</th>
1713
</tr>
1814
</thead>
1915
<tbody>
20-
<tr ng-repeat="r in tracks">
16+
<tr ng-repeat="t in tracks">
2117
<th><span class="glyphicon glyphicon-plus-sign" /></th>
22-
<td>{{r.title}}</td>
18+
<td>{{t.tracknum}}</td>
19+
<td><a href="#/local/track/{{t.id}}">{{t.title}}</a></td>
20+
<td><a href="#/local/artist/{{t.artist_id}}">{{t.artist}}</a></td>
2321
</tr>
2422
</tbody>
2523
</table>

web/src/html/browse_artist.html

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<div ng-init="init()" />
22

3-
<div>
4-
<form novalidate class="simple-form" ng-submit="submitSearch()">
5-
<input type="text" ng-model="searchText" placeholder="Search" />
6-
</form>
7-
</div>
8-
9-
<p>Artist: {{artist}}</p>
3+
<p>Artist: {{artist_info.artist}}</p>
104

115
<table class="table table-striped">
126
<thead>

web/src/html/browse_track.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div ng-init="init()" />
2+
3+
<p>Track: {{t.artist}}</p>
4+

web/src/html/search.html

+11-9
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,35 @@
1010
<thead>
1111
<tr>
1212
<th class="col-xs-1"></th>
13+
<th class="col-xs-1">Number</th>
1314
<th class="col-xs-5">Track</th>
1415
<th class="col-xs-3">Album</th>
15-
<th class="col-xs-3">Artist</th>
16+
<th class="col-xs-2">Artist</th>
1617
</tr>
1718
</thead>
1819
<tbody>
1920
<tr ng-repeat="r in tracks">
2021
<th><span class="glyphicon glyphicon-plus-sign" /></th>
21-
<td>{{r.track}}</td>
22-
<td>{{r.album}}</td>
23-
<td>{{r.artist}}</td>
22+
<td>{{r.tracknum}}</td>
23+
<td><a href="#/local/track/{{r.id}}">{{r.title}}</a></td>
24+
<td><a href="#/local/album/{{r.album_id}}">{{r.album}}</a></td>
25+
<td><a href="#/local/artist/{{r.artist_id}}">{{r.artist}}</a></td>
2426
</tr>
2527
</tbody>
2628
</table>
2729
<table class="table table-striped">
2830
<thead>
2931
<tr>
3032
<th class="col-xs-1"></th>
31-
<th class="col-xs-5">Album</th>
32-
<th class="col-xs-6">Artist</th>
33+
<th class="col-xs-6">Album</th>
34+
<th class="col-xs-5">Artist</th>
3335
</tr>
3436
</thead>
3537
<tbody>
3638
<tr ng-repeat="r in albums">
3739
<th><span class="glyphicon glyphicon-plus-sign" /></th>
38-
<td><a href="#/local/album/{{r.album_id}}">{{r.album}}</a></td>
39-
<td>{{r.artist}}</td>
40+
<td><a href="#/local/album/{{r.id}}">{{r.album}}</a></td>
41+
<td><a href="#/local/artist/{{r.artist_id}}">{{r.artist}}</a></td>
4042
</tr>
4143
</tbody>
4244
</table>
@@ -50,7 +52,7 @@
5052
<tbody>
5153
<tr ng-repeat="r in artists">
5254
<th><span class="glyphicon glyphicon-plus-sign" /></th>
53-
<td><a href="#/local/artist/{{r.contributor_id}}">{{r.contributor}}</a></td>
55+
<td><a href="#/local/artist/{{r.id}}">{{r.artist}}</a></td>
5456
</tr>
5557
</tbody>
5658
</table>

web/src/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<script type="text/javascript" src="js/slim-client.js"></script>
2424

2525
<script type="text/javascript" src="js/search.js"></script>
26+
<script type="text/javascript" src="js/browse_track.js"></script>
2627
<script type="text/javascript" src="js/browse_album.js"></script>
2728
<script type="text/javascript" src="js/browse_artist.js"></script>
2829
<script type="text/javascript" src="js/playlist.js"></script>

web/src/js/app.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var app = angular.module('piradio', ['ngRoute', 'ui.bootstrap'])
55
when('/search', {templateUrl: 'html/search.html', controller: SearchController, reloadOnSearch: false}).
66
when('/local/album/:album', {templateUrl: 'html/browse_album.html', controller: AlbumController, reloadOnSearch: true}).
77
when('/local/artist/:artist', {templateUrl: 'html/browse_artist.html', controller: ArtistController, reloadOnSearch: true}).
8+
when('/local/track/:track', {templateUrl: 'html/browse_track.html', controller: TrackController, reloadOnSearch: true}).
89
when('/playlist', {templateUrl: 'html/playlist.html', controller: PlaylistController, reloadOnSearch: false}).
910
otherwise({redirectTo: '/search'});
1011
}])

web/src/js/browse_album.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
function AlbumController($scope, $routeParams, slimClient) {
22

33
$scope.client = slimClient;
4-
$scope.tracks = [];
54

65
$scope.init = function() {
76
var album = $routeParams.album;
87
if (album != "") {
9-
slimClient.tracks_for_album(album).
10-
success(function(result) {
118

12-
res = result['result'];
9+
slimClient.albums("album_id:" + album).
10+
success(function(result) {
11+
$scope.album_info = result['albums_loop'][0];
12+
});
1313

14-
$scope.tracks = res['titles_loop'];
15-
}).
16-
error(function(result) {
17-
alert("Failed: " + result);
14+
slimClient.tracks("album_id:" + album).
15+
success(function(result) {
16+
$scope.tracks = result['titles_loop'];
1817
});
18+
1919
}
2020
};
2121

web/src/js/browse_artist.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
function ArtistController($scope, $routeParams, slimClient) {
22

33
$scope.client = slimClient;
4-
$scope.tracks = [];
54

65
$scope.init = function() {
76
var artist = $routeParams.artist;
87
if (artist != "") {
9-
slimClient.albums_for_artist(artist).
8+
slimClient.albums("artist_id:" + artist).
109
success(function(result) {
11-
12-
res = result['result'];
13-
14-
$scope.albums = res['albums_loop'];
15-
}).
16-
error(function(result) {
17-
alert("Failed: " + result);
10+
$scope.albums = result['albums_loop'];
11+
});
12+
slimClient.artists("artist_id:" + artist).
13+
success(function(result) {
14+
$scope.artist_info = result['artists_loop'][0];
1815
});
1916
}
2017
};

web/src/js/browse_track.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function TrackController($scope, $routeParams, slimClient) {
2+
3+
$scope.client = slimClient;
4+
5+
$scope.init = function() {
6+
var track = $routeParams.track;
7+
if (track != "") {
8+
slimClient.songinfo("track_id:" + track).
9+
success(function(result) {
10+
$scope.track = result['songinfo_loop'];
11+
});
12+
}
13+
};
14+
15+
}
16+

web/src/js/search.js

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function SearchController($scope, slimClient) {
1+
function SearchController($scope, $location, slimClient) {
22

33
$scope.client = slimClient;
44
$scope.searchText = "";
@@ -8,22 +8,36 @@ function SearchController($scope, slimClient) {
88

99
$scope.submitSearch = function() {
1010
if ($scope.searchText != "") {
11-
slimClient.search( $scope.searchText ).
11+
slimClient.tracks( "search:" + $scope.searchText ).
1212
success(function(result) {
13-
14-
res = result['result'];
15-
16-
$scope.albums = res['albums_loop'];
17-
$scope.tracks = res['tracks_loop'];
18-
$scope.artists = res['contributors_loop'];
19-
}).
20-
error(function(result) {
21-
alert("Failed: " + result);
13+
$scope.tracks = result['titles_loop'];
14+
});
15+
slimClient.albums( "search:" + $scope.searchText ).
16+
success(function(result) {
17+
$scope.albums = result['albums_loop'];
18+
});
19+
slimClient.artists( "search:" + $scope.searchText ).
20+
success(function(result) {
21+
$scope.artists = result['artists_loop'];
2222
});
2323
}
2424
};
2525

26+
$scope.$watch("searchText", function(val) {
27+
if (!val || val.length == 0) {
28+
$location.search('search', null);
29+
} else {
30+
$location.search('search', val);
31+
}
32+
});
33+
2634
$scope.init = function() {
35+
if ($location.search().search) {
36+
$scope.searchText = $location.search().search;
37+
$scope.submitSearch();
38+
} else {
39+
$scope.searchText = "";
40+
}
2741
};
2842

2943
}

web/src/js/slim-client.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@ function SlimClient($http, $location, serverStatus) {
1616
});
1717
};
1818

19-
this.search = function(text) {
20-
data = [ "search", 0, 100, "term:" + text ];
19+
this.songinfo = function(search) {
20+
data = [ "songinfo", 0, 100, search, "tags:adelsty" ];
2121
return slimRequest(data);
2222
};
2323

24-
this.tracks_for_album = function(album) {
25-
data = [ "titles", 0, 100, "album_id:" + album, "sort:tracknum" ];
24+
this.tracks = function(search) {
25+
data = [ "titles", 0, 100, search, "sort:albumtrack", "tags:aels" ];
2626
return slimRequest(data);
2727
};
2828

29-
this.albums_for_artist = function(artist) {
30-
data = [ "albums", 0, 100, "artist_id:" + artist ];
29+
this.albums = function(search) {
30+
data = [ "albums", 0, 100, search, "tags:alS" ];
31+
return slimRequest(data);
32+
};
33+
34+
this.artists = function(search) {
35+
data = [ "artists", 0, 100, search ];
3136
return slimRequest(data);
3237
};
3338

0 commit comments

Comments
 (0)