Fix error getting local videos

This commit is contained in:
Ivan Agosto 2024-03-19 21:42:26 -06:00
parent 6784b5ebbe
commit da1d3e301e
3 changed files with 11 additions and 9 deletions

View File

@ -16,7 +16,7 @@ open class Client {
val url = URL("https://${ManagerSingleton.url}/api/v1/$uri")
val con = url.openConnection() as HttpURLConnection
con.setRequestProperty("User-Agent", "P2play/0.1")
con.setRequestProperty("User-Agent", "P2play/0.5.3")
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
con.setRequestProperty("Accept", "*/*")

View File

@ -1,7 +1,6 @@
package org.libre.agosto.p2play.ajax
import android.util.JsonReader
import android.util.JsonToken
import org.libre.agosto.p2play.ManagerSingleton
import org.libre.agosto.p2play.models.VideoModel
import java.io.InputStreamReader
@ -30,12 +29,11 @@ class Videos: Client() {
return videos
}
private fun getVideos(start:Int, sort:String = "-publishedAt", filter:String = ""):ArrayList<VideoModel>{
private fun getVideos(start:Int, sort:String = "-publishedAt", isLocal:Boolean = false):ArrayList<VideoModel>{
val nsfw = ManagerSingleton.nfsw
val count = ManagerSingleton.videos_count
var params = "start=$start&count=$count&sort=$sort&nsfw=$nsfw"
if(filter != "")
params+="&filter=$filter"
var params = "start=$start&count=$count&sort=$sort&nsfw=$nsfw&isLocal=$isLocal"
val con = this._newCon("videos?$params","GET")
var videos = arrayListOf<VideoModel>()
try {
@ -65,7 +63,7 @@ class Videos: Client() {
}
fun getLocalVideos(start:Int = 0): ArrayList<VideoModel>{
return this.getVideos(start,"-publishedAt", "local")
return this.getVideos(start,"-publishedAt", true)
}
fun myVideos(token: String, start: Int = 0): ArrayList<VideoModel>{
@ -99,6 +97,10 @@ class Videos: Client() {
val data = JsonReader(response)
videos = parseVideos(data)
data.close()
} else {
val response = InputStreamReader(con.inputStream)
val data = JsonReader(response)
print(data)
}
} catch(err:Exception){
err.printStackTrace()

View File

@ -95,9 +95,9 @@
<string name="showMore">Show more</string>
<!-- Messages -->
<string name="subscribeMsg">You have subscribed to this channel</string>
<string name="rateMsg">You rated the video</string>
<string name="rateMsg">You have rated the video</string>
<string name="unSubscribeMsg">You have unsubscribed from this channel</string>
<string name="makedCommentaryMsg">You commented on this video</string>
<string name="makedCommentaryMsg">You have commented on this video</string>
<string name="errorCommentaryMsg">An error has occurred, try again</string>
<string name="emptyCommentaryMsg">Please make a comment first</string>
<!-- End Reproductor strings -->