private static string GetApiUrl(qBitTorrentAPIPath path) { string url = $"http://{TVSettings.Instance.qBitTorrentHost}:{TVSettings.Instance.qBitTorrentPort}/"; switch (TVSettings.Instance.qBitTorrentAPIVersion) { case qBitTorrentAPIVersion.v1: { return(path switch { qBitTorrentAPIPath.settings => url + "query/preferences", qBitTorrentAPIPath.torrents => url + "query/torrents?filter=all", qBitTorrentAPIPath.torrentDetails => url + "query/propertiesFiles/", qBitTorrentAPIPath.addFile => url + "command/upload", qBitTorrentAPIPath.addUrl => url + "command/download", qBitTorrentAPIPath.delete => url + "command/delete", _ => throw new ArgumentOutOfRangeException(nameof(path), path, null) }); }
private static string GetApiUrl(qBitTorrentAPIPath path) { string url = $"http://{TVSettings.Instance.qBitTorrentHost}:{TVSettings.Instance.qBitTorrentPort}/"; switch (TVSettings.Instance.qBitTorrentAPIVersion) { case qBitTorrentAPIVersion.v1: { switch (path) { case qBitTorrentAPIPath.settings: return(url + "query/preferences"); case qBitTorrentAPIPath.torrents: return(url + "query/torrents?filter=all"); case qBitTorrentAPIPath.torrentDetails: return(url + "query/propertiesFiles/"); case qBitTorrentAPIPath.addFile: return(url + "command/upload"); case qBitTorrentAPIPath.addUrl: return(url + "command/download"); default: throw new ArgumentOutOfRangeException(nameof(path), path, null); } } case qBitTorrentAPIVersion.v2: { switch (path) { case qBitTorrentAPIPath.settings: return(url + "api/v2/app/preferences"); case qBitTorrentAPIPath.torrents: return(url + "api/v2/torrents/info?filter=all"); case qBitTorrentAPIPath.torrentDetails: return(url + "api/v2/torrents/files?hash="); case qBitTorrentAPIPath.addFile: return(url + "api/v2/torrents/add"); case qBitTorrentAPIPath.addUrl: return(url + "api/v2/torrents/add"); default: throw new ArgumentOutOfRangeException(nameof(path), path, null); } } case qBitTorrentAPIVersion.v0: throw new NotSupportedException("Only qBitTorrent API v1 and v2 are supported"); default: throw new ArgumentOutOfRangeException(nameof(TVSettings.Instance.qBitTorrentAPIVersion), TVSettings.Instance.qBitTorrentAPIVersion, null); } }