Fix issue #10
This commit is contained in:
parent
0f995cc615
commit
3353b7205b
|
@ -121,23 +121,23 @@ public interface PeertubeService {
|
|||
|
||||
//Overview videos
|
||||
@GET("overviews/videos")
|
||||
Call<OverviewVideo> getOverviewVideos(@Query("page") String page, @Query("languageOneOf") List<String> languageOneOf);
|
||||
Call<OverviewVideo> getOverviewVideos(@Header("Authorization") String credentials, @Query("page") String page, @Query("languageOneOf") List<String> languageOneOf);
|
||||
|
||||
//Most liked videos
|
||||
@GET("videos?sort=-likes")
|
||||
Call<VideoData> getMostLikedVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
Call<VideoData> getMostLikedVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
|
||||
//Most liked videos
|
||||
//Trending videos
|
||||
@GET("videos?sort=-trending")
|
||||
Call<VideoData> getTrendingVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
Call<VideoData> getTrendingVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
|
||||
//Recently added videos
|
||||
@GET("videos?sort=-publishedAt")
|
||||
Call<VideoData> getRecentlyAddedVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
Call<VideoData> getRecentlyAddedVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
|
||||
//Local videos
|
||||
@GET("videos?sort=-publishedAt&filter=local")
|
||||
Call<VideoData> getLocalVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
Call<VideoData> getLocalVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
||||
|
||||
//History
|
||||
@GET("users/me/history/videos")
|
||||
|
@ -145,7 +145,7 @@ public interface PeertubeService {
|
|||
|
||||
//Search
|
||||
@GET("search/videos")
|
||||
Call<VideoData> searchVideos(@Query("search") String search, @Query("start") String maxId, @Query("count") String count);
|
||||
Call<VideoData> searchVideos(@Header("Authorization") String credentials, @Query("search") String search, @Query("start") String maxId, @Query("count") String count);
|
||||
|
||||
//Get notifications
|
||||
@GET("users/me/notifications")
|
||||
|
|
|
@ -161,7 +161,11 @@ public class RetrofitPeertubeAPI {
|
|||
}
|
||||
|
||||
private String getToken() {
|
||||
return "Bearer " + token;
|
||||
if( token != null) {
|
||||
return "Bearer " + token;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private PeertubeService init() {
|
||||
|
@ -331,19 +335,19 @@ public class RetrofitPeertubeAPI {
|
|||
}
|
||||
break;
|
||||
case MOST_LIKED:
|
||||
videoCall = peertubeService.getMostLikedVideos(max_id, count, filter);
|
||||
videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, filter);
|
||||
break;
|
||||
case LOCAL:
|
||||
videoCall = peertubeService.getLocalVideos(max_id, count, filter);
|
||||
videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, filter);
|
||||
break;
|
||||
case TRENDING:
|
||||
videoCall = peertubeService.getTrendingVideos(max_id, count, filter);
|
||||
videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, filter);
|
||||
break;
|
||||
case HISTORY:
|
||||
videoCall = peertubeService.getHistory(getToken(), max_id, count);
|
||||
break;
|
||||
case RECENT:
|
||||
videoCall = peertubeService.getRecentlyAddedVideos(max_id, count, filter);
|
||||
videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, filter);
|
||||
break;
|
||||
}
|
||||
if (videoCall != null) {
|
||||
|
@ -374,7 +378,7 @@ public class RetrofitPeertubeAPI {
|
|||
APIResponse apiResponse = new APIResponse();
|
||||
PeertubeService peertubeService = init();
|
||||
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
||||
Call<OverviewVideo> overviewVideoCall = peertubeService.getOverviewVideos(page, filter);
|
||||
Call<OverviewVideo> overviewVideoCall = peertubeService.getOverviewVideos(getToken(), page, filter);
|
||||
try {
|
||||
Response<OverviewVideo> response = overviewVideoCall.execute();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
|
@ -647,7 +651,7 @@ public class RetrofitPeertubeAPI {
|
|||
*/
|
||||
public APIResponse searchPeertube(String query, String max_id) {
|
||||
PeertubeService peertubeService = init();
|
||||
Call<VideoData> searchVideosCall = peertubeService.searchVideos(query, max_id, count);
|
||||
Call<VideoData> searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count);
|
||||
APIResponse apiResponse = new APIResponse();
|
||||
try {
|
||||
Response<VideoData> response = searchVideosCall.execute();
|
||||
|
|
Loading…
Reference in New Issue