Commit 12f9320b authored by Stefm's avatar Stefm

Added some properties in both classes, extended unit test for better code...

Added some properties in both classes, extended unit test for better code coverare and added the ability for multiple resolutions
parent f601eceb
6.0.0 (2016-09-17)
------------------
New
~~~~
- Added ParserSettings Property ReplaceRegexAndListTokens
- Added ParserSettings Property ReplaceRegexWithoutListTokens
- Added ParserSettings Property ResolutionStringOutput
- Added ParserSettings Property ResolutionStringUnknown
- Added ParserSettings Enum ResolutionOutputBehavior
- Added SeriesID Property Resolutions
- Added SeriesID Enum ResolutionsMap
- Added SeriesID Property DetectedOldSpacingChar
- Added SeriesID Property ProcessingDuration
- Removed Property Resolution
- Removed Enum Resolutions
- Removed Old SeriesID ctor
- Removed useless comments
- Support für multi resolution tokens in string
- Added Unit Tests
- Unit Tests improved for better code coverage
- Project/Demo/Assembly/Package Icon
- Added some more code comments
Fix
~~~~
- Issue#005 - RemovewithoutListtokens are removed without checking for dots bevore and after
- Issue#006 - Error with double resolution tokens
- Issue#007 - Add Raw and/or Regex replace
- Some smaller fixes
5.2.0 (2016-08-12)
------------------
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeriesIDParser", "SeriesIDParser\SeriesIDParser.csproj", "{D584FD1D-63D3-4FE2-A229-7F01E7A93797}"
EndProject
......
......@@ -33,6 +33,16 @@ using System.IO;
namespace SeriesIDParser
{
/// <summary>
/// The properties for the ResolutionOutputBehavior
/// </summary>
public enum ResolutionOutputBehavior
{
AllFoundResolutions,
HighestResolution,
LowestResolution
}
/// <summary>
/// The settings who can give to the SeriesIDParser to modify the behavior. Object is prefilled with the default values and list entries
/// </summary>
......@@ -50,7 +60,7 @@ namespace SeriesIDParser
{
// ### Resolution Detection
_detectUltraHD8kTokens = new List<string>() { "8k", "4320k" };
_detectUltraHDTokens = new List<string>() { "UHD", "2160p" };
_detectUltraHDTokens = new List<string>() { "NetflixUHD", "UHD", "2160p" };
_detectFullHDTokens = new List<string>() { "FullHD", "1080p" };
_detectHDTokens = new List<string>() { "HDTV", "720p", "HD" };
_detectSDTokens = new List<string>() { "DVDRIP", "DVD", "XVID", "SD" };
......@@ -143,6 +153,17 @@ namespace SeriesIDParser
}
private string _resolutionStringUnknown = "UNKNOWN";
/// <summary>
/// Defines the string who is convertet from the enum Resolutions to something readable for e.g. the ParsedString. Default: 'UNKNOWN'
/// </summary>
public string ResolutionStringUnknown
{
get { return _resolutionStringUnknown; }
set { _resolutionStringUnknown = value; }
}
private string _resolutionStringSD = "SD";
/// <summary>
/// Defines the string who is convertet from the enum Resolutions to something readable for e.g. the ParsedString. Default: 'SD'
......@@ -196,6 +217,17 @@ namespace SeriesIDParser
get { return _resolutionStringUltraHD8K; }
set { _resolutionStringUltraHD8K = value; }
}
private ResolutionOutputBehavior _resolutionStringOutput = ResolutionOutputBehavior.LowestResolution;
/// <summary>
/// Defines how the resolution is formated in the output strings e.g. ParsedString. Default: LowesrResolution
/// </summary>
public ResolutionOutputBehavior ResolutionStringOutput
{
get { return _resolutionStringOutput; }
set { _resolutionStringOutput = value; }
}
#endregion Output
......@@ -281,6 +313,29 @@ namespace SeriesIDParser
get { return _removeWithoutListTokens; }
set { _removeWithoutListTokens = value; }
}
private List<KeyValuePair<string, string>> _replaceRegexAndListTokens = new List<KeyValuePair<string, string>>();
/// <summary>
/// Defines the empty list with the KeyValuePair to replace (regex, replace)
/// </summary>
public List<KeyValuePair<string, string>> ReplaceRegexAndListTokens
{
get { return _replaceRegexAndListTokens; }
set { _replaceRegexAndListTokens = value; }
}
private List<KeyValuePair<string, string>> _replaceRegexWithoutListTokens = new List<KeyValuePair<string, string>>();
/// <summary>
/// Defines the empty list with the KeyValuePair to replace (regex, replace)
/// </summary>
public List<KeyValuePair<string, string>> ReplaceRegexWithoutListTokens
{
get { return _replaceRegexWithoutListTokens; }
set { _replaceRegexWithoutListTokens = value; }
}
#endregion RemoveAndReplace
......@@ -297,6 +352,7 @@ namespace SeriesIDParser
{
try
{
string data = string.Empty;
XmlSerializer x = new XmlSerializer(obj.GetType());
using (MemoryStream ms = new MemoryStream())
{
......@@ -304,9 +360,11 @@ namespace SeriesIDParser
ms.Position = 0;
using (StreamReader sr = new StreamReader(ms, Encoding.Default))
{
return sr.ReadToEnd();
data = sr.ReadToEnd();
}
}
return data;
}
catch (Exception)
{
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.2.0.0")]
[assembly: AssemblyFileVersion("5.2.0.0")]
[assembly: AssemblyVersion("6.0.0.0")]
[assembly: AssemblyFileVersion("6.0.0.0")]
This diff is collapsed.
......@@ -32,11 +32,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.S01E05.Teil5.GERMAN.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai.Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -48,6 +49,7 @@ namespace SeriesIDParser_Test
});
// Small s-e - Test002
id = new SeriesID();
id.Episode = 5;
......@@ -56,11 +58,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.s01e05.Teil5.GERMAN.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai.Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -72,6 +75,7 @@ namespace SeriesIDParser_Test
});
// three s-e - Test003
id = new SeriesID();
id.Episode = 5;
......@@ -80,11 +84,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.S001E005.Teil5.GERMAN.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai.Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -96,6 +101,7 @@ namespace SeriesIDParser_Test
});
// single s-e - Test004
id = new SeriesID();
id.Episode = 5;
......@@ -104,11 +110,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.s01e05.Teil5.GERMAN.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai.Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -129,11 +136,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.S001E5.Teil5.GERMAN.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai.Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -154,11 +162,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.S01E05.Teil5.GERMAN.GERMAN.720p.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai.Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -179,11 +188,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Dubai.Airport.S01E05.Teil5.GERMAN.DOKU.HDTV.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DOKU", "x264" };
id.Resolution = Resolutions.HD_720p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p };
id.Season = 1;
id.State = State.OK_SUCCESS;
id.Title = "Dubai-Airport";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -204,11 +214,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Better.Call.Saul.S02E10.GERMAN.DL.DUBBED.1080p.WebHD.h264-iNFOTv";
id.RemovedTokens = new List<string>() { "German", "DUBBED", "h264", "WebHD" };
id.Resolution = Resolutions.FullHD_1080p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.FullHD_1080p };
id.Season = 2;
id.State = State.OK_SUCCESS;
id.Title = "Better.Call.Saul";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -229,11 +240,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Better.Call.Saul.S02E10.GERMAN.DL.DUBBED.1080p.WebHD.h264 - iNFOTv";
id.RemovedTokens = new List<string>() { "German", "DUBBED", "h264", "WebHD" };
id.Resolution = Resolutions.FullHD_1080p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.FullHD_1080p };
id.Season = 2;
id.State = State.OK_SUCCESS;
id.Title = "Better.Call.Saul";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -254,11 +266,12 @@ namespace SeriesIDParser_Test
id.IsSeries = true;
id.OriginalString = "Better.Call.Saul.S02E10.GERMAN.DL.DUBBED.1080p.WebHD.h264 - iNFOTv.avi";
id.RemovedTokens = new List<string>() { "German", "DUBBED", "h264", "WebHD" };
id.Resolution = Resolutions.FullHD_1080p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.FullHD_1080p };
id.Season = 2;
id.State = State.OK_SUCCESS;
id.Title = "Better.Call.Saul";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -279,11 +292,12 @@ namespace SeriesIDParser_Test
id.IsSeries = false;
id.OriginalString = "Der.Hobbit.Smaugs.Einoede.2013.EXTENDED.German.DL.1080p.BluRay.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "x264", "EXTENDED", "BluRay" };
id.Resolution = Resolutions.FullHD_1080p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.FullHD_1080p };
id.Season = -1;
id.State = State.OK_SUCCESS;
id.Title = "Der.Hobbit.Smaugs.Einoede";
id.Year = 2013;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -304,11 +318,12 @@ namespace SeriesIDParser_Test
id.IsSeries = false;
id.OriginalString = "A.Chinese.Ghost.Story.3.1991.German.DTS.1080p.BD9.x264";
id.RemovedTokens = new List<string>() { "German", "DTS", "x264" };
id.Resolution = Resolutions.FullHD_1080p;
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.FullHD_1080p };
id.Season = -1;
id.State = State.OK_SUCCESS;
id.Title = "A.Chinese.Ghost.Story.3";
id.Year = 1991;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
......@@ -321,30 +336,57 @@ namespace SeriesIDParser_Test
// Series down sampled - Test013
// Series multi Resolutions - Test013
id = new SeriesID();
id.Episode = 1;
id.EpisodeTitle = "Endlich.frei";
id.FileExtension = "mkv";
id.IsSeries = true;
id.OriginalString = "Narcos.S02E01.Endlich.frei.German.DD51.DL.1080p.NetflixUHD.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "DL", "Netflix", "x264" };
id.Resolution = Resolutions.FullHD_1080p;
id.OriginalString = "Narcos.S02E01.Endlich.frei.German.DD51.DL.1080p.720p.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "x264" };
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.HD_720p, ResolutionsMap.FullHD_1080p };
id.Season = 2;
id.State = State.OK_SUCCESS;
id.Title = "Narcos";
id.Year = 1991;
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
FullTitle = "Narcos.S02E01.Endlich.frei",
ParsedString = "Narcos.S02E01.Enich.frei.1080p.German.Netflix.x264.mkv",
ParsedString = "Narcos.S02E01.Endlich.frei.720p.German.x264.mkv",
Expected = id,
Settings = new ParserSettings(true),
Comment = "Test013"
});
// Series down sampled (Original String) - Test014
id = new SeriesID();
id.Episode = 1;
id.EpisodeTitle = "Endlich.frei";
id.FileExtension = "mkv";
id.IsSeries = true;
id.OriginalString = "Narcos.S02E01.Endlich.frei.German.DD51.DL.1080p.NetflixUHD.x264.mkv";
id.RemovedTokens = new List<string>() { "German", "x264" };
id.Resolutions = new List<ResolutionsMap> { ResolutionsMap.FullHD_1080p, ResolutionsMap.UltraHD_2160p };
id.Season = 2;
id.State = State.OK_SUCCESS;
id.Title = "Narcos";
id.Year = -1;
id.DetectedOldSpacingChar = '.';
testData.Add(new TestData()
{
Actual = id.OriginalString,
FullTitle = "Narcos.S02E01.Endlich.frei",
ParsedString = "Narcos.S02E01.Endlich.frei.1080p.German.x264.mkv",
Expected = id,
Settings = new ParserSettings(true),
Comment = "Test014"
});
//_data.Add(new TestData() { actual = "The.Big.Bang.Theory.S09E12.Der.romantische.Asteroid.GERMAN.DL.DUBBED.1080p.WebHD.x264", expected = "x" }); // Usual
//_data.Add(new TestData() { actual = "House.of.Cards.S04E04.Akt.der.Verzweiflung.German.DD51.Synced.DL.2160p.NetflixUHD.x264", expected = "" }); // Usual
//_data.Add(new TestData() { actual = "Arrow.S04E03.Auferstehung.GERMAN.DUBBED.DL.1080p.WebHD.x264", expected = "" }); // Usual
......
This diff is collapsed.
......@@ -28,16 +28,17 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.tbxException = new System.Windows.Forms.TextBox();
this.btnParse = new System.Windows.Forms.Button();
this.tbxInput = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.dataGridViewResult = new System.Windows.Forms.DataGridView();
this.label3 = new System.Windows.Forms.Label();
this.ColumnProperty = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.label3 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResult)).BeginInit();
this.SuspendLayout();
//
......@@ -55,7 +56,7 @@
//
this.tbxException.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbxException.Location = new System.Drawing.Point(74, 421);
this.tbxException.Location = new System.Drawing.Point(74, 468);
this.tbxException.Multiline = true;
this.tbxException.Name = "tbxException";
this.tbxException.ReadOnly = true;
......@@ -89,7 +90,7 @@
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(11, 424);
this.label2.Location = new System.Drawing.Point(11, 471);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 13);
this.label2.TabIndex = 4;
......@@ -110,18 +111,9 @@
this.dataGridViewResult.Location = new System.Drawing.Point(74, 59);
this.dataGridViewResult.Name = "dataGridViewResult";
this.dataGridViewResult.ReadOnly = true;
this.dataGridViewResult.Size = new System.Drawing.Size(862, 339);
this.dataGridViewResult.Size = new System.Drawing.Size(862, 386);
this.dataGridViewResult.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(28, 59);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(40, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Result:";
//
// ColumnProperty
//
this.ColumnProperty.HeaderText = "Property";
......@@ -142,11 +134,20 @@
this.ColumnValue.ReadOnly = true;
this.ColumnValue.Width = 500;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(28, 59);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(40, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Result:";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(949, 582);
this.ClientSize = new System.Drawing.Size(949, 629);
this.Controls.Add(this.label3);
this.Controls.Add(this.dataGridViewResult);
this.Controls.Add(this.label2);
......@@ -154,6 +155,7 @@
this.Controls.Add(this.btnParse);
this.Controls.Add(this.tbxException);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.Text = "SeriesIDParser - Demo App";
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResult)).EndInit();
......
......@@ -65,11 +65,13 @@ namespace SeriesIDParser_WinForm_Demo
dataGridViewResult.Rows.Add("Season", "int", sid.Season);
dataGridViewResult.Rows.Add("Episode", "int", sid.Episode);
dataGridViewResult.Rows.Add("IDString", "string", sid.IDString);
dataGridViewResult.Rows.Add("Resolution", "enum Resolutions", sid.Resolution);
dataGridViewResult.Rows.Add("Resolutions", "enum list Resolutions", string.Join(", ", sid.Resolutions));
dataGridViewResult.Rows.Add("Year", "int", sid.Year);
dataGridViewResult.Rows.Add("FileExtension", "string", sid.FileExtension);
dataGridViewResult.Rows.Add("RemovedTokens", "string list", string.Join(", ", sid.RemovedTokens));
dataGridViewResult.Rows.Add("State", "enum State", sid.State);
dataGridViewResult.Rows.Add("DetectedOldSpacingChar", "char", sid.DetectedOldSpacingChar);
dataGridViewResult.Rows.Add("ProcessingDuration", "TimeSpan", sid.ProcessingDuration.TotalMilliseconds + " ms");
tbxException.Clear();
if (sid.Exception != null)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -32,6 +32,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon_black.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
......@@ -87,6 +90,9 @@
<Name>SeriesIDParser</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="icon_black.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment