Fixed: Refresh movie failing.

pull/2/head
Leonardo Galli 7 years ago
parent ba531fff4d
commit fc805e5078

@ -1,9 +1,13 @@
namespace NzbDrone.Core.Parser using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.Parser
{ {
public class IsoLanguage public class IsoLanguage
{ {
public string TwoLetterCode { get; set; } public string TwoLetterCode { get; set; }
public string ThreeLetterCode { get; set; } public string ThreeLetterCode { get; set; }
public List<string> AltCodes = new List<string>();
public Language Language { get; set; } public Language Language { get; set; }
public IsoLanguage(string twoLetterCode, string threeLetterCode, Language language) public IsoLanguage(string twoLetterCode, string threeLetterCode, Language language)
@ -13,5 +17,14 @@
Language = language; Language = language;
} }
public IsoLanguage(List<string> twoLetterCodes, string threeLetterCode, Language language)
{
TwoLetterCode = twoLetterCodes.First();
twoLetterCodes.RemoveAt(0);
ThreeLetterCode = threeLetterCode;
Language = language;
AltCodes.AddRange(twoLetterCodes);
}
} }
} }

@ -7,9 +7,7 @@ namespace NzbDrone.Core.Parser
{ {
private static readonly HashSet<IsoLanguage> All = new HashSet<IsoLanguage> private static readonly HashSet<IsoLanguage> All = new HashSet<IsoLanguage>
{ {
new IsoLanguage("en", "eng", Language.English), new IsoLanguage(new List<string> {"en", "us", "uk"}, "eng", Language.English),
new IsoLanguage("us", "usa", Language.English), //For tmdb mapping
new IsoLanguage("uk", "brit", Language.English), //For tmdb mapping too.
new IsoLanguage("fr", "fra", Language.French), new IsoLanguage("fr", "fra", Language.French),
new IsoLanguage("es", "spa", Language.Spanish), new IsoLanguage("es", "spa", Language.Spanish),
new IsoLanguage("de", "deu", Language.German), new IsoLanguage("de", "deu", Language.German),
@ -39,7 +37,7 @@ namespace NzbDrone.Core.Parser
if (isoCode.Length == 2) if (isoCode.Length == 2)
{ {
//Lookup ISO639-1 code //Lookup ISO639-1 code
return All.SingleOrDefault(l => l.TwoLetterCode == isoCode); return All.SingleOrDefault(l => l.TwoLetterCode == isoCode) ?? All.SingleOrDefault(l => l.AltCodes.Contains(isoCode));
} }
else if (isoCode.Length == 3) else if (isoCode.Length == 3)
{ {

Loading…
Cancel
Save