LibreTube/app/src/main/java/com/github/libretube/api/PipedApi.kt

198 lines
5.9 KiB
Kotlin
Raw Normal View History

2022-08-14 13:25:28 +05:30
package com.github.libretube.api
2021-12-18 16:34:14 +05:30
2022-10-29 02:50:07 +05:30
import com.github.libretube.api.obj.Channel
2022-10-29 14:50:34 +05:30
import com.github.libretube.api.obj.ChannelTabResponse
2022-10-29 02:50:07 +05:30
import com.github.libretube.api.obj.CommentsPage
import com.github.libretube.api.obj.DeleteUserRequest
import com.github.libretube.api.obj.Login
import com.github.libretube.api.obj.Message
2022-11-21 18:42:46 +05:30
import com.github.libretube.api.obj.PipedConfig
2022-10-29 02:50:07 +05:30
import com.github.libretube.api.obj.Playlist
import com.github.libretube.api.obj.PlaylistId
import com.github.libretube.api.obj.Playlists
import com.github.libretube.api.obj.SearchResult
2022-10-29 03:09:25 +05:30
import com.github.libretube.api.obj.SegmentData
2022-10-29 02:50:07 +05:30
import com.github.libretube.api.obj.StreamItem
import com.github.libretube.api.obj.Streams
import com.github.libretube.api.obj.Subscribe
import com.github.libretube.api.obj.Subscribed
2022-10-29 02:50:07 +05:30
import com.github.libretube.api.obj.Subscription
import com.github.libretube.api.obj.Token
2022-09-22 21:31:03 +05:30
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
2021-12-18 16:34:14 +05:30
interface PipedApi {
2022-11-21 18:42:46 +05:30
@GET("config")
suspend fun getConfig(): PipedConfig
2021-12-18 16:34:14 +05:30
@GET("trending")
2022-10-29 02:50:07 +05:30
suspend fun getTrending(@Query("region") region: String): List<StreamItem>
2021-12-18 16:34:14 +05:30
@GET("streams/{videoId}")
2022-10-29 02:50:07 +05:30
suspend fun getStreams(@Path("videoId") videoId: String): Streams
2021-12-28 01:37:07 +05:30
2022-05-08 03:14:29 +05:30
@GET("comments/{videoId}")
2022-10-29 02:50:07 +05:30
suspend fun getComments(@Path("videoId") videoId: String): CommentsPage
2022-05-08 03:14:29 +05:30
2022-05-16 15:41:22 +05:30
@GET("sponsors/{videoId}")
2022-05-21 13:32:04 +05:30
suspend fun getSegments(
@Path("videoId") videoId: String,
@Query("category") category: String
2022-10-29 03:09:25 +05:30
): SegmentData
2022-05-16 15:41:22 +05:30
@GET("nextpage/comments/{videoId}")
2022-05-20 03:52:10 +05:30
suspend fun getCommentsNextPage(
@Path("videoId") videoId: String,
@Query("nextpage") nextPage: String
2022-10-29 02:50:07 +05:30
): CommentsPage
2021-12-28 01:37:07 +05:30
@GET("search")
suspend fun getSearchResults(
@Query("q") searchQuery: String,
2021-12-28 23:41:51 +05:30
@Query("filter") filter: String
2022-10-29 03:09:25 +05:30
): SearchResult
2021-12-28 01:37:07 +05:30
2022-05-15 16:42:46 +05:30
@GET("nextpage/search")
suspend fun getSearchResultsNextPage(
@Query("q") searchQuery: String,
@Query("filter") filter: String,
@Query("nextpage") nextPage: String
2022-10-29 02:50:07 +05:30
): SearchResult
2022-05-15 16:42:46 +05:30
2021-12-28 01:37:07 +05:30
@GET("suggestions")
suspend fun getSuggestions(@Query("query") query: String): List<String>
2022-02-05 00:25:05 +05:30
@GET("channel/{channelId}")
2022-10-29 02:50:07 +05:30
suspend fun getChannel(@Path("channelId") channelId: String): Channel
2022-02-05 19:39:50 +05:30
2022-10-29 14:50:34 +05:30
@GET("channels/tabs")
suspend fun getChannelTab(
@Query("data") data: String,
@Query("nextpage") nextPage: String? = null
): ChannelTabResponse
@GET("user/{name}")
2022-10-29 02:50:07 +05:30
suspend fun getChannelByName(@Path("name") channelName: String): Channel
2022-02-05 19:39:50 +05:30
@GET("nextpage/channel/{channelId}")
2022-05-20 03:52:10 +05:30
suspend fun getChannelNextPage(
@Path("channelId") channelId: String,
@Query("nextpage") nextPage: String
2022-10-29 02:50:07 +05:30
): Channel
2022-02-06 18:40:27 +05:30
@GET("playlists/{playlistId}")
2022-10-29 02:50:07 +05:30
suspend fun getPlaylist(@Path("playlistId") playlistId: String): Playlist
2022-02-06 18:40:27 +05:30
@GET("nextpage/playlists/{playlistId}")
2022-05-20 03:52:10 +05:30
suspend fun getPlaylistNextPage(
@Path("playlistId") playlistId: String,
@Query("nextpage") nextPage: String
2022-10-29 02:50:07 +05:30
): Playlist
2022-02-06 18:40:27 +05:30
2022-02-06 21:25:40 +05:30
@POST("login")
2022-10-29 02:50:07 +05:30
suspend fun login(@Body login: Login): Token
2022-02-06 21:25:40 +05:30
@POST("register")
2022-10-29 02:50:07 +05:30
suspend fun register(@Body login: Login): Token
2022-02-06 21:25:40 +05:30
2022-06-25 21:25:03 +05:30
@POST("user/delete")
suspend fun deleteAccount(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body password: DeleteUserRequest
2022-06-26 00:56:37 +05:30
)
2022-06-25 21:25:03 +05:30
2022-02-06 21:25:40 +05:30
@GET("feed")
2022-10-29 02:50:07 +05:30
suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem>
2022-02-06 21:25:40 +05:30
@GET("feed/unauthenticated")
suspend fun getUnauthenticatedFeed(
@Query("channels") channels: String
): List<StreamItem>
@POST("feed/unauthenticated")
suspend fun getUnauthenticatedFeed(
@Body channels: List<String>
): List<StreamItem>
2022-08-03 17:11:45 +05:30
2022-02-06 21:25:40 +05:30
@GET("subscribed")
2022-05-20 03:52:10 +05:30
suspend fun isSubscribed(
@Query("channelId") channelId: String,
@Header("Authorization") token: String
): Subscribed
2022-02-06 21:25:40 +05:30
@GET("subscriptions")
2022-10-29 02:50:07 +05:30
suspend fun subscriptions(@Header("Authorization") token: String): List<Subscription>
2022-02-06 21:25:40 +05:30
@GET("subscriptions/unauthenticated")
suspend fun unauthenticatedSubscriptions(
@Query("channels") channels: String
): List<Subscription>
@POST("subscriptions/unauthenticated")
suspend fun unauthenticatedSubscriptions(
@Body channels: List<String>
): List<Subscription>
2022-08-03 17:11:45 +05:30
2022-02-09 23:40:39 +05:30
@POST("subscribe")
2022-05-21 13:32:04 +05:30
suspend fun subscribe(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body subscribe: Subscribe
): Message
2022-02-09 23:40:39 +05:30
@POST("unsubscribe")
2022-05-21 13:32:04 +05:30
suspend fun unsubscribe(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body subscribe: Subscribe
): Message
2022-02-09 23:40:39 +05:30
2022-03-31 23:04:19 +05:30
@POST("import")
2022-05-20 03:52:10 +05:30
suspend fun importSubscriptions(
@Query("override") override: Boolean,
@Header("Authorization") token: String,
@Body channels: List<String>
2022-10-29 02:50:07 +05:30
): Message
2022-03-31 23:04:19 +05:30
2022-06-20 22:16:00 +05:30
@POST("import/playlist")
2022-12-08 22:45:39 +05:30
suspend fun clonePlaylist(
2022-06-20 22:16:00 +05:30
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body playlistId: PlaylistId
2022-11-05 22:11:00 +05:30
): PlaylistId
2022-06-20 22:16:00 +05:30
2022-04-12 23:55:08 +05:30
@GET("user/playlists")
2022-11-17 22:46:12 +05:30
suspend fun getUserPlaylists(@Header("Authorization") token: String): List<Playlists>
2022-04-12 23:55:08 +05:30
2022-09-10 16:07:13 +05:30
@POST("user/playlists/rename")
suspend fun renamePlaylist(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body playlistId: PlaylistId
): PlaylistId
2022-09-10 16:07:13 +05:30
2022-04-15 00:21:54 +05:30
@POST("user/playlists/delete")
2022-05-21 13:32:04 +05:30
suspend fun deletePlaylist(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body playlistId: PlaylistId
): Message
2022-04-15 00:21:54 +05:30
2022-04-15 16:56:06 +05:30
@POST("user/playlists/create")
2022-05-21 13:32:04 +05:30
suspend fun createPlaylist(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body name: Playlists
): PlaylistId
2022-04-15 16:56:06 +05:30
2022-04-18 00:20:10 +05:30
@POST("user/playlists/add")
2022-05-21 13:32:04 +05:30
suspend fun addToPlaylist(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body playlistId: PlaylistId
): Message
2022-04-18 00:20:10 +05:30
@POST("user/playlists/remove")
2022-05-20 03:52:10 +05:30
suspend fun removeFromPlaylist(
@Header("Authorization") token: String,
2022-10-29 02:50:07 +05:30
@Body playlistId: PlaylistId
): Message
2022-05-20 03:52:10 +05:30
}