Jump to content

Manually trigger incremental sync after startup


SJC2123
Go to solution Solved by SJC2123,

Recommended Posts

SJC2123

I have installed Kodi + Emby on a Sony Bravia TV (Android TV OS)

 

The problem is, the Incremental Sync only runs when the app is first started.

 

When an AndroidTV device is turned off, the system stays "awake" for 5 minutes - after this time, the network is turned off and the device goes to full sleep. Kodi is still running, but unable to receive new content broadcasts from the Emby server. So then when the TV is turned back on, the library remains out of date unless you fully restart the Kodi app or go to the Emby addon and select Manually Sync (but this is slower than restarting, and not 'incremental').

 

I don't know if the Emby addon can detect when the device leaves sleep mode or when the Network connection becomes active again - so the only solution I can think of, is to be able to manually trigger an incremental sync via hotkey.

So I just need to know if there is a command in the Emby addon to trigger the incremental sync. I've done similar things with other addons, such as "<a mod="shift,ctrl">RunScript(script.audio.profiles,0)</a>", so it should be possible.

Does a command already exist, or can one be added? It's the only inconvenient thing about this setup.

 

Thanks.

Edited by Enesce
Link to comment
Share on other sites

xnappo

There is definitely a way to run the plugin to trigger a sync, here is the command:

plugin://plugin.video.emby/?mode=manualsync

 

However please post a log of this behavior, maybe there is something that can be done to detect this.

Edited by xnappo
  • Like 1
Link to comment
Share on other sites

SJC2123

There is definitely a way to run the plugin to trigger a sync, here is the command:

plugin://plugin.video.emby/?mode=manualsync

 

However please post a log of this behavior, maybe there is something that can be done to detect this.

 

Thanks - that command works.

The manual sync process is just a bit slow, large media collection + slow CPU on low powered TV.

 

I wanted to use the Incremental Sync process since it is much much faster - I've modified the Emby addon to add a "fastsync" command based on looking at the code for the "manualsync" command you provided. It appears to be working, but I'm not sure if calling this procedure post-startup is a bad idea for the database or anything like that. There is also no visual notification of the sync. Here's what I changed:

 

/plugin.video.emby/default.py

            elif mode in ("manualsync", "repair"):
changed to:

            elif mode in ("manualsync", "fastsync", "repair"):
                    if mode == "manualsync":
                        librarysync.ManualSync().sync(dialog=True)
changed to:

                    if mode == "manualsync":
                        librarysync.ManualSync().sync(dialog=True)
                    elif mode == "fastsync":
                        lib.startSync()
 

and then in the Kodi keymap xml file:

