mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
New: Add Language Tests
This commit is contained in:
parent
5ee2b10c2c
commit
6706138fa0
@ -31,7 +31,10 @@ public class LanguageFixture : CoreTest
|
||||
new object[] { 19, Language.Flemish },
|
||||
new object[] { 20, Language.Greek },
|
||||
new object[] { 21, Language.Korean },
|
||||
new object[] { 22, Language.Hungarian }
|
||||
new object[] { 22, Language.Hungarian },
|
||||
new object[] { 23, Language.Hebrew },
|
||||
new object[] { 24, Language.Lithuanian },
|
||||
new object[] { 25, Language.Czech }
|
||||
};
|
||||
|
||||
public static object[] ToIntCases =
|
||||
@ -57,7 +60,10 @@ public class LanguageFixture : CoreTest
|
||||
new object[] { Language.Flemish, 19 },
|
||||
new object[] { Language.Greek, 20 },
|
||||
new object[] { Language.Korean, 21 },
|
||||
new object[] { Language.Hungarian, 22 }
|
||||
new object[] { Language.Hungarian, 22 },
|
||||
new object[] { Language.Hebrew, 23 },
|
||||
new object[] { Language.Lithuanian, 24 },
|
||||
new object[] { Language.Czech, 25 }
|
||||
};
|
||||
|
||||
[Test]
|
||||
|
44
src/NzbDrone.Core.Test/ParserTests/IsoLanguagesFixture.cs
Normal file
44
src/NzbDrone.Core.Test/ParserTests/IsoLanguagesFixture.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ParserTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class IsoLanguagesFixture : CoreTest
|
||||
{
|
||||
[TestCase("en")]
|
||||
[TestCase("eng")]
|
||||
[TestCase("en-US")]
|
||||
public void should_return_iso_language_for_English(string isoCode)
|
||||
{
|
||||
var result = IsoLanguages.Find(isoCode);
|
||||
result.Language.Should().Be(Language.English);
|
||||
}
|
||||
|
||||
[TestCase("enus")]
|
||||
[TestCase("enusa")]
|
||||
[TestCase("wo")]
|
||||
[TestCase("ca-IT")]
|
||||
public void unknown_or_invalid_code_should_return_null(string isoCode)
|
||||
{
|
||||
var result = IsoLanguages.Find(isoCode);
|
||||
result.Should().Be(null);
|
||||
}
|
||||
|
||||
[TestCase("pt")]
|
||||
[TestCase("por")]
|
||||
public void should_return_portuguese(string isoCode)
|
||||
{
|
||||
var result = IsoLanguages.Find(isoCode);
|
||||
result.Language.Should().Be(Language.Portuguese);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,80 +1,232 @@
|
||||
//using System.Collections.Generic;
|
||||
//using FluentAssertions;
|
||||
//using NUnit.Framework;
|
||||
//using NzbDrone.Core.Languages;
|
||||
//using NzbDrone.Core.Parser;
|
||||
//using NzbDrone.Core.Test.Framework;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
//namespace NzbDrone.Core.Test.ParserTests
|
||||
//{
|
||||
namespace NzbDrone.Core.Test.ParserTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class LanguageParserFixture : CoreTest
|
||||
{
|
||||
[TestCase("Pulp.Fiction.1994.English.1080p.XviD-LOL")]
|
||||
[TestCase("The Danish Girl 2015")]
|
||||
[TestCase("Fantastic.Beasts.The.Crimes.Of.Grindelwald.2018.2160p.WEBRip.x265.10bit.HDR.DD5.1-GASMASK")]
|
||||
public void should_parse_language_english(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
// [TestFixture]
|
||||
// public class LanguageParserFixture : CoreTest
|
||||
// {
|
||||
// // TODO: REWORK THIS TEST
|
||||
// //[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", Language.English)]
|
||||
// //[TestCase("Castle.2009.S01E14.French.HDTV.XviD-LOL", Language.French)]
|
||||
// //[TestCase("Ouija.Origin.of.Evil.2016.MULTi.TRUEFRENCH.1080p.BluRay.x264-MELBA", Language.French, Language.English)]
|
||||
// //[TestCase("Everest.2015.FRENCH.VFQ.BDRiP.x264-CNF30", Language.French)]
|
||||
// //[TestCase("Showdown.In.Little.Tokyo.1991.MULTI.VFQ.VFF.DTSHD-MASTER.1080p.BluRay.x264-ZombiE", Language.French, Language.English)]
|
||||
// //[TestCase("The.Polar.Express.2004.MULTI.VF2.1080p.BluRay.x264-PopHD", Language.French, Language.English)]
|
||||
// //[TestCase("Castle.2009.S01E14.Spanish.HDTV.XviD-LOL", Language.Spanish)]
|
||||
// //[TestCase("Castle.2009.S01E14.German.HDTV.XviD-LOL", Language.German)]
|
||||
// //[TestCase("Castle.2009.S01E14.Italian.HDTV.XviD-LOL", Language.Italian)]
|
||||
// //[TestCase("Castle.2009.S01E14.Danish.HDTV.XviD-LOL", Language.Danish)]
|
||||
// //[TestCase("Castle.2009.S01E14.Dutch.HDTV.XviD-LOL", Language.Dutch)]
|
||||
// //[TestCase("Castle.2009.S01E14.Japanese.HDTV.XviD-LOL", Language.Japanese)]
|
||||
// //[TestCase("Castle.2009.S01E14.Cantonese.HDTV.XviD-LOL", Language.Cantonese)]
|
||||
// //[TestCase("Castle.2009.S01E14.Mandarin.HDTV.XviD-LOL", Language.Mandarin)]
|
||||
// //[TestCase("Castle.2009.S01E14.Korean.HDTV.XviD-LOL", Language.Korean)]
|
||||
// //[TestCase("Castle.2009.S01E14.Russian.HDTV.XviD-LOL", Language.Russian)]
|
||||
// //[TestCase("Castle.2009.S01E14.Polish.HDTV.XviD-LOL", Language.Polish)]
|
||||
// //[TestCase("Castle.2009.S01E14.Vietnamese.HDTV.XviD-LOL", Language.Vietnamese)]
|
||||
// //[TestCase("Castle.2009.S01E14.Swedish.HDTV.XviD-LOL", Language.Swedish)]
|
||||
// //[TestCase("Castle.2009.S01E14.Norwegian.HDTV.XviD-LOL", Language.Norwegian)]
|
||||
// //[TestCase("Castle.2009.S01E14.Finnish.HDTV.XviD-LOL", Language.Finnish)]
|
||||
// //[TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", Language.Turkish)]
|
||||
// //[TestCase("Castle.2009.S01E14.Czech.HDTV.XviD-LOL", Language.Czech)]
|
||||
// //[TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", Language.Portuguese)]
|
||||
// //[TestCase("Burn.Notice.S04E15.Brotherly.Love.GERMAN.DUBBED.WS.WEBRiP.XviD.REPACK-TVP", Language.German)]
|
||||
// //[TestCase("Revolution S01E03 No Quarter 2012 WEB-DL 720p Nordic-philipo mkv", Language.Norwegian)]
|
||||
// //[TestCase("Constantine.2014.S01E01.WEBRiP.H264.AAC.5.1-NL.SUBS", Language.Dutch)]
|
||||
// //[TestCase("Castle.2009.S01E14.HDTV.XviD.HUNDUB-LOL", Language.Hungarian)]
|
||||
// //[TestCase("Castle.2009.S01E14.HDTV.XviD.ENG.HUN-LOL", Language.Hungarian)]
|
||||
// //[TestCase("Castle.2009.S01E14.HDTV.XviD.HUN-LOL", Language.Hungarian)]
|
||||
// //[TestCase("Castle.2009.S01E14.HDTV.XviD.CZ-LOL", Language.Czech)]
|
||||
// //[TestCase("Passengers.2016.German.DL.AC3.Dubbed.1080p.WebHD.h264.iNTERNAL-PsO", Language.German)]
|
||||
// //[TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", Language.German)]
|
||||
// //[TestCase("Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO", Language.German)]
|
||||
// //[TestCase("Valana la Legende FRENCH BluRay 720p 2016 kjhlj", Language.French)]
|
||||
// //[TestCase("Smurfs.The.Lost.Village.2017.1080p.BluRay.HebDub.x264-iSrael",Language.Hebrew)]
|
||||
// //[TestCase("The Danish Girl 2015", Language.English)]
|
||||
// //[TestCase("Nocturnal Animals (2016) MULTi VFQ English [1080p] BluRay x264-PopHD", Language.English, Language.French)]
|
||||
// //[TestCase("Wonder.Woman.2017.720p.BluRay.DD5.1.x264-TayTO.CZ-FTU", Language.Czech)]
|
||||
// //[TestCase("Fantastic.Beasts.The.Crimes.Of.Grindelwald.2018.2160p.WEBRip.x265.10bit.HDR.DD5.1-GASMASK", Language.English)]
|
||||
// //[TestCase("Vert.Emeraude.2016.VFi.1080P.mHD.X264.AC3-ROMKENT")]
|
||||
// public void should_parse_language(string postTitle, params Language[] languages)
|
||||
// {
|
||||
// var movieInfo = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
// var languageTitle = postTitle;
|
||||
// if (movieInfo != null)
|
||||
// {
|
||||
// languageTitle = movieInfo.SimpleReleaseTitle;
|
||||
// }
|
||||
// var result = LanguageParser.ParseLanguages(languageTitle);
|
||||
// result = LanguageParser.EnhanceLanguages(languageTitle, result);
|
||||
// result.Should().BeEquivalentTo(languages);
|
||||
// }
|
||||
result.Languages.Should().BeEquivalentTo(Language.English);
|
||||
}
|
||||
|
||||
// [TestCase("2 Broke Girls - S01E01 - Pilot.en.sub", Language.English)]
|
||||
// [TestCase("2 Broke Girls - S01E01 - Pilot.eng.sub", Language.English)]
|
||||
// [TestCase("2 Broke Girls - S01E01 - Pilot.sub", Language.Unknown)]
|
||||
// [TestCase("2 Broke Girls - S01E01 - Pilot.eng.forced.sub", Language.English)]
|
||||
// [TestCase("2 Broke Girls - S01E01 - Pilot-eng-forced.sub", Language.English)]
|
||||
// public void should_parse_subtitle_language(string fileName, Language language)
|
||||
// {
|
||||
// var result = LanguageParser.ParseSubtitleLanguage(fileName);
|
||||
// result.Should().Be(language);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
[TestCase("Pulp.Fiction.1994.French.1080p.XviD-LOL")]
|
||||
public void should_parse_language_french(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.French);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Spanish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_spanish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Spanish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.German.1080p.XviD-LOL")]
|
||||
public void should_parse_language_german(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.German);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Italian.1080p.XviD-LOL")]
|
||||
public void should_parse_language_italian(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Italian);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Danish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_danish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Danish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Dutch.1080p.XviD-LOL")]
|
||||
public void should_parse_language_dutch(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Dutch);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Japanese.1080p.XviD-LOL")]
|
||||
public void should_parse_language_japanese(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Japanese);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Icelandic.1080p.XviD-LOL")]
|
||||
public void should_parse_language_icelandic(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Icelandic);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Chinese.1080p.XviD-LOL")]
|
||||
public void should_parse_language_chinese(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Chinese);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Russian.1080p.XviD-LOL")]
|
||||
public void should_parse_language_russian(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Russian);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Polish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_polish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Polish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Vietnamese.1080p.XviD-LOL")]
|
||||
public void should_parse_language_vietnamese(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Vietnamese);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Swedish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_swedish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Swedish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Norwegian.1080p.XviD-LOL")]
|
||||
public void should_parse_language_norwegian(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Norwegian);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Finnish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_finnish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Finnish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Turkish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_turkish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Turkish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Portuguese.1080p.XviD-LOL")]
|
||||
public void should_parse_language_portuguese(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Portuguese);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Flemish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_flemish(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Flemish);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Greek.1080p.XviD-LOL")]
|
||||
public void should_parse_language_greek(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Greek);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Korean.1080p.XviD-LOL")]
|
||||
public void should_parse_language_korean(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Korean);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Hungarian.1080p.XviD-LOL")]
|
||||
public void should_parse_language_hungarian(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Hungarian);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Hebrew.1080p.XviD-LOL")]
|
||||
public void should_parse_language_hebrew(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Hebrew);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.AC3.LT.EN-CNN")]
|
||||
public void should_parse_language_lithuanian(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Lithuanian);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.CZ.1080p.XviD-LOL")]
|
||||
public void should_parse_language_czech(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.Czech);
|
||||
}
|
||||
|
||||
[TestCase("Pulp Fiction.en.sub")]
|
||||
[TestCase("Pulp Fiction.eng.sub")]
|
||||
[TestCase("Pulp.Fiction.eng.forced.sub")]
|
||||
[TestCase("Pulp-Fiction-eng-forced.sub")]
|
||||
public void should_parse_subtitle_language(string fileName)
|
||||
{
|
||||
var result = LanguageParser.ParseSubtitleLanguage(fileName);
|
||||
result.Should().Be(Language.English);
|
||||
}
|
||||
|
||||
[TestCase("Pulp Fiction.sub")]
|
||||
public void should_parse_subtitle_language_unknown(string fileName)
|
||||
{
|
||||
var result = LanguageParser.ParseSubtitleLanguage(fileName);
|
||||
result.Should().Be(Language.Unknown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
||||
namespace NzbDrone.Core.Parser
|
||||
@ -8,23 +6,15 @@ public class IsoLanguage
|
||||
{
|
||||
public string TwoLetterCode { get; set; }
|
||||
public string ThreeLetterCode { get; set; }
|
||||
public List<string> AltCodes = new List<string>();
|
||||
public string CountryCode { get; set; }
|
||||
public Language Language { get; set; }
|
||||
|
||||
public IsoLanguage(string twoLetterCode, string threeLetterCode, Language language)
|
||||
public IsoLanguage(string twoLetterCode, string countryCode, string threeLetterCode, Language language)
|
||||
{
|
||||
TwoLetterCode = twoLetterCode;
|
||||
ThreeLetterCode = threeLetterCode;
|
||||
CountryCode = countryCode;
|
||||
Language = language;
|
||||
}
|
||||
|
||||
public IsoLanguage(List<string> twoLetterCodes, string threeLetterCode, Language language)
|
||||
{
|
||||
TwoLetterCode = twoLetterCodes.First();
|
||||
twoLetterCodes.RemoveAt(0);
|
||||
ThreeLetterCode = threeLetterCode;
|
||||
Language = language;
|
||||
AltCodes.AddRange(twoLetterCodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,47 +8,55 @@ public static class IsoLanguages
|
||||
{
|
||||
private static readonly HashSet<IsoLanguage> All = new HashSet<IsoLanguage>
|
||||
{
|
||||
new IsoLanguage(new List<string> { "en", "us", "uk" }, "eng", Language.English),
|
||||
new IsoLanguage("fr", "fra", Language.French),
|
||||
new IsoLanguage("es", "spa", Language.Spanish),
|
||||
new IsoLanguage("de", "deu", Language.German),
|
||||
new IsoLanguage("it", "ita", Language.Italian),
|
||||
new IsoLanguage("da", "dan", Language.Danish),
|
||||
new IsoLanguage("nl", "nld", Language.Dutch),
|
||||
new IsoLanguage("ja", "jpn", Language.Japanese),
|
||||
|
||||
// new IsoLanguage("", "", Language.Cantonese),
|
||||
// new IsoLanguage("", "", Language.Mandarin),
|
||||
new IsoLanguage("ru", "rus", Language.Russian),
|
||||
new IsoLanguage("pl", "pol", Language.Polish),
|
||||
new IsoLanguage("vi", "vie", Language.Vietnamese),
|
||||
new IsoLanguage("sv", "swe", Language.Swedish),
|
||||
new IsoLanguage("no", "nor", Language.Norwegian),
|
||||
new IsoLanguage("nb", "nob", Language.Norwegian),
|
||||
new IsoLanguage("fi", "fin", Language.Finnish),
|
||||
new IsoLanguage("tr", "tur", Language.Turkish),
|
||||
new IsoLanguage("pt", "por", Language.Portuguese),
|
||||
|
||||
// new IsoLanguage("nl", "nld", Language.Flemish),
|
||||
new IsoLanguage("el", "ell", Language.Greek),
|
||||
new IsoLanguage("ko", "kor", Language.Korean),
|
||||
new IsoLanguage("hu", "hun", Language.Hungarian),
|
||||
new IsoLanguage("he", "heb", Language.Hebrew),
|
||||
new IsoLanguage("cs", "ces", Language.Czech),
|
||||
new IsoLanguage("an", "any", Language.Any)
|
||||
new IsoLanguage("en", "", "eng", Language.English),
|
||||
new IsoLanguage("fr", "", "fra", Language.French),
|
||||
new IsoLanguage("es", "", "spa", Language.Spanish),
|
||||
new IsoLanguage("de", "", "deu", Language.German),
|
||||
new IsoLanguage("it", "", "ita", Language.Italian),
|
||||
new IsoLanguage("da", "", "dan", Language.Danish),
|
||||
new IsoLanguage("nl", "", "nld", Language.Dutch),
|
||||
new IsoLanguage("ja", "", "jpn", Language.Japanese),
|
||||
new IsoLanguage("is", "", "isl", Language.Icelandic),
|
||||
new IsoLanguage("zh", "", "zho", Language.Chinese),
|
||||
new IsoLanguage("ru", "", "rus", Language.Russian),
|
||||
new IsoLanguage("pl", "", "pol", Language.Polish),
|
||||
new IsoLanguage("vi", "", "vie", Language.Vietnamese),
|
||||
new IsoLanguage("sv", "", "swe", Language.Swedish),
|
||||
new IsoLanguage("no", "", "nor", Language.Norwegian),
|
||||
new IsoLanguage("nb", "", "nob", Language.Norwegian),
|
||||
new IsoLanguage("fi", "", "fin", Language.Finnish),
|
||||
new IsoLanguage("tr", "", "tur", Language.Turkish),
|
||||
new IsoLanguage("pt", "", "por", Language.Portuguese),
|
||||
new IsoLanguage("el", "", "ell", Language.Greek),
|
||||
new IsoLanguage("ko", "", "kor", Language.Korean),
|
||||
new IsoLanguage("hu", "", "hun", Language.Hungarian),
|
||||
new IsoLanguage("he", "", "heb", Language.Hebrew),
|
||||
new IsoLanguage("cs", "", "ces", Language.Czech)
|
||||
};
|
||||
|
||||
public static IsoLanguage Find(string isoCode)
|
||||
{
|
||||
if (isoCode.Length == 2)
|
||||
var isoArray = isoCode.Split('-');
|
||||
|
||||
var langCode = isoArray[0].ToLower();
|
||||
|
||||
if (langCode.Length == 2)
|
||||
{
|
||||
//Lookup ISO639-1 code
|
||||
return All.SingleOrDefault(l => l.TwoLetterCode == isoCode) ?? All.SingleOrDefault(l => l.AltCodes.Contains(isoCode));
|
||||
var isoLanguages = All.Where(l => l.TwoLetterCode == langCode).ToList();
|
||||
|
||||
if (isoArray.Length > 1)
|
||||
{
|
||||
isoLanguages = isoLanguages.Any(l => l.CountryCode == isoArray[1].ToLower()) ?
|
||||
isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() : isoLanguages;
|
||||
}
|
||||
|
||||
return isoLanguages.FirstOrDefault();
|
||||
}
|
||||
else if (isoCode.Length == 3)
|
||||
else if (langCode.Length == 3)
|
||||
{
|
||||
//Lookup ISO639-2T code
|
||||
return All.SingleOrDefault(l => l.ThreeLetterCode == isoCode);
|
||||
return All.FirstOrDefault(l => l.ThreeLetterCode == langCode);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -14,9 +14,12 @@ public static class LanguageParser
|
||||
{
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser));
|
||||
|
||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<czech>\b(?:CZ|SK)\b)",
|
||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|(?<german>german\b|videomann)|(?<flemish>flemish)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VOSTFR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<dutch>nl\W?subs?)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex SubtitleLanguageRegex = new Regex(".+?[-_. ](?<iso_code>[a-z]{2,3})(?:[-_. ]forced)?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static List<Language> ParseLanguages(string title)
|
||||
@ -124,7 +127,15 @@ public static List<Language> ParseLanguages(string title)
|
||||
languages.Add(Language.Hebrew);
|
||||
}
|
||||
|
||||
if (lowerTitle.Contains("czech"))
|
||||
// Case sensitive
|
||||
var caseSensitiveMatch = CaseSensitiveLanguageRegex.Match(title);
|
||||
|
||||
if (caseSensitiveMatch.Groups["lithuanian"].Captures.Cast<Capture>().Any())
|
||||
{
|
||||
languages.Add(Language.Lithuanian);
|
||||
}
|
||||
|
||||
if (caseSensitiveMatch.Groups["czech"].Captures.Cast<Capture>().Any())
|
||||
{
|
||||
languages.Add(Language.Czech);
|
||||
}
|
||||
@ -176,11 +187,6 @@ public static List<Language> ParseLanguages(string title)
|
||||
languages.Add(Language.Hebrew);
|
||||
}
|
||||
|
||||
if (match.Groups["czech"].Success)
|
||||
{
|
||||
languages.Add(Language.Czech);
|
||||
}
|
||||
|
||||
if (title.ToLower().Contains("multi"))
|
||||
{
|
||||
//Let's add english language to multi release as a safe guard.
|
||||
|
Loading…
Reference in New Issue
Block a user