< Summary - Jellyfin

Information
Class: MediaBrowser.Model.Configuration.TypeOptions
Assembly: MediaBrowser.Model
File(s): /srv/git/jellyfin/MediaBrowser.Model/Configuration/TypeOptions.cs
Line coverage
99%
Covered lines: 305
Uncovered lines: 3
Coverable lines: 308
Total lines: 365
Line coverage: 99%
Branch coverage
60%
Covered branches: 6
Total branches: 10
Branch coverage: 60%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
GetImageOptions(...)60%15.271062.5%
GetLimit(...)100%11100%
GetMinWidth(...)100%11100%
IsEnabled(...)100%11100%

File(s)

/srv/git/jellyfin/MediaBrowser.Model/Configuration/TypeOptions.cs

#LineLine coverage
 1#nullable disable
 2#pragma warning disable CS1591
 3
 4using System;
 5using System.Collections.Generic;
 6using MediaBrowser.Model.Entities;
 7
 8namespace MediaBrowser.Model.Configuration
 9{
 10    public class TypeOptions
 11    {
 112        public static readonly ImageOption DefaultInstance = new ImageOption();
 13
 114        public static readonly Dictionary<string, ImageOption[]> DefaultImageOptions = new Dictionary<string, ImageOptio
 115        {
 116            {
 117                "Movie", new[]
 118                {
 119                    new ImageOption
 120                    {
 121                        Limit = 1,
 122                        MinWidth = 1280,
 123                        Type = ImageType.Backdrop
 124                    },
 125
 126                    // Don't download this by default as it's rarely used.
 127                    new ImageOption
 128                    {
 129                        Limit = 0,
 130                        Type = ImageType.Art
 131                    },
 132
 133                    // Don't download this by default as it's rarely used.
 134                    new ImageOption
 135                    {
 136                        Limit = 0,
 137                        Type = ImageType.Disc
 138                    },
 139
 140                    new ImageOption
 141                    {
 142                        Limit = 1,
 143                        Type = ImageType.Primary
 144                    },
 145
 146                    new ImageOption
 147                    {
 148                        Limit = 0,
 149                        Type = ImageType.Banner
 150                    },
 151
 152                    new ImageOption
 153                    {
 154                        Limit = 1,
 155                        Type = ImageType.Thumb
 156                    },
 157
 158                    new ImageOption
 159                    {
 160                        Limit = 1,
 161                        Type = ImageType.Logo
 162                    }
 163                }
 164            },
 165            {
 166                "MusicVideo", new[]
 167                {
 168                    new ImageOption
 169                    {
 170                        Limit = 1,
 171                        MinWidth = 1280,
 172                        Type = ImageType.Backdrop
 173                    },
 174
 175                    // Don't download this by default as it's rarely used.
 176                    new ImageOption
 177                    {
 178                        Limit = 0,
 179                        Type = ImageType.Art
 180                    },
 181
 182                    // Don't download this by default as it's rarely used.
 183                    new ImageOption
 184                    {
 185                        Limit = 0,
 186                        Type = ImageType.Disc
 187                    },
 188
 189                    new ImageOption
 190                    {
 191                        Limit = 1,
 192                        Type = ImageType.Primary
 193                    },
 194
 195                    new ImageOption
 196                    {
 197                        Limit = 0,
 198                        Type = ImageType.Banner
 199                    },
 1100
 1101                    new ImageOption
 1102                    {
 1103                        Limit = 1,
 1104                        Type = ImageType.Thumb
 1105                    },
 1106
 1107                    new ImageOption
 1108                    {
 1109                        Limit = 1,
 1110                        Type = ImageType.Logo
 1111                    }
 1112                }
 1113            },
 1114            {
 1115                "Series", new[]
 1116                {
 1117                    new ImageOption
 1118                    {
 1119                        Limit = 1,
 1120                        MinWidth = 1280,
 1121                        Type = ImageType.Backdrop
 1122                    },
 1123
 1124                    // Don't download this by default as it's rarely used.
 1125                    new ImageOption
 1126                    {
 1127                        Limit = 0,
 1128                        Type = ImageType.Art
 1129                    },
 1130
 1131                    new ImageOption
 1132                    {
 1133                        Limit = 1,
 1134                        Type = ImageType.Primary
 1135                    },
 1136
 1137                    new ImageOption
 1138                    {
 1139                        Limit = 1,
 1140                        Type = ImageType.Banner
 1141                    },
 1142
 1143                    new ImageOption
 1144                    {
 1145                        Limit = 1,
 1146                        Type = ImageType.Thumb
 1147                    },
 1148
 1149                    new ImageOption
 1150                    {
 1151                        Limit = 1,
 1152                        Type = ImageType.Logo
 1153                    }
 1154                }
 1155            },
 1156            {
 1157                "MusicAlbum", new[]
 1158                {
 1159                    new ImageOption
 1160                    {
 1161                        Limit = 0,
 1162                        MinWidth = 1280,
 1163                        Type = ImageType.Backdrop
 1164                    },
 1165
 1166                    // Don't download this by default as it's rarely used.
 1167                    new ImageOption
 1168                    {
 1169                        Limit = 0,
 1170                        Type = ImageType.Disc
 1171                    }
 1172                }
 1173            },
 1174            {
 1175                "MusicArtist", new[]
 1176                {
 1177                    new ImageOption
 1178                    {
 1179                        Limit = 1,
 1180                        MinWidth = 1280,
 1181                        Type = ImageType.Backdrop
 1182                    },
 1183
 1184                    // Don't download this by default
 1185                    // They do look great, but most artists won't have them, which means a banner view isn't really poss
 1186                    new ImageOption
 1187                    {
 1188                        Limit = 0,
 1189                        Type = ImageType.Banner
 1190                    },
 1191
 1192                    // Don't download this by default
 1193                    // Generally not used
 1194                    new ImageOption
 1195                    {
 1196                        Limit = 0,
 1197                        Type = ImageType.Art
 1198                    },
 1199
 1200                    new ImageOption
 1201                    {
 1202                        Limit = 1,
 1203                        Type = ImageType.Logo
 1204                    }
 1205                }
 1206            },
 1207            {
 1208                "BoxSet", new[]
 1209                {
 1210                    new ImageOption
 1211                    {
 1212                        Limit = 1,
 1213                        MinWidth = 1280,
 1214                        Type = ImageType.Backdrop
 1215                    },
 1216
 1217                    new ImageOption
 1218                    {
 1219                        Limit = 1,
 1220                        Type = ImageType.Primary
 1221                    },
 1222
 1223                    new ImageOption
 1224                    {
 1225                        Limit = 1,
 1226                        Type = ImageType.Thumb
 1227                    },
 1228
 1229                    new ImageOption
 1230                    {
 1231                        Limit = 1,
 1232                        Type = ImageType.Logo
 1233                    },
 1234
 1235                    // Don't download this by default as it's rarely used.
 1236                    new ImageOption
 1237                    {
 1238                        Limit = 0,
 1239                        Type = ImageType.Art
 1240                    },
 1241
 1242                    // Don't download this by default as it's rarely used.
 1243                    new ImageOption
 1244                    {
 1245                        Limit = 0,
 1246                        Type = ImageType.Disc
 1247                    },
 1248
 1249                    // Don't download this by default as it's rarely used.
 1250                    new ImageOption
 1251                    {
 1252                        Limit = 0,
 1253                        Type = ImageType.Banner
 1254                    }
 1255                }
 1256            },
 1257            {
 1258                "Season", new[]
 1259                {
 1260                    new ImageOption
 1261                    {
 1262                        Limit = 0,
 1263                        MinWidth = 1280,
 1264                        Type = ImageType.Backdrop
 1265                    },
 1266
 1267                    new ImageOption
 1268                    {
 1269                        Limit = 1,
 1270                        Type = ImageType.Primary
 1271                    },
 1272
 1273                    new ImageOption
 1274                    {
 1275                        Limit = 0,
 1276                        Type = ImageType.Banner
 1277                    },
 1278
 1279                    new ImageOption
 1280                    {
 1281                        Limit = 0,
 1282                        Type = ImageType.Thumb
 1283                    }
 1284                }
 1285            },
 1286            {
 1287                "Episode", new[]
 1288                {
 1289                    new ImageOption
 1290                    {
 1291                        Limit = 0,
 1292                        MinWidth = 1280,
 1293                        Type = ImageType.Backdrop
 1294                    },
 1295
 1296                    new ImageOption
 1297                    {
 1298                        Limit = 1,
 1299                        Type = ImageType.Primary
 1300                    }
 1301                }
 1302            }
 1303        };
 304
 305        public TypeOptions()
 306        {
 44307            MetadataFetchers = Array.Empty<string>();
 44308            MetadataFetcherOrder = Array.Empty<string>();
 44309            ImageFetchers = Array.Empty<string>();
 44310            ImageFetcherOrder = Array.Empty<string>();
 44311            ImageOptions = Array.Empty<ImageOption>();
 44312        }
 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        {
 1182328            foreach (var i in ImageOptions)
 329            {
 308330                if (i.Type == type)
 331                {
 50332                    return i;
 333                }
 334            }
 335
 258336            if (DefaultImageOptions.TryGetValue(Type, out ImageOption[] options))
 337            {
 0338                foreach (var i in options)
 339                {
 0340                    if (i.Type == type)
 341                    {
 0342                        return i;
 343                    }
 344                }
 345            }
 346
 258347            return DefaultInstance;
 348        }
 349
 350        public int GetLimit(ImageType type)
 351        {
 168352            return GetImageOptions(type).Limit;
 353        }
 354
 355        public int GetMinWidth(ImageType type)
 356        {
 140357            return GetImageOptions(type).MinWidth;
 358        }
 359
 360        public bool IsEnabled(ImageType type)
 361        {
 136362            return GetLimit(type) > 0;
 363        }
 364    }
 365}