瀏覽代碼

Overhaul content ratings

Shadowghost 2 年之前
父節點
當前提交
ed2280a060
共有 26 個文件被更改,包括 346 次插入174 次删除
  1. 17 1
      Emby.Server.Implementations/Localization/LocalizationManager.cs
  2. 11 0
      Emby.Server.Implementations/Localization/Ratings/0-prefer.csv
  3. 13 7
      Emby.Server.Implementations/Localization/Ratings/au.csv
  4. 11 6
      Emby.Server.Implementations/Localization/Ratings/be.csv
  5. 8 6
      Emby.Server.Implementations/Localization/Ratings/br.csv
  6. 20 6
      Emby.Server.Implementations/Localization/Ratings/ca.csv
  7. 7 8
      Emby.Server.Implementations/Localization/Ratings/co.csv
  8. 12 10
      Emby.Server.Implementations/Localization/Ratings/de.csv
  9. 7 4
      Emby.Server.Implementations/Localization/Ratings/dk.csv
  10. 24 6
      Emby.Server.Implementations/Localization/Ratings/es.csv
  11. 10 10
      Emby.Server.Implementations/Localization/Ratings/fi.csv
  12. 12 5
      Emby.Server.Implementations/Localization/Ratings/fr.csv
  13. 22 7
      Emby.Server.Implementations/Localization/Ratings/gb.csv
  14. 9 6
      Emby.Server.Implementations/Localization/Ratings/ie.csv
  15. 11 4
      Emby.Server.Implementations/Localization/Ratings/jp.csv
  16. 6 7
      Emby.Server.Implementations/Localization/Ratings/kz.csv
  17. 6 6
      Emby.Server.Implementations/Localization/Ratings/mx.csv
  18. 8 6
      Emby.Server.Implementations/Localization/Ratings/nl.csv
  19. 9 6
      Emby.Server.Implementations/Localization/Ratings/no.csv
  20. 15 11
      Emby.Server.Implementations/Localization/Ratings/nz.csv
  21. 6 1
      Emby.Server.Implementations/Localization/Ratings/ro.csv
  22. 6 5
      Emby.Server.Implementations/Localization/Ratings/ru.csv
  23. 10 5
      Emby.Server.Implementations/Localization/Ratings/se.csv
  24. 22 7
      Emby.Server.Implementations/Localization/Ratings/uk.csv
  25. 50 23
      Emby.Server.Implementations/Localization/Ratings/us.csv
  26. 14 11
      tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs

+ 17 - 1
Emby.Server.Implementations/Localization/LocalizationManager.cs

@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
+using System.Linq;
 using System.Reflection;
 using System.Text.Json;
 using System.Threading.Tasks;
@@ -25,7 +26,7 @@ namespace Emby.Server.Implementations.Localization
         private const string CulturesPath = "Emby.Server.Implementations.Localization.iso6392.txt";
         private const string CountriesPath = "Emby.Server.Implementations.Localization.countries.json";
         private static readonly Assembly _assembly = typeof(LocalizationManager).Assembly;
-        private static readonly string[] _unratedValues = { "n/a", "unrated", "not rated" };
+        private static readonly string[] _unratedValues = { "n/a", "unrated", "not rated", "nr" };
 
         private readonly IServerConfigurationManager _configurationManager;
         private readonly ILogger<LocalizationManager> _logger;
@@ -194,6 +195,7 @@ namespace Emby.Server.Implementations.Localization
         {
             var countryCode = _configurationManager.Configuration.MetadataCountryCode;
 
+            // Fall back to US ratings if no country code is specified or country code does not exist.
             if (string.IsNullOrEmpty(countryCode))
             {
                 countryCode = "us";
@@ -221,12 +223,14 @@ namespace Emby.Server.Implementations.Localization
         {
             ArgumentException.ThrowIfNullOrEmpty(rating);
 
+            // Handle unrated content
             if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
             {
                 return null;
             }
 
             // Fairly common for some users to have "Rated R" in their rating field
+            rating = rating.Replace("Rated :", string.Empty, StringComparison.OrdinalIgnoreCase);
             rating = rating.Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase);
 
             var ratingsDictionary = GetParentalRatingsDictionary();
@@ -257,6 +261,18 @@ namespace Emby.Server.Implementations.Localization
                 }
             }
 
