totaldebug / pyarr

Python client for Servarr API's (Sonarr, Radarr, Readarr, Lidarr)
https://docs.totaldebug.uk/pyarr
MIT License
72 stars 19 forks source link

Add V3 Sonarr API support #101

Closed haijeploeg closed 2 years ago

haijeploeg commented 2 years ago

I am the developer op Excludarr and I would like to replace my own API wrapper for Sonarr and Radarr with this library. I'm running into a problem that the default /api endpoint is being used in Sonarr. Sonarr is not being clear about there being a v3 endpoint as well. The v3 endpoint of the api returns more information, for example if the show has ended or not. Also the v3 api endpoint supports adding an import exclusion when deleting the serie.

Expected behavior

I expect to supply the ver_uri when initializing the SonarrAPI class

Current behavior

I cannot specify the ver_uri for SonarrAPI.

Possible solutions

I suggest the following:

class SonarrAPI(BaseArrAPI):
    """API wrapper for Sonarr endpoints."""

    def __init__(self, host_url: str, api_key: str, ver_uri=""):
        """Initialise SonarrAPI
        Args:
            host_url (str): URL for Sonarr
            api_key (str): API key for Sonarr
            ver_uri (str): API version for Sonarr
        """

        super().__init__(host_url, api_key, ver_uri)

Context and reason

Excludarr relies on wether or not the show has ended or not. Also it would be nice if the addImportExclusion option is available when deleting a show. I have this currently like this in my code:

def delete_serie(self, id, delete_files, add_import_exclusion):
    params = {
        "deleteFiles": delete_files,
        "addImportExclusion": add_import_exclusion,
    }
    return self.client.http_delete(self.serie_id_path.format(id=id), params=params)

This functionality would really help me to intergrate this in Excludarr. I am more than happy to help or assist you if you need any help :)

Checklist

github-actions[bot] commented 2 years ago

Hello @haijeploeg, thank you for your interest in our work!

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.{% endraw %}

Archmonger commented 2 years ago

As a heads up, Sonarr's v3 endpoint is still heavily under development and is not ready for production use yet. We need to wait for them to finish development (and ideally also documentation) of the v3 endpoint prior to integrating into pyarr as the default.

I'll see if it's reasonable to add in a customizable ver_uri on our end though.

Archmonger commented 2 years ago

PR has been created to add this feature for you. This parameter will likely be removed once the v3 endpoint becomes official.

marksie1988 commented 2 years ago

v3.1.2 has now been released with this workaround.