kiranshila / Doplarr

An *arr request bot for Discord
MIT License
425 stars 30 forks source link

Overseerr Support #5

Closed kiranshila closed 2 years ago

kiranshila commented 3 years ago

Integrate Ombi/Overseer somehow

ghost commented 3 years ago

Hey mate, not sure if this is in the scope of your Doplarr bot... But!

Overseerr has native support for separate 4K Radarr/Sonarr servers.. Overseerr also manages user permissions, like who can request 4K, who can't, who can request "normal" content, and who can't .. and so on.

It would be nice to have separate commands for the separate 4K Radarr/Sonarr servers, which are configured through Overseerr. So commands like /4kmovie and /4ktv to request through Overseerr, specifically using the separate 4K Radarr/Sonarr servers.

I made a similair request on the requestrr repo.

kiranshila commented 3 years ago

So, the tricky bit is that it's a slippery slope, once we add separate commands for individual profiles, we'd have to keep doing that for all potential profiles, which doesn't scale. The profile selection would happen inside the single \request interaction. I'm going to track that feature in #14.

So - we would need to connect the discord user to the overserr user and then add a separate interaction screen for profile selection that filters by what that user is able to request.

The reason we would do this inside the interaction is because it would be a hot mess to try to connect the overserr permissions to discord permission as the permissions structuring for the slash commands is a nightmare.

I haven't used either ombi or overseerr, nor do I personally plan to, so I have to look more into how it all works.

There seem to be even more options than those two as well, I saw Conreq and Cheddarr just to name a few. The more APIs we add, the more difficult managing them all become, so I think I might just pick one for the time being.

From a cursory look, I think I will go with Overseerr. Of the people following this issue, are there any thoughts on this?

onedr0p commented 3 years ago

Overseerr looks like the most popular choice of them all. The developers are super responsive and their app is very fast and very pretty.

If anything you could deploy multiple Doplarr bots with different profiles configured to each one.

cpt-kuesel commented 3 years ago

I vote for Overseerr Support as well. Their API structure is well built, at least thats what I gathered from talking with the requestrr and lunasea devs.

kiranshila commented 3 years ago

Great! I'm going to work on the backlog of a few of these easier bugs/enhancements first, then I'll dive into this.

onedr0p commented 3 years ago

@kiranshila thanks, looking forward to it!

onedr0p commented 3 years ago

Also, here's a link to their API docs https://api-docs.overseerr.dev/

kiranshila commented 3 years ago

I've been reading the overseer docs, seems straightforward. The fact that users can "just have" a discord id as part of their metadata makes this pretty easy. I'm going to need to do some checks to make sure that if we are using overseer, validate that the user can perform the request and if not, return a permission error dialog.

cpt-kuesel commented 3 years ago

i am running overseerr and am willing to test anything you need tested in that regard!

ahkamyaqeen commented 3 years ago

@kiranshila if you are open to pull requests, I'd love to help implement this feature (I do have a background in using Clojure)

kiranshila commented 3 years ago

@ahkamyaqeen Yeah, if you'd like - I was going to tackle it this weekend, though.

kiranshila commented 3 years ago

Started today - the api is actually a little wonky, not using the modern query params spec, which is throwing errors for search terms with spaces as the Java 11 URLEncoder encodes spaces as +.

I opened an issue here https://github.com/sct/overseerr/issues/2010

onedr0p commented 3 years ago

@kiranshila there's a interesting stackoverflow about that issue. Seems pretty lengthy, maybe there's a workaround for now?

https://stackoverflow.com/questions/4737841/urlencoder-not-able-to-translate-space-character

kiranshila commented 3 years ago

Yeah, + is correct, Java isn't wrong lol, its a bug in Overseerr. I have a fix in place rn, it's just annoying haha

onedr0p commented 3 years ago

Oh definitely a Bug on their end, I'm just mentioning you can likely workaround it for now until it's fixed by them upstream. The first answer in the stackoverflow seemed like it would do.

/ignore me, didn't read you put a work around in already lol

kiranshila commented 3 years ago

The specific HTTP wrapper I am using does a URI encode before it submits the request anyway, so I am manually creating the query param string instead of the nice {:query-params ... construct. URI encoding puts spaces to %20, so it works out.

kiranshila commented 3 years ago

Made a lot of progress today, requesting movies basically works:

You get an error message in discord for quota limits

image

And an error for missing associated account image

I think I prefer this - requiring you have a mapping from user in overseerr to discord rather than having a default, but let me know what you think.

cpt-kuesel commented 3 years ago

I like your approach on this! My Overseerr users that are on my Discord Server all have their respective Discord ID mapped. So I am well prepared 😄

Which profile do you use when you send the request to Overseerr? Do you take the default one for movies/shows that is configured in Overseerr? Or does the user need to choose it when I have multiple? My preference would just be default profile.

ghost commented 3 years ago

It would be nice if checked for permission(s) as well, and reported back to the user if they don't have permission. E.g. to the profiles associated with the 4K Sonarr / Radarr instances.

kiranshila commented 3 years ago

I like your approach on this! My Overseerr users that are on my Discord Server all have their respective Discord ID mapped. So I am well prepared smile

Which profile do you use when you send the request to Overseerr? Do you take the default one for movies/shows that is configured in Overseerr? Or does the user need to choose it when I have multiple? My preference would just be default profile.

As far as I can tell, I can't actually select the profile for the requests via the API, so it will always use whatever is setup in Overseerr

kiranshila commented 3 years ago

It would be nice if checked for permission(s) as well, and reported back to the user if they don't have permission. E.g. to the profiles associated with the 4K Sonarr / Radarr instances.

What permissions are you referring to? Just 4K vs non-4K, or quota limits, or other stuff. I'm still trying to think of a nice way to do the 4K split, but it looks like that requires having two different servers up, it can't just use a different profile afaik.

ghost commented 3 years ago

It would be nice if checked for permission(s) as well, and reported back to the user if they don't have permission. E.g. to the profiles associated with the 4K Sonarr / Radarr instances.

What permissions are you referring to? Just 4K vs non-4K, or quota limits, or other stuff. I'm still trying to think of a nice way to do the 4K split, but it looks like that requires having two different servers up, it can't just use a different profile afaik.

Exactly what I'm referring to (the 4K vs the non-4K permissions) :smile: .

To use 4K instances in Overseerr, you'll need separate Radarr / Sonarr instances for that. So, in Overseerr, it's usually setup (if you want to use 4K instances) like so: 1x Radarr for non-4K movie content 1x Sonarr for non-4K TV content 1x Radarr for 4K movie content 1x Sonarr for 4K TV content All instances are separate and doesn't share profiles.

In my case, I've just named the non-4K Radarr/Sonarr profiles to "HD-1080p" and the 4K Radarr/Sonarr profiles to "UHD-4K". So they do have different profile names, not sure if that matters at all.

E.g. https://i.imgur.com/79ymn1c.png

kiranshila commented 3 years ago

Got it. Yeah, I'll need to chew on that a bit - I'll probably do it like the drop down for profile select, but I have to find which API endpoint lets me check if a user has permission for that.

cpt-kuesel commented 3 years ago

just for clarification, i meant the overseer profiles as well, @VP-EN did a better job describing it :)

ghost commented 3 years ago

Hey @kiranshila, I'm not sure how far you are with this, but I got to think :smile: Is it possible to add an (optional) option for Doplarr to request content on both profiles (regular + 4K)?

E.g.. If one user tries to request a Movie in 4K, that it also sends the same request (same movie) to the regular sonarr/radarr as well.

Not sure if "options" are a part of Doplarr, so forgive me if this should be a in a separate GH issue.

kiranshila commented 2 years ago

Sorry I've been quiet on this - got a ton of school stuff to catch up on. I'll finish this up soon.

kiranshila commented 2 years ago

Ok I think I got it all working - if someone with an overseerr setup wants to try it out, check out the ghcr.io/kiranshila/doplarr:overseerr docker image

kiranshila commented 2 years ago

If y'all don't find any major problems, I'm ready for the release

onedr0p commented 2 years ago

@kiranshila it would be good to know what environment variables to set :) But go ahead and merge it. I'm sure there will be feedback after you release it.

kiranshila commented 2 years ago

Oh sorry, it's in the readme in this branch. You just set overseerr_url and overseerr_api, just like radarr and sonarr

cpt-kuesel commented 2 years ago

I tried it and movies and tv shows work as expected.

Anime shows can't be requested, at least thats the conclusion i have come to.

Also requesting something thats already available gives the user no feedback and doesn't close the request.

cpt-kuesel commented 2 years ago

To clarify on animes: I am able to click request and get the response has been requested, but the actual request doesnt go through

ghost commented 2 years ago

I'm quite busy today, so I'll only be able to test it tomorrow Edit Sorry probably won't be able to test it today either 😕

kiranshila commented 2 years ago

@cpt-kuesel

Also requesting something thats already available gives the user no feedback and doesn't close the request.

Ah yes - forgot about that.

I am able to click request and get the response has been requested, but the actual request doesnt go through

I am unable to reproduce this. Is there any error in the log? Is your anime setup somehow different?

cpt-kuesel commented 2 years ago

I didn't see any errors in doplarr or overseerr logs unfortunately.

I don't think my anime setup is different. Both tv shows and anime are defined in the default profile for sonarr and differ only in root folder and tags. image

cpt-kuesel commented 2 years ago

Okay so I tried a bit more and was partially successful. I did manage to request the anime shows i couldn't request before.

And I think I know the problem. I can only request them if choose a specific season. If i choose all seasons the request doesnt go through.

kiranshila commented 2 years ago

When you say it doesn't go through - like the request isn't showing up at all in Overseerr?

cpt-kuesel commented 2 years ago

Correct, it never reaches Overseerr. Not even in the overseerr logs.

onedr0p commented 2 years ago

I was able to get this working and tested against adding a movie and tv show 🎉

kiranshila commented 2 years ago

I think after I fix whatever is happening with @cpt-kuesel's anime and add a duplicate request message, we should be good to go

ghost commented 2 years ago

I'm probably just an idiot, but I followed the guide quite closely, added the bot..

docker run \
-e OVERSEERR_URL='https://overseerr.xxxx.com' \
-e OVERSEERR_API='xxxxxxxxxxxxxxxxxxxxxxxxx=' \
-e BOT_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxx' \
-e ROLE_ID='xxxxxxxxxxxxxxxxxxxxxxxx' \
--name doplarr ghcr.io/kiranshila/doplarr:overseerr

Getting this from the docker logs:

19:05:38,774 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
19:05:38,774 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
19:05:38,774 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/app/target/Doplarr.jar!/logback.xml]
19:05:38,778 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@b0e5507 - URL [jar:file:/app/target/Doplarr.jar!/logback.xml] is not of type file
19:05:38,828 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
19:05:38,828 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
19:05:38,830 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
19:05:38,863 |-WARN in ch.qos.logback.core.ConsoleAppender[CONSOLE] - This appender no longer admits a layout as a sub-component, set an encoder instead.
19:05:38,863 |-WARN in ch.qos.logback.core.ConsoleAppender[CONSOLE] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
19:05:38,863 |-WARN in ch.qos.logback.core.ConsoleAppender[CONSOLE] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
19:05:38,864 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
19:05:38,864 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
19:05:38,864 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
19:05:38,864 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@6bbe50c9 - Registering current configuration as safe fallback point

Assuming this is alright, since the bot is showing it's online.

~~but I have a problem - the /request options are greyed out. I double checked the permissions given to the assigned role.. The "Use Application Commands" is set to enabled both in the role and in the channel I'm trying to use..~~ NEVERMIND.. Forgot to read this part lol:

Every user that you wish to have access to the slash commands needs to be
assigned this role (even the server owner/admins).
kiranshila commented 2 years ago

@VP-EN Yeah, I should probably bold that or something - that seems to be the most common thing people are missing. This is an artifact of the discord slash command permissions nonsense, there isn't really a way around it.

ghost commented 2 years ago

@VP-EN Yeah, I should probably bold that or something - that seems to be the most common thing people are missing. This is an artifact of the discord slash command permissions nonsense, there isn't really a way around it.

Slightly annoying, but that's not your fault 😄 I guess I'll create some trash role for the sole purpose of the bot 👍

The requesting works very good though. Again, as you already mentioned, it would be awesome with both a "this is already on Plex", if Overseerr knows it's already on Plex, or "this has already been requested" if Overseerr already knows it has been requested, and so on.

Thanks a lot for your work on this 👍

kiranshila commented 2 years ago

Slightly annoying, but that's not your fault smile I guess I'll create some trash role for the sole purpose of the bot +1

An alternative idea would be to make the role bit optional, if you want everyone on the server to have access to it, then we could just not use a role at all. Those are the two options the discord API has, all or nothing.

ghost commented 2 years ago

I think assigning it to a certain part (certain group of people) of my Discord is sufficient in my case.

I'm wondering how I can limit the bot to only work in a specific channel though. Do you have any thoughts on this/ideas?

kiranshila commented 2 years ago

I'm wondering how I can limit the bot to only work in a specific channel though. Do you have any thoughts on this/ideas?

It's not possible with the current slash command API, that's why we need the role.

ghost commented 2 years ago

I'm wondering how I can limit the bot to only work in a specific channel though. Do you have any thoughts on this/ideas?

It's not possible with the current slash command API, that's why we need the role.

I see, thanks again mate. You're a legend.

ghost commented 2 years ago

Sorry to spam up this issue.. but I have this one user on Discord I tried to test this with. I copied and added his Discord ID to his Plex profile on Overseerr, but when he's trying to request, he gets the You do not have an associated account on Overseerr message.

It works on my own user, and I just copied my own ID into my Plex profile Overseerr.

kiranshila commented 2 years ago

Ooo interesting - I suppose I should try to add more than one user to my test setup here haha

ghost commented 2 years ago

Edit: The user in question 👍 https://i.imgur.com/fRBQRvJ.png