pannal / Sub-Zero.bundle

Subtitles for Plex, as good you would expect them to be.
Other
1.76k stars 120 forks source link

When a movie/tv show is deleted the subtitles remain #152

Open taimoorq opened 8 years ago

taimoorq commented 8 years ago

Thanks for a great plugin. One question i have though is whether there's a way to delete subtitles for media that has been deleted? For tv shows this causes issues because even though the show is deleted the subtitles remain in the folder which causes the left over shows to pick up the wrong subtitles.

pannal commented 8 years ago

I get that there should be some cleaning after TV shows are deleted.

But how does an old TV show pick up old subtitles of a deleted TV show? Are you using metadata storage?

ukdtom commented 8 years ago

OP is storing subs next to the media, as sidecars. When PMS allows the King to delete a media, PMS will do so, but it'll not touch files put in by 3.Party.

IMHO, this should be handled by Plex, where they should nuke everything file that is part of that media, according to the database.

And this is not related to Sub-Zero, but also goes for manually added subs

/T

taimoorq commented 8 years ago

ukdtom is correct the subtitles get placed in the same folder as the media. is there a way to change that? Would that make a difference?

As for the subtitles being picked up by other shows, not sure how that happens. When i go to the available subtitles i see them all listed with the same name and can change the active subtitle until i get to the right one.

Do you guys not experience this in your setup? What settings could i have that are different. I didn't do any additional configuration post install so i think i am going with the default settings.

ukdtom commented 8 years ago

Haven't tested, but would guess, that if subs fetched by Sub-Zero was stored in the bundle directory (Meta) then they would be cleaned out during a delete

Check Sub-Zero settings:

storewithmeta

/Tommy

taimoorq commented 8 years ago

Thanks Tommy. I'll try that out and see if that makes a difference.

pannal commented 8 years ago

Switching to internal storage is a solution, but not a very elegant one.

Adding a cleanup task which runs fairly rare, like once every day, would be a nice feature addition. I don't know how to implement this from the get-go, though, I'll have to think on that one, first.

Edit: Using the internal SZ subtitle storage to determine deleted items may be an option, though the storage isn't tested enough to be reliable.

ukdtom commented 8 years ago

Take care with the size of the dict! Some people out there does literally have thousands of medias :-)

And as said before, I really think this is a PMS issue, and not a SZ issue

/T

pannal commented 8 years ago

I'm not too sure about the Dict size and issues regarding that. As far as I can tell, the PMS saves it to the internal meta storage whatever it takes (correct me if I'm wrong). We're talking about kilobytes of information storage, if they use JSON (or even pickle) serialization.

Do you have real-life information about that?

Edit: If the storage turns out to be a problem, some kind of local sqlite3 db wouldn't be too much of a hassle. (although we couldn't rely on a standard sqlite implementation, because the Plex sandbox doesn't allow us access to the native python sqlite)

ukdtom commented 8 years ago

Nope regarding the dict size. Was simply raising a flag here :-)

And regarding direct access to the database, then that's a No Go, since Plex sadly didn't provide the _sqlite3.so file for all platforms, meaning no way to import SQLite :-( (All NAS platforms hit by this, as well as a lot of Linux ones as well)

And when talking to Plex, this was considered as "Will not fix"

/T

pannal commented 8 years ago

I'm with you there. Using sqlite with plex is possible, but only in a hacky and very hard to support way.

I'd go for a different (not python-native-sqlite) way if need be.

We should raise a very different issue with the Plex guys in the long term:

Urging them to ditch the stupid restricted python "implementation". Python is never wholly and securely sandboxed, just because of the way it is, and RestrictedPython (their "plugin implementation") has been broken from day one.

I've never actively or passively been held-back by useless "security-concerns" as much as I've been when programming in the Plex environment. And for no reason - look at my basic approach of re-enabling certain core features - they're simply holding us back.

Re-gaining access to native python sqlite - and with that, direct access to the Plex database - is a piece of cake. Why don't they really support their money-making plugins by exposing the power of python to those plugin makers?

pannal commented 7 years ago

@taimoorq is this ticket still relevant? I've added automatic leftover subtitle cleanup some versions ago. Did that fix your issue?

pannal commented 7 years ago

I guess it is. See here.

taimoorq commented 7 years ago

yeah feel free to close this one. I'm good now.

Thanks!

pannal commented 7 years ago

Hmm no, this isn't totally resolved. I've fixed leftover subtitles but not after-deleted-leftovers.

ukdtom commented 7 years ago

If SZ was running as a daemon, you could maybe use WebHooks ?

pannal commented 7 years ago

Yeah, maybe. I've implemented the websocket stuff of plex_activity in the last release - maybe they expose the delete event.