Skip to content

Commit

Permalink
Sonarr V4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
darkalfx committed Jan 2, 2024
1 parent 750acb7 commit 473a645
Show file tree
Hide file tree
Showing 7 changed files with 825 additions and 157 deletions.
109 changes: 0 additions & 109 deletions Requestrr.WebApi/ClientApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function Sonarr(props) {
<Dropdown
name="API"
value={apiVersion}
items={[{ name: "Version 2", value: "2" }, { name: "Version 3", value: "3" }]}
items={[{ name: "Version 2", value: "2" }, { name: "Version 3", value: "3" }, { name: "Version 4", value: "4" }]}
onChange={newApiVersion => { setApiVersion(newApiVersion) }} />
</Col>
<Col lg="6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,44 +224,48 @@ function SonarrCategory(props) {
props.apiVersion !== "2"
? <>
<Row>
<Col lg="6">
<div className="input-group-button mb-4">
<Dropdown
name="Language"
value={props.category.languageId}
items={reduxState.sonarr.languages.map(x => { return { name: x.name, value: x.id } })}
onChange={newLanguage => setCategory("languageId", newLanguage)} />
<button className="btn btn-icon btn-3 btn-default" onClick={() => dispatch(loadLanguages(true))} disabled={!props.canConnect} type="button">
<span className="btn-inner--icon">
{
reduxState.sonarr.isLoadingLanguages ? (
<Oval
wrapperClass="loader"
type="Oval"
color="#11cdef"
height={19}
width={19}
/>)
: (<i className="fas fa-download"></i>)
}</span>
<span className="btn-inner--text">Load</span>
</button>
</div>
{
!reduxState.sonarr.areLanguagesValid ? (
<Alert className="mt-3 mb-4 text-wrap " color="warning">
<strong>Could not find any languages.</strong>
</Alert>)
: null
}
{
props.isSubmitted && reduxState.sonarr.languages.length === 0 ? (
<Alert className="mt-3 mb-4 text-wrap " color="warning">
<strong>A language is required.</strong>
</Alert>)
: null
}
</Col>
{props.apiVersion == "3"
? <>
<Col lg="6">
<div className="input-group-button mb-4">
<Dropdown
name="Language"
value={props.category.languageId}
items={reduxState.sonarr.languages.map(x => { return { name: x.name, value: x.id } })}
onChange={newLanguage => setCategory("languageId", newLanguage)} />
<button className="btn btn-icon btn-3 btn-default" onClick={() => dispatch(loadLanguages(true))} disabled={!props.canConnect} type="button">
<span className="btn-inner--icon">
{
reduxState.sonarr.isLoadingLanguages ? (
<Oval
wrapperClass="loader"
type="Oval"
color="#11cdef"
height={19}
width={19}
/>)
: (<i className="fas fa-download"></i>)
}</span>
<span className="btn-inner--text">Load</span>
</button>
</div>
{
!reduxState.sonarr.areLanguagesValid ? (
<Alert className="mt-3 mb-4 text-wrap " color="warning">
<strong>Could not find any languages.</strong>
</Alert>)
: null
}
{
props.isSubmitted && reduxState.sonarr.languages.length === 0 ? (
<Alert className="mt-3 mb-4 text-wrap " color="warning">
<strong>A language is required.</strong>
</Alert>)
: null
}
</Col>
</>
: null}
<Col lg="6">
<div className="input-group-button mb-4">
<MultiDropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ public static Task TestConnectionAsync(HttpClient httpClient, ILogger<SonarrClie
{
return SonarrClientV2.TestConnectionAsync(httpClient, logger, settings);
}
else
else if (settings.Version == "3")
{
return SonarrClientV3.TestConnectionAsync(httpClient, logger, settings);
}
else if (settings.Version == "4")
{
return SonarrClientV4.GetRootPaths(httpClient, logger, settings);
}

throw new System.Exception($"Sonarr V{settings.Version} is not yet supported.");
}

public static Task<IList<JSONRootPath>> GetRootPaths(HttpClient httpClient, ILogger<SonarrClient> logger, SonarrSettings settings)
Expand All @@ -38,10 +44,16 @@ public static Task<IList<JSONRootPath>> GetRootPaths(HttpClient httpClient, ILog
{
return SonarrClientV2.GetRootPaths(httpClient, logger, settings);
}
else
else if (settings.Version == "3")
{
return SonarrClientV3.GetRootPaths(httpClient, logger, settings);
}
else if (settings.Version == "4")
{
return SonarrClientV4.GetRootPaths(httpClient, logger, settings);
}

throw new System.Exception($"Sonarr V{settings.Version} is not yet supported.");
}

public static Task<IList<JSONProfile>> GetProfiles(HttpClient httpClient, ILogger<SonarrClient> logger, SonarrSettings settings)
Expand All @@ -50,10 +62,16 @@ public static Task<IList<JSONProfile>> GetProfiles(HttpClient httpClient, ILogge
{
return SonarrClientV2.GetProfiles(httpClient, logger, settings);
}
else
else if (settings.Version == "3")
{
return SonarrClientV3.GetProfiles(httpClient, logger, settings);
}
else if (settings.Version == "4")
{
return SonarrClientV4.GetProfiles(httpClient, logger, settings);
}

throw new System.Exception($"Sonarr V{settings.Version} is not yet supported.");
}

public static Task<IList<JSONLanguageProfile>> GetLanguages(HttpClient httpClient, ILogger<SonarrClient> logger, SonarrSettings settings)
Expand All @@ -62,10 +80,16 @@ public static Task<IList<JSONLanguageProfile>> GetLanguages(HttpClient httpClien
{
return Task.FromResult((IList<JSONLanguageProfile>)new List<JSONLanguageProfile>());
}
else
else if (settings.Version == "3")
{
return SonarrClientV3.GetLanguages(httpClient, logger, settings);
}
else if (settings.Version == "4")
{
return SonarrClientV4.GetLanguages(httpClient, logger, settings);
}

throw new System.Exception($"Sonarr V{settings.Version} is not yet supported.");
}

public static Task<IList<JSONTag>> GetTags(HttpClient httpClient, ILogger<SonarrClient> logger, SonarrSettings settings)
Expand All @@ -74,10 +98,16 @@ public static Task<IList<JSONTag>> GetTags(HttpClient httpClient, ILogger<Sonarr
{
return Task.FromResult((IList<JSONTag>)new List<JSONTag>());
}
else
else if (settings.Version == "3")
{
return SonarrClientV3.GetTags(httpClient, logger, settings);
}
else if (settings.Version == "4")
{
return SonarrClientV4.GetTags(httpClient, logger, settings);
}

throw new System.Exception($"Sonarr V{settings.Version} is not yet supported.");
}

public Task<SearchedTvShow> SearchTvShowAsync(TvShowRequest request, int tvDbId)
Expand Down Expand Up @@ -111,10 +141,16 @@ private T CreateInstance<T>() where T : class
{
return new SonarrClientV2(_httpClientFactory, _logger, _settingsProvider) as T;
}
else
else if (_settingsProvider.Provide().Version == "3")
{
return new SonarrClientV3(_httpClientFactory, _logger, _settingsProvider) as T;
}
else if (_settingsProvider.Provide().Version == "4")
{
return new SonarrClientV4(_httpClientFactory, _logger, _settingsProvider) as T;
}

throw new System.Exception($"Sonarr V{_settingsProvider.Provide().Version} is not yet supported.");
}

public class JSONRootPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ await Task.WhenAll(seasons.Select(async s =>
{
name = "SeasonSearch",
seasonNumber = s.SeasonNumber,
seriesId = int.Parse(tvShow.DownloadClientId)
seriesId = tvShow.DownloadClientId
}));

await response.ThrowIfNotSuccessfulAsync("SonarrSeasonSearchCommand failed", x => x.error);
Expand Down
Loading

0 comments on commit 473a645

Please sign in to comment.