Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,3 @@ __pycache__/

# JetBrains Rider IDE
.idea/
/AnitomySharpTests/Resource.resx
/AnitomySharpTests/Resource.Designer.cs
/AnitomySharpTests/AnitomySharpTests.csproj
/AnitomySharp.sln
/AnitomySharp/AnitomySharp.csproj
37 changes: 37 additions & 0 deletions AnitomySharp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33829.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnitomySharp", "AnitomySharp\AnitomySharp.csproj", "{1240372C-C46B-4604-BB75-EFFC393549F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnitomySharpTests", "AnitomySharpTests\AnitomySharpTests.csproj", "{06FF06C1-C5E3-4C2D-A6AE-CDB4C8068527}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnitomySharpUI", "AnitomySharpUI\AnitomySharpUI.csproj", "{5AF3F53E-3F8B-410C-B6C3-61818ECEBC0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1240372C-C46B-4604-BB75-EFFC393549F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1240372C-C46B-4604-BB75-EFFC393549F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1240372C-C46B-4604-BB75-EFFC393549F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1240372C-C46B-4604-BB75-EFFC393549F7}.Release|Any CPU.Build.0 = Release|Any CPU
{06FF06C1-C5E3-4C2D-A6AE-CDB4C8068527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06FF06C1-C5E3-4C2D-A6AE-CDB4C8068527}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06FF06C1-C5E3-4C2D-A6AE-CDB4C8068527}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06FF06C1-C5E3-4C2D-A6AE-CDB4C8068527}.Release|Any CPU.Build.0 = Release|Any CPU
{5AF3F53E-3F8B-410C-B6C3-61818ECEBC0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AF3F53E-3F8B-410C-B6C3-61818ECEBC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AF3F53E-3F8B-410C-B6C3-61818ECEBC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AF3F53E-3F8B-410C-B6C3-61818ECEBC0C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06FDC297-490E-43DF-AD8A-C182493C21AF}
EndGlobalSection
EndGlobal
3 changes: 1 addition & 2 deletions AnitomySharp/Anitomy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@

namespace AnitomySharp
{

/// <summary>
/// A library capable of parsing Anime filenames
/// This code is a C++ to C# port of <see href="https://github.com/erengy/anitomy">Anitomy</see>>,
/// using the already existing Java port <see href="https://github.com/Vorror/anitomyJ">AnitomyJ</see> as a reference.
/// </summary>
public class AnitomySharp
{
private AnitomySharp() {}
private AnitomySharp() { }

/// <summary>
/// Parses an anime <see cref="filename"/> into its constituent elements.
Expand Down
10 changes: 10 additions & 0 deletions AnitomySharp/AnitomySharp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
10 changes: 5 additions & 5 deletions AnitomySharp/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

namespace AnitomySharp
{
/// <summary>
/// An <see cref="Element"/> represents an identified Anime <see cref="Token"/>.
/// A single filename may contain multiple of the same
/// token(e.g <see cref="ElementCategory.ElementEpisodeNumber"/>).
/// </summary>
/// <summary>
/// An <see cref="Element"/> represents an identified Anime <see cref="Token"/>.
/// A single filename may contain multiple of the same
/// token(e.g <see cref="ElementCategory.ElementEpisodeNumber"/>).
/// </summary>
public class Element
{
/** Element Categories */
Expand Down
54 changes: 27 additions & 27 deletions AnitomySharp/Keyword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace AnitomySharp
{

/// <summary>
/// A class to manager the list of known anime keywords. This class is analogous to <code>keyword.cpp</code> of Anitomy, and <code>KeywordManager.java</code> of AnitomyJ
/// </summary>
Expand All @@ -32,23 +31,23 @@ static KeywordManager()
var optionsUnidentifiableInvalid = new KeywordOptions(false, true, false);
var optionsUnidentifiableUnsearchable = new KeywordOptions(false, false, true);

Add(Element.ElementCategory.ElementAnimeSeasonPrefix,
Add(Element.ElementCategory.ElementAnimeSeasonPrefix,
optionsUnidentifiable,
new List<string> {"SAISON", "SEASON"});
new List<string> { "SAISON", "SEASON" });

Add(Element.ElementCategory.ElementAnimeType,
optionsUnidentifiable,
new List<string> {"GEKIJOUBAN", "MOVIE", "OAD", "OAV", "ONA", "OVA", "SPECIAL", "SPECIALS", "TV"});
new List<string> { "GEKIJOUBAN", "MOVIE", "OAD", "OAV", "ONA", "OVA", "SPECIAL", "SPECIALS", "TV" });

Add(Element.ElementCategory.ElementAnimeType,
optionsUnidentifiableUnsearchable,
new List<string> {"SP"}); // e.g. "Yumeiro Patissiere SP Professional"
new List<string> { "SP" }); // e.g. "Yumeiro Patissiere SP Professional"

Add(Element.ElementCategory.ElementAnimeType,
optionsUnidentifiableInvalid,
new List<string> {"ED", "ENDING", "NCED", "NCOP", "OP", "OPENING", "PREVIEW", "PV"});
new List<string> { "ED", "ENDING", "NCED", "NCOP", "OP", "OPENING", "PREVIEW", "PV" });

Add(Element.ElementCategory.ElementAudioTerm,
Add(Element.ElementCategory.ElementAudioTerm,
optionsDefault,
new List<string> {
// Audio channels
Expand All @@ -63,63 +62,63 @@ static KeywordManager()

Add(Element.ElementCategory.ElementDeviceCompatibility,
optionsDefault,
new List<string> {"IPAD3", "IPHONE5", "IPOD", "PS3", "XBOX", "XBOX360"});
new List<string> { "IPAD3", "IPHONE5", "IPOD", "PS3", "XBOX", "XBOX360" });

Add(Element.ElementCategory.ElementDeviceCompatibility,
optionsUnidentifiable,
new List<string> {"ANDROID"});
new List<string> { "ANDROID" });

Add(Element.ElementCategory.ElementEpisodePrefix,
optionsDefault,
new List<string> {"EP", "EP.", "EPS", "EPS.", "EPISODE", "EPISODE.", "EPISODES", "CAPITULO", "EPISODIO", "FOLGE"});
new List<string> { "EP", "EP.", "EPS", "EPS.", "EPISODE", "EPISODE.", "EPISODES", "CAPITULO", "EPISODIO", "EPIS\u00F3DIO", "FOLGE" });

Add(Element.ElementCategory.ElementEpisodePrefix,
optionsInvalid,
new List<string> {"E", "\\x7B2C"}); // single-letter episode keywords are not valid tokens
new List<string> { "E", "\\x7B2C" }); // single-letter episode keywords are not valid tokens

Add(Element.ElementCategory.ElementFileExtension,
optionsDefault,
new List<string> {"3GP", "AVI", "DIVX", "FLV", "M2TS", "MKV", "MOV", "MP4", "MPG", "OGM", "RM", "RMVB", "TS", "WEBM", "WMV"});
new List<string> { "3GP", "AVI", "DIVX", "FLV", "M2TS", "MKV", "MOV", "MP4", "MPG", "OGM", "RM", "RMVB", "TS", "WEBM", "WMV" });

