1
0
mirror of https://framagit.org/tom79/fedilab-tube synced 2025-04-20 21:37:28 +02:00
This commit is contained in:
Thomas 2020-10-22 08:57:51 +02:00
parent 0f995cc615
commit 3353b7205b
2 changed files with 18 additions and 14 deletions

View File

@ -121,23 +121,23 @@ public interface PeertubeService {
//Overview videos //Overview videos
@GET("overviews/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 //Most liked videos
@GET("videos?sort=-likes") @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") @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 //Recently added videos
@GET("videos?sort=-publishedAt") @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 //Local videos
@GET("videos?sort=-publishedAt&filter=local") @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 //History
@GET("users/me/history/videos") @GET("users/me/history/videos")
@ -145,7 +145,7 @@ public interface PeertubeService {
//Search //Search
@GET("search/videos") @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 notifications
@GET("users/me/notifications") @GET("users/me/notifications")

View File

@ -161,7 +161,11 @@ public class RetrofitPeertubeAPI {
} }
private String getToken() { private String getToken() {
if( token != null) {
return "Bearer " + token; return "Bearer " + token;
}else{
return null;
}
} }
private PeertubeService init() { private PeertubeService init() {
@ -331,19 +335,19 @@ public class RetrofitPeertubeAPI {
} }
break; break;
case MOST_LIKED: case MOST_LIKED:
videoCall = peertubeService.getMostLikedVideos(max_id, count, filter); videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, filter);
break; break;
case LOCAL: case LOCAL:
videoCall = peertubeService.getLocalVideos(max_id, count, filter); videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, filter);
break; break;
case TRENDING: case TRENDING:
videoCall = peertubeService.getTrendingVideos(max_id, count, filter); videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, filter);
break; break;
case HISTORY: case HISTORY:
videoCall = peertubeService.getHistory(getToken(), max_id, count); videoCall = peertubeService.getHistory(getToken(), max_id, count);
break; break;
case RECENT: case RECENT:
videoCall = peertubeService.getRecentlyAddedVideos(max_id, count, filter); videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, filter);
break; break;
} }
if (videoCall != null) { if (videoCall != null) {
@ -374,7 +378,7 @@ public class RetrofitPeertubeAPI {
APIResponse apiResponse = new APIResponse(); APIResponse apiResponse = new APIResponse();
PeertubeService peertubeService = init(); PeertubeService peertubeService = init();
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null; 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 { try {
Response<OverviewVideo> response = overviewVideoCall.execute(); Response<OverviewVideo> response = overviewVideoCall.execute();
if (response.isSuccessful() && response.body() != null) { if (response.isSuccessful() && response.body() != null) {
@ -647,7 +651,7 @@ public class RetrofitPeertubeAPI {
*/ */
public APIResponse searchPeertube(String query, String max_id) { public APIResponse searchPeertube(String query, String max_id) {
PeertubeService peertubeService = init(); 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(); APIResponse apiResponse = new APIResponse();
try { try {
Response<VideoData> response = searchVideosCall.execute(); Response<VideoData> response = searchVideosCall.execute();