Developer questions

Hi, I’m writing a Download client integration for Sonarr and will submit it as a pull request but I want to ask a question about the inner workings of Sonarr before I submit it so I keep things in keeping with standards?

Is there a recommended way to persist data between restarts? The download client I’m writing for doesn’t have an api to list it’s current queue, I can get the status of a job by passing in the job id so need to store a list of job id’s started by Sonarr for later retrieval, I’m currently using a singleton class but this won’t survive a Sonarr restart.

If I add more functionality at a later date and change or add items on the download clients settings page, how can I prevent this from breaking someones existing setup?

Which download client doesn’t support listing the torrents on the api. And who do we need to treat with tar and feathers?
It’s really ugly. It’d make the thing pretty unreliable.

Anyway, on startup (IHandle<ApplicationStartupEvent>) it might be possible to read the list from the HistoryService, since any grab would be tracked there. Still very ugly, it’s definitely better to improve that download client’s api, or if it’s not possible… use another client. Sometimes it’s not worth the headaches.

Btw we don’t do singletons, just add a separate service+interface, the service should then use ICacheManager to store the data (in memory). It kinda behaves like a singleton, but is completely mockable for unit testing.

PS: We do have quite strict standards on what gets merged in. It has to work properly, contain sufficient unittests and follow the proper design. Otherwise we’d be saddled up with supporting it.

It’s OffCloud, and they kind of do and kind of don’t support returning a download list. The official API where you use only the API key can only add a torrent and check it’s specific status. I’ve done some digging and they have an API they use but it needs a login cookie generated from the login page (messy). Their API docs are sparse would be generous, plus they are a year old.

I don’t mind if it gets rejected, I’m doing it for myself mainly, using rclone mount to keep everything in the cloud and without the round trip back to my pc but handled by Sonarr.

I will take a look at the things you suggested thanks.

1 Like