mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
First API implementation
This commit is contained in:
parent
24ca36197c
commit
768ec981f3
11 changed files with 604 additions and 45 deletions
|
|
@ -0,0 +1,81 @@
|
|||
package com.cappielloantonio.play.subsonic.api.albumsonglist;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.api.browsing.BrowsingService;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class AlbumSongListClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private AlbumSongListService albumSongListService;
|
||||
|
||||
public AlbumSongListClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
.baseUrl(subsonic.getUrl())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(getOkHttpClient())
|
||||
.build();
|
||||
|
||||
this.albumSongListService = retrofit.create(AlbumSongListService.class);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getAlbumList() {
|
||||
Log.d(TAG, "getAlbumList()");
|
||||
return albumSongListService.getAlbumList(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getAlbumList2() {
|
||||
Log.d(TAG, "getAlbumList2()");
|
||||
return albumSongListService.getAlbumList2(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getRandomSongs(int size) {
|
||||
Log.d(TAG, "getRandomSongs()");
|
||||
return albumSongListService.getRandomSongs(subsonic.getParams(), size);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getSongsByGenre(String genre, int count) {
|
||||
Log.d(TAG, "getSongsByGenre()");
|
||||
return albumSongListService.getSongsByGenre(subsonic.getParams(), genre, count);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getNowPlaying() {
|
||||
Log.d(TAG, "getNowPlaying()");
|
||||
return albumSongListService.getNowPlaying(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getStarred() {
|
||||
Log.d(TAG, "getStarred()");
|
||||
return albumSongListService.getStarred(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getStarred2() {
|
||||
Log.d(TAG, "getStarred2()");
|
||||
return albumSongListService.getStarred2(subsonic.getParams());
|
||||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor getHttpLoggingInterceptor() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.cappielloantonio.play.subsonic.api.albumsonglist;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface AlbumSongListService {
|
||||
@GET("getAlbumList?type=random")
|
||||
Call<SubsonicResponse> getAlbumList(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getAlbumList2?type=random")
|
||||
Call<SubsonicResponse> getAlbumList2(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getRandomSongs?size={size}")
|
||||
Call<SubsonicResponse> getRandomSongs(@QueryMap Map<String, String> params, int size);
|
||||
|
||||
@GET("getSongsByGenre?genre={genre}?count={count}")
|
||||
Call<SubsonicResponse> getSongsByGenre(@QueryMap Map<String, String> params, String genre, int count);
|
||||
|
||||
@GET("getNowPlaying")
|
||||
Call<SubsonicResponse> getNowPlaying(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getStarred")
|
||||
Call<SubsonicResponse> getStarred(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getStarred2")
|
||||
Call<SubsonicResponse> getStarred2(@QueryMap Map<String, String> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
package com.cappielloantonio.play.subsonic.api.browsing;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class BrowsingClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private BrowsingService browsingService;
|
||||
|
||||
public BrowsingClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
.baseUrl(subsonic.getUrl())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(getOkHttpClient())
|
||||
.build();
|
||||
|
||||
this.browsingService = retrofit.create(BrowsingService.class);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getMusicFolders() {
|
||||
Log.d(TAG, "getMusicFolders()");
|
||||
return browsingService.getMusicFolders(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getIndexes() {
|
||||
Log.d(TAG, "getIndexes()");
|
||||
return browsingService.getIndexes(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getMusicDirectory(String id) {
|
||||
Log.d(TAG, "getMusicDirectory()");
|
||||
return browsingService.getMusicDirectory(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getGenres() {
|
||||
Log.d(TAG, "getGenres()");
|
||||
return browsingService.getGenres(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getArtists() {
|
||||
Log.d(TAG, "getArtists()");
|
||||
return browsingService.getArtists(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getArtist(String id) {
|
||||
Log.d(TAG, "getArtist()");
|
||||
return browsingService.getArtist(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getAlbum(String id) {
|
||||
Log.d(TAG, "getAlbum()");
|
||||
return browsingService.getAlbum(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getSong(String id) {
|
||||
Log.d(TAG, "getSong()");
|
||||
return browsingService.getSong(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getVideos() {
|
||||
Log.d(TAG, "getVideos()");
|
||||
return browsingService.getVideos(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getVideoInfo(String id) {
|
||||
Log.d(TAG, "getVideoInfo()");
|
||||
return browsingService.getVideoInfo(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getArtistInfo(String id) {
|
||||
Log.d(TAG, "getArtistInfo()");
|
||||
return browsingService.getArtistInfo(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getArtistInfo2(String id) {
|
||||
Log.d(TAG, "getArtistInfo2()");
|
||||
return browsingService.getArtistInfo2(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getAlbumInfo(String id) {
|
||||
Log.d(TAG, "getAlbumInfo()");
|
||||
return browsingService.getAlbumInfo(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getAlbumInfo2(String id) {
|
||||
Log.d(TAG, "getAlbumInfo2()");
|
||||
return browsingService.getAlbumInfo2(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getSimilarSongs(String id, int count) {
|
||||
Log.d(TAG, "getSimilarSongs()");
|
||||
return browsingService.getSimilarSongs(subsonic.getParams(), id, count);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getSimilarSongs2(String id, int limit) {
|
||||
Log.d(TAG, "getSimilarSongs2()");
|
||||
return browsingService.getSimilarSongs2(subsonic.getParams(), id, limit);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getTopSongs(String id, int count) {
|
||||
Log.d(TAG, "getTopSongs()");
|
||||
return browsingService.getTopSongs(subsonic.getParams(), id, count);
|
||||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor getHttpLoggingInterceptor() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.cappielloantonio.play.subsonic.api.browsing;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface BrowsingService {
|
||||
@GET("getMusicFolders")
|
||||
Call<SubsonicResponse> getMusicFolders(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getIndexes")
|
||||
Call<SubsonicResponse> getIndexes(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getMusicDirectory?id={id}")
|
||||
Call<SubsonicResponse> getMusicDirectory(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getGenres")
|
||||
Call<SubsonicResponse> getGenres(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getArtists")
|
||||
Call<SubsonicResponse> getArtists(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getArtist?id={id}")
|
||||
Call<SubsonicResponse> getArtist(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getAlbum?id={id}")
|
||||
Call<SubsonicResponse> getAlbum(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getSong?id={id}")
|
||||
Call<SubsonicResponse> getSong(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getVideos")
|
||||
Call<SubsonicResponse> getVideos(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getVideoInfo?id={id}")
|
||||
Call<SubsonicResponse> getVideoInfo(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getArtistInfo?id={id}")
|
||||
Call<SubsonicResponse> getArtistInfo(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getArtistInfo2?id={id}")
|
||||
Call<SubsonicResponse> getArtistInfo2(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getAlbumInfo?id={id}")
|
||||
Call<SubsonicResponse> getAlbumInfo(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getAlbumInfo2?id={id}")
|
||||
Call<SubsonicResponse> getAlbumInfo2(@QueryMap Map<String, String> params, String id);
|
||||
|
||||
@GET("getSimilarSongs?id={id}?count={count}")
|
||||
Call<SubsonicResponse> getSimilarSongs(@QueryMap Map<String, String> params, String id, int count);
|
||||
|
||||
@GET("getSimilarSongs2?id={id}?count={count}")
|
||||
Call<SubsonicResponse> getSimilarSongs2(@QueryMap Map<String, String> params, String id, int count);
|
||||
|
||||
@GET("getTopSongs?id={id}?count={count}")
|
||||
Call<SubsonicResponse> getTopSongs(@QueryMap Map<String, String> params, String id, int count);
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.cappielloantonio.play.subsonic.api.mediaretrieval;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.api.playlist.PlaylistService;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class MediaRetrievalClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private MediaRetrievalService mediaRetrievalService;
|
||||
|
||||
public MediaRetrievalClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
.baseUrl(subsonic.getUrl())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(getOkHttpClient())
|
||||
.build();
|
||||
|
||||
this.mediaRetrievalService = retrofit.create(MediaRetrievalService.class);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> stream(String id, int maxBitRate, String format) {
|
||||
Log.d(TAG, "stream()");
|
||||
return mediaRetrievalService.stream(subsonic.getParams(), id, maxBitRate, format);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> download(String id) {
|
||||
Log.d(TAG, "download()");
|
||||
return mediaRetrievalService.download(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor getHttpLoggingInterceptor() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.cappielloantonio.play.subsonic.api.mediaretrieval;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface MediaRetrievalService {
|
||||
@GET("stream?id={id}?maxBitRate={maxBitRate}?format={format}")
|
||||
Call<SubsonicResponse> stream(@QueryMap Map<String, String> params, String id, int maxBitRate, String format);
|
||||
|
||||
@GET("download?id={id}")
|
||||
Call<SubsonicResponse> download(@QueryMap Map<String, String> params, String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.cappielloantonio.play.subsonic.api.playlist;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.api.albumsonglist.AlbumSongListService;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class PlaylistClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private PlaylistService playlistService;
|
||||
|
||||
public PlaylistClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
.baseUrl(subsonic.getUrl())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(getOkHttpClient())
|
||||
.build();
|
||||
|
||||
this.playlistService = retrofit.create(PlaylistService.class);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getPlaylists() {
|
||||
Log.d(TAG, "getPlaylists()");
|
||||
return playlistService.getPlaylists(subsonic.getParams());
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> getPlaylist(String id) {
|
||||
Log.d(TAG, "getPlaylist()");
|
||||
return playlistService.getPlaylist(subsonic.getParams(), id);
|
||||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor getHttpLoggingInterceptor() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.cappielloantonio.play.subsonic.api.playlist;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface PlaylistService {
|
||||
@GET("getPlaylists")
|
||||
Call<SubsonicResponse> getPlaylists(@QueryMap Map<String, String> params);
|
||||
|
||||
@GET("getPlaylist?id={id}")
|
||||
Call<SubsonicResponse> getPlaylist(@QueryMap Map<String, String> params, String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.cappielloantonio.play.subsonic.api.searching;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class SearchingClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private SearchingService searchingService;
|
||||
|
||||
public SearchingClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
.baseUrl(subsonic.getUrl())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(getOkHttpClient())
|
||||
.build();
|
||||
|
||||
this.searchingService = retrofit.create(SearchingService.class);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> search2(String query) {
|
||||
Log.d(TAG, "search2()");
|
||||
return searchingService.search2(subsonic.getParams(), query);
|
||||
}
|
||||
|
||||
public Call<SubsonicResponse> search3(String query) {
|
||||
Log.d(TAG, "search3()");
|
||||
return searchingService.search3(subsonic.getParams(), query);
|
||||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
private HttpLoggingInterceptor getHttpLoggingInterceptor() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.cappielloantonio.play.subsonic.api.searching;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface SearchingService {
|
||||
@GET("search2?query={query}")
|
||||
Call<SubsonicResponse> search2(@QueryMap Map<String, String> params, String query);
|
||||
|
||||
@GET("search3?query={query}")
|
||||
Call<SubsonicResponse> search3(@QueryMap Map<String, String> params, String query);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue