Skip to content
Browse files

Merge pull request #14 from thetjyoung/master

C# code upload
  • Loading branch information...
2 parents 5598371 + b8e8280 commit e5324344d71e5fb59226b0d419016dd0e64fcc76 @thetjyoung thetjyoung committed Apr 12, 2013
View
20 C# source/AMA/AMA.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMA", "AMA\AMA.csproj", "{97AB5018-00E7-4335-8B64-6DA3CE2FBB7E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {97AB5018-00E7-4335-8B64-6DA3CE2FBB7E}.Debug|x86.ActiveCfg = Debug|x86
+ {97AB5018-00E7-4335-8B64-6DA3CE2FBB7E}.Debug|x86.Build.0 = Debug|x86
+ {97AB5018-00E7-4335-8B64-6DA3CE2FBB7E}.Release|x86.ActiveCfg = Release|x86
+ {97AB5018-00E7-4335-8B64-6DA3CE2FBB7E}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
BIN C# source/AMA/AMA.suo
Binary file not shown.
View
72 C# source/AMA/AMA/AMA.csproj
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{97AB5018-00E7-4335-8B64-6DA3CE2FBB7E}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>AMA</RootNamespace>
+ <AssemblyName>AMA</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</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|x86' ">
+ <PlatformTarget>x86</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.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <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="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Ripper.cs" />
+ <Compile Include="TitleRetriever.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Form1.resx">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </EmbeddedResource>
+ </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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
102 C# source/AMA/AMA/Form1.Designer.cs
@@ -0,0 +1,102 @@
+namespace AMA
+{
+ 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.comboBox1 = new System.Windows.Forms.ComboBox();
+ this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
+ this.button1 = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.button2 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBox1
+ //
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(57, 70);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(121, 21);
+ this.comboBox1.TabIndex = 0;
+ this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(57, 125);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 1;
+ this.button1.Text = "Browse";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(53, 24);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(182, 20);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Default storage location:";
+ //
+ // button2
+ //
+ this.button2.Location = new System.Drawing.Point(337, 176);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(75, 23);
+ this.button2.TabIndex = 3;
+ this.button2.Text = "OK";
+ this.button2.UseVisualStyleBackColor = true;
+ this.button2.Click += new System.EventHandler(this.button2_Click);
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(424, 211);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.comboBox1);
+ this.Name = "Form1";
+ this.Text = "Storage Location";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button button2;
+ }
+}
+
View
60 C# source/AMA/AMA/Form1.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.IO;
+
+namespace AMA
+{
+ public partial class Form1 : Form
+ {
+
+ public Form1()
+ {
+ InitializeComponent();
+ addDrives();
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ DialogResult result = folderBrowserDialog1.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ string folderName = folderBrowserDialog1.SelectedPath;
+ label1.Text = "Default storage location: " + folderName;
+ File.WriteAllText("settings.conf","PATH-" + folderName);
+ }
+ }
+
+ private void addDrives()
+ {
+ DriveInfo[] drives = DriveInfo.GetDrives();
+ foreach (DriveInfo drive in drives)
+ {
+ if (drive.IsReady)
+ {
+ comboBox1.Items.Add(drive.Name);
+ }
+ }
+ comboBox1.SelectedIndex = 0;
+ }
+
+ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ label1.Text = "Default storage location: " + ((ComboBox)sender).SelectedItem + "Movies";
+ File.WriteAllText("settings.conf", "PATH-" + ((ComboBox)sender).SelectedItem + "Movies");
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ this.Dispose(true);
+ Application.Exit();
+ }
+
+ }
+}
View
123 C# source/AMA/AMA/Form1.resx
@@ -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="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>12, 25</value>
+ </metadata>
+</root>
View
85 C# source/AMA/AMA/Program.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+using System.Drawing;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace AMA
+{
+ class Program
+ {
+ private NotifyIcon notifyIcon1 = new NotifyIcon();
+ protected Thread m_thread;
+ protected ManualResetEvent m_shutdownEvent;
+
+ [STAThread]
+ static void Main(string[] args)
+ {
+ Program p = new Program();
+ p.setup();
+ }
+
+ private void setup()
+ {
+ if (!File.Exists("settings.conf"))
+ {
+ Form1 form = new Form1();
+ form.ShowDialog();
+ }
+
+ ThreadStart ts = new ThreadStart(MonitorDrives);
+ this.m_shutdownEvent = new ManualResetEvent(false);
+ m_thread = new Thread(ts);
+ m_thread.Start();
+ }
+ private void showPopup(string s)
+ {
+ notifyIcon1.Icon = new Icon("dvd.ico");
+ notifyIcon1.Visible = true;
+ notifyIcon1.ShowBalloonTip(5000, "Attention!", s, ToolTipIcon.Info);
+ }
+
+ protected void MonitorDrives()
+ {
+ while (true)
+ {
+ foreach (DriveInfo drive in DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.CDRom))
+ {
+ if (drive.IsReady)
+ {
+ showPopup(" " + drive.Name + " DVD inserted!");
+ TitleRetriever t = new TitleRetriever(drive.Name);
+ string DVDtitle = t.getMovieName();
+ showPopup(DVDtitle + "\n--Ripping--");
+ Ripper r = new Ripper();
+ string filename = r.rip(drive.Name, DVDtitle);
+ if (filename != "-1")
+ {
+ showPopup("Ripped!\n--Transcoding--");
+ r.transcode(filename, DVDtitle);
+ }
+ else
+ showPopup("Error Ripping! Exiting!");
+ ///////////////////need to add code to copy file to location in settings.conf////////////////////
+ //if (File.Exists(path))
+ // File.Move(path, newpath);
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ showPopup("Done!");
+ string rt = "";
+ mciSendStringA("set CDAudio door open", rt, 127, 0);
+
+ }
+ }
+
+ }
+ }
+
+ [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void mciSendStringA(string lpstrCommand,
+ string lpstrReturnString, long uReturnLength, long hwndCallback);
+ }
+}
View
36 C# source/AMA/AMA/Properties/AssemblyInfo.cs
@@ -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("AMA")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AMA")]
+[assembly: AssemblyCopyright("Copyright © 2013")]
+[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("fefd6dbd-c701-4853-a6d3-c58e177878a8")]
+
+// 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")]
View
71 C# source/AMA/AMA/Ripper.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Diagnostics;
+using System.IO;
+
+namespace AMA
+{
+ class Ripper
+ {
+ public Ripper()
+ { }
+
+ public void transcode(string mkvFile, string dvdTitle)
+ {
+ Process p = new Process();
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.FileName = "HandBrakeCLI.exe";
+ p.StartInfo.Arguments = "-i \"" + mkvFile + "\" -o " + dvdTitle + ".mp4 -f mp4 -e x264";
+ if(p.Start())
+ {
+ Console.Write("Transcoding");
+ p.WaitForExit();
+ if(p.ExitCode == 0)
+ Console.Write("Successfully transcoded " + dvdTitle);
+ else
+ Console.Write("Error: " + p.ExitCode);
+ }
+ else
+ Console.Write("Error transcoding, quitting");
+ }
+
+
+ public string rip(string drive, string dvdTitle)
+ {
+ string outpath = Path.Combine(Path.GetTempPath(), dvdTitle);
+ //////////////debug code//////////////////////
+ //remove before release
+ //if (true)
+ // return Directory.GetFiles(outpath)[0];
+ //////////////////////////////////////////////
+ Console.Write("Saving to: " + outpath);
+
+ if (!Directory.Exists(outpath))
+ Directory.CreateDirectory(outpath);
+
+ Process p = new Process();
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.FileName = @"C:\Program Files\MakeMKV\makemkvcon.exe";
+ p.StartInfo.Arguments = "-r --minlength=2700 mkv disc:0 all \"" + outpath + "\"";
+ Console.Write("\nSaving to: " + outpath);
+ Console.Write("\n" + p.StartInfo.Arguments);
+ if(p.Start())
+ {
+ Console.Write("\nRipping");
+ p.WaitForExit();
+ if(p.ExitCode == 0)
+ {
+ Console.Write("\nSuccessfully ripped " + dvdTitle);
+ return Directory.GetFiles(outpath)[0];
+ }
+ else
+ Console.Write("\nError: " + p.ExitCode);
+ }
+ else
+ Console.Write("\nError ripping, quitting");
+ return "-1";
+ }
+ }
+}
View
214 C# source/AMA/AMA/TitleRetriever.cs
@@ -0,0 +1,214 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Xml;
+
+namespace AMA
+{
+ class TitleRetriever
+ {
+ string drive = "G";
+ string dvdTitle = "";
+ string dvdYear = "";
+ string dvdPlot = "";
+
+ public TitleRetriever(string d)
+ {
+ drive = d;
+ }
+
+ private string getCorrectTitle()
+ {
+ string title = dvdTitle + "(" + dvdYear + ")";
+ return title;
+ }
+
+ private string getDVDId()
+ {
+ StringBuilder outputBuilder;
+ ProcessStartInfo processStartInfo;
+ Process process;
+ outputBuilder = new StringBuilder();
+
+ processStartInfo = new ProcessStartInfo();
+ processStartInfo.CreateNoWindow = true;
+ processStartInfo.RedirectStandardOutput = true;
+ processStartInfo.RedirectStandardInput = true;
+ processStartInfo.UseShellExecute = false;
+ processStartInfo.Arguments = drive;
+ processStartInfo.FileName = "dvdid.exe";
+
+ process = new Process();
+ process.StartInfo = processStartInfo;
+ // enable raising events because Process does not raise events by default
+ process.EnableRaisingEvents = true;
+ // attach the event handler for OutputDataReceived before starting the process
+ process.OutputDataReceived += new DataReceivedEventHandler
+ (
+ delegate(object sender, DataReceivedEventArgs e)
+ {
+ // append the new data to the data already read-in
+ outputBuilder.Append(e.Data);
+ }
+ );
+ // start the process
+ // then begin asynchronously reading the output
+ // then wait for the process to exit
+ // then cancel asynchronously reading the output
+ process.Start();
+ process.BeginOutputReadLine();
+ process.WaitForExit();
+ process.CancelOutputRead();
+
+ // use the output
+ string output = outputBuilder.ToString();
+ return output.Replace("|", "");
+
+ }
+
+ private void parseXMLResponse(XmlDocument response)
+ {
+ XmlNode node = response.SelectSingleNode("//dvdXml/dvd/title");
+ dvdTitle = node.InnerText.ToString();
+ node = response.SelectSingleNode("//dvdXml/dvd/year");
+ dvdYear = node.InnerText.ToString();
+ node = response.SelectSingleNode("//dvdXml/dvd/plot");
+ dvdPlot = node.InnerText.ToString();
+
+ if (dvdTitle == "")
+ dvdTitle = "Title Unavailable";
+ }
+
+ public string getMovieName()
+ {
+ string dvdid = getDVDId();
+ string username = "nyanyo";
+ string password = "mydvdid";
+ string apiHttp = @"http://api.dvdxml.com/";
+
+ string request =
+ "<dvdXml>"
+ +"<authentication>"
+ +"<user>" + username + "</user>"
+ +"<password>" + password + "</password>"
+ +"</authentication>"
+ +"<requests>"
+ +"<request type =\"information\">"
+ +"<dvdId>" + dvdid + "</dvdId>"
+ +"</request>"
+ +"</requests>"
+ +"</dvdXml>";
+
+ XmlDocument doc = new XmlDocument();
+ XmlDocument response = new XmlDocument();
+ doc.LoadXml(request);
+ response = PostXMLTransaction(apiHttp, doc);
+ parseXMLResponse(response);
+
+ string newTitle = getCorrectTitle();
+ return newTitle;
+ }
+
+ public static XmlDocument PostXMLTransaction(string v_strURL, XmlDocument v_objXMLDoc)
+ {
+ //Declare XMLResponse document
+ XmlDocument XMLResponse = null;
+
+ //Declare an HTTP-specific implementation of the WebRequest class.
+ HttpWebRequest objHttpWebRequest;
+
+ //Declare an HTTP-specific implementation of the WebResponse class
+ HttpWebResponse objHttpWebResponse = null;
+
+ //Declare a generic view of a sequence of bytes
+ Stream objRequestStream = null;
+ Stream objResponseStream = null;
+
+ //Declare XMLReader
+ XmlTextReader objXMLReader;
+
+ //Creates an HttpWebRequest for the specified URL.
+ objHttpWebRequest = (HttpWebRequest)WebRequest.Create(v_strURL);
+
+ try
+ {
+ //---------- Start HttpRequest
+
+ //Set HttpWebRequest properties
+ byte[] bytes;
+ bytes = System.Text.Encoding.ASCII.GetBytes(v_objXMLDoc.InnerXml);
+ objHttpWebRequest.Method = "POST";
+ objHttpWebRequest.ContentLength = bytes.Length;
+ objHttpWebRequest.ContentType = "text/xml; encoding='utf-8'";
+
+ //Get Stream object
+ objRequestStream = objHttpWebRequest.GetRequestStream();
+
+ //Writes a sequence of bytes to the current stream
+ objRequestStream.Write(bytes, 0, bytes.Length);
+
+ //Close stream
+ objRequestStream.Close();
+
+ //---------- End HttpRequest
+
+ //Sends the HttpWebRequest, and waits for a response.
+ objHttpWebResponse = (HttpWebResponse)objHttpWebRequest.GetResponse();
+
+ //---------- Start HttpResponse
+ if (objHttpWebResponse.StatusCode == HttpStatusCode.OK)
+ {
+ //Get response stream
+ objResponseStream = objHttpWebResponse.GetResponseStream();
+
+ //Load response stream into XMLReader
+ objXMLReader = new XmlTextReader(objResponseStream);
+
+ //Declare XMLDocument
+ XmlDocument xmldoc = new XmlDocument();
+ xmldoc.Load(objXMLReader);
+
+ //Set XMLResponse object returned from XMLReader
+ XMLResponse = xmldoc;
+
+ //Close XMLReader
+ objXMLReader.Close();
+ }
+
+ //Close HttpWebResponse
+ objHttpWebResponse.Close();
+ }
+ catch (WebException we)
+ {
+ //TODO: Add custom exception handling
+ throw new Exception(we.Message);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ //Close connections
+ objRequestStream.Close();
+ objResponseStream.Close();
+ objHttpWebResponse.Close();
+
+ //Release objects
+ objXMLReader = null;
+ objRequestStream = null;
+ objResponseStream = null;
+ objHttpWebResponse = null;
+ objHttpWebRequest = null;
+ }
+
+ //Return
+ return XMLResponse;
+ }
+ }
+}
View
BIN C# source/AMA/AMA/bin/Debug/AMA.exe
Binary file not shown.
View
BIN C# source/AMA/AMA/bin/Debug/AMA.pdb
Binary file not shown.
View
BIN C# source/AMA/AMA/bin/Debug/AMA.vshost.exe
Binary file not shown.
View
11 C# source/AMA/AMA/bin/Debug/AMA.vshost.exe.manifest
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+ <security>
+ <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
View
BIN C# source/AMA/AMA/bin/Debug/HandBrakeCLI.exe
Binary file not shown.
View
BIN C# source/AMA/AMA/bin/Debug/Title
Binary file not shown.
View
BIN C# source/AMA/AMA/bin/Debug/dvd.ico
Binary file not shown.
View
BIN C# source/AMA/AMA/bin/Debug/dvdid.exe
Binary file not shown.
View
BIN C# source/AMA/AMA/bin/Debug/makemkvcon.exe
Binary file not shown.
View
1 C# source/AMA/AMA/bin/Debug/settings.conf
@@ -0,0 +1 @@
+PATH-C:\Users\TJ\Videos
View
BIN C# source/AMA/AMA/obj/x86/Debug/AMA.Form1.resources
Binary file not shown.
View
8 C# source/AMA/AMA/obj/x86/Debug/AMA.csproj.FileListAbsolute.txt
@@ -0,0 +1,8 @@
+c:\users\tj\documents\visual studio 2010\Projects\AMA\AMA\obj\x86\Debug\ResolveAssemblyReference.cache
+c:\users\tj\documents\visual studio 2010\Projects\AMA\AMA\bin\Debug\AMA.exe
+c:\users\tj\documents\visual studio 2010\Projects\AMA\AMA\bin\Debug\AMA.pdb
+c:\users\tj\documents\visual studio 2010\Projects\AMA\AMA\obj\x86\Debug\AMA.exe
+c:\users\tj\documents\visual studio 2010\Projects\AMA\AMA\obj\x86\Debug\AMA.pdb
+C:\Users\TJ\Documents\Visual Studio 2010\Projects\AMA\AMA\obj\x86\Debug\AMA.Form1.resources
+C:\Users\TJ\Documents\Visual Studio 2010\Projects\AMA\AMA\obj\x86\Debug\GenerateResource.read.1.tlog
+C:\Users\TJ\Documents\Visual Studio 2010\Projects\AMA\AMA\obj\x86\Debug\GenerateResource.write.1.tlog
View
BIN C# source/AMA/AMA/obj/x86/Debug/AMA.exe
Binary file not shown.
View
BIN C# source/AMA/AMA/obj/x86/Debug/AMA.pdb
Binary file not shown.
View
BIN C# source/AMA/AMA/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
View
BIN C# source/AMA/AMA/obj/x86/Debug/GenerateResource.read.1.tlog
Binary file not shown.
View
BIN C# source/AMA/AMA/obj/x86/Debug/GenerateResource.write.1.tlog
Binary file not shown.
View
16 MetaData/dvdid.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<dvdXml>
+ <authenticated>True</authenticated>
+ <dvd>
+ <title></title>
+ <dvdCover>http://www.dvdxml.com/dvdcover/.jpg</dvdCover>
+ <year>0</year>
+ <length>0</length>
+ <rating></rating>
+ <dvdId>a440dc9a6a90da15</dvdId>
+ <genre></genre>
+ <studio></studio>
+ <cast></cast>
+ <plot></plot>
+ </dvd>
+</dvdXml>
View
BIN Python_Notification.pyc
Binary file not shown.
View
BIN __pycache__/Python_Notification.cpython-33.pyc
Binary file not shown.

0 comments on commit e532434

Please sign in to comment.
Something went wrong with that request. Please try again.