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

Track Movie/Show removal from Kodi library initiated by Kodi #973

Open
dineshalphaque opened this issue Jan 22, 2024 · 7 comments
Open

Track Movie/Show removal from Kodi library initiated by Kodi #973

dineshalphaque opened this issue Jan 22, 2024 · 7 comments

Comments

@dineshalphaque
Copy link

Here's the problem in a nutshell,

  1. TV Shows are usually added from within Elementum, either via Search or browsing Trakt->Recommended, right clicking and Add to Library from the context menu
  2. They get added to the Kodi Library fine, with the relevant episode strm files created in the show's directory.
  3. Deleting a show, using context menu and Manage followed by Remove Show from Library would initially remove the show, and the relevant strm files (clicked Yes on removing the files explicitly in the popup).
  4. However after a while (within 1-2 hours), the Show reappears in the Kodi Library, and the strm files get recreated again. It's as if it never got deleted with watched states all correct as per before deletion.
  5. This ONLY happens for TV Shows and not for Movies. Movies get deleted and remain deleted.

Any idea why this is so ? It's been going on for quite a while (~15 months, ever since I first tried deleting TV Shows from Kodi Library).

I do have Trakt synch turned on from within Elementum, but i've manually deleted the Show from Trakt Collection, and it is not reflected there anymore (i.e. it stays deleted). Don't think this is related to Trakt. Am trying to narrow down if this is a Kodi or Elementum related problem, as the Kodi forums do not have anyone facing this problem.

Log files do show the Elementum library synch running every so often, but not much detail in there to help.

Also, since 0.1.96, a few options to Advanced settings have been added,

  1. Remove movies from Elementum database
  2. Remove shows from Elementum database
  3. Clear deleted movies
  4. Clear deleted shows

What do these options do exactly, and would they help in this situation ?

Am on Elementum 0.1.99 and Kodi 20.2 running on Debian on ARM, specifically the OSMC device.

@antonsoroko
Copy link

@dineshalphaque we still need a log file, at least to see your configuration. looks like you have not enabled some "kodi library to trakt" sync options about remove.

this issue reminds me #825 very much. please read it, since it has a answers from elgatito about how this process works (and in which situations it can fail) and how you can remove "ghost" shows (e.g. open elementum's (mot kodi's but elementum's) library and remove show from it).
anyway, please read #825.

also, there is option to remove show from kodi library in "elementum interface" (open elementum, find show, click "remove from library" in context menu) that should work more reliable - try it as well.

(btw, instead of manual removing from trakt collection you can enable option "Remove from Trakt, when show is deleted from Kodi library" for convenience.)


Also, since 0.1.96, a few options to Advanced settings have been added,

those are not settings but commands/actions.

<setting type="action" label="30685" action="RunPlugin(plugin://plugin.video.elementum/cmd/database/clear_movies)" />
<setting type="action" label="30686" action="RunPlugin(plugin://plugin.video.elementum/cmd/database/clear_shows)" />
<setting type="action" label="30462" action="RunPlugin(plugin://plugin.video.elementum/cmd/database/clear_deleted_movies)" />
<setting type="action" label="30463" action="RunPlugin(plugin://plugin.video.elementum/cmd/database/clear_deleted_shows)" />

https://github.com/elgatito/elementum/blob/e3da4dad26f725f6e0edf3093d888828926b6b63/api/routes.go#L408-L411
https://github.com/elgatito/elementum/blob/e3da4dad26f725f6e0edf3093d888828926b6b63/api/cmd.go#L192
https://github.com/elgatito/elementum/blob/e3da4dad26f725f6e0edf3093d888828926b6b63/api/cmd.go#L178

so "Remove shows from Elementum database" will remove ALL shows from internal elementum library (aka database).
and "Clear deleted shows" will remove shows that were marked as deleted (e.g. when you removed them from elementum library or kodi library) from internal elementum library.

and as you learned in #825 - this elementum library is used to sync shows to kodi library.
so if you remove "deleted" - nothing should change in your case. but if you remove ALL - then you will start kind of "from scratch" so it can solve some "ghost" show issues, but this is WRONG and slow approach. read above about proper approach.


@elgatito please correct me if i am wrong.

@dineshalphaque
Copy link
Author

@dineshalphaque we still need a log file, at least to see your configuration. looks like you have not enabled some "kodi library to trakt" sync options about remove.

Have attached logs from a fresh reboot below, but in essence I've always had enabled bidirectional synch with Trakt for collections and seemingly all bidirectional synch between Kodi and Elementum libraries.

this issue reminds me #825 very much. please read it, since it has a answers from elgatito about how this process works (and in which situations it can fail) and how you can remove "ghost" shows (e.g. open elementum's (mot kodi's but elementum's) library and remove show from it). anyway, please read #825.

Thanks for that ! Had a good read and it did explain things somewhat, though I don't think I fully understand how synch works among Trakt, Elementum and Kodi. Still think there's a glitch somewhere when deleting from Kodi library as the show is not also deleted in the Elementum library.

Would it be right to presume that it would be better to delete shows using the Elementum context menu of Remove from library, as then Elementum can ensure that it's simultaneously removed from Kodi and Trakt ?

also, there is option to remove show from kodi library in "elementum interface" (open elementum, find show, click "remove from library" in context menu) that should work more reliable - try it as well.

Referring to this, in above paragraph.

(btw, instead of manual removing from trakt collection you can enable option "Remove from Trakt, when show is deleted from Kodi library" for convenience.)