Add(Element.ElementCategory.ElementFileExtension,
optionsInvalid,
new List<string> {"AAC", "AIFF", "FLAC", "M4A", "MP3", "MKA", "OGG", "WAV", "WMA", "7Z", "RAR", "ZIP", "ASS", "SRT"});
new List<string> { "AAC", "AIFF", "FLAC", "M4A", "MP3", "MKA", "OGG", "WAV", "WMA", "7Z", "RAR", "ZIP", "ASS", "SRT" });

Add(Element.ElementCategory.ElementLanguage,
optionsDefault,
new List<string> {"ENG", "ENGLISH", "ESPANO", "JAP", "PT-BR", "SPANISH", "VOSTFR"});
new List<string> { "ENG", "ENGLISH", "ESPANO", "JAP", "PT-BR", "SPANISH", "VOSTFR" });

Add(Element.ElementCategory.ElementLanguage,
optionsUnidentifiable,
new List<string> {"ESP", "ITA"}); // e.g. "Tokyo ESP:, "Bokura ga Ita"
new List<string> { "ESP", "ITA" }); // e.g. "Tokyo ESP:, "Bokura ga Ita"

Add(Element.ElementCategory.ElementOther,
optionsDefault,
new List<string> {"REMASTER", "REMASTERED", "UNCENSORED", "UNCUT", "TS", "VFR", "WIDESCREEN", "WS"});
new List<string> { "REMASTER", "REMASTERED", "UNCENSORED", "UNCUT", "TS", "VFR", "WIDESCREEN", "WS" });

Add(Element.ElementCategory.ElementReleaseGroup,
optionsDefault,
new List<string> {"THORA"});
new List<string> { "THORA" });

Add(Element.ElementCategory.ElementReleaseInformation,
optionsDefault,
new List<string> {"BATCH", "COMPLETE", "PATCH", "REMUX"});
new List<string> { "BATCH", "COMPLETE", "PATCH", "REMUX" });

Add(Element.ElementCategory.ElementReleaseInformation,
optionsUnidentifiable,
new List<string> {"END", "FINAL"}); // e.g. "The End of Evangelion", 'Final Approach"
new List<string> { "END", "FINAL" }); // e.g. "The End of Evangelion", 'Final Approach"

