Conversation
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
You should use setdefault() instead
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Line seemed too long, wanted to simplify reading it. Will move to one line
There was a problem hiding this comment.
Isn't this function only used in one place? Might make more sense to scrap the function then... It only makes it harder to read.
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Why is this not done in prepare_config?
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Why save it in a variable? I don't anything is gained by it
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
I'm not a fan of if one-liners. Just move continue down.
flexget/plugins/filter/unique.py
Outdated
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Nothing happens if field is not specified?
There was a problem hiding this comment.
defaults to the entire entity.
def extract_fields(self, entry, field_names):
if field_names:
pass
return {field: entry.get(field) for field in field_names}
else:
return entry
There was a problem hiding this comment.
Should I document it somewhere?
There was a problem hiding this comment.
I just wonder if it ever happens that two entries are identical and wouldn't you want to ensure uniqueness on specific parameters? I'm not sure I see the "general" case.
There was a problem hiding this comment.
I copied this behavior from the "duplicates" plugin. I think it's a good behavior for ensuring uniqueness of simple entities.
Would you have required specifying field?
There was a problem hiding this comment.
The duplicates plugin requires action and field.
There was a problem hiding this comment.
OK, I've misremembered.
I'm feeling like if you say "I want these entities to be unique" and you're not saying based on which criteria, it's legit to compare the entire entity.
If you feel like this is a weird behavior, I'll remove it and mandate the field
There was a problem hiding this comment.
I think it's better to mirror duplicates plugin and require field.
flexget/tests/test_unique.py
Outdated
flexget/tests/test_unique.py
Outdated
flexget/tests/test_unique.py
Outdated
There was a problem hiding this comment.
What are all these imports for?
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Isn't any(entry_fields) the same as entry_fields? You can also short-circuit this if by checking entry_fields first ie. if entry_fields and entry_fields == prospect_fields.
57ba3cd to
356cd14
Compare
|
Thanks for the review! Fixed issues you commented about |
flexget/tests/test_unique.py
Outdated
flexget/tests/test_unique.py
Outdated
There was a problem hiding this comment.
I don't think this is really needed.
85a7257 to
a19e789
Compare
flexget/tests/test_unique.py
Outdated
There was a problem hiding this comment.
I don't think this import is used
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
task.entries only contains entries that are accepted or undecided btw
There was a problem hiding this comment.
I think I'd like to keep the skips, in case they're rejected / accepted mid-plugin
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Doesn't make sense to check this after you've extracted the fields :)
a19e789 to
d760813
Compare
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
Won't you potentially end up with a bunch of None values?
There was a problem hiding this comment.
I could, but if that's what the user wants to determine uniqueness by...
I'd prefer that than failing the run because of a missing field. Not sure what's the flexget norms on that
There was a problem hiding this comment.
I don't think it makes much sense to compare the entries if they don't have all the fields present.
flexget/tests/test_unique.py
Outdated
There was a problem hiding this comment.
You don't need these two either.
flexget/tests/test_unique.py
Outdated
There was a problem hiding this comment.
This seems wrong :) Beware of copy/pasting. You make a lot of errors.
There was a problem hiding this comment.
Yeah. I hope my colleagues will never see this :)
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
There was a problem hiding this comment.
I thought this was autoconverting to a list. Apparently not. Oh well
b0b0f27 to
a1b1b37
Compare
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
This check is also performed after field extraction
a1b1b37 to
22c7f90
Compare
|
No rush whatsoever, but I think I cleared all of the review issues. Would appreciate more feedback! |
|
I still think it'd be best to skip entries that do not have all specified fields present. |
|
Right now it's failing for these entities, like duplicate: |
|
ping @cvium |
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
This will crash if the field is not present.
There was a problem hiding this comment.
Same here: https://github.com/flexget/Flexget/blob/master/flexget/plugins/filter/duplicates.py#L38
Think we should skip entries/prospects without the required fields instead?
There was a problem hiding this comment.
Yes. Duplicates should not be changed in this PR though.
There was a problem hiding this comment.
R. Done and added testing for it.
22c7f90 to
803b728
Compare
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
I think it would be better to use EAFP in this case. Just have extract_fields assume all fields are present and catch the KeyError here.
803b728 to
272b959
Compare
flexget/plugins/filter/unique.py
Outdated
There was a problem hiding this comment.
oh right you are
Takes action on all duplicates, except for the first
272b959 to
dd8b352
Compare
|
Hmm, this plugin is starting to look a lot like Aren't the ideas similar? |
|
from #1231:
|
|
I see. |
|
Wanna update the wiki? |
|
sure, how do I |
|
You can pretty much copy https://flexget.com/Plugins/duplicates |
|
Great. Will do soon |
|
Done |
Takes action on all duplicates, except for the first
Motivation for changes:
Redoing #1231 in a separate plugin
Allowing to create unique lists by rejecting second+ items based on a list of fields.
Also created tests
Detailed changes:
New plugin "unique":
Addressed issues:
(no tickets)
Personal usecase - select only one entry of each kind (e.g. only one torrent for a movie)
Config usage if relevant (new plugin or updated schema):
New plugin as described above.
Nothing else
Log and/or tests output (preferably both):