Skip to content

Commit 57db601

Browse files
add seerr integration
1 parent 99fcb92 commit 57db601

6 files changed

Lines changed: 749 additions & 2 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.OpenApi;
3+
using Swashbuckle.AspNetCore.SwaggerGen;
4+
5+
namespace AniWorldReminder_API.Classes
6+
{
7+
public class SwaggerAuthOperationFilter : IOperationFilter
8+
{
9+
private static readonly string[] ApiKeyPaths =
10+
[
11+
"getDownloads",
12+
"removeFinishedDownload",
13+
"getDownloadsCount",
14+
"captchaNotify",
15+
"setDownloaderPreferences",
16+
"getDownloaderPreferences",
17+
"api/v3/"
18+
];
19+
20+
public void Apply(OpenApiOperation operation, OperationFilterContext context)
21+
{
22+
bool requiresBearer = context.ApiDescription.ActionDescriptor.EndpointMetadata?
23+
.OfType<AuthorizeAttribute>()
24+
.Any() == true;
25+
26+
string relativePath = context.ApiDescription.RelativePath ?? string.Empty;
27+
bool requiresApiKey = ApiKeyPaths.Any(path =>
28+
relativePath.StartsWith(path, StringComparison.OrdinalIgnoreCase));
29+
30+
if (!requiresBearer && !requiresApiKey)
31+
return;
32+
33+
operation.Security ??= [];
34+
35+
if (requiresBearer)
36+
{
37+
operation.Security.Add(new OpenApiSecurityRequirement
38+
{
39+
[
40+
new OpenApiSecuritySchemeReference("Bearer")
41+
] = []
42+
});
43+
}
44+
45+
if (requiresApiKey)
46+
{
47+
operation.Security.Add(new OpenApiSecurityRequirement
48+
{
49+
[
50+
new OpenApiSecuritySchemeReference("ApiKey")
51+
] = []
52+
});
53+
}
54+
}
55+
56+
}
57+
}

