Skip to content

[add] btn - exact_only option to omit second search#1787

Closed
tubedogg wants to merge 1 commit intoFlexget:developfrom
tubedogg:btn-exact-only
Closed

[add] btn - exact_only option to omit second search#1787
tubedogg wants to merge 1 commit intoFlexget:developfrom
tubedogg:btn-exact-only

Conversation

@tubedogg
Copy link
Copy Markdown
Contributor

Motivation for changes:

If the title to be searched ends in a parenthesis, and there are no results on the first search, btn automatically runs a second search omitting the text in parenthesis. This can cause unwanted results to be accepted. This change adds a second config type, a dict with api_key and exact_only. When exact_only is set to yes, the second search will never be run.

Detailed changes:

  • btn now accepts either of the below config types.
  • If exact_only is true (yes), the second search will never be run.

Config usage if relevant (new plugin or updated schema):

Original style:

  discovery:
    from:
      - btn: API_KEY_HERE

Optional new style:

  discovery:
    from:
      - btn:
          api_key: API_KEY_HERE
          exact_only: yes

If the title to be searched ends in a parenthesis, and there are no
results on the first search, btn automatically runs a second search
omitting the text in parenthesis. This can cause unwanted results to be
accepted. This change adds a second config type, a dict with api_key
and exact_only. When exact_only is set to yes, the second search will
never be run.
results = set()
for search in searches:
data = json.dumps({'method': 'getTorrents', 'params': [api_key, search], 'id': 1})
data = json.dumps({'method': 'getTorrents', 'params': [config.get('api_key'), search], 'id': 1})
Copy link
Copy Markdown
Contributor

@cvium cvium Apr 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor detail, api_key is always present, so there's no need to use config.get('api_key') over config['api_key']. I prefer to use the latter in that scenario.

@liiight
Copy link
Copy Markdown
Member

liiight commented Apr 11, 2017

Maybe that value can be exposed by the next_series plugins?

@tubedogg
Copy link
Copy Markdown
Contributor Author

(Looking at next_series_episodes though it should be very similar in next_series_seasons)

Okay, what about if we inserted this at line 67:

        grab_series_config = next((d for i,d in enumerate(task.config['series']) if series.name in d), {})
        series_config = ''
        if grab_series_config:
            series_config = grab_series_config.values()[0]

And then add series_config to the entry that's created immediately thereafter? Any plugin receiving the entry could utilize any series settings it wanted to.

@cvium
Copy link
Copy Markdown
Contributor

cvium commented Apr 11, 2017

Sounds incredibly hacky.

@liiight
Copy link
Copy Markdown
Member

liiight commented Apr 11, 2017

From the looks of it, there's no way to know outside of the series plugin if exact was used (this can be manual via config or exact). Maybe the soltuion is just to set an attribute to True and then return in the entry under series_exact or something

@tubedogg
Copy link
Copy Markdown
Contributor Author

While we're talking about it, identified_by should be exposed too, so next_series_* can take it into account when deciding whether to process a series, i.e. #1785. series_identified_by?

@liiight
Copy link
Copy Markdown
Member

liiight commented Apr 18, 2017

Thus is irrelevant now with the new series metainfo changes, right?

@tubedogg
Copy link
Copy Markdown
Contributor Author

Yeah it should be.

@tubedogg tubedogg closed this Apr 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants