Jump to content

Recommended Posts

Slugger
Posted

Afraid not.  Currently no 3rd party integrations and none planned.

Slugger
Posted
2 minutes ago, jaketame said:

Noted. Would you support pull requests if I worked on something?

Absolutely!  The only thing I'd say is that I want to try to avoid logic operations in this tool.  Off the top of my head, what you're suggesting (if I understand correctly) is when you delete items from Emby, you would then (optionally, via an additional flag) delete the series in Sonarr/Radarr/etc.?  To me, there's a lot of logic having to happen to make that possible.  Off the top of my head, how do you know which Sonarr series to delete?

At its core, this tool is all about applying a bunch of filters to the Get Items API call and then calling Emby delete on all of the items the filters found.  I did add a few "logic" tests around series favs and tags and dates, but that's about as far as I'd like to take it.

Anyways, definitely willing to consider any and all PRs.

6 minutes ago, jaketame said:

5 Users, if not watched within 90 days = delete, i would use this? https://gitlab.com/ddb_db/embysweeper/-/wikis/Examples/Delete-Watched-Items

For 5 different users, you'd want to use this with a batch.  If you're using IsPlayed=false as a filter then that filter requires a user context, so you'd have to run embysweeper 5 times, once for each user.  The batch command makes setting this up a breeze.

What you can't do right now with the delete command is consider the created date.  There is a --min-watched-days option to compare the last watched date, but there isn't one for comparing the created date.  Easy enough to add (because the serieskeep command has it), but it's currently not there.  I'd take a PR for that, too. ;)  Or if you opened a ticket, I'd add that one on a future Sunday morning.

I'd need more details on exactly what you're trying to do.  "If not watched in 90 days = delete".  What happens if it's watched?  Then it's not deleted?  If it's also deleted if watched then can the rule be simplified to just "delete anything older than 90 days".  If you can simplify it to that, then you don't care about the users and don't need a batch (still need the creation date comparator added).

nobody01
Posted
2 hours ago, Slugger said:

Absolutely!  The only thing I'd say is that I want to try to avoid logic operations in this tool.  Off the top of my head, what you're suggesting (if I understand correctly) is when you delete items from Emby, you would then (optionally, via an additional flag) delete the series in Sonarr/Radarr/etc.?  To me, there's a lot of logic having to happen to make that possible.  Off the top of my head, how do you know which Sonarr series to delete?

At its core, this tool is all about applying a bunch of filters to the Get Items API call and then calling Emby delete on all of the items the filters found.  I did add a few "logic" tests around series favs and tags and dates, but that's about as far as I'd like to take it.

Anyways, definitely willing to consider any and all PRs.

Yes, it would require a fair bit of logic, mainly ensuring tmdb ids are matched correctly across (https://github.com/ASK-ME-ABOUT-LOOM/purgeomatic) likely similar to this.

Quote

For 5 different users, you'd want to use this with a batch.  If you're using IsPlayed=false as a filter then that filter requires a user context, so you'd have to run embysweeper 5 times, once for each user.  The batch command makes setting this up a breeze.

What you can't do right now with the delete command is consider the created date.  There is a --min-watched-days option to compare the last watched date, but there isn't one for comparing the created date.  Easy enough to add (because the serieskeep command has it), but it's currently not there.  I'd take a PR for that, too. ;)  Or if you opened a ticket, I'd add that one on a future Sunday morning.

I'd need more details on exactly what you're trying to do.  "If not watched in 90 days = delete".  What happens if it's watched?  Then it's not deleted?  If it's also deleted if watched then can the rule be simplified to just "delete anything older than 90 days".  If you can simplify it to that, then you don't care about the users and don't need a batch (still need the creation date comparator added).

So yes basically if its not flagged as a 'keep' series / movie, delete anything older than 90 days if its been watched and lets say 120 days if not watched, just trying to cycle data thats requested but not watched

Slugger
Posted (edited)
35 minutes ago, jaketame said:

