cloudstream
cloudstream copied to clipboard
GitHub account
Looks good, @LagradOst ?
Is there anything missing or incomplete? I can help if there's anything :pray:
The main functions (backupGithub & restorePromptGithub) are working for me, we now need to decide if it's best to add a dedicated "backup data on cloud" button or to make it do that automatically or both. Also before merging I think someone else should compile it and try all the features to see if it's actually working fine.
Can you explain how it works in layman terms?
Basically the current backup feature already coded in cloudstream works thanks to two main functions: Backup () writes and stores in the phone memory a txt file with the user data RestorePrompt() use the txt file the user selects and convert back the txt into cloudstream data
This cloud solutions mimics this procedure BackupGithub() creates a gist in your gist.github account and uploads there the txt file made by backup(). In order to do that you need to provide a GitHub token for authentication RestorePromptGithub() simply downloads the gist and uses the current RestorePrompt()
After logging in , every time we open CS3 , it downloads and uploads the text(back up data) right?
I only coded backupGithub & restorePromptGithub, the logic regarding how to automate the process is not there yet. I was in fact asking if it's best to add a dedicated "backup data on cloud" button or to make it do that automatically or both.
I think it should be automatic. We use multiple devices(me personally tv, laptop, phone). We can just continue from another device without doing anything. Or maybe options for automatic and and dedicated button???
Okay for automatic restoration I'm thinking something like
ioSafe {
initAll()
// No duplicates (which can happen by registerMainAPI)
apis = allProviders.distinctBy { it }
if (githubApi.getLatestLoginData() != null && settingsManager.getBoolean(getString(R.string.automatic_cloud_backups), false)){
this.restorePromptGithub()
}
}
at https://github.com/recloudstream/cloudstream/blob/master/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt#L584 and something like
override fun onDestroy() {
val broadcastIntent = Intent()
broadcastIntent.action = "restart_service"
broadcastIntent.setClass(this, VideoDownloadRestartReceiver::class.java)
if (githubApi.getLatestLoginData() != null && settingsManager.getBoolean(getString(R.string.automatic_cloud_backups), false)) {
this.backupGithub()
}
this.sendBroadcast(broadcastIntent)
afterPluginsLoadedEvent -= ::onAllPluginsLoaded
super.onDestroy()
}
At https://github.com/recloudstream/cloudstream/blob/master/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt#L400 I am not 100% this will cause a race condition since its threaded, but if you ever see that it does not backup the data to github try moving it to the onStop or lastly onPause
This would assume you had a switch in settings with the key R.string.automatic_cloud_backups :+1: Why have a button, when you can just toggle the automatic functionality :shrug:
There's something to fix in the restoreprompt: it looks like it's restoring cached data before it gets the backup from cloud. does it make sense?
I am not quite sure what you mean :confused:
I wasn't sure what I meant either 🤣 anyway we made some changes, it still needs testing, if someone else can compile it and test it, that would be nice
Can it backup and restore app settings?
hm. it still doesnt seem to properly push the settings to the gist
To make the home page refresh you can do the following: In the HomeFragment companion object:
val reloadStoredDataEvent = Event<Unit>()
in the onstop and onresume in homefragment.kt inlude the new method like the following
override fun onResume() {
super.onResume()
reloadStored()
afterPluginsLoadedEvent += ::firstLoadHomePage
mainPluginsLoadedEvent += ::firstLoadHomePage
reloadStoredDataEvent += ::reloadStoredEvent
}
override fun onStop() {
afterPluginsLoadedEvent -= ::firstLoadHomePage
mainPluginsLoadedEvent -= ::firstLoadHomePage
reloadStoredDataEvent -= ::reloadStoredEvent
super.onStop()
}
private fun reloadStoredEvent(input: Unit) {
reloadStored()
}
Now you can call HomeFragment.reloadStoredDataEvent.invoke(Unit) from wherever you want and it'll reload all the local data @antonydp
I tested this now on a fresh dummy account on a fresh cs3 install and got some things to say.
- the toast when exiting the app saying "saved data" is super annoying, it is better to have a toast if it fails
- It did not work for me and instead created many gist with the same name?????

- The account got fucked because it looked sus af to have an 20min old acc creating many gists. please add a note that that might happend if ppl create new accounts

I can take a look at the code too, but these are kinda important impo
closed but why?
What did this PR do?
https://github.com/recloudstream/cloudstream/pull/128#issuecomment-1675069301
https://codeberg.org/cloudstream/cloudstream/issues/426#issuecomment-849020