mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
change fetch instances
This commit is contained in:
parent
ae713e3ef1
commit
bd77249443
@ -53,7 +53,7 @@ interface PipedApi {
|
||||
suspend fun unsubscribe(@Header("Authorization") token: String, @Body subscribe: Subscribe): Message
|
||||
|
||||
//only for fetching servers list
|
||||
@GET("Instances.md")
|
||||
suspend fun getInstances(): String
|
||||
@GET
|
||||
suspend fun getInstances(@Url url: String): List<Instances>
|
||||
|
||||
}
|
@ -48,16 +48,9 @@ class Settings : PreferenceFragmentCompat() {
|
||||
}
|
||||
|
||||
private fun fetchInstance() {
|
||||
val api: PipedApi by lazy{
|
||||
Retrofit.Builder()
|
||||
.baseUrl("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/")
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.build()
|
||||
.create(PipedApi::class.java)
|
||||
}
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
api.getInstances()
|
||||
RetrofitInstance.api.getInstances("https://instances.tokhmi.xyz/")
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e("settings", "IOException, you might not have internet connection")
|
||||
@ -72,20 +65,9 @@ class Settings : PreferenceFragmentCompat() {
|
||||
//println("dafaq $response")
|
||||
val listEntries: MutableList<String> = ArrayList()
|
||||
val listEntryValues: MutableList<String> = ArrayList()
|
||||
var skipped = 0
|
||||
val lines = response.split("\n")
|
||||
for(line in lines) {
|
||||
val split = line.split("|")
|
||||
if (split.size == 5) {
|
||||
if (skipped < 2) {
|
||||
skipped++
|
||||
}else{
|
||||
println("dafaq $line")
|
||||
listEntries.add(split[0])
|
||||
listEntryValues.add(split[1])
|
||||
}
|
||||
}
|
||||
|
||||
for(item in response){
|
||||
listEntries.add(item.name!!)
|
||||
listEntryValues.add(item.api_url!!)
|
||||
}
|
||||
val entries = listEntries.toTypedArray<CharSequence>()
|
||||
val entryValues = listEntryValues.toTypedArray<CharSequence>()
|
||||
|
12
app/src/main/java/com/github/libretube/obj/Instances.kt
Normal file
12
app/src/main/java/com/github/libretube/obj/Instances.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package com.github.libretube.obj
|
||||
|
||||
data class Instances(
|
||||
var name: String? = null,
|
||||
var api_url: String? = null,
|
||||
var locations: String? = null,
|
||||
var version: String? = null,
|
||||
var up_to_date: Boolean? = null,
|
||||
var cdn: Boolean? = null,
|
||||
var registered: Long? = null,
|
||||
var last_checked: Long? = null
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user