AniWorldReminder_API/Interfaces/ITMDBService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ public interface ITMDBService
44
{
55
Task<TMDBSearchTVModel?> SearchTVShow(string tvShowName);
66
Task<TMDBSearchTVByIdModel?> SearchTVShowById(int? tvShowId);
7+
Task<TMDBSearchTVByIdModel?> SearchTVShowByTvdbId(int tvdbId);
78
}
89
}
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
namespace AniWorldReminder_API.Models
2+
{
3+
public class SonarrSystemStatusModel
4+
{
5+
public string Version { get; set; } = "3.0.0";
6+
public DateTime BuildTime { get; set; } = DateTime.UtcNow;
7+
public bool IsDebug { get; set; }
8+
public bool IsProduction { get; set; } = true;
9+
public bool IsAdmin { get; set; } = true;
10+
public bool IsUserInteractive { get; set; }
11+
public string StartupPath { get; set; } = AppContext.BaseDirectory;
12+
public string AppData { get; set; } = AppContext.BaseDirectory;
13+
public string OsName { get; set; } = Environment.OSVersion.Platform.ToString();
14+
public string OsVersion { get; set; } = Environment.OSVersion.VersionString;
15+
public bool IsNetCore { get; set; } = true;
16+
public bool IsMono { get; set; }
17+
public bool IsLinux { get; set; } = OperatingSystem.IsLinux();
18+
public bool IsOsx { get; set; } = OperatingSystem.IsMacOS();
19+
public bool IsWindows { get; set; } = OperatingSystem.IsWindows();
20+
public bool IsDocker { get; set; }
21+
public string Mode { get; set; } = "bridge";
22+
public string Branch { get; set; } = "main";
23+
public string Authentication { get; set; } = "external";
24+
public string SqliteVersion { get; set; } = string.Empty;
25+
public int MigrationVersion { get; set; }
26+
public string UrlBase { get; set; } = string.Empty;
27+
public string RuntimeVersion { get; set; } = Environment.Version.ToString();
28+
public string RuntimeName { get; set; } = ".NET";
29+
public DateTime StartTime { get; set; } = DateTime.UtcNow;
30+
public string PackageUpdateMechanism { get; set; } = "manual";
31+
}
32+
33+
public class SonarrQualityProfileModel
34+
{
35+
public int Id { get; set; }
36+
public string Name { get; set; } = string.Empty;
37+
}
38+
39+
public class SonarrRootFolderModel
40+
{
41+
public int Id { get; set; }
42+
public string Path { get; set; } = string.Empty;
43+
public long FreeSpace { get; set; }
44+
public long TotalSpace { get; set; }
45+
public List<SonarrUnmappedFolderModel> UnmappedFolders { get; set; } = [];
46+
}
47+
48+
public class SonarrUnmappedFolderModel
49+
{
50+
public string Name { get; set; } = string.Empty;
51+
public string Path { get; set; } = string.Empty;
52+
}
53+
54+
public class SonarrLanguageProfileModel
55+
{
56+
public int Id { get; set; }
57+
public string Name { get; set; } = string.Empty;
58+
}
59+
60+
public class SonarrTagModel
61+
{
62+
public int Id { get; set; }
63+
public string Label { get; set; } = string.Empty;
64+
}
65+
66+
public class SonarrSeriesLookupModel
67+
{
68+
public int? Id { get; set; }
69+
public string Title { get; set; } = string.Empty;
70+
public string SortTitle { get; set; } = string.Empty;
71+
public int SeasonCount { get; set; }
72+
public string Status { get; set; } = "continuing";
73+
public string Overview { get; set; } = string.Empty;
74+
public string Network { get; set; } = string.Empty;
75+
public string AirTime { get; set; } = string.Empty;
76+
public List<object> Images { get; set; } = [];
77+
public string RemotePoster { get; set; } = string.Empty;
78+
public List<SonarrSeasonLookupModel> Seasons { get; set; } = [];
79+
public int Year { get; set; }
80+
public string Path { get; set; } = string.Empty;
81+
public int ProfileId { get; set; }
82+
public int LanguageProfileId { get; set; }
83+
public bool SeasonFolder { get; set; } = true;
84+
public bool Monitored { get; set; } = true;
85+
public string MonitorNewItems { get; set; } = "all";
86+
public bool UseSceneNumbering { get; set; }
87+
public int Runtime { get; set; } = 24;
88+
public int TvdbId { get; set; }
89+
public int TvRageId { get; set; }
90+
public int TvMazeId { get; set; }
91+
public string FirstAired { get; set; } = string.Empty;
92+
public string SeriesType { get; set; } = "standard";
93+
public string CleanTitle { get; set; } = string.Empty;
94+
public string ImdbId { get; set; } = string.Empty;
95+
public string TitleSlug { get; set; } = string.Empty;
96+
public string Certification { get; set; } = string.Empty;
97+
public List<string> Genres { get; set; } = [];
98+
public List<int> Tags { get; set; } = [];
99+
public string Added { get; set; } = DateTime.UtcNow.ToString("O");
100+
public SonarrRatingsModel Ratings { get; set; } = new();
101+
}
102+
103+
public class SonarrSeasonLookupModel
104+
{
105+
public int SeasonNumber { get; set; }
106+
public bool Monitored { get; set; }
107+
public SonarrSeasonStatisticsModel Statistics { get; set; } = new();
108+
}
109+
110+
public class SonarrSeasonStatisticsModel
111+
{
112+
public int EpisodeFileCount { get; set; }
113+
public int EpisodeCount { get; set; }
114+
public int TotalEpisodeCount { get; set; }
115+
public long SizeOnDisk { get; set; }
116+
public decimal PercentOfEpisodes { get; set; }
117+
}
118+
119+
public class SonarrRatingsModel
120+
{
121+
public int Votes { get; set; }
122+
public decimal Value { get; set; }
123+
}
124+
125+
public class SonarrAddSeriesRequestModel
126+
{
127+
public int TvdbId { get; set; }
128+
public string? Title { get; set; }
129+
public int QualityProfileId { get; set; }
130+
public int LanguageProfileId { get; set; }
131+
public List<SonarrSeasonLookupModel> Seasons { get; set; } = [];
132+
public List<int> Tags { get; set; } = [];
133+
public bool SeasonFolder { get; set; }
134+
public bool Monitored { get; set; }
135+
public string MonitorNewItems { get; set; } = "all";
136+
public string? RootFolderPath { get; set; }
137+
public string SeriesType { get; set; } = "standard";
138+
public SonarrAddOptionsModel? AddOptions { get; set; }
139+
}
140+
141+
public class SonarrAddOptionsModel
142+
{
143+
public bool IgnoreEpisodesWithFiles { get; set; }
144+
public bool IgnoreEpisodesWithoutFiles { get; set; }
145+
public bool SearchForMissingEpisodes { get; set; }
146+
}
147+
148+
public class SonarrEpisodeModel
149+
{
150+
public int Id { get; set; }
151+
public int SeriesId { get; set; }
152+
public int EpisodeFileId { get; set; }
153+
public int SeasonNumber { get; set; }
154+
public int EpisodeNumber { get; set; }
155+
public string Title { get; set; } = string.Empty;
156+
public string AirDate { get; set; } = string.Empty;
157+
public string AirDateUtc { get; set; } = string.Empty;
158+
public string Overview { get; set; } = string.Empty;
159+
public bool HasFile { get; set; }
160+
public bool Monitored { get; set; } = true;
161+
public int AbsoluteEpisodeNumber { get; set; }
162+
public bool UnverifiedSceneNumbering { get; set; }
163+
}
164+
165+
public class SonarrEpisodeMonitorRequestModel
166+
{
167+
public List<int> EpisodeIds { get; set; } = [];
168+
public bool Monitored { get; set; }
169+
}
170+
171+
public class SonarrCommandRequestModel
172+
{
173+
public string Name { get; set; } = string.Empty;
174+
public int? SeriesId { get; set; }
175+
}
176+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace AniWorldReminder_API.Models
4+
{
5+
public class TMDBFindByExternalIdResponseModel
6+
{
7+
[JsonPropertyName("tv_results")]
8+
public List<Result> TvResults { get; set; } = [];
9+
}
10+
}

0 commit comments

Comments
 (0)