Fix error getting local videos
This commit is contained in:
parent
6784b5ebbe
commit
da1d3e301e
|
@ -16,7 +16,7 @@ open class Client {
|
||||||
val url = URL("https://${ManagerSingleton.url}/api/v1/$uri")
|
val url = URL("https://${ManagerSingleton.url}/api/v1/$uri")
|
||||||
val con = url.openConnection() as HttpURLConnection
|
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("Content-Type", "application/x-www-form-urlencoded")
|
||||||
con.setRequestProperty("Accept", "*/*")
|
con.setRequestProperty("Accept", "*/*")
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.libre.agosto.p2play.ajax
|
package org.libre.agosto.p2play.ajax
|
||||||
|
|
||||||
import android.util.JsonReader
|
import android.util.JsonReader
|
||||||
import android.util.JsonToken
|
|
||||||
import org.libre.agosto.p2play.ManagerSingleton
|
import org.libre.agosto.p2play.ManagerSingleton
|
||||||
import org.libre.agosto.p2play.models.VideoModel
|
import org.libre.agosto.p2play.models.VideoModel
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
@ -30,12 +29,11 @@ class Videos: Client() {
|
||||||
return videos
|
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 nsfw = ManagerSingleton.nfsw
|
||||||
val count = ManagerSingleton.videos_count
|
val count = ManagerSingleton.videos_count
|
||||||
var params = "start=$start&count=$count&sort=$sort&nsfw=$nsfw"
|
var params = "start=$start&count=$count&sort=$sort&nsfw=$nsfw&isLocal=$isLocal"
|
||||||
if(filter != "")
|
|
||||||
params+="&filter=$filter"
|
|
||||||
val con = this._newCon("videos?$params","GET")
|
val con = this._newCon("videos?$params","GET")
|
||||||
var videos = arrayListOf<VideoModel>()
|
var videos = arrayListOf<VideoModel>()
|
||||||
try {
|
try {
|
||||||
|
@ -65,7 +63,7 @@ class Videos: Client() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLocalVideos(start:Int = 0): ArrayList<VideoModel>{
|
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>{
|
fun myVideos(token: String, start: Int = 0): ArrayList<VideoModel>{
|
||||||
|
@ -99,6 +97,10 @@ class Videos: Client() {
|
||||||
val data = JsonReader(response)
|
val data = JsonReader(response)
|
||||||
videos = parseVideos(data)
|
videos = parseVideos(data)
|
||||||
data.close()
|
data.close()
|
||||||
|
} else {
|
||||||
|
val response = InputStreamReader(con.inputStream)
|
||||||
|
val data = JsonReader(response)
|
||||||
|
print(data)
|
||||||
}
|
}
|
||||||
} catch(err:Exception){
|
} catch(err:Exception){
|
||||||
err.printStackTrace()
|
err.printStackTrace()
|
||||||
|
|
|
@ -95,9 +95,9 @@
|
||||||
<string name="showMore">Show more</string>
|
<string name="showMore">Show more</string>
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
<string name="subscribeMsg">You have subscribed to this channel</string>
|
<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="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="errorCommentaryMsg">An error has occurred, try again</string>
|
||||||
<string name="emptyCommentaryMsg">Please make a comment first</string>
|
<string name="emptyCommentaryMsg">Please make a comment first</string>
|
||||||
<!-- End Reproductor strings -->
|
<!-- End Reproductor strings -->
|
||||||
|
|
Loading…
Reference in New Issue