Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote sync #623

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
1122137
feat: add remote sync capability - POC
Chiff Apr 3, 2023
100d3da
feat: add remote sync capability - fix build.gradle.kts
Chiff Apr 3, 2023
d50fbe5
feat: add remote sync capability - fix build.gradle.kts, remove unuse…
Chiff Apr 3, 2023
5ec4439
feat: add remote sync capability - update scheduling logic
Chiff Apr 4, 2023
92578e5
feat: add remote sync capability - improve downloading
Chiff Apr 4, 2023
b77aecf
feat: add remote sync capability - update notes
Chiff Apr 4, 2023
3d53ac6
Merge branch 'master' into feature/remote-sync
Chiff Apr 21, 2023
f4dfd2f
feat: add remote sync capability - refactor and improve syncing when …
Chiff Apr 22, 2023
e1e039b
feat: add remote sync capability - refactor and improve syncing when …
Chiff Apr 22, 2023
fe36b69
feat: add remote sync capability - refactor, refresh ui on restore an…
Chiff May 1, 2023
7145bef
feat: add remote sync capability - schedule updates only when value w…
Chiff May 3, 2023
78b0cad
Merge branch 'recloudstream:master' into feature/remote-sync
Chiff May 8, 2023
842ac5f
feat: add remote sync capability - run upload on activity destroy
Chiff May 8, 2023
13978f8
feat: add remote sync capability - update sync meta only if backup ap…
Chiff May 8, 2023
de3019b
feat: add remote sync capability - fix file exists check
Chiff May 8, 2023
dee51d8
feat: add remote sync capability - fix sync/restore logic
Chiff May 8, 2023
0405cdc
feat: add remote sync capability - downloader will now wait when uplo…
Chiff May 8, 2023
13d9cee
feat: add remote sync capability - add info button in login dialog
Chiff May 8, 2023
2557d82
feat: add remote sync capability - add info button in login dialog
MarekFilo May 13, 2023
4b28bf9
fix: add remote sync capability - fix icon for flashbang theme
Chiff Jun 11, 2023
05705b1
fix: add remote sync capability - fix icon backup import from older v…
Chiff Jun 11, 2023
0fb2e68
Merge branch 'master' into feature/remote-sync
Chiff Jun 22, 2023
2c0e40a
Lower targetSdk to get all installed packages
CranberrySoup Aug 23, 2023
dead501
Merge branch 'master' of https://github.com/CranberrySoup/cloudstream
CranberrySoup Aug 23, 2023
cbebafb
Update sdk version
CranberrySoup Sep 4, 2023
3c3ca21
Let's not be too radical
CranberrySoup Sep 4, 2023
fb94cc8
Merge remote-tracking branch 'origin/master'
CranberrySoup Sep 15, 2023
6dc3b10
Merge branch 'recloudstream:master' into master
CranberrySoup Sep 15, 2023
45ecc90
Merge remote-tracking branch 'origin/master'
CranberrySoup Sep 15, 2023
6e89ed9
Many fixes
CranberrySoup Sep 15, 2023
71ae9a5
Revert targetSdk
CranberrySoup Sep 15, 2023
65c9274
Make account homepage persistent
CranberrySoup Sep 15, 2023
05dd490
Merge branch 'recloudstream:master' into master
CranberrySoup Sep 22, 2023
361a5bb
Merge branch 'feature/remote-sync' into sync
CranberrySoup Sep 22, 2023
f8603a7
Merge pull request #1 from CranberrySoup/sync
CranberrySoup Sep 22, 2023
2c3bdaf
fix conflicts
CranberrySoup Sep 22, 2023
923e93a
Google profile picture
CranberrySoup Oct 27, 2023
4b7fc62
Add Pcloud and refactor
CranberrySoup Oct 29, 2023
9e85359
Safer API and fixed syncing resume watching
CranberrySoup Oct 31, 2023
09f0a1b
Removed androidx.browser
CranberrySoup Oct 31, 2023
3bd7b95
Merge branch 'master' into feature/remote-sync
CranberrySoup Oct 31, 2023
6fc45f6
Fix merge issues
CranberrySoup Oct 31, 2023
7486d89
Small fixes
CranberrySoup Oct 31, 2023
744d1eb
Merge branch 'master' into feature/remote-sync
CranberrySoup Nov 17, 2023
6b4b212
Update app/src/main/res/layout/add_account_input_oauth.xml
CranberrySoup Nov 17, 2023
bbcb70c
Moved drawable
CranberrySoup Nov 17, 2023
c329587
Merge remote-tracking branch 'origin/feature/remote-sync' into featur…
CranberrySoup Nov 17, 2023
c5ba7d7
Merge branch 'master' into feature/remote-sync
fire-light42 Mar 13, 2024
f332875
Update LibraryFragment.kt
fire-light42 Mar 13, 2024
d11dd16
Update InAppUpdater.kt
fire-light42 Mar 13, 2024
3b03665
Update settings_account.xml
fire-light42 Mar 13, 2024
afaa06e
Merge branch 'feature/remote-sync' into master
Luna712 Jun 12, 2024
37e81b7
Fix
Luna712 Jun 12, 2024
7b33af7
Merge pull request #2 from Luna712/master
CranberrySoup Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
.externalNativeBuild
.cxx
local.properties
/.idea
41 changes: 41 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream
import java.net.URL
import java.util.Properties
import java.io.FileInputStream