So yes basically if its not flagged as a 'keep' series / movie, delete anything older than 90 days if its been watched and lets say 120 days if not watched, just trying to cycle data thats requested but not watched

So we need the --min-age-days test added to the delete command to handle the "not watched for 120 days" test.  If you're looking to dip your toes into the code and want to do a PR, by all means this is probably a pretty good one to start with.  If not, open a ticket to remind me and I'll get to it the next free Sunday morning I have.

Filters that require a user context (IsPlayed, IsFavorite) are available but can be tricky...

"Delete anything older than 90 days if it's been watched."  Watched by whom?  Someone specific?  Easy, no problem.  Watched by everyone?  Can't be done with this tool as written today.  Why?  Because to use IsPlayed, you must also specify the --cleanup-user option which basically decides what user is considered for these user context filters (and that's because that's a requirement to make the emby api call with these filters).  For example,

embysweeper delete --cleanup-user john --filters=IsPlayed=true --min-watched-days=90

This says delete any media item (movie, tv, etc) that user "john" has watched as long as it was last watched at least 90 days ago.  That's easy enough.

But if you only want to delete things that have been watched by every user, that isn't possible with this tool.  That requires more logic be applied -- emby api filters alone can't find things that have been watched by multiple users only.

If you read my batch example, you'll see how I get around this limitation in my own setup.  For me, I have 4 users.  Each user has their own library ("User1 TV", "User2 TV", etc.).  And I setup a batch where I run a "delete if watched" rule for each user/library pair.  If every user were using the same library of media, I wouldn't be able to do what I do.

I had thought about adding the ability to do rules like "watched by every user" or "is marked fav by at least one user", but that goes beyond filtering and requires implementing a bunch of logic.  That's not necessarily bad, but outside the scope of what I was trying to create here.  But, I definitely would consider a PR that added this kind of extra logic, if done sensibly (i.e. I don't want some crazy syntax or rules files, etc. required to set it up).

Edited by Slugger
Slugger
Posted
43 minutes ago, jaketame said:

Yes, it would require a fair bit of logic, mainly ensuring tmdb ids are matched correctly across (https://github.com/ASK-ME-ABOUT-LOOM/purgeomatic) likely similar to this.

I took a look at that github proj.  I see what you're after.  The Sonarr api provides the tvdbid and the Emby api provides the tvdbid so that would be your link without much trouble.  I won't be implementing these types of integrations but would most certainly accept PRs that add them as extra, optional flags.

  • Like 1
nobody01
Posted
13 minutes ago, Slugger said:

So we need the --min-age-days test added to the delete command to handle the "not watched for 120 days" test.  If you're looking to dip your toes into the code and want to do a PR, by all means this is probably a pretty good one to start with.  If not, open a ticket to remind me and I'll get to it the next free Sunday morning I have.

Filters that require a user context (IsPlayed, IsFavorite) are available but can be tricky...

"Delete anything older than 90 days if it's been watched."  Watched by whom?  Someone specific?  Easy, no problem.  Watched by everyone?  Can't be done with this tool as written today.  Why?  Because to use IsPlayed, you must also specify the --cleanup-user option which basically decides what user is considered for these user context filters (and that's because that's a requirement to make the emby api call with these filters).  For example,

embysweeper delete --cleanup-user john --filters=IsPlayed=true --min-watched-days=90

This says delete any media item (movie, tv, etc) that user "john" has watched as long as it was last watched at least 90 days ago.  That's easy enough.

But if you only want to delete things that have been watched by every user, that isn't possible with this tool.  That requires more logic be applied -- emby api filters alone can't find things that have been watched by multiple users only.

If you read my batch example, you'll see how I get around this limitation in my own setup.  For me, I have 4 users.  Each user has their own library ("User1 TV", "User2 TV", etc.).  And I setup a batch where I run a "delete if watched" rule for each user/library pair.  If every user were using the same library of media, I wouldn't be able to do what I do.

I had thought about adding the ability to do rules like "watched by every user" or "is marked fav by at least one user", but that goes beyond filtering and requires implementing a bunch of logic.  That's not necessarily bad, but outside the scope of what I was trying to create here.  But, I definitely would consider a PR that added this kind of extra logic, if done sensibly (i.e. I don't want some crazy syntax or rules files, etc. required to set it up).

I appreciate your really detailed response! There is a product call Janitorr that might be a better fit so will check it out, if not will see what i can do inside Go. https://github.com/Schaka/janitorr

Its keeping track of watched for example, we'd potentially need to track with a cache of some sort to check users against IsPlayed and record, allow 90 days for =<1 and 120days for >2

nobody01
Posted
2 minutes ago, Slugger said:

I took a look at that github proj.  I see what you're after.  The Sonarr api provides the tvdbid and the Emby api provides the tvdbid so that would be your link without much trouble.  I won't be implementing these types of integrations but would most certainly accept PRs that add them as extra, optional flags.

I've been doing some work albeit in python around tmdb extraction so have some knowledge here in creating collections so could transpose over. 

Slugger
Posted
10 minutes ago, jaketame said:

I appreciate your really detailed response! There is a product call Janitorr that might be a better fit so will check it out, if not will see what i can do inside Go. https://github.com/Schaka/janitorr

Ooooh... that project took on the "implement all the extra logic" problem that I shied away from. :)

It's interesting to skim that proj readme.  They did what I thought I would have had to do to implement some of the more challenging logic operations -- they load your entire media library into RAM and then process it in memory themselves.  I got to a similar conclusion and I decided, "nope I don't need that" and they decided "yup, let's do it!"  I just skimmed the docs and the setup but it probably will handle all of your desired use cases around media age, etc.  Honestly, if I had found that project before I went about writing this, I'd have probably just used that instead.

If you just want to filter and delete using the emby api, this is the tool for sure.  If you want to apply logic on top of the filtering, that's definitely where you hit the limitations of this tool.  I did a few extra logic tests for tags/favs/and some age/date stuff, but not much.  More date logic tests I can definitely get behind.  But things like "watched by everyone" or "watched by this subset of users", etc. is not on my roadmap (mainly because in my setup I don't need it).

  • Thanks 1
  • 1 month later...
Dickydodah!
Posted (edited)

@SluggerI've been using this for a while now and want to expand the use a bit. I'm using a config file for ease of making changes. I'm now trying to exclude anything marked as a favorite. As this can be done at the series/show level as well as at the episode level (but not at the season level) I guessed that I needed to add "IsFavorite=false" as below. In the examples there is also a "--ignore-series-fav" option but this only seems to be available with the delete command and not the serieskeep. Will the "IsFavorite=false" work in both scenarios?

 serieskeep
 -q --log-file=Logs/EmbySweeper-log.txt
 --server-host="localhost"
 --server-login="XXXXXXX"
 --server-password=XXXXXXXX
 --server-port=8096
 --lib-include "TV Shows"
 --cleanup-user=TV
 --filters=IsPlayed=true;IsFavorite=false
 --min-age-days=0
 --keep 1
 # -d

Edited by Dickydodah!
Slugger
Posted

Try adding this:

--series-filters=IsFavorite=false

That should exclude any series that is marked as a fav from being processed.  The --ignore-series-fav option isn't included in the the serieskeep command because this command has the more generic --series-filters option, which allows you to exclude series using any and all available filters.

Dickydodah!
Posted

Is that in addition to  --filters=IsPlayed=true;IsFavorite=false that I already have?

Slugger
Posted

Yes, you'll need both.  The series-filters will eliminate series to process then the other filters will eliminate episodes of series that are going to be processed.  Together, those two options should ignore any series marked a fav and any episode marked a fav.  The end result should be deleting any episodes that aren't marked fav whose series is also not a fav.  As always, test thoroughly before uncommenting the -d option.

Dickydodah!
Posted (edited)

Thanks as always for your prompt reply. I'd played around with a fair few different formats but couldn't quite get it right. I shall try this out and it should keep my son happy as I now manage his Emby server as well as mine.

Edited by Dickydodah!
  • 2 months later...
Posted

Is there a option for a dry-run to use before deleting your entire library by mistake?

Dickydodah!
Posted

By default Emby Sweeper deletes nothing. When you add the "-d" option it will delete those marked for deletion in the log. If you are on Windows an added bonus is that Embys API deletes to the recycle bin so you can get the files back. I would suggest making up a test library with only a small selection of shows/movies and trying it out on there so that you can get to grips with the syntax.

  • Agree 1
  • 2 months later...
Posted

@SluggerIn the batch example on the Gitlab wiki you say something like "If more than one person wants the same show I actually make a copy in each person's library." I'm curious how you're doing that? TIA!

  • 9 months later...
Josh_Oshiro
Posted

Not to necro but is the series-filters option depreciated on 3.0? I assume so since I keep getting "unknown flag for  --series-filters" but some of the documentation mentions this as well so figured I'd check

Posted

Yeah the filtering changed in 3.0.  Now all of the filters from the Emby API are exposed via the --filters option.  If you post a command line from the older version, I can probably help you get it converted.

Dickydodah!
Posted

Hi @Sluggerjust got to say thanks for such a useful bit of software. I was wondering how you deal with the situation I find I'm in.

I have Emby sweeper set to run every morning and it deletes the watched episodes but leaves the latest watched so that Emby keeps the seies in the "Continue Watching" list. This works perfectly with one small issue. When a series is ended and I've watched all episodes in all seasons the very last episode is kept. This of course is the correct behaviour with my options file as below. A really nice to have would be a way to delete the last episode automatically. Currently I use Sonarr to filter on ended series and sort by number of episodes and delete those with only 1 episode left, if I have watched it. A bit clumsy and easy to accidently delete the wrong thing.

# TV shows cleanup
#
serieskeep
# --log-file=Logs/EmbySweeper-log.txt        # Standard logs
# -qq --log-file=Logs/EmbySweeper-log.txt    # Error logs
  -q --log-file=Logs/EmbySweeper-log.txt    # Warning and error logs
# -v --log-file=Logs/EmbySweeper-log.txt    # verbose logs
# -v --log-http=Logs/HTTP            # Verbose logs with API calls
  --server-host="localhost"
  --server-login=##########
  --server-password=#########
  --server-port=8096
  --lib-include "TV Shows"
  --filters IsPlayed=true;IsFavorite=false
  --cleanup-user=####
  --series-filters=IsFavorite=false
  --min-age-days=0
  --keep 1
  -d

Posted

Hmm... you'd have to experiment, but off the top of my head I think you could do something with the --series-filters

You have to duplicate your rule.  Leave the one you have as is.  Then duplicate it and modify the series filters to:

--series-filters=IsFavorite=false;Status=Ended

--keep 0

I'm assuming the Status value represents the status of the series as pulled from tvdb.  The api docs aren't clear what the field actually represents but it looks promising from the 5 mins I spent looking at it.

Basically, to do what you want, you have to find a unique filter you can add somewhere to an additional rule to cleanup that final episode when you detect the series is over.

Dickydodah!
Posted

I will have to setup a test library and have a go. It could be quite a challenge but interesting. It will take me a while before I have time to concentrate on it but I think I understand the logic 🙂 

One small question, you say I need to duplicate the rule. Does this mean that I will need to run Embysweeper twice to use the two rules (options.txt files)? If that is the case it makes a lot of sense and makes the implimentation nice and simple.🤞

Posted

You could run it twice.  Or you could use the batch subcommand.  The batch command allows you to run multiple command lines per run.  See the wiki page for an example.  I use the batch command to run my various scenarios.  I have a bunch of different config files for all my different scenarios then call embysweeper overnight to run them all and keep my media nice and tidy.

Dickydodah!
Posted

I forgot about that command. I shall have a play 😁

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...