mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Channel Tabs backend
This commit is contained in:
parent
8474471691
commit
36e2da52fb
@ -1,6 +1,7 @@
|
||||
package com.github.libretube.api
|
||||
|
||||
import com.github.libretube.api.obj.Channel
|
||||
import com.github.libretube.api.obj.ChannelTabResponse
|
||||
import com.github.libretube.api.obj.CommentsPage
|
||||
import com.github.libretube.api.obj.DeleteUserRequest
|
||||
import com.github.libretube.api.obj.Login
|
||||
@ -63,6 +64,12 @@ interface PipedApi {
|
||||
@GET("channel/{channelId}")
|
||||
suspend fun getChannel(@Path("channelId") channelId: String): Channel
|
||||
|
||||
@GET("channels/tabs")
|
||||
suspend fun getChannelTab(
|
||||
@Query("data") data: String,
|
||||
@Query("nextpage") nextPage: String? = null
|
||||
): ChannelTabResponse
|
||||
|
||||
@GET("user/{name}")
|
||||
suspend fun getChannelByName(@Path("name") channelName: String): Channel
|
||||
|
||||
|
@ -12,5 +12,6 @@ data class Channel(
|
||||
var nextpage: String? = null,
|
||||
var subscriberCount: Long = 0,
|
||||
var verified: Boolean = false,
|
||||
var relatedStreams: List<StreamItem>? = null
|
||||
var relatedStreams: List<StreamItem>? = listOf(),
|
||||
var tabs: List<ChannelTab>? = listOf()
|
||||
)
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.github.libretube.api.obj
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class ChannelTab(
|
||||
val name: String? = null,
|
||||
val data: String? = null
|
||||
)
|
@ -0,0 +1,6 @@
|
||||
package com.github.libretube.api.obj
|
||||
|
||||
data class ChannelTabResponse(
|
||||
val content: List<ContentItem> = listOf(),
|
||||
val nextpage: String? = null
|
||||
)
|
@ -3,7 +3,7 @@ package com.github.libretube.api.obj
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class SearchItem(
|
||||
data class ContentItem(
|
||||
var url: String? = null,
|
||||
var thumbnail: String? = null,
|
||||
var uploaderName: String? = null,
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class SearchResult(
|
||||
val items: MutableList<SearchItem>? = arrayListOf(),
|
||||
val items: MutableList<ContentItem>? = arrayListOf(),
|
||||
val nextpage: String? = "",
|
||||
val suggestion: String? = "",
|
||||
val corrected: Boolean? = null
|
||||
|
@ -8,7 +8,7 @@ import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.SubscriptionHelper
|
||||
import com.github.libretube.api.obj.SearchItem
|
||||
import com.github.libretube.api.obj.ContentItem
|
||||
import com.github.libretube.databinding.ChannelRowBinding
|
||||
import com.github.libretube.databinding.PlaylistSearchRowBinding
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
@ -26,12 +26,12 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class SearchAdapter(
|
||||
private val searchItems: MutableList<SearchItem>,
|
||||
private val searchItems: MutableList<ContentItem>,
|
||||
private val childFragmentManager: FragmentManager
|
||||
) :
|
||||
RecyclerView.Adapter<SearchViewHolder>() {
|
||||
|
||||
fun updateItems(newItems: List<SearchItem>) {
|
||||
fun updateItems(newItems: List<ContentItem>) {
|
||||
val searchItemsSize = searchItems.size
|
||||
searchItems.addAll(newItems)
|
||||
notifyItemRangeInserted(searchItemsSize, newItems.size)
|
||||
@ -81,7 +81,7 @@ class SearchAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindWatch(item: SearchItem, binding: VideoRowBinding) {
|
||||
private fun bindWatch(item: ContentItem, binding: VideoRowBinding) {
|
||||
binding.apply {
|
||||
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
||||
thumbnailDuration.setFormattedDuration(item.duration!!)
|
||||
@ -114,7 +114,7 @@ class SearchAdapter(
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun bindChannel(
|
||||
item: SearchItem,
|
||||
item: ContentItem,
|
||||
binding: ChannelRowBinding
|
||||
) {
|
||||
binding.apply {
|
||||
@ -164,7 +164,7 @@ class SearchAdapter(
|
||||
}
|
||||
|
||||
private fun bindPlaylist(
|
||||
item: SearchItem,
|
||||
item: ContentItem,
|
||||
binding: PlaylistSearchRowBinding
|
||||
) {
|
||||
binding.apply {
|
||||
|
@ -171,6 +171,14 @@ class ChannelFragment : BaseFragment() {
|
||||
)
|
||||
binding.channelRecView.adapter = channelAdapter
|
||||
}
|
||||
|
||||
response.tabs?.forEach {
|
||||
try {
|
||||
RetrofitInstance.api.getChannelTab(it.data!!).toString()
|
||||
} catch (e: Exception) {
|
||||
Log.e("error", e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user