Skip to content

Commit b58dce6

Browse files
author
David Norman
committed
Adding some spotify (at the moment - may change to separate views for local/spotify/radio)
1 parent 19ec96f commit b58dce6

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

web/src/html/playlist.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</thead>
1717
<tbody>
1818
<tr ng-class="($index==data.playlist_cur_index)?'success':''" ng-repeat="r in data.playlist_loop">
19-
<td><a href="javascript:;" ng-click="playlist_remove(r.id)"><span class="glyphicon glyphicon-remove-circle"></span></a></td>
19+
<td><a href="javascript:;" ng-click="playlist_remove($index)"><span class="glyphicon glyphicon-remove-circle"></span></a></td>
2020
<td>{{r.tracknum}}</td>
2121
<td><a href="#/local/track/{{r.id}}">{{r.title}}</a></td>
2222
<td><a href="#/local/album/{{r.album_id}}">{{r.album}}</a></td>

web/src/html/search.html

+16
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
<td><a href="#/local/album/{{r.album_id}}">{{r.album}}</a></td>
2525
<td><a href="#/local/artist/{{r.artist_id}}">{{r.artist}}</a></td>
2626
</tr>
27+
<tr ng-repeat="r in spotify_tracks">
28+
<td><a href="javascript:;" ng-click="add_spotify_track(r.id)"><span class="glyphicon glyphicon-plus-sign" /></a></td>
29+
<td>{{r.tracknum}}</td>
30+
<td><a href="#/local/track/{{r.id}}">{{r.name}}</a></td>
31+
<td><a href="#/local/album/{{r.album_id}}">{{r.album}}</a></td>
32+
<td><a href="#/local/artist/{{r.artist_id}}">{{r.artist}}</a></td>
33+
</tr>
2734
</tbody>
2835
</table>
2936
<table class="table table-striped">
@@ -40,6 +47,11 @@
4047
<td><a href="#/local/album/{{r.id}}">{{r.album}}</a></td>
4148
<td><a href="#/local/artist/{{r.artist_id}}">{{r.artist}}</a></td>
4249
</tr>
50+
<tr ng-repeat="r in spotify_albums">
51+
<td><a href="javascript:;" ng-click="add_spotify_album(r.id)"><span class="glyphicon glyphicon-plus-sign" /></a></td>
52+
<td><a href="#/local/album/{{r.id}}">{{r.name}}</a></td>
53+
<td><a href="#/local/artist/{{r.artist_id}}">{{r.artist}}</a></td>
54+
</tr>
4355
</tbody>
4456
</table>
4557
<table class="table table-striped">
@@ -54,5 +66,9 @@
5466
<td><a href="javascript:;" ng-click="add_artist(r.id)"><span class="glyphicon glyphicon-plus-sign" /></a></td>
5567
<td><a href="#/local/artist/{{r.id}}">{{r.artist}}</a></td>
5668
</tr>
69+
<tr ng-repeat="r in spotify_artists">
70+
<td><a href="javascript:;" ng-click="add_spotify_artist(r.id)"><span class="glyphicon glyphicon-plus-sign" /></a></td>
71+
<td><a href="#/local/artist/{{r.id}}">{{r.name}}</a></td>
72+
</tr>
5773
</tbody>
5874
</table>

web/src/js/search.js

+29
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ function SearchController($scope, $location, slimClient) {
55
$scope.albums = [];
66
$scope.artists = [];
77
$scope.tracks = [];
8+
$scope.spotify_artists = [];
9+
$scope.spotify_albums = [];
10+
$scope.spotify_tracks = [];
811

912
$scope.add_track = slimClient.add_track;
1013
$scope.add_album = slimClient.add_album;
1114
$scope.add_artist = slimClient.add_artist;
15+
$scope.add_spotify_track = slimClient.add_spotify_track;
16+
$scope.add_spotify_album = slimClient.add_spotify_album;
17+
$scope.add_spotify_artist = slimClient.add_spotify_artist;
1218

1319
$scope.submitSearch = function() {
1420
if ($scope.searchText != "") {
@@ -24,6 +30,29 @@ function SearchController($scope, $location, slimClient) {
2430
success(function(result) {
2531
$scope.artists = result['artists_loop'];
2632
});
33+
slimClient.spotify_search( "search:" + $scope.searchText ).
34+
success(function(result) {
35+
result['loop_loop'].forEach(function(e, i) {
36+
if (e.name.startsWith("Album")) {
37+
slimClient.spotify_fetch(e.id).
38+
success(function(result) {
39+
$scope.spotify_albums = result['loop_loop'];
40+
});
41+
}
42+
if (e.name.startsWith("Artist")) {
43+
slimClient.spotify_fetch(e.id).
44+
success(function(result) {
45+
$scope.spotify_artists = result['loop_loop'];
46+
});
47+
}
48+
if (e.name.startsWith("Track")) {
49+
slimClient.spotify_fetch(e.id).
50+
success(function(result) {
51+
$scope.spotify_tracks = result['loop_loop'];
52+
});
53+
}
54+
});
55+
});
2756
}
2857
};
2958

web/src/js/slim-client.js

+27-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function SlimClient($http, $location, serverStatus) {
5151
return slimRequest(data);
5252
};
5353

54-
this.playlist_remove = function(track_id) {
55-
data = ["playlistcontrol", "cmd:delete", "track_id:"+track_id];
54+
this.playlist_remove = function(track_num) {
55+
data = ["playlist", "delete", track_num];
5656
return slimRequest(data);
5757
};
5858

@@ -81,5 +81,30 @@ function SlimClient($http, $location, serverStatus) {
8181
return slimRequest(data);
8282
};
8383

84+
this.spotify_search = function(search) {
85+
data = ["spotify", "items", 0, 100, "item_id:8", search];
86+
return slimRequest(data);
87+
};
88+
89+
this.spotify_fetch = function(id) {
90+
data = ["spotify", "items", 0, 100, "item_id:"+id];
91+
return slimRequest(data);
92+
};
93+
94+
this.add_spotify_track = function(item) {
95+
data = ["spotify", "playlist", "add", "item_id:"+item];
96+
return slimRequest(data);
97+
};
98+
99+
this.add_spotify_album = function(item) {
100+
data = ["spotify", "playlist", "add", "item_id:"+item];
101+
return slimRequest(data);
102+
};
103+
104+
this.add_spotify_artist = function(item) {
105+
data = ["spotify", "playlist", "add", "item_id:"+item];
106+
return slimRequest(data);
107+
};
108+
84109
};
85110

0 commit comments

Comments
 (0)