Add(Element.ElementCategory.ElementReleaseVersion,
optionsDefault,
new List<string> {"V0", "V1", "V2", "V3", "V4"});
new List<string> { "V0", "V1", "V2", "V3", "V4" });

Add(Element.ElementCategory.ElementSource,
optionsDefault,
new List<string> {"BD", "BDRIP", "BLURAY", "BLU-RAY", "DVD", "DVD5", "DVD9", "DVD-R2J", "DVDRIP", "DVD-RIP", "R2DVD", "R2J", "R2JDVD", "R2JDVDRIP", "HDTV", "HDTVRIP", "TVRIP", "TV-RIP", "WEBCAST", "WEBRIP"});
new List<string> { "BD", "BDRIP", "BLURAY", "BLU-RAY", "DVD", "DVD5", "DVD9", "DVD-R2J", "DVDRIP", "DVD-RIP", "R2DVD", "R2J", "R2JDVD", "R2JDVDRIP", "HDTV", "HDTVRIP", "TVRIP", "TV-RIP", "WEBCAST", "WEBRIP" });

Add(Element.ElementCategory.ElementSubtitles,
optionsDefault,
new List<string> {"ASS", "BIG5", "DUB", "DUBBED", "HARDSUB", "HARDSUBS", "RAW", "SOFTSUB", "SOFTSUBS", "SUB", "SUBBED", "SUBTITLED"});
new List<string> { "ASS", "BIG5", "DUB", "DUBBED", "HARDSUB", "HARDSUBS", "RAW", "SOFTSUB", "SOFTSUBS", "SUB", "SUBBED", "SUBTITLED" });

Add(Element.ElementCategory.ElementVideoTerm,
optionsDefault,
Expand All @@ -131,6 +130,7 @@ static KeywordManager()
"HI10", "HI10P", "HI444", "HI444P", "HI444PP",
"H264", "H265", "H.264", "H.265", "X264", "X265", "X.264",
"AVC", "HEVC", "HEVC2", "DIVX", "DIVX5", "DIVX6", "XVID",
"AV1",
// Video format
"AVI", "RMVB", "WMV", "WMV3", "WMV9",
// Video quality
Expand All @@ -140,7 +140,7 @@ static KeywordManager()

Add(Element.ElementCategory.ElementVolumePrefix,
optionsDefault,
new List<string> {"VOL", "VOL.", "VOLUME"});
new List<string> { "VOL", "VOL.", "VOLUME" });

PeekEntries = new List<Tuple<Element.ElementCategory, List<string>>>
{
Expand Down Expand Up @@ -181,11 +181,11 @@ public static bool FindAndSet(string keyword, ref Element.ElementCategory catego
{
return false;
}

if (category == Element.ElementCategory.ElementUnknown)
{
category = foundEntry.Category;
}
}
else if (foundEntry.Category != category)
{
return false;
Expand Down Expand Up @@ -246,7 +246,7 @@ public class KeywordOptions
public bool Searchable { get; }
public bool Valid { get; }

public KeywordOptions() : this(true, true, true) {}
public KeywordOptions() : this(true, true, true) { }

/// <summary>
/// Constructs a new keyword options
Expand Down
3 changes: 2 additions & 1 deletion AnitomySharp/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ private void SearchForKeywords()
if (Empty(Element.ElementCategory.ElementFileChecksum) && ParserHelper.IsCrc32(word))
{
category = Element.ElementCategory.ElementFileChecksum;
} else if (Empty(Element.ElementCategory.ElementVideoResolution) && ParserHelper.IsResolution(word))
}
else if (Empty(Element.ElementCategory.ElementVideoResolution) && ParserHelper.IsResolution(word))
{
category = Element.ElementCategory.ElementVideoResolution;
}
Expand Down
20 changes: 10 additions & 10 deletions AnitomySharp/ParserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace AnitomySharp
{

/// <summary>
/// Utility class to assist in the parsing.
/// </summary>
Expand Down Expand Up @@ -156,7 +155,8 @@ public bool IsElementCategorySearchable(Element.ElementCategory category)
/// </summary>
public bool IsElementCategorySingular(Element.ElementCategory category)
{
switch (category) {
switch (category)
{
case Element.ElementCategory.ElementAnimeSeason:
case Element.ElementCategory.ElementAnimeType:
case Element.ElementCategory.ElementAudioTerm:
Expand Down Expand Up @@ -275,18 +275,18 @@ public void BuildElement(Element.ElementCategory category, bool keepDelimiters,
if (keepDelimiters)
{
element.Append(delimiter);
}
}
else if (Token.InListRange(i, tokens))
{
switch (delimiter)
{
case ",":
case "&":
element.Append(delimiter);
break;
default:
element.Append(' ');
break;
case ",":
case "&":
element.Append(delimiter);
break;
default:
element.Append(' ');
break;
}
}
break;
Expand Down
Loading