mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
removed unnecessary comments
This commit is contained in:
parent
e4ed0d4fcb
commit
22a04bafd2
3 changed files with 8 additions and 45 deletions
|
@ -199,7 +199,6 @@ dependencies {
|
|||
|
||||
// Library/extensions searching with Levenshtein distance
|
||||
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
||||
|
||||
}
|
||||
|
||||
task androidSourcesJar(type: Jar) {
|
||||
|
|
|
@ -33,16 +33,17 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
var userName: String,
|
||||
var userAvatar: String,
|
||||
)
|
||||
|
||||
companion object {
|
||||
const val GITHUB_USER_KEY: String = "github_user" // user data like profile
|
||||
var currentSession: GithubOAuthEntity? = null
|
||||
}
|
||||
|
||||
private fun getAuthKey(): GithubOAuthEntity? {
|
||||
return getKey(accountId, GITHUB_USER_KEY)
|
||||
}
|
||||
|
||||
|
||||
data class gistsElements (
|
||||
data class GistsElements (
|
||||
@JsonProperty("id") val gistId:String,
|
||||
@JsonProperty("files") val files: Map<String, File>,
|
||||
@JsonProperty("owner") val owner: OwnerData
|
||||
|
@ -54,6 +55,7 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
data class File (
|
||||
@JsonProperty("content") val dataRaw: String?
|
||||
)
|
||||
|
||||
data class GistRequestBody(
|
||||
@JsonProperty("description") val description: String,
|
||||
@JsonProperty("public") val public : Boolean,
|
||||
|
@ -76,7 +78,7 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
|
||||
if (!response.isSuccessful) { return false }
|
||||
|
||||
val repo = tryParseJson<List<gistsElements>>(response.text)?.filter {
|
||||
val repo = tryParseJson<List<GistsElements>>(response.text)?.filter {
|
||||
it.files.keys.first() == "Cloudstream_Backup_data.txt"
|
||||
}
|
||||
|
||||
|
@ -89,13 +91,9 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
|||
),
|
||||
requestBody = GistRequestBody("Cloudstream private backup gist", false, FilesGist(ContentFilesGist(backupData?.toJson()))).toJson().toRequestBody(
|
||||
RequestBodyTypes.JSON.toMediaTypeOrNull()))
|
||||
/*
|
||||
"""{"description":"Cloudstream private backup gist","public":false,"files":{"Cloudstream_Backup_data.txt":{"content":"initialization"}}}""".toRequestBody(
|
||||
RequestBodyTypes.JSON.toMediaTypeOrNull()))
|
||||
|
||||
*/
|
||||
if (!gitresponse.isSuccessful) {return false}
|
||||
tryParseJson<gistsElements>(gitresponse.text).let {
|
||||
tryParseJson<GistsElements>(gitresponse.text).let {
|
||||
setKey(accountId, GITHUB_USER_KEY, GithubOAuthEntity(
|
||||
token = githubToken,
|
||||
gistId = it?.gistId?: run {
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.lagradost.cloudstream3.syncproviders.providers.MALApi.Companion.MAL_U
|
|||
import com.lagradost.cloudstream3.syncproviders.providers.OpenSubtitlesApi.Companion.OPEN_SUBTITLES_USER_KEY
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||
import com.lagradost.cloudstream3.utils.BackupUtils.getBackup
|
||||
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getDefaultSharedPrefs
|
||||
|
@ -300,40 +299,7 @@ object BackupUtils {
|
|||
|
||||
val gistId = githubApi.getLatestLoginData()?.server ?: throw IllegalArgumentException ("Requires Username")
|
||||
val token = githubApi.getLatestLoginData()?.password ?: throw IllegalArgumentException ("Requires Username")
|
||||
/* ioSafe {
|
||||
val tmpDir = createTempDir()
|
||||
val gitUrl = githubApi.getLatestLoginData()?.email ?: throw IllegalArgumentException ("Requires Username")
|
||||
val token = githubApi.getLatestLoginData()?.password ?: throw IllegalArgumentException ("Requires Username")
|
||||
val git = Git.cloneRepository()
|
||||
.setURI(gitUrl)
|
||||
.setDirectory(tmpDir)
|
||||
.setTimeout(30)
|
||||
.setCredentialsProvider(
|
||||
UsernamePasswordCredentialsProvider(token, "")
|
||||
)
|
||||
.call()
|
||||
tmpDir.listFiles()?.first { it.name != ".git" }?.writeText(backup.toJson())
|
||||
git.add()
|
||||
.addFilepattern(".")
|
||||
.call()
|
||||
git.commit()
|
||||
.setAll(true)
|
||||
.setMessage("Update backup")
|
||||
.call()
|
||||
git.remoteAdd()
|
||||
.setName("origin")
|
||||
.setUri(URIish(gitUrl))
|
||||
.call()
|
||||
git.push()
|
||||
.setRemote(gitUrl)
|
||||
.setTimeout(30)
|
||||
.setCredentialsProvider(
|
||||
UsernamePasswordCredentialsProvider(token, "")
|
||||
)
|
||||
.call();
|
||||
tmpDir.deleteRecursively()
|
||||
}
|
||||
*/
|
||||
|
||||
ioSafe {
|
||||
app.patch("https://api.github.com/gists/$gistId",
|
||||
headers= mapOf(
|
||||
|
@ -358,7 +324,7 @@ object BackupUtils {
|
|||
val gistId = githubApi.getLatestLoginData()?.server ?: throw IllegalAccessException()
|
||||
val jsondata = app.get(" https://api.github.com/gists/$gistId").text
|
||||
val dataraw =
|
||||
parseJson<GithubApi.gistsElements>(jsondata ?: "").files.values.first().dataRaw
|
||||
parseJson<GithubApi.GistsElements>(jsondata ?: "").files.values.first().dataRaw
|
||||
?: throw IllegalAccessException()
|
||||
val data = parseJson<BackupFile>(dataraw)
|
||||
restore(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue