mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +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);
|
||||||
|
}
|
||||||
|
|
@ -1,52 +1,67 @@
|
||||||
package com.cappielloantonio.play.subsonic.models;
|
package com.cappielloantonio.play.subsonic.models;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
public class SubsonicResponse {
|
public class SubsonicResponse {
|
||||||
protected Error error;
|
@SerializedName("error")
|
||||||
protected ScanStatus scanStatus;
|
@Expose
|
||||||
protected TopSongs topSongs;
|
public Error error;
|
||||||
protected SimilarSongs2 similarSongs2;
|
|
||||||
protected SimilarSongs similarSongs;
|
public ScanStatus scanStatus;
|
||||||
protected ArtistInfo2 artistInfo2;
|
public TopSongs topSongs;
|
||||||
protected ArtistInfo artistInfo;
|
public SimilarSongs2 similarSongs2;
|
||||||
protected AlbumInfo albumInfo;
|
public SimilarSongs similarSongs;
|
||||||
protected Starred2 starred2;
|
public ArtistInfo2 artistInfo2;
|
||||||
protected Starred starred;
|
public ArtistInfo artistInfo;
|
||||||
protected Shares shares;
|
public AlbumInfo albumInfo;
|
||||||
protected PlayQueue playQueue;
|
public Starred2 starred2;
|
||||||
protected Bookmarks bookmarks;
|
public Starred starred;
|
||||||
protected InternetRadioStations internetRadioStations;
|
public Shares shares;
|
||||||
protected NewestPodcasts newestPodcasts;
|
public PlayQueue playQueue;
|
||||||
protected Podcasts podcasts;
|
public Bookmarks bookmarks;
|
||||||
protected Lyrics lyrics;
|
public InternetRadioStations internetRadioStations;
|
||||||
protected Songs songsByGenre;
|
public NewestPodcasts newestPodcasts;
|
||||||
protected Songs randomSongs;
|
public Podcasts podcasts;
|
||||||
protected AlbumList2 albumList2;
|
public Lyrics lyrics;
|
||||||
protected AlbumList albumList;
|
public Songs songsByGenre;
|
||||||
protected ChatMessages chatMessages;
|
public Songs randomSongs;
|
||||||
protected User user;
|
public AlbumList2 albumList2;
|
||||||
protected Users users;
|
public AlbumList albumList;
|
||||||
protected License license;
|
public ChatMessages chatMessages;
|
||||||
protected JukeboxPlaylist jukeboxPlaylist;
|
public User user;
|
||||||
protected JukeboxStatus jukeboxStatus;
|
public Users users;
|
||||||
protected PlaylistWithSongs playlist;
|
public License license;
|
||||||
protected Playlists playlists;
|
public JukeboxPlaylist jukeboxPlaylist;
|
||||||
protected SearchResult3 searchResult3;
|
public JukeboxStatus jukeboxStatus;
|
||||||
protected SearchResult2 searchResult2;
|
public PlaylistWithSongs playlist;
|
||||||
protected SearchResult searchResult;
|
public Playlists playlists;
|
||||||
protected NowPlaying nowPlaying;
|
public SearchResult3 searchResult3;
|
||||||
protected VideoInfo videoInfo;
|
public SearchResult2 searchResult2;
|
||||||
protected Videos videos;
|
public SearchResult searchResult;
|
||||||
protected Child song;
|
public NowPlaying nowPlaying;
|
||||||
protected AlbumWithSongsID3 album;
|
public VideoInfo videoInfo;
|
||||||
protected ArtistWithAlbumsID3 artist;
|
public Videos videos;
|
||||||
protected ArtistsID3 artists;
|
public Child song;
|
||||||
protected Genres genres;
|
public AlbumWithSongsID3 album;
|
||||||
protected Directory directory;
|
public ArtistWithAlbumsID3 artist;
|
||||||
protected Indexes indexes;
|
public ArtistsID3 artists;
|
||||||
protected MusicFolders musicFolders;
|
public Genres genres;
|
||||||
protected ResponseStatus status;
|
public Directory directory;
|
||||||
protected String version;
|
public Indexes indexes;
|
||||||
|
public MusicFolders musicFolders;
|
||||||
|
|
||||||
|
@SerializedName("status")
|
||||||
|
@Expose
|
||||||
|
public ResponseStatus status;
|
||||||
|
|
||||||
|
@SerializedName("version")
|
||||||
|
@Expose
|
||||||
|
public String version;
|
||||||
|
|
||||||
|
@SerializedName("type")
|
||||||
|
@Expose
|
||||||
|
public String type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the error property.
|
* Gets the value of the error property.
|
||||||
|
|
@ -947,4 +962,25 @@ public class SubsonicResponse {
|
||||||
public void setVersion(String value) {
|
public void setVersion(String value) {
|
||||||
this.version = value;
|
this.version = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the type property.
|
||||||
|
*
|
||||||
|
* @return possible object is
|
||||||
|
* {@link String }
|
||||||
|
*/
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the type property.
|
||||||
|
*
|
||||||
|
* @param value allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*/
|
||||||
|
public void setType(String value) {
|
||||||
|
this.type = value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue