Kometa-Team / Kometa

Python script to update metadata information for items in plex as well as automatically build collections and playlists. The Wiki Documentation is linked below.
https://kometa.wiki
MIT License
2.5k stars 306 forks source link

Smart Collections #226

Closed meisnate12 closed 3 years ago

meisnate12 commented 3 years ago

Add smart collections functionality

(Done) Add smart_label which can be given one of the sort options below. Using the smart label will create a special smart collection where the smart collection just searches for a label which is added to all the movies the collection builders find

Sort Options title.asc, title.desc, year.asc, year.desc, originally_available.asc, originally_available.desc, critic_rating.asc, critic_rating.desc, audience_rating.asc, audience_rating.desc, user_rating.asc, user_rating.desc, content_rating.asc, content_rating.desc, duration.asc, duration.desc, plays.asc, plays.desc, added.asc, added.desc, random

(Done) Add another option to build some smart collection similarily to how plex_search is formatted

danhew commented 3 years ago

Thanks for adding this.

Will it be able to add a label/smart collection without making a non-smart collection?

meisnate12 commented 3 years ago

Yes if you use either attributes above the smart collection will be created automatically and if it's already a normal collection it will be converted to a smart collection

miguelamaral commented 3 years ago

Would it be possible for the script to ignore any values not found in the collection? At the moment it throws an error and skips the collection altogether, as seen here:

Baltic:
  smart_filter:
    any:
      country: Estonia, Latvia, Lithuania
    sort_by: year.asc
Scanning Baltic Collection
Smart Movie Filter
Sort By: year.asc
Plex Error: country: Latvia not found

I've also noticed the collection's thumbnail label doesn't always match the actual number of films. I figure it's probably got nothing to do with script, as it's been brought up here?

Thanks!

meisnate12 commented 3 years ago

yea the number of items has nothing to do with PMM.

It would be possible to have it function that way but to me, it makes more sense to have it fail if the item isn't found that way you know a mistake has been made and it emulates how the advance filter works in plex. You cant select an option that isn't already in your library. I would either remove the option that isn't found or add a movie to your library that will have that tag there

meisnate12 commented 3 years ago

PS nice job figuring out how to use smart_filter without me detailing it anywhere

miguelamaral commented 3 years ago

Yeah, I understand this would be a very specific use case. I was just hoping to transform a bunch of regular collections into smart collections, but it wouldn't work without those changes. Basically, grouping a predefined set of countries/regions would be unfeasible, as the script would likely fail unless you manually checked the Plex countries list before every run:

# Eastern Europe
country: Belarus, Bulgaria, Czech Republic, Hungary, Poland, Republic of Moldova, Romania, Russian Federation, Slovakia, Ukraine
# Latin America
country: Anguilla, Antigua and Barbuda, Argentina, Aruba, Bahamas, Barbados, Belize, Bolivarian Republic of Venezuela, "Bonaire, Sint Eustatius and Saba", Bouvet Island, Brazil, Cayman Islands, Chile, Colombia, Costa Rica, Cuba, Curaçao, Dominica, Dominican Republic, Ecuador, El Salvador, Falkland Islands (Malvinas), French Guiana, Grenada, Guadeloupe, Guatemala, Guyana, Haiti, Honduras, Jamaica, Martinique, Mexico, Montserrat, Nicaragua, Panama, Paraguay, Peru, Plurinational State of Bolivia, Puerto Rico, Saint Barthélemy, Saint Kitts and Nevis, Saint Lucia, Saint Martin (French part), Saint Vincent and the Grenadines, Sint Maarten (Dutch part), South Georgia and the South Sandwich Islands, Suriname, Trinidad and Tobago, Turks and Caicos Islands, Uruguay, Virgin Islands (British), Virgin Islands (U.S.)

I agree the default behaviour should be for it to fail, so something like a --ignore-invalid-options flag could work? Thanks again!

miguelamaral commented 3 years ago

Ah, lmao, it took me a while to figure out how to use the smart_filter, actually!

meisnate12 commented 3 years ago

i could add a flag under smart_filter which can allow it to ignore fails.

I'm working on the wiki pages for smart_filter and the other 1.9.0 changes now so hopefully ill have that done soon and people wont have to either read code or guess how to use it haha but I tried to make it as similar to how the advance search looks as much as possible

miguelamaral commented 3 years ago

Yeah, that'd be great! I think I actually found the smart_filter method in use afterwards in an updated config file, so that helped. Though I lack experience with python, the fact I can sort of make sense of most of the code must mean you're doing something right!

meisnate12 commented 3 years ago

ok add validate: false under smart_filter and it should not error out