Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom text search for indexers #700

Closed
JaiMistry opened this issue Apr 10, 2021 · 19 comments
Closed

Custom text search for indexers #700

JaiMistry opened this issue Apr 10, 2021 · 19 comments

Comments

@JaiMistry
Copy link

One of the major downsides with Sonarr is that you cannot enter a custom query to send to your indexers. There has been an issue opened here for 7 years now for this exact feature request, but has had no traction.

Would this be something that could be implemented on Hydra instead?

@theotherp
Copy link
Owner

theotherp commented Apr 10, 2021 via email

@Minituff
Copy link

It sounds like he is asking to add a feature in Hydra that Sonarr is refusing to add. This issue Sonarr/Sonarr#3712 that I opened has some more info on it.

So the request would be to allow hydra to parse the query coming from Sonarr and actually change/modify/delete it before passing it over to the indexers.

This would be an example workflow:

  1. Sonarr sends query to Hydra: My Hero Academia 84
  2. Hydra parses query My Hero Academia 84
  3. Hydra checks custom config which is to change absolute episode number (84) to season/ep format (S4 E21)
  4. Hydra modifies query: My Hero Academia S4 E21
  5. Hydra sends modified query to indexer My Hero Academia S4 E21

The reason why this is helpful is the the query My Hero Academia 84 will not actually find the episode but the query My Hero Academia S4 E21 will. Sonarr does not allow us to edit or modify the query string that is sent to indexers so we are hoping Hydra can help.

@JaiMistry
Copy link
Author

I don't understand the requirement, please explain further.

On Sat, 10 Apr 2021, 20:53 Jai Mistry, @.***> wrote: One of the major downsides with Sonarr is that you cannot enter a custom query to send to your indexers. There has been an issue opened here <Sonarr/Sonarr#1128> for 7 years now for this exact feature request, but has had no traction. Would this be something that could be implemented on Hydra instead? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#700>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNUA6KPLZSVE6DZ3QXAGYLTICNCNANCNFSM42WZGQ4A .

@Minituff's comment explains it well.

@theotherp
Copy link
Owner

theotherp commented Apr 10, 2021 via email

@Minituff
Copy link

Minituff commented Apr 10, 2021

I actually think a simple regex replacement would be able to do about 50% of the work for this case. The only difficult part would be that you'd need to equate EP 84 (absolute order) actually equals S4 E21 (aired order). If that query was sent to Hyrdra with the TVDB ID does the API let you determine which EP number it is?

Using My Hero Academia as an example the TVDB 3 sections: Aired Order, DVD Order, and Absolute order. I'm wondering if it is possible to convert them.

If that theory is correct, then the regex would look something like this:
My Hero Academia (\d*) -> My Hero Academia {Whatever came back from TVDB}

@theotherp
Copy link
Owner

I don't understand why the sonarr people don't change the query if it doesn't work? Does this affect only certain indexers or would a complete change of the query before sending it to all indexers be enough? I might give that a try but having it only affect certain indexers would make it a nightmare to configure.

@theotherp
Copy link
Owner

What makes this even more complicated is that sonarr actually searches for the string My Hero Academy S4 (and My Hero Academia 4th Season etc.) and the season 4 and the episode 21. It's not just a search string. On the other hand that would allow hydra to directly use that information instead of having to parse the query and get the info from tvmaze or some other metadata provider.

So for this use case the config would be something like my hero academia .* -> my hero academia s{season:00}e{episode:00}.

I'll give it a go. Do you have other examples I could test this against?

This would also resolve #638 although that one targets the query built by hydra, not the one provided via an API request.

@theotherp
Copy link
Owner

Ok, I got a proof of concept working. The configuration UI will be bare-bones though because I don't expect a lot of people to use this.

Example config value: TVSEARCH;QUERY;{title:my hero academia}{0:.*};{title} s{season:00}e{episode:00}.
The first value is the context, the second the value to be replaced (QUERY or TITLE).
The third value is a semi-regex that needs to match the input. The braces mark a matching group. The first part is the name by which it may be referenced (see next value), the second a regex that it must match.
The fourth value is the replacement which may refer to groups in the third value.

In this case a query my hero academia s1 with season 1 and episode 1 (from the search requests meta data as provided by sonarr) would be mapped to my hero academia s01e01.

@theotherp
Copy link
Owner

Done.

@furbyhaxx
Copy link

Hi, is it possible that this is broken in the most recent version?
search type: QUERY
Affected value : title
input pattern
: {title:Fairy Tail}{ep:[0-9]+} or {title:Fairy Tail} {episode:00} or {title:Fairy Tail}{0:.*}
output pattern: {title} german e{ep}

test string: FairyTail 49

should work right?

nothing works. it doesn't match or it ignores the episode numbers. sometimes there's also an error, telling me that episode group is not allowed in input pattern.

@theotherp
Copy link
Owner

The query is sent to *arr. If it doesn't work you should talk to to their devs.

@furbyhaxx
Copy link

I think I am missunderstanding something.
I want that when sonarr is searching for "Fairy Tail 49" hydra rewrites this to "Fairy Tail e49"

@theotherp
Copy link
Owner

Oh. Holy shit, I don't even remember implementing this. I'll take a look.

@furbyhaxx
Copy link

furbyhaxx commented Jun 13, 2022

I feel you ^^, I should've looked at the code in the first place. in "CustomSearchRequestMapping.java" the comment say's:

// What should happen: q=Boku no Hero Academia S4, season=4, ep=21 -> Boku no Hero Academia s04e21
// What the user should enter roughly: {0:(my hero academia|Boku no Hero Academia) {ignore:.} -> {0} s{season:00} e{episode:00}
//How it's configured: "TVSEARCH;QUERY;{0:(my hero academia|Boku no Hero Academia) {ignore:.
};{0} s{season:00} e{episode:00}"

//{title:the haunting} {0:.*} -> The Haunting of Bly Manor {0}

so if I try: {a:the haunting} {b:.*} -> {a} {b} = the haunting {b}

looks like a missing loop as only the first group gets recognized.

@furbyhaxx
Copy link

I got a temporary workaround by using: fairy tail {0:.*} -> fairy tail german e{0}
BUT, it's only applied for internal searches and not external.

@theotherp
Copy link
Owner

Fixed in next version.

@furbyhaxx
Copy link

Fixed in next version.

Thanks, does it also fox the issue that it's only applied to internal searches?

@theotherp
Copy link
Owner

By the way, in the future please open a new issue instead of commenting on the old one.

It should work for external searches at well. Perhaps the search type does not match. Please set the logfile level to debug, enable the logging marker "Config mapping", restart hydra, recreate the problem and attach a newly created debug infos zip.

@furbyhaxx
Copy link

yeah, sorry for hijacking the issue. anyway, I tried to create a debug infos file but get an undefined error:
`An error occurred:
undefined: undefined

Message: undefined`

The replacement works as expected now but not when sonarr is searching as the search type is "SEARCH"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants