2019-05-17 20:22:01 +02:00
|
|
|
function restpath!(target, req)
|
2019-05-21 15:13:08 +02:00
|
|
|
# @show req[:path]
|
2019-05-17 20:22:01 +02:00
|
|
|
length(req[:path]) < 2 && return false
|
|
|
|
return req[:path][1] == "rest" &&
|
|
|
|
startswith(req[:path][2], target)
|
|
|
|
end
|
|
|
|
restp(p, app...) = branch(req -> restpath!(p, req), app...)
|
|
|
|
|
2019-05-21 15:40:42 +02:00
|
|
|
function torrentdl(query::AbstractString)
|
|
|
|
global rpc, me
|
|
|
|
TransmissionRPC.getauth(rpc)
|
2019-05-21 15:48:20 +02:00
|
|
|
todl = RuTrackers.getdiscography(me, query)
|
2019-05-21 15:59:25 +02:00
|
|
|
TransmissionRPC.add.(Ref(rpc), RuTrackers.download.(Ref(me), todl))
|
2019-05-21 16:43:27 +02:00
|
|
|
todl
|
2019-05-21 15:40:42 +02:00
|
|
|
end
|
|
|
|
|
2019-05-17 20:22:01 +02:00
|
|
|
dispatch = stack(
|
|
|
|
# Browsing
|
|
|
|
restp("getMusicFolders", _ -> getMusicFolders()),
|
2019-05-21 11:05:53 +02:00
|
|
|
restp("getMusicDirectory", req -> getMusicDirectory(req)),
|
2019-05-17 20:22:01 +02:00
|
|
|
restp("getAlbumList", req -> getAlbumList(req)),
|
|
|
|
restp("getGenres", _ -> getGenres()),
|
|
|
|
restp("getArtists", _ -> getArtists()),
|
|
|
|
restp("getArtist", r -> getArtist(r)),
|
|
|
|
restp("getAlbum", req -> getAlbum(req)),
|
|
|
|
restp("getSong", req -> getSong(req)),
|
|
|
|
# Album/song list
|
|
|
|
restp("getRandomSongs", req -> getRandomSongs(req)),
|
|
|
|
# Searching
|
2019-05-21 15:40:42 +02:00
|
|
|
restp("search3", req -> search3(req; dl = torrentdl)),
|
2019-05-17 20:22:01 +02:00
|
|
|
# Playlists
|
|
|
|
restp("createPlaylist", req -> createPlaylist(req)),
|
|
|
|
restp("getPlaylists", req -> getPlaylists(req)),
|
|
|
|
restp("getPlaylist", req -> getPlaylist(req)),
|
|
|
|
restp("updatePlaylist", req -> updatePlaylist(req)),
|
|
|
|
restp("deletePlaylist", req -> deletePlaylist(req)),
|
|
|
|
# User management
|
|
|
|
restp("getUser", req -> getUser(req)),
|
|
|
|
# Media retrieval
|
|
|
|
restp("stream", req -> stream(req)),
|
|
|
|
restp("getCoverArt", req -> getCoverArt(req)),
|
|
|
|
# Media library scanning (can be used to check download status!)
|
|
|
|
# getScanStatus startScan
|
|
|
|
)
|