advplyr / audiobookshelf-app

Mobile application for Audiobookshelf
https://audiobookshelf.org
GNU General Public License v3.0
1.27k stars 172 forks source link

[ENHANCEMENT]: Add a Manual Sync Button #1076

Open JSylvia007 opened 8 months ago

JSylvia007 commented 8 months ago

Is your feature request related to a problem? Please describe.

I use an aftermarket android head unit in my car (full android, not android auto), and when I turn off the car, the head unit "dies" and loses access to the internet, so the last portion of whatever I'm listening to does not sync.

Describe the solution you'd like

I'd like a "sync" button somewhere on the home screen of the app or in the 3-dot menu.

Describe alternatives you've considered

I've sit and waited and manually "backed" out of the app, but this doesn't always sync. Perhaps there is a way to manually increase the frequency that the background sync happens?

nichwall commented 8 months ago

Duplicate of https://github.com/advplyr/audiobookshelf-app/issues/590

(But this is for a button and that is a swipe event, didn't see any others for a button sync event)

advplyr commented 8 months ago

I'm wondering how to reproduce that specific issue you are having. Ideally a sync button shouldn't be necessary and so I want to see where I can make an improvement with your specific case.

As of v0.9.72-beta the offline listening sync is triggered in 2 ways:

  1. The first time the server is connected to. That is either from launching the app and it connects to the last saved server or you choose a server to connect to.
  2. The server was connected but lost network connectivity for more than 5 seconds. Once the device reports that it has network connectivity again and it has been more than 5 seconds it will sync any offline listening sessions.

As of v0.9.72-beta here is how the offline listening sync works:

  1. The device requests from the server all of the media progress for the user
  2. It then compares the media progress last updated timestamps for all of the downloaded media on the device. The downloaded media progress will get updated with what the server has if the server progress was updated more recently.
  3. The offline listening sessions are sent to the server. These are what is shown in the listening sessions page and includes the time listening, device info and the media progress. The server does the same process of checking the last updated timestamps and using the progress sent from the device if it is the most recent.
yur1xpp commented 8 months ago

@advplyr I would say a manual way to trigger sync would still be very useful in many cases. For me personally, and within the iOS context, a Shortcut action to trigger sync would help tremendously.

My case is that my ABS server is not facing the internet, so most of audiobooks in my devices are offline. I would listen to them on iPhone when I'm on the road, and then when I'm back home, I would need to manually launch the ABS app for it to trigger sync before head over to my iPad and continue listening. If I don't do that, the progress in iPad would override the iPhone progress.

With this Shortcut action, I could automate in a way that it automatically sync my iPhone progress when I'm at home (arrive at location/connected to WiFi trigger) since they're connected to the same home wifi. This is all done in background (without needing to launch ABS app at home). So when I pick up my iPad, it's already synced.

Another use case is that since my ABS is not facing the internet, but I could still connect to them via VPN. The thing about this setup is that they don't exit through commercial VPN (so my traffic is not anonymous). So if there's a a manual sync Shortcut, I could briefly connect to the home VPN when ABS app launched, trigger sync, and turn off home VPN and connect to commercial VPN on my iPhone (all these are automate-able in iOS). This solved the issue where my iPhone didn't pick up the progress from my iPad from the day before as mentioned above.

JSylvia007 commented 7 months ago

I'm wondering how to reproduce that specific issue you are having. Ideally a sync button shouldn't be necessary and so I want to see where I can make an improvement with your specific case.

As of v0.9.72-beta the offline listening sync is triggered in 2 ways:

  1. The first time the server is connected to. That is either from launching the app and it connects to the last saved server or you choose a server to connect to.
  2. The server was connected but lost network connectivity for more than 5 seconds. Once the device reports that it has network connectivity again and it has been more than 5 seconds it will sync any offline listening sessions.

As of v0.9.72-beta here is how the offline listening sync works:

  1. The device requests from the server all of the media progress for the user
  2. It then compares the media progress last updated timestamps for all of the downloaded media on the device. The downloaded media progress will get updated with what the server has if the server progress was updated more recently.
  3. The offline listening sessions are sent to the server. These are what is shown in the listening sessions page and includes the time listening, device info and the media progress. The server does the same process of checking the last updated timestamps and using the progress sent from the device if it is the most recent.

I'm using 0.9.73 beta, and here is the issue...

On my connected car piece, I use a WiFi Access Point. That WAP dies the second I power off the car. So the head-unit needs to sync the progress before I turn off the car. Simply put, this is not happening, even if there is a green cloud in the history.

I will haven been listening for over an hour in the car, validate that the progress is syncing with history option in the menu, and then manually exiting the app using the back button and confirming exit, hoping that it will also trigger a sync. Then I turn the car off.

When I walk into the house, I open the app on my phone, and if I press play (stream), it will start off back where IT last was, not where my actual listening time is. I was hoping that a manual sync button might fix this.

frogmannnn commented 7 months ago

I'm wondering how to reproduce that specific issue you are having. Ideally a sync button shouldn't be necessary and so I want to see where I can make an improvement with your specific case.

As of v0.9.72-beta the offline listening sync is triggered in 2 ways:

  1. The first time the server is connected to. That is either from launching the app and it connects to the last saved server or you choose a server to connect to.
  2. The server was connected but lost network connectivity for more than 5 seconds. Once the device reports that it has network connectivity again and it has been more than 5 seconds it will sync any offline listening sessions.

As of v0.9.72-beta here is how the offline listening sync works:

  1. The device requests from the server all of the media progress for the user
  2. It then compares the media progress last updated timestamps for all of the downloaded media on the device. The downloaded media progress will get updated with what the server has if the server progress was updated more recently.
  3. The offline listening sessions are sent to the server. These are what is shown in the listening sessions page and includes the time listening, device info and the media progress. The server does the same process of checking the last updated timestamps and using the progress sent from the device if it is the most recent.

There may actually be a bug here because this is not my experience. Android app 0.9.73 beta, v2.8.0 server. Local media progress that is disconnected from the server is different and never seems to sync. When server is connected progress defaults to what is on the server.

frogmannnn commented 7 months ago

Some screenshots to demonstrate... Screenshot_20240315-044236~2 Screenshot_20240315-044324 Screenshot_20240315-044249

advplyr commented 7 months ago

What server address are you connected to in that last screenshot? A local ip address or the https address?

frogmannnn commented 7 months ago

What server address are you connected to in that last screenshot? A local ip address or the https address?

The https address. I can force a sync by playing the media then using the connect to server button, but is does not sync other content. If I am not playing the media directly and connect to the server progress defaults to the server side (and will override local progress if played).

advplyr commented 7 months ago

I'm not sure I understand. Can you give me a step by step on reproducing this including as much detail as you think is necessary?

frogmannnn commented 7 months ago

I'll try.

  1. Download a audiobook
  2. Go offline (in my case this is turning off wifi/VPN)
  3. Play/make progress
  4. Close the app/ play a different audiobook
  5. Go online / re login to the server
  6. When you go back to the original book the progress will be the server progress not the offline progress