<keymap>
  <home>
    <keyboard>
      <u>RunPlugin(plugin://plugin.video.emby/?mode=fastsync)</u>
    </keyboard>
  </home>
</keymap>

 

This is the Kodi debug log from the moment the device is powered off, to when its turned back on:

The network interface woke up several times for just a few seconds, don't know why. I was pinging it from a computer to monitor the status.

17:01:44 T:18446744071987682192   DEBUG: Thread JobWorker 18446744071987682192 terminating (autodelete)
17:05:28 T:18446744072032529296   DEBUG: JSONRPC: Incoming request: {"params": {"sort": {"method": "random"}, "filter": {"operator": "lessthan", "field": "playcount", "value": "1"}, "properties": ["title", "originaltitle", "votes", "playcount", "year", "genre", "studio", "country", "tagline", "plot", "runtime", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume", "art", "streamdetails", "mpaa", "director", "writer", "cast", "dateadded", "imdbnumber"], "limits": {"end": 20}}, "jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetMovies"}
17:05:28 T:18446744072032529296   DEBUG: int CVideoDatabase::RunQuery(const string&) took 31 ms for 29 items query: select * from movie_view  WHERE ((movie_view.playCount IS NULL OR movie_view.playCount < 1))
17:05:29 T:18446744072032529296   DEBUG: JSONRPC: Incoming request: {"params": {"sort": {"method": "random"}, "filter": {"operator": "lessthan", "field": "playcount", "value": "1"}, "properties": ["title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime", "director", "writer", "cast", "dateadded", "lastplayed"], "limits": {"end": 20}}, "jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetEpisodes"}
17:05:29 T:18446744072032529296   DEBUG: int CVideoDatabase::RunQuery(const string&) took 34 ms for 210 items query: select * from episode_view  WHERE ((episode_view.playCount IS NULL OR episode_view.playCount < 1))
17:05:29 T:18446744072032529296   DEBUG: JSONRPC: Incoming request: {"params": {"sort": {"method": "random"}, "filter": {"operator": "lessthan", "field": "playcount", "value": "1"}, "properties": ["title", "playcount", "genre", "artist", "album", "year", "file", "thumbnail", "fanart", "rating", "lastplayed"], "limits": {"end": 20}}, "jsonrpc": "2.0", "id": 1, "method": "AudioLibrary.GetSongs"}
17:05:29 T:18446744072032529296   DEBUG: bool CMusicDatabase::GetSongsFullByWhere(const string&, const CDatabase::Filter&, CFileItemList&, const SortDescription&, bool) query = SELECT songview.*, song_artist.idArtist AS idArtist, artist.strArtist AS strArtist, artist.strMusicBrainzArtistID AS strMusicBrainzArtistID FROM songview LEFT JOIN song_artist on song_artist.idsong = songview.idsong LEFT JOIN artist ON song_artist.idArtist = artist.idArtist  WHERE ((CAST(songview.iTimesPlayed as DECIMAL(5,1)) < 1))
17:05:29 T:18446744072032529296   DEBUG: JSONRPC: Incoming request: {"params": {"sort": {"method": "random"}, "properties": ["title", "description", "albumlabel", "theme", "mood", "style", "type", "artist", "genre", "year", "thumbnail", "fanart", "rating", "playcount"], "limits": {"end": 20}}, "jsonrpc": "2.0", "id": 1, "method": "AudioLibrary.GetAlbums"}
17:05:29 T:18446744072032529296   DEBUG: bool CMusicDatabase::GetAlbumsByWhere(const string&, const CDatabase::Filter&, VECALBUMS&, int&, const SortDescription&, bool) query: SELECT albumview.*, albumartistview.*  FROM albumview LEFT JOIN albumartistview on albumartistview.idalbum = albumview.idalbum  WHERE albumview.strReleaseType = 'album'
17:05:29 T:18446744072032529296   DEBUG: bool CMusicDatabase::GetAlbumsByWhere(const string&, const CDatabase::Filter&, VECALBUMS&, int&, const SortDescription&, bool) - query took 1 ms
17:05:29 T:18446744072032529296   DEBUG: JSONRPC: Incoming request: {"params": {"sort": {"method": "random"}, "filter": {"operator": "lessthan", "field": "playcount", "value": "1"}, "properties": ["title", "artist", "playcount", "studio", "director", "year", "plot", "genre", "runtime", "art", "file", "streamdetails", "resume"], "limits": {"end": 20}}, "jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetMusicVideos"}
17:05:29 T:18446744072032529296   DEBUG: int CVideoDatabase::RunQuery(const string&) took 1 ms for 0 items query: select * from musicvideo_view  WHERE ((musicvideo_view.playCount IS NULL OR musicvideo_view.playCount < 1))
17:06:16 T:18446744072360958864   DEBUG: CAnnouncementManager - Announcement: OnScreensaverActivated from xbmc
17:06:16 T:18446744072360958864   DEBUG: GOT ANNOUNCEMENT, type: 4, from xbmc, message OnScreensaverActivated
17:06:16 T:18446744072360958864   DEBUG: ------ Window Init () ------
17:06:16 T:18446744072031488912  NOTICE: EMBY KodiMonitor -> Method: GUI.OnScreensaverActivated Data: null
17:15:39 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
17:15:45 T:18446744072034622352   DEBUG: Previous line repeats 108 times.
17:15:45 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
17:15:51 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0",  "id": 1, "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "originaltitle", "playcount", "year", "genre", "studio", "country", "tagline", "plot", "runtime", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume", "art", "streamdetails", "mpaa", "director"], "limits": {"end": 20}, "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}
17:15:51 T:18446744072033569680   DEBUG: int CVideoDatabase::RunQuery(const string&) took 21 ms for 29 items query: select * from movie_view  WHERE ((movie_view.playCount IS NULL OR movie_view.playCount < 1))
17:15:51 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetEpisodes", "params": { "properties": ["title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime"], "limits": {"end": 20}, "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}
17:15:51 T:18446744072033569680   DEBUG: int CVideoDatabase::RunQuery(const string&) took 30 ms for 210 items query: select * from episode_view  WHERE ((episode_view.playCount IS NULL OR episode_view.playCount < 1))
17:15:52 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0",  "id": 1, "method": "VideoLibrary.GetMusicVideos", "params": {"properties": ["title", "artist", "playcount", "year", "plot", "genre", "runtime", "fanart", "thumbnail", "file", "streamdetails", "resume"],  "limits": {"end": 20}, "sort": {"method": "random"}}}
17:15:52 T:18446744072033569680   DEBUG: int CVideoDatabase::RunQuery(const string&) took 6 ms for 0 items query: select * from musicvideo_view
17:15:52 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "AudioLibrary.GetAlbums", "params": {"properties": ["title", "description", "albumlabel", "theme", "mood", "style", "type", "artist", "genre", "year", "thumbnail", "fanart", "rating", "playcount"], "limits": {"end": 20}, "sort": {"method": "random"}}}
17:15:52 T:18446744072033569680   DEBUG: bool CMusicDatabase::GetAlbumsByWhere(const string&, const CDatabase::Filter&, VECALBUMS&, int&, const SortDescription&, bool) query: SELECT albumview.*, albumartistview.*  FROM albumview LEFT JOIN albumartistview on albumartistview.idalbum = albumview.idalbum  WHERE albumview.strReleaseType = 'album'
17:15:52 T:18446744072033569680   DEBUG: bool CMusicDatabase::GetAlbumsByWhere(const string&, const CDatabase::Filter&, VECALBUMS&, int&, const SortDescription&, bool) - query took 3 ms
17:15:52 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": {"properties": ["genre", "description", "mood", "style", "born", "died", "formed", "disbanded", "yearsactive", "instrument", "fanart", "thumbnail"], "sort": {"method": "random"}, "limits": {"end": 20}}, "id": 1}
17:15:52 T:18446744072033569680   DEBUG: bool CMusicDatabase::GetArtistsByWhere(const string&, const CDatabase::Filter&, CFileItemList&, const SortDescription&, bool) query: SELECT artistview.* FROM artistview  WHERE (artistview.idArtist IN (SELECT song_artist.idArtist FROM song_artist) OR artistview.idArtist IN (SELECT album_artist.idArtist FROM album_artist)) and artistview.strArtist != '' and artistview.strArtist <> 'Various artists'
17:15:52 T:18446744072033569680   DEBUG: Time to retrieve artists from dataset = 6
17:15:52 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "AudioLibrary.GetSongs", "params": {"properties": ["title", "playcount", "artist", "album", "year", "file", "thumbnail", "fanart", "rating"], "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}, "limits": {"end": 20},  "sort": {"method": "random"}}}
17:15:52 T:18446744072033569680   DEBUG: bool CMusicDatabase::GetSongsFullByWhere(const string&, const CDatabase::Filter&, CFileItemList&, const SortDescription&, bool) query = SELECT songview.*, song_artist.idArtist AS idArtist, artist.strArtist AS strArtist, artist.strMusicBrainzArtistID AS strMusicBrainzArtistID FROM songview LEFT JOIN song_artist on song_artist.idsong = songview.idsong LEFT JOIN artist ON song_artist.idArtist = artist.idArtist  WHERE ((CAST(songview.iTimesPlayed as DECIMAL(5,1)) < 1))
17:15:52 T:18446744072033569680   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "method": "Addons.GetAddons", "params": {"properties": ["name", "author", "summary", "version", "fanart", "thumbnail"]}, "id": 1}
17:15:52 T:18446744072033569680   DEBUG: Skin Widgets: Total time needed to request random queries: 0:00:01.510263
17:30:50 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
17:32:11 T:18446744072034622352   DEBUG: Previous line repeats 493 times.
17:32:11 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
17:33:17 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
17:33:33 T:18446744072034622352   DEBUG: Previous line repeats 292 times.
17:33:33 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
17:33:36 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
17:33:42 T:18446744072034622352   DEBUG: Previous line repeats 94 times.
17:33:42 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
17:45:41 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
17:45:47 T:18446744072034622352   DEBUG: Previous line repeats 93 times.
17:45:47 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
18:01:28 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:01:34 T:18446744072034622352   DEBUG: Previous line repeats 97 times.
18:01:34 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
18:02:02 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:02:08 T:18446744072034622352   DEBUG: Previous line repeats 108 times.
18:02:08 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
18:09:02 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:09:16 T:18446744072034622352   DEBUG: Previous line repeats 278 times.
18:09:16 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
18:15:43 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:15:48 T:18446744072034622352   DEBUG: Previous line repeats 104 times.
18:15:48 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
18:22:54 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:22:55 T:18446744072361999248   DEBUG: Previous line repeats 24 times.
18:22:55 T:18446744072361999248   DEBUG: CAnnouncementManager - Announcement: OnScreensaverDeactivated from xbmc
18:22:55 T:18446744072361999248   DEBUG: GOT ANNOUNCEMENT, type: 4, from xbmc, message OnScreensaverDeactivated
18:22:55 T:18446744072031488912  NOTICE: EMBY KodiMonitor -> Method: GUI.OnScreensaverDeactivated Data: {"shuttingdown":false}
18:22:55 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:22:56 T:18446744072360958864   DEBUG: Previous line repeats 20 times.
18:22:56 T:18446744072360958864   DEBUG: ------ Window Deinit () ------
18:22:56 T:18446744072360958864   DEBUG: virtual CNetworkInterface* CNetworkLinux::GetFirstConnectedInterface() no connected interface found - requery list
18:22:59 T:18446744072034622352   DEBUG: Previous line repeats 21 times.
18:22:59 T:18446744072034622352  NOTICE: EMBY DownloadUtils -> SessionId: 9666f8ef05d288b2f5ce40f561181010
Perhaps an option to run incremental sync when exiting the screensaver, if screensaver duration is greater than X minutes? Edited by Enesce
Link to comment
Share on other sites

fantasticn

Nice. Thanks for sharing. But changes to the default.py could be automatically reverted with the next update of the addon. Any chance to have this implemented in the emby-addon directly?

 

As to executing the task based on certain events (screensaver deactivated etc.) you could try the callbacks-script: https://github.com/KenV99/script.service.kodi.callbacks

  • Like 1
Link to comment
Share on other sites

SJC2123

do a fork on github, make and test your changes and submit a pull request and we can merge this into the main branch.

I shall do that. I've been using it for past few days + the Kodi Callbacks addon @@fantasticn mentioned for OnScreensaverDeactivated to trigger the sync, works like a charm. Just the "recently added episodes" widget takes 10-15 seconds to refresh, but it does that on startup too.

Should I add an option for doing a fastsync on screensaver deactivate to my pull (so dont need that kodi callbacks addon), or is that more of a "just me" feature?

Link to comment
Share on other sites

xnappo

Yeah, I agree - I don't think it hurts anything and these type of boxes are becoming a really popular Kodi platform.

Link to comment
Share on other sites

  • Solution
SJC2123

I made the pull request and it has been merged, fastsync command and screensaver deactivated sync should be in the next plugin update :)

  • Like 2
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...