Initial Commit, batch meta data update functionality working. Fixed a bug where hyphens were stripped from episode names.

This commit is contained in:
2017-08-31 15:35:53 -05:00
commit 1f14137c5b
20 changed files with 1243 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
!*.exe
packages/
MKVTest/bin
MKVTest/obj
*.mkv
*.txt
MKVTest/.vs
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MKVTest", "MKVTest\MKVTest.csproj", "{A750A634-6881-4083-B909-73EFE4C96802}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A750A634-6881-4083-B909-73EFE4C96802}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A750A634-6881-4083-B909-73EFE4C96802}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A750A634-6881-4083-B909-73EFE4C96802}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A750A634-6881-4083-B909-73EFE4C96802}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1DE3F207-A6CC-4FE8-B26A-DFC0A7448E8D}
EndGlobalSection
EndGlobal
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
+223
View File
@@ -0,0 +1,223 @@
namespace MKVTest
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.selectFolderButton = new System.Windows.Forms.Button();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.openFolderFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.selectFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.inputFilesListView = new System.Windows.Forms.ListView();
this.detailsGroupBox = new System.Windows.Forms.GroupBox();
this.buttonPanel = new System.Windows.Forms.Panel();
this.applyChangesButton = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.currentTitleLabel = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
this.mainMenuStrip.SuspendLayout();
this.detailsGroupBox.SuspendLayout();
this.buttonPanel.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// selectFolderButton
//
this.selectFolderButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.selectFolderButton.Location = new System.Drawing.Point(2, 8);
this.selectFolderButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.selectFolderButton.Name = "selectFolderButton";
this.selectFolderButton.Size = new System.Drawing.Size(80, 29);
this.selectFolderButton.TabIndex = 1;
this.selectFolderButton.Text = "Select Folder";
this.selectFolderButton.UseVisualStyleBackColor = true;
this.selectFolderButton.Click += new System.EventHandler(this.button1_Click);
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.tableLayoutPanel1.Controls.Add(this.mainMenuStrip, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.inputFilesListView, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.detailsGroupBox, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.buttonPanel, 2, 4);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 5;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.08529F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 37.45736F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 37.45736F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 43F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(560, 401);
this.tableLayoutPanel1.TabIndex = 2;
//
// mainMenuStrip
//
this.tableLayoutPanel1.SetColumnSpan(this.mainMenuStrip, 3);
this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(28, 28);
this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileMainMenu});
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
this.mainMenuStrip.Name = "mainMenuStrip";
this.mainMenuStrip.Size = new System.Drawing.Size(560, 24);
this.mainMenuStrip.TabIndex = 2;
this.mainMenuStrip.Text = "menuStrip1";
//
// fileMainMenu
//
this.fileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openFolderFileMainMenu,
this.selectFileMainMenu});
this.fileMainMenu.Name = "fileMainMenu";
this.fileMainMenu.Size = new System.Drawing.Size(37, 20);
this.fileMainMenu.Text = "&File";
//
// openFolderFileMainMenu
//
this.openFolderFileMainMenu.Name = "openFolderFileMainMenu";
this.openFolderFileMainMenu.Size = new System.Drawing.Size(139, 22);
this.openFolderFileMainMenu.Text = "&Open Folder";
//
// selectFileMainMenu
//
this.selectFileMainMenu.Name = "selectFileMainMenu";
this.selectFileMainMenu.Size = new System.Drawing.Size(139, 22);
this.selectFileMainMenu.Text = "&Select File";
//
// inputFilesListView
//
this.tableLayoutPanel1.SetColumnSpan(this.inputFilesListView, 2);
this.inputFilesListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.inputFilesListView.LabelWrap = false;
this.inputFilesListView.Location = new System.Drawing.Point(3, 33);
this.inputFilesListView.Name = "inputFilesListView";
this.tableLayoutPanel1.SetRowSpan(this.inputFilesListView, 4);
this.inputFilesListView.Size = new System.Drawing.Size(330, 365);
this.inputFilesListView.TabIndex = 3;
this.inputFilesListView.UseCompatibleStateImageBehavior = false;
this.inputFilesListView.View = System.Windows.Forms.View.Details;
//
// detailsGroupBox
//
this.detailsGroupBox.Controls.Add(this.flowLayoutPanel1);
this.detailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.detailsGroupBox.Location = new System.Drawing.Point(339, 33);
this.detailsGroupBox.Name = "detailsGroupBox";
this.tableLayoutPanel1.SetRowSpan(this.detailsGroupBox, 3);
this.detailsGroupBox.Size = new System.Drawing.Size(218, 320);
this.detailsGroupBox.TabIndex = 5;
this.detailsGroupBox.TabStop = false;
this.detailsGroupBox.Text = "Details";
//
// buttonPanel
//
this.buttonPanel.Controls.Add(this.applyChangesButton);
this.buttonPanel.Controls.Add(this.selectFolderButton);
this.buttonPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonPanel.Location = new System.Drawing.Point(339, 359);
this.buttonPanel.Name = "buttonPanel";
this.buttonPanel.Size = new System.Drawing.Size(218, 39);
this.buttonPanel.TabIndex = 8;
//
// applyChangesButton
//
this.applyChangesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.applyChangesButton.Enabled = false;
this.applyChangesButton.Location = new System.Drawing.Point(112, 7);
this.applyChangesButton.Name = "applyChangesButton";
this.applyChangesButton.Size = new System.Drawing.Size(102, 29);
this.applyChangesButton.TabIndex = 2;
this.applyChangesButton.Text = "Apply Changes";
this.applyChangesButton.UseVisualStyleBackColor = true;
this.applyChangesButton.Click += new System.EventHandler(this.applyChangesButton_Click);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.currentTitleLabel);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 16);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(212, 301);
this.flowLayoutPanel1.TabIndex = 0;
//
// currentTitleLabel
//
this.currentTitleLabel.AutoSize = true;
this.currentTitleLabel.Location = new System.Drawing.Point(2, 0);
this.currentTitleLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.currentTitleLabel.Name = "currentTitleLabel";
this.currentTitleLabel.Size = new System.Drawing.Size(67, 13);
this.currentTitleLabel.TabIndex = 11;
this.currentTitleLabel.Text = "Current Title:";
//
// Form1
//
this.AcceptButton = this.selectFolderButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(560, 401);
this.Controls.Add(this.tableLayoutPanel1);
this.MainMenuStrip = this.mainMenuStrip;
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "Form1";
this.Text = "Form1";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.mainMenuStrip.ResumeLayout(false);
this.mainMenuStrip.PerformLayout();
this.detailsGroupBox.ResumeLayout(false);
this.buttonPanel.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button selectFolderButton;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.MenuStrip mainMenuStrip;
private System.Windows.Forms.ToolStripMenuItem fileMainMenu;
private System.Windows.Forms.ToolStripMenuItem openFolderFileMainMenu;
private System.Windows.Forms.ToolStripMenuItem selectFileMainMenu;
private System.Windows.Forms.ListView inputFilesListView;
private System.Windows.Forms.GroupBox detailsGroupBox;
private System.Windows.Forms.Panel buttonPanel;
private System.Windows.Forms.Button applyChangesButton;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label currentTitleLabel;
}
}
+238
View File
@@ -0,0 +1,238 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MKVTest
{
/* Call mkvpropedit.exe
* Edit "Title" detail property: --edit info --set "title=%TITLE%" %FILE%
* Edit video track one: --edit track:v1 --set "name(or language)="%VAR%" %FILE%
* Edit audio track one: --edit track:a1 --set "name(or language)="%VAR%" %FILE%
* To add simply replace "--set" with "--add".
*/
public partial class Form1 : Form
{
public static string Language = "eng";
private static readonly ContextMenuStrip menu = new ContextMenuStrip();
public Form1()
{
InitializeComponent();
inputFilesListView.ItemSelectionChanged += UpdateFilePropPrediction;
inputFilesListView.MouseClick += ShowMenu;
this.Resize += Form1_Resize;
var item = new ToolStripMenuItem
{
Name = "RemoveItem",
Text = @"Remove"
};
menu.Items.Add(item);
var inputColumn = new ColumnHeader()
{
Text = @"Files",
Name = @"HeaderColumn",
Width = inputFilesListView.Width - 10
};
inputFilesListView.Columns.Add(inputColumn);
}
private void ShowMenu(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (inputFilesListView.FocusedItem.Bounds.Contains(e.Location) == true)
{
menu.Show(Cursor.Position);
}
}
}
private void UpdateFilePropPrediction(object sender, ListViewItemSelectionChangedEventArgs e)
{
var info = new MkvFileInfo();
var file = info.GetAttributes(e.Item.Name);
flowLayoutPanel1.Controls.Clear();
flowLayoutPanel1.Invalidate();
var titleLabel = new Label()
{
Parent = flowLayoutPanel1,
Text = @"Current Title: " + file.SegementInformation?.Title,
AutoSize = true
};
flowLayoutPanel1.Container?.Add(titleLabel);
var videoTrackNumber = 1;
var audioTrackNumber = 1;
foreach (var fileTrack in file.Tracks)
{
if (fileTrack.Type == MkvTrack.TrackType.Video)
{
var nameLabel = new Label
{
AutoSize = true,
Text = @"Track:v" + videoTrackNumber + @" Name: " + fileTrack.Name,
Parent = flowLayoutPanel1
};
var languageLabel = new Label
{
AutoSize = true,
Text = @"Track:v" + videoTrackNumber + @" Language: " + fileTrack.Language,
Parent = flowLayoutPanel1
};
videoTrackNumber++;
if (flowLayoutPanel1.Container != null)
{
flowLayoutPanel1.Container.Add(nameLabel);
flowLayoutPanel1.Container.Add(languageLabel);
}
}
if (fileTrack.Type == MkvTrack.TrackType.Audio)
{
var nameLabel = new Label
{
AutoSize = true,
Text = @"Track:a" + audioTrackNumber + @" Name: " + fileTrack.Name,
Parent = flowLayoutPanel1
};
var languageLabel = new Label
{
AutoSize = true,
Text = @"Track:a" + audioTrackNumber + @" Language: " + fileTrack.Language,
Parent = flowLayoutPanel1
};
audioTrackNumber++;
if (flowLayoutPanel1.Container != null)
{
flowLayoutPanel1.Container.Add(nameLabel);
flowLayoutPanel1.Container.Add(languageLabel);
}
}
}
}
/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
private string GetEpisodeName(string text)
{
var s = new StringBuilder();
var hyphenCount = 0;
var index = 0;
var fileExtensionStartPoint = text.LastIndexOf(".", StringComparison.InvariantCulture);
foreach (var c in text)
{
if (c == '-' && hyphenCount != 2)
{
hyphenCount++;
index++;
continue;
}
if (hyphenCount == 2)
{
if (c == '.' && index == fileExtensionStartPoint)
{
break;
}
s.Append(c);
}
index++;
}
return s.ToString().Trim();
}
private void ListFiles(string folderPath)
{
var dir = new DirectoryInfo(folderPath);
var files = dir.GetFiles("*.mkv", SearchOption.TopDirectoryOnly);
foreach (var file in files)
{
var node = new ListViewItem()
{
Tag = true, //Assume the file needs to be updated.
Name = file.FullName,
Text = file.Name
};
inputFilesListView.Items.Add(node);
}
if (inputFilesListView.Items.Count > 0)
{
applyChangesButton.Enabled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
var d = new FolderBrowserDialog();
if (d.ShowDialog() == DialogResult.OK)
{
ClearForm();
ListFiles(d.SelectedPath);
}
}
private void Form1_Resize(object sender, EventArgs e)
{
inputFilesListView.Columns[0].Width = inputFilesListView.Width - 10;
}
private void applyChangesButton_Click(object sender, EventArgs e)
{
foreach (ListViewItem node in inputFilesListView.Items)
{
//Check to see if the item has been modified.
if (node.Tag == null || (bool) node.Tag == false) continue;
if (!File.Exists(node.Name)) continue;
var command = "/C mkvpropedit.exe --edit info --set \"title=" + GetEpisodeName(node.Text) +
"\" --edit track:v1 --set \"name=" + GetEpisodeName(node.Text) +
"\" --edit track:v1 --set \"language=eng\" --edit track:a1 --set \"name=English\" --edit track:a1 --set \"language=eng\" \"" + node.Name + "\" > temp.txt";
var process = new System.Diagnostics.Process();
var startInfo = new System.Diagnostics.ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
FileName = "cmd.exe",
Arguments = command
};
process.StartInfo = startInfo;
process.Start();
while (!process.HasExited)
{
}
if (process.ExitCode == 0) continue;
var error = File.ReadAllLines("temp.txt");
MessageBox.Show(@"Error on node: " + node.Text + (error.Length > 0 ? Environment.NewLine + error[0] : string.Empty));
break;
}
File.Delete("temp.txt");
}
private void ClearForm()
{
inputFilesListView.Items.Clear();
flowLayoutPanel1.Controls.Clear();
flowLayoutPanel1.Invalidate();
}
}
}
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+95
View File
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A750A634-6881-4083-B909-73EFE4C96802}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>MKVTest</RootNamespace>
<AssemblyName>MKVTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="MkvFile.cs" />
<Compile Include="MkvFileInfo.cs" />
<Compile Include="MkvSegmentInformation.cs" />
<Compile Include="MkvTrack.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SerializeMkvInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="mkvinfo.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="mkvpropedit.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MKVTest
{
class MkvFile
{
public List<MkvTrack> Tracks;
public MkvSegmentInformation SegementInformation;
public string FullName;
public string FileName;
}
}
+109
View File
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MKVTest
{
class MkvFileInfo
{
public MkvFile GetAttributes(string filePath)
{
var file = new MkvFile { Tracks = GetShit(filePath, out MkvSegmentInformation info), SegementInformation = info };
return file;
}
private static List<MkvTrack> GetShit(string filePath, out MkvSegmentInformation information)
{
var tracks = new List<MkvTrack>();
information = null;
var command = "/C mkvinfo.exe \"" + filePath + "\" > info.txt";
var process = new System.Diagnostics.Process();
var startInfo = new System.Diagnostics.ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
FileName = "cmd.exe",
Arguments = command
};
process.StartInfo = startInfo;
process.Start();
while (!process.HasExited)
{
}
var info = File.ReadAllLines("info.txt");
var readingSegInfo = false;
var readingTrack = false;
var track = new MkvTrack();
for (var i = 0; i < info.Length; i++)
{
if (info[i] == "|+ Segment information")
{
readingSegInfo = true;
readingTrack = false;
continue;
}
if (info[i] == "| + A track")
{
readingTrack = true;
readingSegInfo = false;
if (track.Name == null && track.Language == null) continue;
tracks.Add(track);
track = new MkvTrack();
}
if (readingSegInfo)
{
if (info[i].Contains("Title:"))
{
var index = info[i].IndexOf(":", StringComparison.Ordinal) + 1;
var seg = new MkvSegmentInformation
{
Title = info[i].Substring(index, info[i].Length - index).Trim()
};
information = seg;
}
}
if (readingTrack)
{
if (info[i].Contains("Name:"))
{
var index = info[i].IndexOf(":", StringComparison.Ordinal) + 1;
track.Name = info[i].Substring(index, (info[i].Length - index)).Trim();
}
if (info[i].Contains("Language:"))
{
var index = info[i].IndexOf(":", StringComparison.Ordinal) + 1;
track.Language = info[i].Substring(index, (info[i].Length - index)).Trim();
}
if (info[i].Contains("Video track"))
{
track.Type = MkvTrack.TrackType.Video;
}
if (info[i].Contains("Audio track"))
{
track.Type = MkvTrack.TrackType.Audio;
}
if (info[i].Contains("Track type: subtitles"))
{
track.Type = MkvTrack.TrackType.Subtitle;
}
}
}
if (information == null)
{
information = new MkvSegmentInformation();
}
return tracks;
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MKVTest
{
class MkvSegmentInformation
{
public string Title;
}
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MKVTest
{
class MkvTrack
{
public string Name;
public string Language;
public TrackType Type;
public enum TrackType
{
Video = 1,
Audio = 2,
Subtitle = 3,
Unkown = 0
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MKVTest
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MKVTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MKVTest")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a750a634-6881-4083-b909-73efe4c96802")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+71
View File
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MKVTest.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MKVTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+30
View File
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MKVTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
+80
View File
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MKVTest
{
class SerializeMkvInfo
{
public string Serialize(string filePath)
{
var file = File.ReadAllLines(filePath);
var depth = 0;
foreach (var line in file)
{
}
}
private string
private int GetDepth(string line)
{
var depth = -1;
for (var i = 0; i < line.Length; i++)
{
if (char.IsPunctuation(line[i]) || char.IsWhiteSpace(line[i]))
{
depth++;
}
else
{
break;
}
}
return depth;
}
private bool IsClusterHead(string data)
{
var isClusterHeader = false;
switch (data)
{
case "EBML head":
break;
case "Chapters":
break;
case "Segment":
break;
case "Segment information":
break;
case "Segment tracks":
break;
case "A track":
break;
case "Video track":
break;
case "Audio track":
break;
}
return isClusterHeader;
}
}
}
Binary file not shown.
Binary file not shown.