diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/albumsonglist/AlbumSongListClient.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/albumsonglist/AlbumSongListClient.java new file mode 100644 index 00000000..a991402a --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/albumsonglist/AlbumSongListClient.java @@ -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 getAlbumList() { + Log.d(TAG, "getAlbumList()"); + return albumSongListService.getAlbumList(subsonic.getParams()); + } + + public Call getAlbumList2() { + Log.d(TAG, "getAlbumList2()"); + return albumSongListService.getAlbumList2(subsonic.getParams()); + } + + public Call getRandomSongs(int size) { + Log.d(TAG, "getRandomSongs()"); + return albumSongListService.getRandomSongs(subsonic.getParams(), size); + } + + public Call getSongsByGenre(String genre, int count) { + Log.d(TAG, "getSongsByGenre()"); + return albumSongListService.getSongsByGenre(subsonic.getParams(), genre, count); + } + + public Call getNowPlaying() { + Log.d(TAG, "getNowPlaying()"); + return albumSongListService.getNowPlaying(subsonic.getParams()); + } + + public Call getStarred() { + Log.d(TAG, "getStarred()"); + return albumSongListService.getStarred(subsonic.getParams()); + } + + public Call 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; + } +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/albumsonglist/AlbumSongListService.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/albumsonglist/AlbumSongListService.java new file mode 100644 index 00000000..3916f4b9 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/albumsonglist/AlbumSongListService.java @@ -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 getAlbumList(@QueryMap Map params); + + @GET("getAlbumList2?type=random") + Call getAlbumList2(@QueryMap Map params); + + @GET("getRandomSongs?size={size}") + Call getRandomSongs(@QueryMap Map params, int size); + + @GET("getSongsByGenre?genre={genre}?count={count}") + Call getSongsByGenre(@QueryMap Map params, String genre, int count); + + @GET("getNowPlaying") + Call getNowPlaying(@QueryMap Map params); + + @GET("getStarred") + Call getStarred(@QueryMap Map params); + + @GET("getStarred2") + Call getStarred2(@QueryMap Map params); +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/browsing/BrowsingClient.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/browsing/BrowsingClient.java new file mode 100644 index 00000000..0b592030 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/browsing/BrowsingClient.java @@ -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 getMusicFolders() { + Log.d(TAG, "getMusicFolders()"); + return browsingService.getMusicFolders(subsonic.getParams()); + } + + public Call getIndexes() { + Log.d(TAG, "getIndexes()"); + return browsingService.getIndexes(subsonic.getParams()); + } + + public Call getMusicDirectory(String id) { + Log.d(TAG, "getMusicDirectory()"); + return browsingService.getMusicDirectory(subsonic.getParams(), id); + } + + public Call getGenres() { + Log.d(TAG, "getGenres()"); + return browsingService.getGenres(subsonic.getParams()); + } + + public Call getArtists() { + Log.d(TAG, "getArtists()"); + return browsingService.getArtists(subsonic.getParams()); + } + + public Call getArtist(String id) { + Log.d(TAG, "getArtist()"); + return browsingService.getArtist(subsonic.getParams(), id); + } + + public Call getAlbum(String id) { + Log.d(TAG, "getAlbum()"); + return browsingService.getAlbum(subsonic.getParams(), id); + } + + public Call getSong(String id) { + Log.d(TAG, "getSong()"); + return browsingService.getSong(subsonic.getParams(), id); + } + + public Call getVideos() { + Log.d(TAG, "getVideos()"); + return browsingService.getVideos(subsonic.getParams()); + } + + public Call getVideoInfo(String id) { + Log.d(TAG, "getVideoInfo()"); + return browsingService.getVideoInfo(subsonic.getParams(), id); + } + + public Call getArtistInfo(String id) { + Log.d(TAG, "getArtistInfo()"); + return browsingService.getArtistInfo(subsonic.getParams(), id); + } + + public Call getArtistInfo2(String id) { + Log.d(TAG, "getArtistInfo2()"); + return browsingService.getArtistInfo2(subsonic.getParams(), id); + } + + public Call getAlbumInfo(String id) { + Log.d(TAG, "getAlbumInfo()"); + return browsingService.getAlbumInfo(subsonic.getParams(), id); + } + + public Call getAlbumInfo2(String id) { + Log.d(TAG, "getAlbumInfo2()"); + return browsingService.getAlbumInfo2(subsonic.getParams(), id); + } + + public Call getSimilarSongs(String id, int count) { + Log.d(TAG, "getSimilarSongs()"); + return browsingService.getSimilarSongs(subsonic.getParams(), id, count); + } + + public Call getSimilarSongs2(String id, int limit) { + Log.d(TAG, "getSimilarSongs2()"); + return browsingService.getSimilarSongs2(subsonic.getParams(), id, limit); + } + + public Call 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; + } +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/browsing/BrowsingService.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/browsing/BrowsingService.java new file mode 100644 index 00000000..9dc3d399 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/browsing/BrowsingService.java @@ -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 getMusicFolders(@QueryMap Map params); + + @GET("getIndexes") + Call getIndexes(@QueryMap Map params); + + @GET("getMusicDirectory?id={id}") + Call getMusicDirectory(@QueryMap Map params, String id); + + @GET("getGenres") + Call getGenres(@QueryMap Map params); + + @GET("getArtists") + Call getArtists(@QueryMap Map params); + + @GET("getArtist?id={id}") + Call getArtist(@QueryMap Map params, String id); + + @GET("getAlbum?id={id}") + Call getAlbum(@QueryMap Map params, String id); + + @GET("getSong?id={id}") + Call getSong(@QueryMap Map params, String id); + + @GET("getVideos") + Call getVideos(@QueryMap Map params); + + @GET("getVideoInfo?id={id}") + Call getVideoInfo(@QueryMap Map params, String id); + + @GET("getArtistInfo?id={id}") + Call getArtistInfo(@QueryMap Map params, String id); + + @GET("getArtistInfo2?id={id}") + Call getArtistInfo2(@QueryMap Map params, String id); + + @GET("getAlbumInfo?id={id}") + Call getAlbumInfo(@QueryMap Map params, String id); + + @GET("getAlbumInfo2?id={id}") + Call getAlbumInfo2(@QueryMap Map params, String id); + + @GET("getSimilarSongs?id={id}?count={count}") + Call getSimilarSongs(@QueryMap Map params, String id, int count); + + @GET("getSimilarSongs2?id={id}?count={count}") + Call getSimilarSongs2(@QueryMap Map params, String id, int count); + + @GET("getTopSongs?id={id}?count={count}") + Call getTopSongs(@QueryMap Map params, String id, int count); +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/mediaretrieval/MediaRetrievalClient.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/mediaretrieval/MediaRetrievalClient.java new file mode 100644 index 00000000..017c9d09 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/mediaretrieval/MediaRetrievalClient.java @@ -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 stream(String id, int maxBitRate, String format) { + Log.d(TAG, "stream()"); + return mediaRetrievalService.stream(subsonic.getParams(), id, maxBitRate, format); + } + + public Call 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; + } +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/mediaretrieval/MediaRetrievalService.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/mediaretrieval/MediaRetrievalService.java new file mode 100644 index 00000000..70bd3d57 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/mediaretrieval/MediaRetrievalService.java @@ -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 stream(@QueryMap Map params, String id, int maxBitRate, String format); + + @GET("download?id={id}") + Call download(@QueryMap Map params, String id); +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/playlist/PlaylistClient.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/playlist/PlaylistClient.java new file mode 100644 index 00000000..40fabc1d --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/playlist/PlaylistClient.java @@ -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 getPlaylists() { + Log.d(TAG, "getPlaylists()"); + return playlistService.getPlaylists(subsonic.getParams()); + } + + public Call 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; + } +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/playlist/PlaylistService.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/playlist/PlaylistService.java new file mode 100644 index 00000000..42a0e0ae --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/playlist/PlaylistService.java @@ -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 getPlaylists(@QueryMap Map params); + + @GET("getPlaylist?id={id}") + Call getPlaylist(@QueryMap Map params, String id); +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/searching/SearchingClient.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/searching/SearchingClient.java new file mode 100644 index 00000000..e553a671 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/searching/SearchingClient.java @@ -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 search2(String query) { + Log.d(TAG, "search2()"); + return searchingService.search2(subsonic.getParams(), query); + } + + public Call 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; + } +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/api/searching/SearchingService.java b/app/src/main/java/com/cappielloantonio/play/subsonic/api/searching/SearchingService.java new file mode 100644 index 00000000..2a71806b --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/api/searching/SearchingService.java @@ -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 search2(@QueryMap Map params, String query); + + @GET("search3?query={query}") + Call search3(@QueryMap Map params, String query); +} diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java index e6ece85f..457e5ee6 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java @@ -1,52 +1,67 @@ package com.cappielloantonio.play.subsonic.models; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; public class SubsonicResponse { - protected Error error; - protected ScanStatus scanStatus; - protected TopSongs topSongs; - protected SimilarSongs2 similarSongs2; - protected SimilarSongs similarSongs; - protected ArtistInfo2 artistInfo2; - protected ArtistInfo artistInfo; - protected AlbumInfo albumInfo; - protected Starred2 starred2; - protected Starred starred; - protected Shares shares; - protected PlayQueue playQueue; - protected Bookmarks bookmarks; - protected InternetRadioStations internetRadioStations; - protected NewestPodcasts newestPodcasts; - protected Podcasts podcasts; - protected Lyrics lyrics; - protected Songs songsByGenre; - protected Songs randomSongs; - protected AlbumList2 albumList2; - protected AlbumList albumList; - protected ChatMessages chatMessages; - protected User user; - protected Users users; - protected License license; - protected JukeboxPlaylist jukeboxPlaylist; - protected JukeboxStatus jukeboxStatus; - protected PlaylistWithSongs playlist; - protected Playlists playlists; - protected SearchResult3 searchResult3; - protected SearchResult2 searchResult2; - protected SearchResult searchResult; - protected NowPlaying nowPlaying; - protected VideoInfo videoInfo; - protected Videos videos; - protected Child song; - protected AlbumWithSongsID3 album; - protected ArtistWithAlbumsID3 artist; - protected ArtistsID3 artists; - protected Genres genres; - protected Directory directory; - protected Indexes indexes; - protected MusicFolders musicFolders; - protected ResponseStatus status; - protected String version; + @SerializedName("error") + @Expose + public Error error; + + public ScanStatus scanStatus; + public TopSongs topSongs; + public SimilarSongs2 similarSongs2; + public SimilarSongs similarSongs; + public ArtistInfo2 artistInfo2; + public ArtistInfo artistInfo; + public AlbumInfo albumInfo; + public Starred2 starred2; + public Starred starred; + public Shares shares; + public PlayQueue playQueue; + public Bookmarks bookmarks; + public InternetRadioStations internetRadioStations; + public NewestPodcasts newestPodcasts; + public Podcasts podcasts; + public Lyrics lyrics; + public Songs songsByGenre; + public Songs randomSongs; + public AlbumList2 albumList2; + public AlbumList albumList; + public ChatMessages chatMessages; + public User user; + public Users users; + public License license; + public JukeboxPlaylist jukeboxPlaylist; + public JukeboxStatus jukeboxStatus; + public PlaylistWithSongs playlist; + public Playlists playlists; + public SearchResult3 searchResult3; + public SearchResult2 searchResult2; + public SearchResult searchResult; + public NowPlaying nowPlaying; + public VideoInfo videoInfo; + public Videos videos; + public Child song; + public AlbumWithSongsID3 album; + public ArtistWithAlbumsID3 artist; + public ArtistsID3 artists; + public Genres genres; + public Directory directory; + 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. @@ -947,4 +962,25 @@ public class SubsonicResponse { public void setVersion(String 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; + } + }