| | 1 | | #nullable disable |
| | 2 | | #pragma warning disable CS1591 |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using MediaBrowser.Model.Entities; |
| | 7 | |
|
| | 8 | | namespace MediaBrowser.Model.Configuration |
| | 9 | | { |
| | 10 | | public class TypeOptions |
| | 11 | | { |
| 1 | 12 | | public static readonly ImageOption DefaultInstance = new ImageOption(); |
| | 13 | |
|
| 1 | 14 | | public static readonly Dictionary<string, ImageOption[]> DefaultImageOptions = new Dictionary<string, ImageOptio |
| 1 | 15 | | { |
| 1 | 16 | | { |
| 1 | 17 | | "Movie", new[] |
| 1 | 18 | | { |
| 1 | 19 | | new ImageOption |
| 1 | 20 | | { |
| 1 | 21 | | Limit = 1, |
| 1 | 22 | | MinWidth = 1280, |
| 1 | 23 | | Type = ImageType.Backdrop |
| 1 | 24 | | }, |
| 1 | 25 | |
|
| 1 | 26 | | // Don't download this by default as it's rarely used. |
| 1 | 27 | | new ImageOption |
| 1 | 28 | | { |
| 1 | 29 | | Limit = 0, |
| 1 | 30 | | Type = ImageType.Art |
| 1 | 31 | | }, |
| 1 | 32 | |
|
| 1 | 33 | | // Don't download this by default as it's rarely used. |
| 1 | 34 | | new ImageOption |
| 1 | 35 | | { |
| 1 | 36 | | Limit = 0, |
| 1 | 37 | | Type = ImageType.Disc |
| 1 | 38 | | }, |
| 1 | 39 | |
|
| 1 | 40 | | new ImageOption |
| 1 | 41 | | { |
| 1 | 42 | | Limit = 1, |
| 1 | 43 | | Type = ImageType.Primary |
| 1 | 44 | | }, |
| 1 | 45 | |
|
| 1 | 46 | | new ImageOption |
| 1 | 47 | | { |
| 1 | 48 | | Limit = 0, |
| 1 | 49 | | Type = ImageType.Banner |
| 1 | 50 | | }, |
| 1 | 51 | |
|
| 1 | 52 | | new ImageOption |
| 1 | 53 | | { |
| 1 | 54 | | Limit = 1, |
| 1 | 55 | | Type = ImageType.Thumb |
| 1 | 56 | | }, |
| 1 | 57 | |
|
| 1 | 58 | | new ImageOption |
| 1 | 59 | | { |
| 1 | 60 | | Limit = 1, |
| 1 | 61 | | Type = ImageType.Logo |
| 1 | 62 | | } |
| 1 | 63 | | } |
| 1 | 64 | | }, |
| 1 | 65 | | { |
| 1 | 66 | | "MusicVideo", new[] |
| 1 | 67 | | { |
| 1 | 68 | | new ImageOption |
| 1 | 69 | | { |
| 1 | 70 | | Limit = 1, |
| 1 | 71 | | MinWidth = 1280, |
| 1 | 72 | | Type = ImageType.Backdrop |
| 1 | 73 | | }, |
| 1 | 74 | |
|
| 1 | 75 | | // Don't download this by default as it's rarely used. |
| 1 | 76 | | new ImageOption |
| 1 | 77 | | { |
| 1 | 78 | | Limit = 0, |
| 1 | 79 | | Type = ImageType.Art |
| 1 | 80 | | }, |
| 1 | 81 | |
|
| 1 | 82 | | // Don't download this by default as it's rarely used. |
| 1 | 83 | | new ImageOption |
| 1 | 84 | | { |
| 1 | 85 | | Limit = 0, |
| 1 | 86 | | Type = ImageType.Disc |
| 1 | 87 | | }, |
| 1 | 88 | |
|
| 1 | 89 | | new ImageOption |
| 1 | 90 | | { |
| 1 | 91 | | Limit = 1, |
| 1 | 92 | | Type = ImageType.Primary |
| 1 | 93 | | }, |
| 1 | 94 | |
|
| 1 | 95 | | new ImageOption |
| 1 | 96 | | { |
| 1 | 97 | | Limit = 0, |
| 1 | 98 | | Type = ImageType.Banner |
| 1 | 99 | | }, |
| 1 | 100 | |
|
| 1 | 101 | | new ImageOption |
| 1 | 102 | | { |
| 1 | 103 | | Limit = 1, |
| 1 | 104 | | Type = ImageType.Thumb |
| 1 | 105 | | }, |
| 1 | 106 | |
|
| 1 | 107 | | new ImageOption |
| 1 | 108 | | { |
| 1 | 109 | | Limit = 1, |
| 1 | 110 | | Type = ImageType.Logo |
| 1 | 111 | | } |
| 1 | 112 | | } |
| 1 | 113 | | }, |
| 1 | 114 | | { |
| 1 | 115 | | "Series", new[] |
| 1 | 116 | | { |
| 1 | 117 | | new ImageOption |
| 1 | 118 | | { |
| 1 | 119 | | Limit = 1, |
| 1 | 120 | | MinWidth = 1280, |
| 1 | 121 | | Type = ImageType.Backdrop |
| 1 | 122 | | }, |
| 1 | 123 | |
|
| 1 | 124 | | // Don't download this by default as it's rarely used. |
| 1 | 125 | | new ImageOption |
| 1 | 126 | | { |
| 1 | 127 | | Limit = 0, |
| 1 | 128 | | Type = ImageType.Art |
| 1 | 129 | | }, |
| 1 | 130 | |
|
| 1 | 131 | | new ImageOption |
| 1 | 132 | | { |
| 1 | 133 | | Limit = 1, |
| 1 | 134 | | Type = ImageType.Primary |
| 1 | 135 | | }, |
| 1 | 136 | |
|
| 1 | 137 | | new ImageOption |
| 1 | 138 | | { |
| 1 | 139 | | Limit = 1, |
| 1 | 140 | | Type = ImageType.Banner |
| 1 | 141 | | }, |
| 1 | 142 | |
|
| 1 | 143 | | new ImageOption |
| 1 | 144 | | { |
| 1 | 145 | | Limit = 1, |
| 1 | 146 | | Type = ImageType.Thumb |
| 1 | 147 | | }, |
| 1 | 148 | |
|
| 1 | 149 | | new ImageOption |
| 1 | 150 | | { |
| 1 | 151 | | Limit = 1, |
| 1 | 152 | | Type = ImageType.Logo |
| 1 | 153 | | } |
| 1 | 154 | | } |
| 1 | 155 | | }, |
| 1 | 156 | | { |
| 1 | 157 | | "MusicAlbum", new[] |
| 1 | 158 | | { |
| 1 | 159 | | new ImageOption |
| 1 | 160 | | { |
| 1 | 161 | | Limit = 0, |
| 1 | 162 | | MinWidth = 1280, |
| 1 | 163 | | Type = ImageType.Backdrop |
| 1 | 164 | | }, |
| 1 | 165 | |
|
| 1 | 166 | | // Don't download this by default as it's rarely used. |
| 1 | 167 | | new ImageOption |
| 1 | 168 | | { |
| 1 | 169 | | Limit = 0, |
| 1 | 170 | | Type = ImageType.Disc |
| 1 | 171 | | } |
| 1 | 172 | | } |
| 1 | 173 | | }, |
| 1 | 174 | | { |
| 1 | 175 | | "MusicArtist", new[] |
| 1 | 176 | | { |
| 1 | 177 | | new ImageOption |
| 1 | 178 | | { |
| 1 | 179 | | Limit = 1, |
| 1 | 180 | | MinWidth = 1280, |
| 1 | 181 | | Type = ImageType.Backdrop |
| 1 | 182 | | }, |
| 1 | 183 | |
|
| 1 | 184 | | // Don't download this by default |
| 1 | 185 | | // They do look great, but most artists won't have them, which means a banner view isn't really poss |
| 1 | 186 | | new ImageOption |
| 1 | 187 | | { |
| 1 | 188 | | Limit = 0, |
| 1 | 189 | | Type = ImageType.Banner |
| 1 | 190 | | }, |
| 1 | 191 | |
|
| 1 | 192 | | // Don't download this by default |
| 1 | 193 | | // Generally not used |
| 1 | 194 | | new ImageOption |
| 1 | 195 | | { |
| 1 | 196 | | Limit = 0, |
| 1 | 197 | | Type = ImageType.Art |
| 1 | 198 | | }, |
| 1 | 199 | |
|
| 1 | 200 | | new ImageOption |
| 1 | 201 | | { |
| 1 | 202 | | Limit = 1, |
| 1 | 203 | | Type = ImageType.Logo |
| 1 | 204 | | } |
| 1 | 205 | | } |
| 1 | 206 | | }, |
| 1 | 207 | | { |
| 1 | 208 | | "BoxSet", new[] |
| 1 | 209 | | { |
| 1 | 210 | | new ImageOption |
| 1 | 211 | | { |
| 1 | 212 | | Limit = 1, |
| 1 | 213 | | MinWidth = 1280, |
| 1 | 214 | | Type = ImageType.Backdrop |
| 1 | 215 | | }, |
| 1 | 216 | |
|
| 1 | 217 | | new ImageOption |
| 1 | 218 | | { |
| 1 | 219 | | Limit = 1, |
| 1 | 220 | | Type = ImageType.Primary |
| 1 | 221 | | }, |
| 1 | 222 | |
|
| 1 | 223 | | new ImageOption |
| 1 | 224 | | { |
| 1 | 225 | | Limit = 1, |
| 1 | 226 | | Type = ImageType.Thumb |
| 1 | 227 | | }, |
| 1 | 228 | |
|
| 1 | 229 | | new ImageOption |
| 1 | 230 | | { |
| 1 | 231 | | Limit = 1, |
| 1 | 232 | | Type = ImageType.Logo |
| 1 | 233 | | }, |
| 1 | 234 | |
|
| 1 | 235 | | // Don't download this by default as it's rarely used. |
| 1 | 236 | | new ImageOption |
| 1 | 237 | | { |
| 1 | 238 | | Limit = 0, |
| 1 | 239 | | Type = ImageType.Art |
| 1 | 240 | | }, |
| 1 | 241 | |
|
| 1 | 242 | | // Don't download this by default as it's rarely used. |
| 1 | 243 | | new ImageOption |
| 1 | 244 | | { |
| 1 | 245 | | Limit = 0, |
| 1 | 246 | | Type = ImageType.Disc |
| 1 | 247 | | }, |
| 1 | 248 | |
|
| 1 | 249 | | // Don't download this by default as it's rarely used. |
| 1 | 250 | | new ImageOption |
| 1 | 251 | | { |
| 1 | 252 | | Limit = 0, |
| 1 | 253 | | Type = ImageType.Banner |
| 1 | 254 | | } |
| 1 | 255 | | } |
| 1 | 256 | | }, |
| 1 | 257 | | { |
| 1 | 258 | | "Season", new[] |
| 1 | 259 | | { |
| 1 | 260 | | new ImageOption |
| 1 | 261 | | { |
| 1 | 262 | | Limit = 0, |
| 1 | 263 | | MinWidth = 1280, |
| 1 | 264 | | Type = ImageType.Backdrop |
| 1 | 265 | | }, |
| 1 | 266 | |
|
| 1 | 267 | | new ImageOption |
| 1 | 268 | | { |
| 1 | 269 | | Limit = 1, |
| 1 | 270 | | Type = ImageType.Primary |
| 1 | 271 | | }, |
| 1 | 272 | |
|
| 1 | 273 | | new ImageOption |
| 1 | 274 | | { |
| 1 | 275 | | Limit = 0, |
| 1 | 276 | | Type = ImageType.Banner |
| 1 | 277 | | }, |
| 1 | 278 | |
|
| 1 | 279 | | new ImageOption |
| 1 | 280 | | { |
| 1 | 281 | | Limit = 0, |
| 1 | 282 | | Type = ImageType.Thumb |
| 1 | 283 | | } |
| 1 | 284 | | } |
| 1 | 285 | | }, |
| 1 | 286 | | { |
| 1 | 287 | | "Episode", new[] |
| 1 | 288 | | { |
| 1 | 289 | | new ImageOption |
| 1 | 290 | | { |
| 1 | 291 | | Limit = 0, |
| 1 | 292 | | MinWidth = 1280, |
| 1 | 293 | | Type = ImageType.Backdrop |
| 1 | 294 | | }, |
| 1 | 295 | |
|
| 1 | 296 | | new ImageOption |
| 1 | 297 | | { |
| 1 | 298 | | Limit = 1, |
| 1 | 299 | | Type = ImageType.Primary |
| 1 | 300 | | } |
| 1 | 301 | | } |
| 1 | 302 | | } |
| 1 | 303 | | }; |
| | 304 | |
|
| | 305 | | public TypeOptions() |
| | 306 | | { |
| 44 | 307 | | MetadataFetchers = Array.Empty<string>(); |
| 44 | 308 | | MetadataFetcherOrder = Array.Empty<string>(); |
| 44 | 309 | | ImageFetchers = Array.Empty<string>(); |
| 44 | 310 | | ImageFetcherOrder = Array.Empty<string>(); |
| 44 | 311 | | ImageOptions = Array.Empty<ImageOption>(); |
| 44 | 312 | | } |
| | 313 | |
|
| | 314 | | public string Type { get; set; } |
| | 315 | |
|
| | 316 | | public string[] MetadataFetchers { get; set; } |
| | 317 | |
|
| | 318 | | public string[] MetadataFetcherOrder { get; set; } |
| | 319 | |
|
| | 320 | | public string[] ImageFetchers { get; set; } |
| | 321 | |
|
| | 322 | | public string[] ImageFetcherOrder { get; set; } |
| | 323 | |
|
| | 324 | | public ImageOption[] ImageOptions { get; set; } |
| | 325 | |
|
| | 326 | | public ImageOption GetImageOptions(ImageType type) |
| | 327 | | { |
| 1182 | 328 | | foreach (var i in ImageOptions) |
| | 329 | | { |
| 308 | 330 | | if (i.Type == type) |
| | 331 | | { |
| 50 | 332 | | return i; |
| | 333 | | } |
| | 334 | | } |
| | 335 | |
|
| 258 | 336 | | if (DefaultImageOptions.TryGetValue(Type, out ImageOption[] options)) |
| | 337 | | { |
| 0 | 338 | | foreach (var i in options) |
| | 339 | | { |
| 0 | 340 | | if (i.Type == type) |
| | 341 | | { |
| 0 | 342 | | return i; |
| | 343 | | } |
| | 344 | | } |
| | 345 | | } |
| | 346 | |
|
| 258 | 347 | | return DefaultInstance; |
| | 348 | | } |
| | 349 | |
|
| | 350 | | public int GetLimit(ImageType type) |
| | 351 | | { |
| 168 | 352 | | return GetImageOptions(type).Limit; |
| | 353 | | } |
| | 354 | |
|
| | 355 | | public int GetMinWidth(ImageType type) |
| | 356 | | { |
| 140 | 357 | | return GetImageOptions(type).MinWidth; |
| | 358 | | } |
| | 359 | |
|
| | 360 | | public bool IsEnabled(ImageType type) |
| | 361 | | { |
| 136 | 362 | | return GetLimit(type) > 0; |
| | 363 | | } |
| | 364 | | } |
| | 365 | | } |