Merge pull request #810 from Bond-009/localization
Fix loading of rating files
This commit is contained in:
commit
181de97ce5
|
@ -43,7 +43,7 @@
|
||||||
<EmbeddedResource Include="Localization\iso6392.txt" />
|
<EmbeddedResource Include="Localization\iso6392.txt" />
|
||||||
<EmbeddedResource Include="Localization\countries.json" />
|
<EmbeddedResource Include="Localization\countries.json" />
|
||||||
<EmbeddedResource Include="Localization\Core\*.json" />
|
<EmbeddedResource Include="Localization\Core\*.json" />
|
||||||
<EmbeddedResource Include="Localization\Ratings\*.txt" />
|
<EmbeddedResource Include="Localization\Ratings\*.csv" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -60,20 +60,27 @@ namespace Emby.Server.Implementations.Localization
|
||||||
|
|
||||||
public async Task LoadAll()
|
public async Task LoadAll()
|
||||||
{
|
{
|
||||||
const string ratingsResource = "Emby.Server.Implementations.Ratings.";
|
const string ratingsResource = "Emby.Server.Implementations.Localization.Ratings.";
|
||||||
|
|
||||||
Directory.CreateDirectory(LocalizationPath);
|
Directory.CreateDirectory(LocalizationPath);
|
||||||
|
|
||||||
var existingFiles = GetRatingsFiles(LocalizationPath).Select(Path.GetFileName);
|
var existingFiles = GetRatingsFiles(LocalizationPath).Select(Path.GetFileName);
|
||||||
|
|
||||||
// Extract from the assembly
|
// Extract from the assembly
|
||||||
foreach (var resource in _assembly.GetManifestResourceNames()
|
foreach (var resource in _assembly.GetManifestResourceNames())
|
||||||
.Where(i => i.StartsWith(ratingsResource)))
|
|
||||||
{
|
{
|
||||||
|
if (!resource.StartsWith(ratingsResource))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string filename = "ratings-" + resource.Substring(ratingsResource.Length);
|
string filename = "ratings-" + resource.Substring(ratingsResource.Length);
|
||||||
|
|
||||||
if (!existingFiles.Contains(filename))
|
if (existingFiles.Contains(filename))
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
using (var stream = _assembly.GetManifestResourceStream(resource))
|
using (var stream = _assembly.GetManifestResourceStream(resource))
|
||||||
{
|
{
|
||||||
string target = Path.Combine(LocalizationPath, filename);
|
string target = Path.Combine(LocalizationPath, filename);
|
||||||
|
@ -85,7 +92,6 @@ namespace Emby.Server.Implementations.Localization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var file in GetRatingsFiles(LocalizationPath))
|
foreach (var file in GetRatingsFiles(LocalizationPath))
|
||||||
{
|
{
|
||||||
|
@ -289,7 +295,8 @@ namespace Emby.Server.Implementations.Localization
|
||||||
/// <returns>Dictionary{System.StringParentalRating}.</returns>
|
/// <returns>Dictionary{System.StringParentalRating}.</returns>
|
||||||
private async Task LoadRatings(string file)
|
private async Task LoadRatings(string file)
|
||||||
{
|
{
|
||||||
Dictionary<string, ParentalRating> dict = new Dictionary<string, ParentalRating>(StringComparer.OrdinalIgnoreCase);
|
Dictionary<string, ParentalRating> dict
|
||||||
|
= new Dictionary<string, ParentalRating>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
using (var str = File.OpenRead(file))
|
using (var str = File.OpenRead(file))
|
||||||
using (var reader = new StreamReader(str))
|
using (var reader = new StreamReader(str))
|
||||||
|
@ -309,7 +316,10 @@ namespace Emby.Server.Implementations.Localization
|
||||||
dict.Add(parts[0], (new ParentalRating { Name = parts[0], Value = value }));
|
dict.Add(parts[0], (new ParentalRating { Name = parts[0], Value = value }));
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
else
|
||||||
|
{
|
||||||
_logger.LogWarning("Misformed line in {Path}", file);
|
_logger.LogWarning("Misformed line in {Path}", file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user