+            // Remove prefix country code to handle "DE-18"
+            index = rating.IndexOf('-', StringComparison.Ordinal);
+            if (index != -1)
+            {
+                var trimmedRating = rating.AsSpan(index).TrimStart('-').Trim();
+
+                if (!trimmedRating.IsEmpty)
+                {
+                    return GetRatingLevel(trimmedRating.ToString());
+                }
+            }
+
             // TODO: Further improve by normalizing out all spaces and dashes
             return null;
         }

+ 11 - 0
Emby.Server.Implementations/Localization/Ratings/0-prefer.csv

@@ -0,0 +1,11 @@
+E,0
+EC,0
+T,7
+M,18
+AO,18
+UR,18
+RP,18
+X,1000
+XX,1000
+XXX,1000
+XXXX,1000

+ 13 - 7
Emby.Server.Implementations/Localization/Ratings/au.csv

@@ -1,7 +1,13 @@
-AU-G,1
-AU-PG,5
-AU-M,6
-AU-MA15+,7
-AU-R18+,9
-AU-X18+,10
-AU-RC,11
+Exempt,0
+G,0
+7+,7
+M,15
+MA,15
+MA15+,15
+PG,16
+16+,16
+R,18
+R18+,18
+X18+,18
+18+,18
+X,1000

+ 11 - 6
Emby.Server.Implementations/Localization/Ratings/be.csv

@@ -1,6 +1,11 @@
-BE-AL,1
-BE-MG6,2
-BE-6,3
-BE-9,5
-BE-12,6
-BE-16,8
+AL,0
+KT,0
+TOUS,0
+MG6,6
+6,6
+9,9
+KNT,12
+12,12
+BE_14,14
+16,16
+18,18

+ 8 - 6
Emby.Server.Implementations/Localization/Ratings/br.csv

@@ -1,6 +1,8 @@
-BR-L,1
-BR-10,5
-BR-12,7
-BR-14,8
-BR-16,8
-BR-18,9
+Livre,0
+L,0
+ER,9
+10,10
+12,12
+14,14
+16,16
+18,18

+ 20 - 6
Emby.Server.Implementations/Localization/Ratings/ca.csv

@@ -1,6 +1,20 @@
-CA-G,1
-CA-PG,5
-CA-14A,7
-CA-A,8
-CA-18A,9
-CA-R,10
+E,0
+G,0
+TV-Y,0
+TV-G,0
+TV-Y7,7
+TV-Y7-FV,7
+PG,9
+TV-PG,9
+PG-13,13
+13+,13
+TV-14,14
+14A,14
+16+,16
+NC-17,17
+R,18
+TV-MA,18
+18A,18
+18+,18
+A,1000
+Prohibited,1001

+ 7 - 8
Emby.Server.Implementations/Localization/Ratings/co.csv

@@ -1,8 +1,7 @@
-CO-T,1
-CO-7,5
-CO-12,7
-CO-15,8
-CO-18,10
-CO-X,100
-CO-BANNED,15
-CO-E,15
+T,0
+7,7
+12,12
+15,15
+18,18
+X,1000
+Prohibited,1001

+ 12 - 10
Emby.Server.Implementations/Localization/Ratings/de.csv

@@ -1,10 +1,12 @@
-DE-0,1
-FSK-0,1
-DE-6,5
-FSK-6,5
-DE-12,7
-FSK-12,7
-DE-16,8
-FSK-16,8
-DE-18,9
-FSK-18,9
+Educational,0
+Infoprogramm,0
+FSK-0,0
+0,0
+FSK-6,6
+6,6
+FSK-12,12
+12,12
+FSK-16,16
+16,16
+FSK-18,18
+18,18

+ 7 - 4
Emby.Server.Implementations/Localization/Ratings/dk.csv

@@ -1,4 +1,7 @@
-DA-A,1
-DA-7,5
-DA-11,6
-DA-15,8
+F,0
+A,0
+7,7
+11,11
+12,12
+15,15
+16,16

+ 24 - 6
Emby.Server.Implementations/Localization/Ratings/es.csv

@@ -1,6 +1,24 @@
-ES-A,1
-ES-APTA,1
-ES-7,3
-ES-12,6
-ES-16,8
-ES-18,11
+A,0
+A/fig,0
+A/i,0
+A/fig/i,0
+APTA,0
+TP,0
+0+,0
+6+,6
+7/fig,7
+7/i,7
+7/i/fig,7
+7,7
+9+,9
+10,10
+12,12
+12/fig,12
+13,13
+14,14
+16,16
+16/fig,16
+18,18
+18/fig,18
+X,1000
+Banned,1001

+ 10 - 10
Emby.Server.Implementations/Localization/Ratings/fi.csv

@@ -1,10 +1,10 @@
-FI-S,1
-FI-T,1
-FI-7,4
-FI-12,5
-FI-16,8
-FI-18,9
-FI-K7,4
-FI-K12,5
-FI-K16,8
-FI-K18,9
+S,0
+T,0
+K7,7
+7,7
+K12,12
+12,12
+K16,16
+16,16
+K18,18
+18,18

+ 12 - 5
Emby.Server.Implementations/Localization/Ratings/fr.csv

@@ -1,5 +1,12 @@
-FR-U,1
-FR-10,5
-FR-12,7
-FR-16,9
-FR-18,10
+Public Averti,0
+Tous Publics,0
+U,0
+0+,0
+6+,6
+9+,9
+10,10
+12,12
+14+,14
+16,16
+18,18
+X,1000

+ 22 - 7
Emby.Server.Implementations/Localization/Ratings/gb.csv

@@ -1,7 +1,22 @@
-GB-U,1
-GB-PG,5
-GB-12,6
-GB-12A,7
-GB-15,8
-GB-18,9
-GB-R18,15
+All,0
+E,0
+G,0
+U,0
+0+,0
+6+,6
+7+,7
+PG,8
+9+,9
+12,12
+12+,12
+12A,12
+Teen,13
+13+,13
+14+,14
+15,15
+16,16
+Caution,18
+18,18
+Mature,1000
+Adult,1000
+R18,1000

+ 9 - 6
Emby.Server.Implementations/Localization/Ratings/ie.csv

@@ -1,6 +1,9 @@
-IE-G,1
-IE-PG,5
-IE-12A,7
-IE-15A,8
-IE-16,9
-IE-18,10
+G,4
+PG,12
+12,12
+12A,12
+12PG,12
+15,15
+15A,15
+16,16
+18,18

+ 11 - 4
Emby.Server.Implementations/Localization/Ratings/jp.csv

@@ -1,4 +1,11 @@
-JP-G,1
-JP-PG12,7
-JP-15+,8
-JP-18+,10
+A,0
+G,0
+B,12
+PG12,12
+C,15
+15+,15
+R15+,15
+16+,16
+D,17
+Z,18
+18+,18

+ 6 - 7
Emby.Server.Implementations/Localization/Ratings/kz.csv

@@ -1,7 +1,6 @@
-KZ-6-,0
-KZ-6+,6
-KZ-12+,12
-KZ-14+,14
-KZ-16+,16
-KZ-18+,18
-KZ-21+,21
+K,0
+БА,12
+Б14,14
+E16,16
+E18,18
+HA,18

+ 6 - 6
Emby.Server.Implementations/Localization/Ratings/mx.csv

@@ -1,6 +1,6 @@
-MX-AA,1
-MX-A,5
-MX-B,7
-MX-B-15,8
-MX-C,9
-MX-D,10
+A,0
+AA,0
+B,12
+B-15,15
+C,18
+D,1000

+ 8 - 6
Emby.Server.Implementations/Localization/Ratings/nl.csv

@@ -1,6 +1,8 @@
-NL-AL,1
-NL-MG6,2
-NL-6,3
-NL-9,5
-NL-12,6
-NL-16,8
+AL,0
+MG6,6
+6,6
+9,9
+12,12
+14,14
+16,16
+18,18

+ 9 - 6
Emby.Server.Implementations/Localization/Ratings/no.csv

@@ -1,6 +1,9 @@
-NO-A,1
-NO-6,3
-NO-9,4
-NO-12,5
-NO-15,8
-NO-18,9
+A,0
+6,6
+7,7
+9,9
+11,11
+12,12
+15,15
+18,18
+Not approved,1001

+ 15 - 11
Emby.Server.Implementations/Localization/Ratings/nz.csv

@@ -1,11 +1,15 @@
-NZ-G,1
-NZ-PG,5
-NZ-M,6
-NZ-R13,7
-NZ-RP13,7
-NZ-R15,8
-NZ-RP16,9
-NZ-R16,9
-NZ-R18,10
-NZ-R,10
-NZ-MA,10
+Exempt,0
+G,0
+GY,13
+PG,13
+R13,13
+RP13,13
+R15,15
+M,16
+R16,16
+RP16,16
+GA,18
+R18,18
+MA,1000
+R,1001
+Objectionable,1001

+ 6 - 1
Emby.Server.Implementations/Localization/Ratings/ro.csv

@@ -1 +1,6 @@
-RO-AG,1
+AG,0
+AP-12,12
+N-15,15
+IM-18,18
+IM-18-XXX,1000
+IC,1001

+ 6 - 5
Emby.Server.Implementations/Localization/Ratings/ru.csv

@@ -1,5 +1,6 @@
-RU-0+,1
-RU-6+,3
-RU-12+,7
-RU-16+,9
-RU-18+,10
+0+,0
+6+,6
+12+,12
+16+,16
+18+,18
+Refused classification,1001

+ 10 - 5
Emby.Server.Implementations/Localization/Ratings/se.csv

@@ -1,5 +1,10 @@
-SE-Btl,1
-SE-Barntillåten,1
-SE-7,3
-SE-11,5
-SE-15,8
+Alla,0
+Barntillåten,0
+Btl,0
+0+,0
+7,7
+9+,9
+10+,10
+11,11
+14,14
+15,15

+ 22 - 7
Emby.Server.Implementations/Localization/Ratings/uk.csv

@@ -1,7 +1,22 @@
-UK-U,1
-UK-PG,5
-UK-12,7
-UK-12A,7
-UK-15,9
-UK-18,10
-UK-R18,15
+All,0
+E,0
+G,0
+U,0
+0+,0
+6+,6
+7+,7
+PG,8
+9+,9
+12,12
+12+,12
+12A,12
+Teen,13
+13+,13
+14+,14
+15,15
+16,16
+Caution,18
+18,18
+Mature,1000
+Adult,1000
+R18,1000

+ 50 - 23
Emby.Server.Implementations/Localization/Ratings/us.csv

@@ -1,23 +1,50 @@
-TV-Y,1
-APPROVED,1
-G,1
-E,1
-EC,1
-TV-G,1
-TV-Y7,3
-TV-Y7-FV,4
-PG,5
-TV-PG,5
-PG-13,7
-T,7
-TV-14,8
-R,9
-M,9
-TV-MA,9
-NC-17,10
-AO,15
-RP,15
-UR,15
-NR,15
-X,15
-XXX,100
+Approved,0
+G,0
+TV-G,0
+TV-Y,0
+TV-Y7,7
+TV-Y7-FV,7
+PG,10
+PG-13,13
+TV-PG,13
+TV-PG-D,13
+TV-PG-L,13
+TV-PG-S,13
+TV-PG-V,13
+TV-PG-DL,13
+TV-PG-DS,13
+TV-PG-DV,13
+TV-PG-LS,13
+TV-PG-LV,13
+TV-PG-SV,13
+TV-PG-DLS,13
+TV-PG-DLV,13
+TV-PG-DSV,13
+TV-PG-LSV,13
+TV-PG-DLSV,13
+TV-14,14
+TV-14-D,14
+TV-14-L,14
+TV-14-S,14
+TV-14-V,14
+TV-14-DL,14
+TV-14-DS,14
+TV-14-DV,14
+TV-14-LS,14
+TV-14-LV,14
+TV-14-SV,14
+TV-14-DLS,14
+TV-14-DLV,14
+TV-14-DSV,14
+TV-14-LSV,14
+TV-14-DLSV,14
+NC-17,17
+R,17
+TV-MA,17
+TV-MA-L,17
+TV-MA-S,17
+TV-MA-V,17
+TV-MA-LS,17
+TV-MA-LV,17
+TV-MA-SV,17
+TV-MA-LSV,17

+ 14 - 11
tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs

@@ -83,11 +83,11 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
             await localizationManager.LoadAll();
             var ratings = localizationManager.GetParentalRatings().ToList();
 
-            Assert.Equal(23, ratings.Count);
+            Assert.Equal(50, ratings.Count);
 
             var tvma = ratings.FirstOrDefault(x => x.Name.Equals("TV-MA", StringComparison.Ordinal));
             Assert.NotNull(tvma);
-            Assert.Equal(9, tvma!.Value);
+            Assert.Equal(17, tvma!.Value);
         }
 
         [Fact]
@@ -100,21 +100,21 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
             await localizationManager.LoadAll();
             var ratings = localizationManager.GetParentalRatings().ToList();
 
-            Assert.Equal(10, ratings.Count);
+            Assert.Equal(12, ratings.Count);
 
             var fsk = ratings.FirstOrDefault(x => x.Name.Equals("FSK-12", StringComparison.Ordinal));
             Assert.NotNull(fsk);
-            Assert.Equal(7, fsk!.Value);
+            Assert.Equal(12, fsk!.Value);
         }
 
         [Theory]
-        [InlineData("CA-R", "CA", 10)]
-        [InlineData("FSK-16", "DE", 8)]
-        [InlineData("FSK-18", "DE", 9)]
-        [InlineData("FSK-18", "US", 9)]
-        [InlineData("TV-MA", "US", 9)]
-        [InlineData("XXX", "asdf", 100)]
-        [InlineData("Germany: FSK-18", "DE", 9)]
+        [InlineData("CA-R", "CA", 18)]
+        [InlineData("FSK-16", "DE", 16)]
+        [InlineData("FSK-18", "DE", 18)]
+        [InlineData("FSK-18", "US", 18)]
+        [InlineData("TV-MA", "US", 17)]
+        [InlineData("XXX", "asdf", 1000)]
+        [InlineData("Germany: FSK-18", "DE", 18)]
         public async Task GetRatingLevel_GivenValidString_Success(string value, string countryCode, int expectedLevel)
         {
             var localizationManager = Setup(new ServerConfiguration()
@@ -135,6 +135,9 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
                 UICulture = "de-DE"
             });
             await localizationManager.LoadAll();
+            Assert.Null(localizationManager.GetRatingLevel("NR"));
+            Assert.Null(localizationManager.GetRatingLevel("unrated"));
+            Assert.Null(localizationManager.GetRatingLevel("Not Rated"));
             Assert.Null(localizationManager.GetRatingLevel("n/a"));
         }