mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Comments API
This commit is contained in:
parent
afb56dea21
commit
d58725495b
@ -10,6 +10,9 @@ interface PipedApi {
|
|||||||
@GET("streams/{videoId}")
|
@GET("streams/{videoId}")
|
||||||
suspend fun getStreams(@Path("videoId") videoId: String): Streams
|
suspend fun getStreams(@Path("videoId") videoId: String): Streams
|
||||||
|
|
||||||
|
@GET("comments/{videoId}")
|
||||||
|
suspend fun getComments(@Path("videoId") videoId: String): CommentsPage
|
||||||
|
|
||||||
@GET("search")
|
@GET("search")
|
||||||
suspend fun getSearchResults(
|
suspend fun getSearchResults(
|
||||||
@Query("q") searchQuery: String,
|
@Query("q") searchQuery: String,
|
||||||
|
@ -253,6 +253,19 @@ class PlayerFragment : Fragment() {
|
|||||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
|
val commentsResponse = try {
|
||||||
|
RetrofitInstance.api.getComments(videoId!!)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
println(e)
|
||||||
|
Log.e(TAG, "IOException, you might not have internet connection")
|
||||||
|
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||||
|
return@launchWhenCreated
|
||||||
|
} catch (e: HttpException) {
|
||||||
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
|
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||||
|
return@launchWhenCreated
|
||||||
|
}
|
||||||
|
Toast.makeText(context, commentsResponse.disabled.toString(), Toast.LENGTH_LONG).show()
|
||||||
var videosNameArray: Array<CharSequence> = arrayOf()
|
var videosNameArray: Array<CharSequence> = arrayOf()
|
||||||
videosNameArray += "HLS"
|
videosNameArray += "HLS"
|
||||||
for (vid in response.videoStreams!!) {
|
for (vid in response.videoStreams!!) {
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package com.github.libretube.obj;
|
|
||||||
|
|
||||||
public class Comment {
|
|
||||||
public String author, thumbnail, commentId, commentText, commentedTime, commentorUrl, repliesPage;
|
|
||||||
public int likeCount;
|
|
||||||
public boolean hearted, pinned, verified;
|
|
||||||
|
|
||||||
public Comment(String author, String thumbnail, String commentId, String commentText, String commentedTime,
|
|
||||||
String commentorUrl, String repliesPage, int likeCount, boolean hearted, boolean pinned, boolean verified) {
|
|
||||||
this.author = author;
|
|
||||||
this.thumbnail = thumbnail;
|
|
||||||
this.commentId = commentId;
|
|
||||||
this.commentText = commentText;
|
|
||||||
this.commentedTime = commentedTime;
|
|
||||||
this.commentorUrl = commentorUrl;
|
|
||||||
this.repliesPage = repliesPage;
|
|
||||||
this.likeCount = likeCount;
|
|
||||||
this.hearted = hearted;
|
|
||||||
this.pinned = pinned;
|
|
||||||
this.verified = verified;
|
|
||||||
}
|
|
||||||
}
|
|
20
app/src/main/java/com/github/libretube/obj/Comment.kt
Normal file
20
app/src/main/java/com/github/libretube/obj/Comment.kt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.github.libretube.obj
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class Comment(
|
||||||
|
val author: String?,
|
||||||
|
val commentId: String?,
|
||||||
|
val commentText: String?,
|
||||||
|
val commentedTime: String?,
|
||||||
|
val commentorUrl: String?,
|
||||||
|
val hearted: Boolean?,
|
||||||
|
val likeCount: Int?,
|
||||||
|
val pinned: Boolean?,
|
||||||
|
val thumbnail: String?,
|
||||||
|
val verified: Boolean?
|
||||||
|
){
|
||||||
|
constructor(): this("", "","","","",null,0,null,"",null)
|
||||||
|
}
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.github.libretube.obj;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CommentsPage {
|
|
||||||
|
|
||||||
public List<Comment> comments;
|
|
||||||
public String nextpage;
|
|
||||||
public boolean disabled;
|
|
||||||
|
|
||||||
public CommentsPage(List<Comment> comments, String nextpage, boolean disabled) {
|
|
||||||
this.comments = comments;
|
|
||||||
this.nextpage = nextpage;
|
|
||||||
this.disabled = disabled;
|
|
||||||
}
|
|
||||||
}
|
|
12
app/src/main/java/com/github/libretube/obj/CommentsPage.kt
Normal file
12
app/src/main/java/com/github/libretube/obj/CommentsPage.kt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.libretube.obj
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class CommentsPage(
|
||||||
|
val comments: List<Comment>? = listOf(),
|
||||||
|
val disabled: Boolean? = null,
|
||||||
|
val nextpage: String? = "",
|
||||||
|
){
|
||||||
|
constructor(): this(emptyList(),null,"")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user