Have already enabled this.

so "Remove shows from Elementum database" will remove ALL shows from internal elementum library (aka database). and "Clear deleted shows" will remove shows that were marked as deleted (e.g. when you removed them from elementum library or kodi library) from internal elementum library.

Too late, ;)

Was playing around and have already executed "Remove shows from Elementum database". Not sure what damage I've caused but can't seen anything discernible yet. What is the impact of me having (sillily) done this ? Is it necessary to have shows in Elementum library if they're already in the Kodi library ? Will this affect Trakt synching of watch states (bidirectional) ?

Ideally, I should have executed "Clear deleted shows" instead, right ?

but if you remove ALL - then you will start kind of "from scratch" so it can solve some "ghost" show issues, but this is WRONG and slow approach. read above about proper approach.

Will the Elementum library be rebuilt from Trakt, or will the consequence of removing all shows from Elementum library clean out my Trakt collection ? (That would be disastrous for me !)

Thanx so much for the time to explain, @antonsoroko and much apologies for all these questions. Am trying to grasp how the interactions between Kodi, Elementum and Trakt work as I prefer to manage collections (add/delete) in Trakt moving forward, and have both Elementum and Kodi libraries mirror what is in Trakt.

Also looking forward to insights from @elgatito

kodi.log

@antonsoroko
Copy link

Still think there's a glitch somewhere when deleting from Kodi library as the show is not also deleted in the Elementum library.

maybe. i do not use kodi library so i can't observe such issues in "real life". but elgatito uses libarary, so maybe he can find some issue in this scenario.

Would it be right to presume that it would be better to delete shows using the Elementum context menu of Remove from library, as then Elementum can ensure that it's simultaneously removed from Kodi and Trakt ?

from what i see in the code - yes. this will be a "short" path, while via kodi - it will be "long" path.
explanation why "long" path can fail is here #825 (comment)

Ideally, I should have executed "Clear deleted shows" instead, right ?

no. if they marked as deleted - they should not be added to kodi. thus nothing changes for your use case. at least in theory.
so it just removes cache of data that maybe could be useful in future (e.g. if you add a show again).

What is the impact of me having (sillily) done this ?

and

Will the Elementum library be rebuilt from Trakt, or will the consequence of removing all shows from Elementum library clean out my Trakt collection ? (That would be disastrous for me !)

nothing bad. i only said it will be "slow" - i meant that elementum would need to get all the info again - this will take some time.

as i said:

so if you remove "deleted" - nothing should change in your case. but if you remove ALL - then you will start kind of "from scratch" so it can solve some "ghost" show issues

"can solve" - because elementum will start sync from scratch (e.g. something in database was broken before - but now it is deleted).

Is it necessary to have shows in Elementum library if they're already in the Kodi library ?
Will this affect Trakt synching of watch states (bidirectional) ?

as i said:

this elementum library is used to sync shows to kodi library.

so in order to sync something from trakt to kodi it should be synced to elementum first.
so as i see it - it is "necessary ..." and yes it will affect.

@elgatito
Copy link
Owner

elgatito commented Jan 23, 2024

@dineshalphaque When you add something into Trakt list (that is selected to sync in Elementum), or directly from Elementum context menu - Show it added to internal Elementum library.

That library is used to loop through all shows and make sure there are strm files for all episodes on the disk.

Once you remove something from Trakt (if removal is enabled in Elementum settings) - strm files are removed from disk and we ask Kodi to remove that foder from library, and mark this Show as removed to make sure we won't create strm again in the next sync.

How show can be re-enabled for sync:

  • You add it again into Trakt list.
  • You manually add it to the library again from context menu.
  • Elementum will re-enable the Show if there are strm files on the disk pointing to this show and you remove app.db file, that contains information about removal status.

I would suggest to try removing a show from Trakt/or with Elementum context menu.
Then check if there are strm files pointing to the same show (it can be a different folder, with pointing to same show inside).

When you remove Show from usual Kodi context menu - then it is not getting removed from Elementum, because we ignore such removals from Kodi.

@elgatito
Copy link
Owner

If you open "In Elementum library" (last folder in Shows menu) - it will show you everything that is active in Elementum library. That is what we use for writing strm files.

@dineshalphaque
Copy link
Author

@elgatito

I would suggest to try removing a show from Trakt/or with Elementum context menu.
Then check if there are strm files pointing to the same show (it can be a different folder, with pointing to same show inside).

When you remove Show from usual Kodi context menu - then it is not getting removed from Elementum, because we ignore such removals from Kodi.

Guess this should be the recommended way moving forward. I'd been consistently removing from Kodi library, and thus observing deleted shows returning. Shall be using the Elementum context "Remove from library" from now on. Issue closed.

Thanx a bunch for explaining how synching works !

@elgatito
Copy link
Owner

Guess this should be the recommended way moving forward. I'd been consistently removing from Kodi library, and thus observing deleted shows returning. Shall be using the Elementum context "Remove from library" from now on. Issue closed.

We are ignoring Kodi library removals, because Kodi will inform you about removal when you try to refresh/rescrape it in your library. Then Kodi will inform about removal and later about creation.

But I think maybe we can just properly get list of current shows and refresh internal state in Elementum.

Let's have this issue open, I will try to think about it,

@elgatito elgatito reopened this Jan 24, 2024
@elgatito elgatito changed the title Deleted TV Shows Keep Reappearing in the Library Track Movie/Show removal from Kodi library initiated by Kodi Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants