This commit is contained in:
Thomas 2020-12-18 16:49:18 +01:00
parent 83e7c41ca0
commit d5a0dcb980
2 changed files with 74 additions and 24 deletions

View File

@ -184,27 +184,56 @@ public interface PeertubeService {
//Timelines Authenticated
//Subscriber timeline
@GET("users/me/subscriptions/videos?sort=-publishedAt")
Call<VideoData> getSubscriptionVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
Call<VideoData> getSubscriptionVideos(
@Header("Authorization") String credentials,
@Query("start") String maxId,
@Query("count") String coun,
@Query("nsfw") boolean nsfwt,
@Query("languageOneOf") List<String> languageOneOf);
//Overview videos
@GET("overviews/videos")
Call<OverviewVideo> getOverviewVideos(@Header("Authorization") String credentials, @Query("page") String page, @Query("languageOneOf") List<String> languageOneOf);
Call<OverviewVideo> getOverviewVideos(
@Header("Authorization") String credentials,
@Query("page") String page,
@Query("nsfw") boolean nsfw,
@Query("languageOneOf") List<String> languageOneOf);
//Most liked videos
@GET("videos?sort=-likes")
Call<VideoData> getMostLikedVideos(@Header("Authorization") String credentials, @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("nsfw") boolean nsfw,
@Query("languageOneOf") List<String> languageOneOf);
//Trending videos
@GET("videos?sort=-trending")
Call<VideoData> getTrendingVideos(@Header("Authorization") String credentials, @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("nsfw") boolean nsfw,
@Query("languageOneOf") List<String> languageOneOf);
//Recently added videos
@GET("videos?sort=-publishedAt")
Call<VideoData> getRecentlyAddedVideos(@Header("Authorization") String credentials, @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("nsfw") boolean nsfw,
@Query("languageOneOf") List<String> languageOneOf);
//Local videos
@GET("videos?sort=-publishedAt&filter=local")
Call<VideoData> getLocalVideos(@Header("Authorization") String credentials, @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("nsfw") boolean nsfw,
@Query("languageOneOf") List<String> languageOneOf);
//History
@GET("users/me/history/videos")
@ -212,6 +241,7 @@ public interface PeertubeService {
@Header("Authorization") String credentials,
@Query("start") String maxId,
@Query("count") String count,
@Query("nsfw") boolean nsfw,
@Query("startDate") String startDate,
@Query("endDate") String endDate
);
@ -226,7 +256,8 @@ public interface PeertubeService {
@Header("Authorization") String credentials,
@Query("search") String search,
@Query("start") String maxId,
@Query("count") String count);
@Query("count") String count,
@Query("nsfw") boolean nsfw);
//Search channels
@GET("search/video-channels")
@ -243,7 +274,8 @@ public interface PeertubeService {
@Header("Authorization") String credentials,
@Query("tagsOneOf") List<String> tagsOneOf,
@Query("start") String maxId,
@Query("count") String count);
@Query("count") String count,
@Query("nsfw") boolean nsfw);
//Get notifications
@GET("users/me/notifications")
@ -269,9 +301,14 @@ public interface PeertubeService {
@GET("users/me/videos?sort=-publishedAt")
Call<VideoData> getMyVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count);
//Get my video
//Get user videos
@GET("accounts/{name}/videos?sort=-publishedAt")
Call<VideoData> getVideosForAccount(@Path("name") String name, @Query("start") String maxId, @Query("count") String count);
Call<VideoData> getVideosForAccount(
@Path("name") String name,
@Query("start") String maxId,
@Query("count") String count,
@Query("nsfw") boolean nsfw
);
@Multipart
@PUT("videos/{id}")
@ -318,7 +355,11 @@ public interface PeertubeService {
Call<ChannelData> getAllChannels();
@GET("video-channels/{channelHandle}/videos")
Call<VideoData> getChannelVideos(@Path("channelHandle") String channelHandle, @Query("start") String maxId, @Query("count") String count);
Call<VideoData> getChannelVideos(
@Path("channelHandle") String channelHandle,
@Query("start") String maxId,
@Query("count") String count,
@Query("nsfw") boolean nsfw);
@POST("video-channels")
Call<ChannelData.ChannelCreation> addChannel(@Header("Authorization") String credentials, @Body ChannelParams channelParams);

View File

@ -100,6 +100,7 @@ public class RetrofitPeertubeAPI {
private final String count;
private String token;
private Set<String> selection;
private boolean showNSFWVideos = true;
public RetrofitPeertubeAPI(Context context) {
_context = context;
@ -107,6 +108,10 @@ public class RetrofitPeertubeAPI {
finalUrl = "https://" + HelperInstance.getLiveInstance(context) + "/api/v1/";
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
String currentSensitive = sharedpreferences.getString(_context.getString(R.string.set_video_sensitive_choice), Helper.BLUR);
if (currentSensitive.compareTo(Helper.DO_NOT_LIST) == 0) {
showNSFWVideos = false;
}
}
public RetrofitPeertubeAPI(Context context, String instance, String token) {
@ -116,6 +121,10 @@ public class RetrofitPeertubeAPI {
finalUrl = "https://" + instance + "/api/v1/";
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
String currentSensitive = sharedpreferences.getString(_context.getString(R.string.set_video_sensitive_choice), Helper.BLUR);
if (currentSensitive.compareTo(Helper.DO_NOT_LIST) == 0) {
showNSFWVideos = false;
}
}
@ -336,7 +345,7 @@ public class RetrofitPeertubeAPI {
public APIResponse getVideosForChannel(String channelId, String max_id) {
APIResponse apiResponse = new APIResponse();
PeertubeService peertubeService = init();
Call<VideoData> videoCall = peertubeService.getChannelVideos(channelId, max_id, count);
Call<VideoData> videoCall = peertubeService.getChannelVideos(channelId, max_id, count, showNSFWVideos);
if (videoCall != null) {
try {
Response<VideoData> response = videoCall.execute();
@ -381,7 +390,7 @@ public class RetrofitPeertubeAPI {
public APIResponse getHistory(String max_id, String startDate, String endDate) {
APIResponse apiResponse = new APIResponse();
PeertubeService peertubeService = init();
Call<VideoData> videoCall = peertubeService.getHistory(getToken(), max_id, count, startDate, endDate);
Call<VideoData> videoCall = peertubeService.getHistory(getToken(), max_id, count, showNSFWVideos, startDate, endDate);
if (videoCall != null) {
try {
Response<VideoData> response = videoCall.execute();
@ -410,29 +419,29 @@ public class RetrofitPeertubeAPI {
videoCall = peertubeService.getMyVideos(getToken(), max_id, count);
break;
case ACCOUNT_VIDEOS:
videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count);
videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count, showNSFWVideos);
break;
case SUBSCRIBTIONS:
if (forAccount == null) {
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, filter);
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, showNSFWVideos, filter);
} else {
videoCall = peertubeService.getChannelVideos(forAccount, max_id, count);
videoCall = peertubeService.getChannelVideos(forAccount, max_id, count, showNSFWVideos);
}
break;
case MOST_LIKED:
videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, filter);
videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, showNSFWVideos, filter);
break;
case LOCAL:
videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, filter);
videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, showNSFWVideos, filter);
break;
case TRENDING:
videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, filter);
videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, showNSFWVideos, filter);
break;
case HISTORY:
videoCall = peertubeService.getHistory(getToken(), max_id, count, null, null);
videoCall = peertubeService.getHistory(getToken(), max_id, count, showNSFWVideos, null, null);
break;
case RECENT:
videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, filter);
videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, showNSFWVideos, filter);
break;
}
if (videoCall != null) {
@ -463,7 +472,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(getToken(), page, filter);
Call<OverviewVideo> overviewVideoCall = peertubeService.getOverviewVideos(getToken(), page, showNSFWVideos, filter);
try {
Response<OverviewVideo> response = overviewVideoCall.execute();
if (response.isSuccessful() && response.body() != null) {
@ -903,7 +912,7 @@ public class RetrofitPeertubeAPI {
*/
public APIResponse searchNextVideos(List<String> tags) {
PeertubeService peertubeService = init();
Call<VideoData> searchVideosCall = peertubeService.searchNextVideo(getToken(), tags, "0", "20");
Call<VideoData> searchVideosCall = peertubeService.searchNextVideo(getToken(), tags, "0", "20", showNSFWVideos);
APIResponse apiResponse = new APIResponse();
try {
Response<VideoData> response = searchVideosCall.execute();
@ -929,7 +938,7 @@ public class RetrofitPeertubeAPI {
*/
public APIResponse searchPeertube(String query, String max_id) {
PeertubeService peertubeService = init();
Call<VideoData> searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count);
Call<VideoData> searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count, showNSFWVideos);
APIResponse apiResponse = new APIResponse();
try {
Response<VideoData> response = searchVideosCall.execute();