Skip to content

Commit

Permalink
Support Subsonic API without .view
Browse files Browse the repository at this point in the history
Some client such as Volusonic use routes without `.view` suffix.
  • Loading branch information
DocMarty84 committed Apr 22, 2020
1 parent b2e8743 commit 8ba14ff
Show file tree
Hide file tree
Showing 15 changed files with 238 additions and 60 deletions.
10 changes: 9 additions & 1 deletion controllers/subsonic/bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

class MusicSubsonicBookmarks(http.Controller):
@http.route(
["/rest/getBookmarks.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getBookmarks.view", "/rest/getBookmarks"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getBookmarks(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -26,9 +30,13 @@ def getBookmarks(self, **kwargs):
@http.route(
[
"/rest/createBookmark.view",
"/rest/createBookmark",
"/rest/deleteBookmark.view",
"/rest/deleteBookmark",
"/rest/getPlayQueue.view",
"/rest/getPlayQueue",
"/rest/savePlayQueue.view",
"/rest/savePlayQueue",
],
type="http",
auth="public",
Expand Down
74 changes: 57 additions & 17 deletions controllers/subsonic/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class MusicSubsonicBrowsing(http.Controller):
@http.route(
["/rest/getMusicFolders.view"],
["/rest/getMusicFolders.view", "/rest/getMusicFolders"],
type="http",
auth="public",
csrf=False,
Expand All @@ -37,7 +37,11 @@ def getMusicFolders(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getIndexes.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getIndexes.view", "/rest/getIndexes"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getIndexes(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -91,7 +95,7 @@ def getIndexes(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getMusicDirectory.view"],
["/rest/getMusicDirectory.view", "/rest/getMusicDirectory"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -128,7 +132,11 @@ def getMusicDirectory(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getGenres.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getGenres.view", "/rest/getGenres"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getGenres(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -143,7 +151,11 @@ def getGenres(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getArtists.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getArtists.view", "/rest/getArtists"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getArtists(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -181,7 +193,11 @@ def getArtists(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getArtist.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getArtist.view", "/rest/getArtist"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getArtist(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -208,7 +224,11 @@ def getArtist(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getAlbum.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getAlbum.view", "/rest/getAlbum"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getAlbum(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -235,7 +255,11 @@ def getAlbum(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getSong.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getSong.view", "/rest/getSong"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getSong(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -258,7 +282,11 @@ def getSong(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getVideos.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getVideos.view", "/rest/getVideos"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getVideos(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -273,7 +301,11 @@ def getVideos(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getVideoInfo.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getVideoInfo.view", "/rest/getVideoInfo"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getVideoInfo(self, **kwargs):
# TODO: support video infos
Expand All @@ -285,7 +317,7 @@ def getVideoInfo(self, **kwargs):
return request.make_error(code="30", message="Videos are not supported yet")

@http.route(
["/rest/getArtistInfo.view"],
["/rest/getArtistInfo.view", "/rest/getArtistInfo"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -320,7 +352,7 @@ def getArtistInfo(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getArtistInfo2.view"],
["/rest/getArtistInfo2.view", "/rest/getArtistInfo2"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -355,7 +387,11 @@ def getArtistInfo2(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getAlbumInfo.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getAlbumInfo.view", "/rest/getAlbumInfo"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getAlbumInfo(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand All @@ -378,7 +414,7 @@ def getAlbumInfo(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getAlbumInfo2.view"],
["/rest/getAlbumInfo2.view", "/rest/getAlbumInfo2"],
type="http",
auth="public",
csrf=False,
Expand All @@ -405,7 +441,7 @@ def getAlbumInfo2(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getSimilarSongs.view"],
["/rest/getSimilarSongs.view", "/rest/getSimilarSongs"],
type="http",
auth="public",
csrf=False,
Expand All @@ -415,7 +451,7 @@ def getSimilarSongs(self, **kwargs):
return self.getSimilarSongs2(**dict(kwargs, tag_name="similarSongs"))

@http.route(
["/rest/getSimilarSongs2.view"],
["/rest/getSimilarSongs2.view", "/rest/getSimilarSongs2"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -445,7 +481,11 @@ def getSimilarSongs2(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getTopSongs.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getTopSongs.view", "/rest/getTopSongs"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getTopSongs(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down
4 changes: 2 additions & 2 deletions controllers/subsonic/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class MusicSubsonicChat(http.Controller):
@http.route(
["/rest/getChatMessages.view"],
["/rest/getChatMessages.view", "/rest/getChatMessages"],
type="http",
auth="public",
csrf=False,
Expand All @@ -28,7 +28,7 @@ def getChatMessages(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/addChatMessage.view"],
["/rest/addChatMessage.view", "/rest/addChatMessage"],
type="http",
auth="public",
csrf=False,
Expand Down
2 changes: 1 addition & 1 deletion controllers/subsonic/jukebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MusicSubsonicJukebox(http.Controller):
@http.route(
["/rest/jukeboxControl.view"],
["/rest/jukeboxControl.view", "/rest/jukeboxControl"],
type="http",
auth="public",
csrf=False,
Expand Down
26 changes: 19 additions & 7 deletions controllers/subsonic/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def _uniquify_list(seq):

class MusicSubsonicListing(http.Controller):
@http.route(
["/rest/getAlbumList.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getAlbumList.view", "/rest/getAlbumList"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getAlbumList(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -149,7 +153,7 @@ def getAlbumList(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getAlbumList2.view"],
["/rest/getAlbumList2.view", "/rest/getAlbumList2"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -297,7 +301,7 @@ def getAlbumList2(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getRandomSongs.view"],
["/rest/getRandomSongs.view", "/rest/getRandomSongs"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -349,7 +353,7 @@ def getRandomSongs(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getSongsByGenre.view"],
["/rest/getSongsByGenre.view", "/rest/getSongsByGenre"],
type="http",
auth="public",
csrf=False,
Expand Down Expand Up @@ -398,7 +402,7 @@ def getSongsByGenre(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getNowPlaying.view"],
["/rest/getNowPlaying.view", "/rest/getNowPlaying"],
type="http",
auth="public",
csrf=False,
Expand All @@ -419,7 +423,11 @@ def getNowPlaying(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getStarred.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getStarred.view", "/rest/getStarred"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getStarred(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -458,7 +466,11 @@ def getStarred(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/getStarred2.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/getStarred2.view", "/rest/getStarred2"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def getStarred2(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down
24 changes: 20 additions & 4 deletions controllers/subsonic/media_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

class MusicSubsonicMediaAnnotation(http.Controller):
@http.route(
["/rest/star.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/star.view", "/rest/star"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def star(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -45,7 +49,11 @@ def star(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/unstar.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/unstar.view", "/rest/unstar"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def unstar(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -80,7 +88,11 @@ def unstar(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/setRating.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/setRating.view", "/rest/setRating"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def setRating(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down Expand Up @@ -121,7 +133,11 @@ def setRating(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/scrobble.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/scrobble.view", "/rest/scrobble"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def scrobble(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down
8 changes: 6 additions & 2 deletions controllers/subsonic/media_library_scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class MusicSubsonicMediaLibraryScanning(http.Controller):
@http.route(
["/rest/getScanStatus.view"],
["/rest/getScanStatus.view", "/rest/getScanStatus"],
type="http",
auth="public",
csrf=False,
Expand All @@ -31,7 +31,11 @@ def getScanStatus(self, **kwargs):
return rest.make_response(root)

@http.route(
["/rest/startScan.view"], type="http", auth="public", csrf=False, methods=["GET", "POST"]
["/rest/startScan.view", "/rest/startScan"],
type="http",
auth="public",
csrf=False,
methods=["GET", "POST"],
)
def startScan(self, **kwargs):
rest = SubsonicREST(kwargs)
Expand Down
Loading

0 comments on commit 8ba14ff

Please sign in to comment.