plugins {
id("com.android.application")
Expand All @@ -26,6 +28,15 @@ fun String.execute() = ByteArrayOutputStream().use { baot ->
else null
}

val localProperties = Properties()
try {
localProperties.load(FileInputStream(rootProject.file("local.properties")))
} catch (_: Exception) {
localProperties.setProperty("debug.gdrive.clientId", "")
localProperties.setProperty("debug.gdrive.secret", "")
}


android {
testOptions {
unitTests.isReturnDefaultValues = true
Expand Down Expand Up @@ -112,6 +123,16 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
resValue(
"string",
"debug_gdrive_secret",
localProperties.getProperty("debug.gdrive.secret") ?: ""
)
resValue(
"string",
"debug_gdrive_clientId",
localProperties.getProperty("debug.gdrive.clientId") ?: ""
)
}
}

Expand Down Expand Up @@ -229,6 +250,26 @@ dependencies {
^ Don't Bump Jackson above 2.13.1 , Crashes on Android TV's and FireSticks that have Min API
Level 25 or Less. */

// color palette for images -> colors
implementation("androidx.palette:palette-ktx:1.0.0")

implementation("org.skyscreamer:jsonassert:1.2.3")
implementation("com.google.api-client:google-api-client:2.0.0") {
exclude(
group = "org.apache.httpcomponents",
)
}
implementation("com.google.oauth-client:google-oauth-client-jetty:1.34.1") {
exclude(
group = "org.apache.httpcomponents",
)
}
implementation("com.google.apis:google-api-services-drive:v3-rev20220815-2.0.0") {
exclude(
group = "org.apache.httpcomponents",
)
}

// Downloading & Networking
implementation("androidx.work:work-runtime:2.9.0")
implementation("androidx.work:work-runtime-ktx:2.9.0")
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import com.lagradost.cloudstream3.plugins.PluginManager.loadAllOnlinePlugins
import com.lagradost.cloudstream3.plugins.PluginManager.loadSinglePlugin
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
import com.lagradost.cloudstream3.services.SubscriptionWorkManager
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.BackupApis
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.OAuth2Apis
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.accountManagers
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appString
Expand Down Expand Up @@ -314,6 +315,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener,
val mainPluginsLoadedEvent =
Event<Boolean>() // homepage api, used to speed up time to load for homepage
val afterRepositoryLoadedEvent = Event<Boolean>()
val afterBackupRestoreEvent = Event<Unit>()

// kinda shitty solution, but cant com main->home otherwise for popups
val bookmarksUpdatedEvent = Event<Boolean>()
Expand Down Expand Up @@ -697,6 +699,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener,
broadcastIntent.setClass(this, VideoDownloadRestartReceiver::class.java)
this.sendBroadcast(broadcastIntent)
afterPluginsLoadedEvent -= ::onAllPluginsLoaded
// run sync before app quits
BackupApis.forEach { it.scheduleUpload() }
super.onDestroy()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lagradost.cloudstream3.syncproviders

import androidx.annotation.WorkerThread
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKeys
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
Expand All @@ -14,18 +15,26 @@ abstract class AccountManager(private val defIndex: Int) : AuthAPI {
val simklApi = SimklApi(0)
val addic7ed = Addic7ed()
val subDlApi = SubDlApi(0)
val googleDriveApi = GoogleDriveApi(0)
val pcloudApi = PcloudApi(0)
val localListApi = LocalList()

// used to login via app intent
val OAuth2Apis
get() = listOf<OAuth2API>(
malApi, aniListApi, simklApi
malApi, aniListApi, simklApi, googleDriveApi, pcloudApi
)

// this needs init with context and can be accessed in settings
val accountManagers
get() = listOf(
malApi, aniListApi, openSubtitlesApi, subDlApi, simklApi //nginxApi
malApi,
aniListApi,
openSubtitlesApi,
subDlApi,
simklApi,
googleDriveApi,
pcloudApi //, nginxApi
)

// used for active syncing
Expand All @@ -34,10 +43,18 @@ abstract class AccountManager(private val defIndex: Int) : AuthAPI {
SyncRepo(malApi), SyncRepo(aniListApi), SyncRepo(localListApi), SyncRepo(simklApi)
)

// used for active backup
val BackupApis
get() = listOf<SafeBackupAPI>(
googleDriveApi, pcloudApi
)

val inAppAuths
get() = listOf<InAppAuthAPIManager>(
get() = listOf(
openSubtitlesApi,
subDlApi
subDlApi,
googleDriveApi,
pcloudApi
)//, nginxApi)

val subtitleProviders
Expand Down Expand Up @@ -87,12 +104,18 @@ abstract class AccountManager(private val defIndex: Int) : AuthAPI {

var accountIndex = defIndex
private var lastAccountIndex = defIndex
protected val accountId get() = "${idPrefix}_account_$accountIndex"
val accountId get() = "${idPrefix}_account_$accountIndex"
private val accountActiveKey get() = "${idPrefix}_active"

// int array of all accounts indexes
private val accountsKey get() = "${idPrefix}_accounts"


// runs on startup
@WorkerThread
open suspend fun initialize() {
}

protected fun removeAccountKeys() {
removeKeys(accountId)
val accounts = getAccounts()?.toMutableList() ?: mutableListOf()
Expand All @@ -119,6 +142,7 @@ abstract class AccountManager(private val defIndex: Int) : AuthAPI {
lastAccountIndex = accountIndex
accountIndex = (accounts?.maxOrNull() ?: 0) + 1
}

protected fun switchToOldAccount() {
accountIndex = lastAccountIndex
}
Expand Down
Loading