diff --git a/CUETools.CTDB/CTDBMetadataSearch.cs b/CUETools.CTDB/CTDBMetadataSearch.cs
new file mode 100644
index 0000000..6049342
--- /dev/null
+++ b/CUETools.CTDB/CTDBMetadataSearch.cs
@@ -0,0 +1,10 @@
+namespace CUETools.CTDB
+{
+ public enum CTDBMetadataSearch
+ {
+ None = 0,
+ Fast = 1,
+ Default = 2,
+ Extensive = 3
+ }
+}
diff --git a/CUETools.CTDB/CTDBResponse.cs b/CUETools.CTDB/CTDBResponse.cs
new file mode 100644
index 0000000..64dd785
--- /dev/null
+++ b/CUETools.CTDB/CTDBResponse.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Xml.Serialization;
+
+namespace CUETools.CTDB
+{
+ [Serializable]
+ [XmlRoot(ElementName = "ctdb", Namespace = "http://db.cuetools.net/ns/mmd-1.0#")]
+ public class CTDBResponse
+ {
+ [XmlElement]
+ public CTDBResponseEntry[] entry;
+ [XmlElement]
+ public CTDBResponseMeta[] musicbrainz;
+ }
+}
diff --git a/CUETools.CTDB/CTDBResponseEntry.cs b/CUETools.CTDB/CTDBResponseEntry.cs
new file mode 100644
index 0000000..d0ac67a
--- /dev/null
+++ b/CUETools.CTDB/CTDBResponseEntry.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Xml.Serialization;
+
+namespace CUETools.CTDB
+{
+ [Serializable]
+ public class CTDBResponseEntry
+ {
+ [XmlAttribute]
+ public string id { get; set; }
+ [XmlAttribute]
+ public string crc32 { get; set; }
+ [XmlAttribute]
+ public int confidence { get; set; }
+ [XmlAttribute]
+ public int npar { get; set; }
+ [XmlAttribute]
+ public int stride { get; set; }
+ [XmlAttribute]
+ public string hasparity { get; set; }
+ [XmlAttribute]
+ public string parity { get; set; }
+ [XmlAttribute]
+ public string toc { get; set; }
+ }
+}
diff --git a/CUETools.CTDB/CTDBResponseMeta.cs b/CUETools.CTDB/CTDBResponseMeta.cs
new file mode 100644
index 0000000..a998db1
--- /dev/null
+++ b/CUETools.CTDB/CTDBResponseMeta.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Xml.Serialization;
+
+namespace CUETools.CTDB
+{
+ [Serializable]
+ public class CTDBResponseMeta
+ {
+ [XmlAttribute]
+ public string source { get; set; }
+ [XmlAttribute]
+ public string id { get; set; }
+ [XmlAttribute]
+ public string artist { get; set; }
+ [XmlAttribute]
+ public string album { get; set; }
+ [XmlAttribute]
+ public string year { get; set; }
+ [XmlAttribute]
+ public string genre { get; set; }
+ [XmlAttribute]
+ public string extra { get; set; }
+ [XmlAttribute]
+ public string country { get; set; }
+ [XmlAttribute]
+ public string releasedate { get; set; }
+ [XmlAttribute]
+ public string discnumber { get; set; }
+ [XmlAttribute]
+ public string disccount { get; set; }
+ [XmlAttribute]
+ public string discname { get; set; }
+ [XmlAttribute]
+ public string coverarturl { get; set; }
+ [XmlAttribute]
+ public string infourl { get; set; }
+ [XmlAttribute]
+ public string barcode { get; set; }
+ [XmlElement]
+ public CTDBResponseMetaTrack[] track;
+ [XmlElement]
+ public CTDBResponseMetaLabel[] label;
+ }
+}
diff --git a/CUETools.CTDB/CTDBResponseMetaLabel.cs b/CUETools.CTDB/CTDBResponseMetaLabel.cs
new file mode 100644
index 0000000..77b8927
--- /dev/null
+++ b/CUETools.CTDB/CTDBResponseMetaLabel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Xml.Serialization;
+
+namespace CUETools.CTDB
+{
+ [Serializable]
+ public class CTDBResponseMetaLabel
+ {
+ [XmlAttribute]
+ public string name { get; set; }
+ [XmlAttribute]
+ public string catno { get; set; }
+ }
+}
diff --git a/CUETools.CTDB/CTDBResponseMetaTrack.cs b/CUETools.CTDB/CTDBResponseMetaTrack.cs
new file mode 100644
index 0000000..024402c
--- /dev/null
+++ b/CUETools.CTDB/CTDBResponseMetaTrack.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Xml.Serialization;
+
+namespace CUETools.CTDB
+{
+ [Serializable]
+ public class CTDBResponseMetaTrack
+ {
+ [XmlAttribute]
+ public string name { get; set; }
+ [XmlAttribute]
+ public string artist { get; set; }
+ [XmlAttribute]
+ public string extra { get; set; }
+ }
+}
diff --git a/CUETools.CTDB/CUETools.CTDB.csproj b/CUETools.CTDB/CUETools.CTDB.csproj
index 82e0614..c8d0f13 100644
--- a/CUETools.CTDB/CUETools.CTDB.csproj
+++ b/CUETools.CTDB/CUETools.CTDB.csproj
@@ -59,8 +59,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/CUETools.CTDB/CUEToolsDB.cs b/CUETools.CTDB/CUEToolsDB.cs
index 61c85c9..5a28ff0 100644
--- a/CUETools.CTDB/CUEToolsDB.cs
+++ b/CUETools.CTDB/CUEToolsDB.cs
@@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
-using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Management;
using System.Net;
-using System.Xml;
-using System.Xml.Serialization;
-using System.Text;
using System.Security.Cryptography;
-using CUETools.CDImage;
+using System.Text;
+using System.Xml.Serialization;
using CUETools.AccurateRip;
+using CUETools.CDImage;
using Krystalware.UploadHelper;
namespace CUETools.CTDB
@@ -578,249 +576,4 @@ namespace CUETools.CTDB
}
}
}
-
- public class DBEntry
- {
- public byte[] parity;
- public int pos;
- public int len;
- public int conf;
- public int npar;
- public int stride;
- public int offset;
- public uint crc;
- public bool hasErrors;
- public bool canRecover;
- public CDRepairFix repair;
- public HttpStatusCode httpStatus;
- public string id;
- public CDImageLayout toc;
- public string hasParity;
-
- public DBEntry(byte[] parity, int pos, int len, int conf, int npar, int stride, uint crc, string id, CDImageLayout toc, string hasParity)
- {
- this.parity = parity;
- this.id = id;
- this.pos = pos;
- this.len = len;
- this.conf = conf;
- this.crc = crc;
- this.npar = npar;
- this.stride = stride;
- this.toc = toc;
- this.hasParity = hasParity;
- }
-
- public string Status
- {
- get
- {
- if (!hasErrors)
- return string.Format("verified OK, confidence {0}", conf);
- if (canRecover)
- return string.Format("differs in {1} samples, confidence {0}", conf, repair.CorrectableErrors);
- if (httpStatus == HttpStatusCode.OK)
- return "could not be verified";
- return "could not be verified: " + httpStatus.ToString();
- }
- }
- }
-
- internal class ReadDB
- {
- byte[] contents;
- public int pos;
-
- public ReadDB(byte[] contents)
- {
- this.contents = contents;
- pos = 0;
- }
-
- public string ReadHDR(out int end)
- {
- int size = ReadInt();
- string res = Encoding.ASCII.GetString(contents, pos, 4);
- pos += 4;
- end = pos + size - 8;
- return res;
- }
-
- public int ReadInt()
- {
- int value =
- (contents[pos + 3] +
- (contents[pos + 2] << 8) +
- (contents[pos + 1] << 16) +
- (contents[pos + 0] << 24));
- pos += 4;
- return value;
- }
-
- public uint ReadUInt()
- {
- uint value =
- ((uint)contents[pos + 3] +
- ((uint)contents[pos + 2] << 8) +
- ((uint)contents[pos + 1] << 16) +
- ((uint)contents[pos + 0] << 24));
- pos += 4;
- return value;
- }
- }
-
- internal class DBHDR : IDisposable
- {
- private long lenOffs;
- private MemoryStream stream;
-
- public DBHDR(MemoryStream stream, string name)
- {
- this.stream = stream;
- lenOffs = stream.Position;
- Write(0);
- Write(name);
- }
-
- public void Dispose()
- {
- long fin = stream.Position;
- stream.Position = lenOffs;
- Write((int)(fin - lenOffs));
- stream.Position = fin;
- }
-
- public void Write(int value)
- {
- byte[] temp = new byte[4];
- temp[3] = (byte)(value & 0xff);
- temp[2] = (byte)((value >> 8) & 0xff);
- temp[1] = (byte)((value >> 16) & 0xff);
- temp[0] = (byte)((value >> 24) & 0xff);
- Write(temp);
- }
-
- public void Write(uint value)
- {
- byte[] temp = new byte[4];
- temp[3] = (byte)(value & 0xff);
- temp[2] = (byte)((value >> 8) & 0xff);
- temp[1] = (byte)((value >> 16) & 0xff);
- temp[0] = (byte)((value >> 24) & 0xff);
- Write(temp);
- }
-
- public void Write(string value)
- {
- Write(Encoding.UTF8.GetBytes(value));
- }
-
- public void Write(byte[] value)
- {
- stream.Write(value, 0, value.Length);
- }
-
- public DBHDR HDR(string name)
- {
- return new DBHDR(stream, name);
- }
- }
-
- [Serializable]
- public class CTDBResponseEntry
- {
- [XmlAttribute]
- public string id { get; set; }
- [XmlAttribute]
- public string crc32 { get; set; }
- [XmlAttribute]
- public int confidence { get; set; }
- [XmlAttribute]
- public int npar { get; set; }
- [XmlAttribute]
- public int stride { get; set; }
- [XmlAttribute]
- public string hasparity { get; set; }
- [XmlAttribute]
- public string parity { get; set; }
- [XmlAttribute]
- public string toc { get; set; }
- }
-
- [Serializable]
- public class CTDBResponseMetaTrack
- {
- [XmlAttribute]
- public string name { get; set; }
- [XmlAttribute]
- public string artist { get; set; }
- [XmlAttribute]
- public string extra { get; set; }
- }
-
- [Serializable]
- public class CTDBResponseMetaLabel
- {
- [XmlAttribute]
- public string name { get; set; }
- [XmlAttribute]
- public string catno { get; set; }
- }
-
- [Serializable]
- public class CTDBResponseMeta
- {
- [XmlAttribute]
- public string source { get; set; }
- [XmlAttribute]
- public string id { get; set; }
- [XmlAttribute]
- public string artist { get; set; }
- [XmlAttribute]
- public string album { get; set; }
- [XmlAttribute]
- public string year { get; set; }
- [XmlAttribute]
- public string genre { get; set; }
- [XmlAttribute]
- public string extra { get; set; }
- [XmlAttribute]
- public string country { get; set; }
- [XmlAttribute]
- public string releasedate { get; set; }
- [XmlAttribute]
- public string discnumber { get; set; }
- [XmlAttribute]
- public string disccount { get; set; }
- [XmlAttribute]
- public string discname { get; set; }
- [XmlAttribute]
- public string coverarturl { get; set; }
- [XmlAttribute]
- public string infourl { get; set; }
- [XmlAttribute]
- public string barcode { get; set; }
- [XmlElement]
- public CTDBResponseMetaTrack[] track;
- [XmlElement]
- public CTDBResponseMetaLabel[] label;
- }
-
- [Serializable]
- [XmlRoot(ElementName="ctdb", Namespace="http://db.cuetools.net/ns/mmd-1.0#")]
- public class CTDBResponse
- {
- [XmlElement]
- public CTDBResponseEntry[] entry;
- [XmlElement]
- public CTDBResponseMeta[] musicbrainz;
- }
-
- public enum CTDBMetadataSearch
- {
- None = 0,
- Fast = 1,
- Default = 2,
- Extensive = 3
- }
}
diff --git a/CUETools.CTDB/DBEntry.cs b/CUETools.CTDB/DBEntry.cs
new file mode 100644
index 0000000..86bdc7e
--- /dev/null
+++ b/CUETools.CTDB/DBEntry.cs
@@ -0,0 +1,59 @@
+using System.Net;
+using CUETools.AccurateRip;
+using CUETools.CDImage;
+
+namespace CUETools.CTDB
+{
+ public class DBEntry
+ {
+ public byte[] parity;
+ public int pos;
+ public int len;
+ public int conf;
+ public int npar;
+ public int stride;
+ public int offset;
+ public uint crc;
+ public bool hasErrors;
+ public bool canRecover;
+ public CDRepairFix repair;
+ public HttpStatusCode httpStatus;
+ public string id;
+ public CDImageLayout toc;
+ public string hasParity;
+
+ public DBEntry(byte[] parity, int pos, int len, int conf, int npar, int stride, uint crc, string id, CDImageLayout toc, string hasParity)
+ {
+ this.parity = parity;
+ this.id = id;
+ this.pos = pos;
+ this.len = len;
+ this.conf = conf;
+ this.crc = crc;
+ this.npar = npar;
+ this.stride = stride;
+ this.toc = toc;
+ this.hasParity = hasParity;
+ }
+
+ public string Status
+ {
+ get
+ {
+ if (!hasErrors)
+ {
+ return string.Format("verified OK, confidence {0}", conf);
+ }
+ if (canRecover)
+ {
+ return string.Format("differs in {1} samples, confidence {0}", conf, repair.CorrectableErrors);
+ }
+ if (httpStatus == HttpStatusCode.OK)
+ {
+ return "could not be verified";
+ }
+ return "could not be verified: " + httpStatus.ToString();
+ }
+ }
+ }
+}
diff --git a/CUETools.CTDB/DBHDR.cs b/CUETools.CTDB/DBHDR.cs
new file mode 100644
index 0000000..553fd27
--- /dev/null
+++ b/CUETools.CTDB/DBHDR.cs
@@ -0,0 +1,63 @@
+using System;
+using System.IO;
+using System.Text;
+
+namespace CUETools.CTDB
+{
+ class DBHDR : IDisposable
+ {
+ private long lenOffs;
+ private MemoryStream stream;
+
+ public DBHDR(MemoryStream stream, string name)
+ {
+ this.stream = stream;
+ lenOffs = stream.Position;
+ Write(0);
+ Write(name);
+ }
+
+ public void Dispose()
+ {
+ long fin = stream.Position;
+ stream.Position = lenOffs;
+ Write((int)(fin - lenOffs));
+ stream.Position = fin;
+ }
+
+ public void Write(int value)
+ {
+ byte[] temp = new byte[4];
+ temp[3] = (byte)(value & 0xff);
+ temp[2] = (byte)((value >> 8) & 0xff);
+ temp[1] = (byte)((value >> 16) & 0xff);
+ temp[0] = (byte)((value >> 24) & 0xff);
+ Write(temp);
+ }
+
+ public void Write(uint value)
+ {
+ byte[] temp = new byte[4];
+ temp[3] = (byte)(value & 0xff);
+ temp[2] = (byte)((value >> 8) & 0xff);
+ temp[1] = (byte)((value >> 16) & 0xff);
+ temp[0] = (byte)((value >> 24) & 0xff);
+ Write(temp);
+ }
+
+ public void Write(string value)
+ {
+ Write(Encoding.UTF8.GetBytes(value));
+ }
+
+ public void Write(byte[] value)
+ {
+ stream.Write(value, 0, value.Length);
+ }
+
+ public DBHDR HDR(string name)
+ {
+ return new DBHDR(stream, name);
+ }
+ }
+}
diff --git a/CUETools.CTDB/ReadDB.cs b/CUETools.CTDB/ReadDB.cs
new file mode 100644
index 0000000..5f6defa
--- /dev/null
+++ b/CUETools.CTDB/ReadDB.cs
@@ -0,0 +1,47 @@
+using System.Text;
+
+namespace CUETools.CTDB
+{
+ class ReadDB
+ {
+ private byte[] contents;
+ public int pos;
+
+ public ReadDB(byte[] contents)
+ {
+ this.contents = contents;
+ this.pos = 0;
+ }
+
+ public string ReadHDR(out int end)
+ {
+ int size = this.ReadInt();
+ string res = Encoding.ASCII.GetString(contents, pos, 4);
+ this.pos += 4;
+ end = pos + size - 8;
+ return res;
+ }
+
+ public int ReadInt()
+ {
+ int value =
+ (this.contents[this.pos + 3] +
+ (this.contents[this.pos + 2] << 8) +
+ (this.contents[this.pos + 1] << 16) +
+ (this.contents[this.pos + 0] << 24));
+ this.pos += 4;
+ return value;
+ }
+
+ public uint ReadUInt()
+ {
+ uint value =
+ ((uint)this.contents[this.pos + 3] +
+ ((uint)this.contents[this.pos + 2] << 8) +
+ ((uint)this.contents[this.pos + 1] << 16) +
+ ((uint)this.contents[this.pos + 0] << 24));
+ this.pos += 4;
+ return value;
+ }
+ }
+}