theotherp / nzbhydra2

Usenet meta search
Other
1.26k stars 76 forks source link

Custom text search for indexers #700

Closed JaiMistry closed 3 years ago

JaiMistry commented 3 years ago

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 commented 3 years ago

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 https://github.com/Sonarr/Sonarr/issues/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 https://github.com/theotherp/nzbhydra2/issues/700, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNUA6KPLZSVE6DZ3QXAGYLTICNCNANCNFSM42WZGQ4A .

Minituff commented 3 years ago

It sounds like he is asking to add a feature in Hydra that Sonarr is refusing to add. This issue https://github.com/Sonarr/Sonarr/issues/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 commented 3 years ago

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 commented 3 years ago

That would be really complicated to implement without either being to specific or too imprecise. A simple regex replacement would be easy but I don't think you could get what you want to work with it. How would hydra know that episode 84 is season x episode y? That would require hydra to actually parse the query, get the series media info and do this specific replacement. That sounds really specific.

On Sat, 10 Apr 2021, 22:11 Jai Mistry, @.***> wrote:

I don't understand the requirement, please explain further. … <#m8004490930958831143> 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 https://github.com/Sonarr/Sonarr/issues/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 https://github.com/theotherp/nzbhydra2/issues/700>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNUA6KPLZSVE6DZ3QXAGYLTICNCNANCNFSM42WZGQ4A .

@Minituff https://github.com/Minituff's comment https://github.com/theotherp/nzbhydra2/issues/700#issuecomment-817195930 explains it well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/theotherp/nzbhydra2/issues/700#issuecomment-817196178, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNUA6J5ARPL7JAXPKPDYHTTICWGNANCNFSM42WZGQ4A .

Minituff commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Done.

furbyhaxx commented 2 years ago

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 commented 2 years ago

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

furbyhaxx commented 2 years ago

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 commented 2 years ago

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

furbyhaxx commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Fixed in next version.

furbyhaxx commented 2 years ago

Fixed in next version.

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

theotherp commented 2 years ago

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 commented 2 years ago

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"