Esempio n. 1
0
		public void OpenCDExtra()
		{
			// test playstation-type CD-Extra
			CUESheet target = new CUESheet(new CUEConfig());
			target.Open("Circuitry\\1.cue");
			Assert.AreEqual<string>("-0:37001:70001:99814:126819:160976", target.TOC.ToString(), "Wrong TOC");

			// test playstation-type CD-Extra with nonstandard pregap
			target = new CUESheet(new CUEConfig());
			target.Open("Headcandy\\Headcandy.cue");
			Assert.AreEqual<string>("-0:141942:168581:223645:248699:279575:312824", target.TOC.ToString(), "Wrong TOC");

			// test playstation-type CD-Extra with no info in cuesheet
			target = new CUESheet(new CUEConfig());
			target.Open("Anatomy\\Anatomy.cue");
			Assert.AreEqual<string>("-0:19687:33144:50680:69872:89822:108084:132098:150625:166271:194882:200172:215884:236046:242815:269518:282018:293416", target.TOC.ToString(), "Wrong TOC");

			// test playstation-type CD-Extra with two data tracks
			target = new CUESheet(new CUEConfig());
			target.Open("Les Mysterieuses Cites d'Or\\Les Mysterieuses Cites d'Or.cue");
			Assert.AreEqual<string>("-0:-31952:127883:137816:149173:160223:171479:180777:186738:196134:205613:214526:221674:227031:232824:239376:249495:259604:266115:267080:275100:281599:284452:291422:295511:297642:302114:309263:312269:320051:326235:333841", target.TOC.ToString(), "Wrong TOC");

			// test playstation-type CD-Extra with two data tracks and no info in cuesheet
			target = new CUESheet(new CUEConfig());
			target.Open("Les Mysterieuses Cites d'Or\\2.cue");
			Assert.AreEqual<string>("-0:-31952:127883:137816:149173:160223:171479:180777:186738:196134:205613:214526:221674:227031:232824:239376:249495:259604:266115:267080:275100:281599:284452:291422:295511:297642:302114:309263:312269:320051:326235:333841", target.TOC.ToString(), "Wrong TOC");
		}
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: ArCueDotNet <filename>");
                return;
            }
            string pathIn = args[0];
            if (!File.Exists(pathIn))
            {
                Console.WriteLine("Input CUE Sheet not found.");
                return;
            }
            CUEConfig config = new CUEConfig();
            config.writeArLogOnVerify = false;
            config.writeArTagsOnVerify = false;
            config.autoCorrectFilenames = true;
            config.extractAlbumArt = false;
            config.embedAlbumArt = false;

            string accurateRipLog;
            try
            {
                CUESheet cueSheet = new CUESheet(config);
                cueSheet.Action = CUEAction.Verify;
                //cueSheet.OutputStyle = CUEStyle.SingleFile;
                cueSheet.Open(pathIn);
                cueSheet.UseAccurateRip();
                cueSheet.GenerateFilenames(AudioEncoderType.NoAudio, "dummy", pathIn);
                cueSheet.Go();

                accurateRipLog = CUESheetLogWriter.GetAccurateRipLog(cueSheet);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return;
            }

            Console.Write(accurateRipLog);
        }
Esempio n. 3
0
        public void ScanLocalDB(string folder)
        {
            // Delete missing files
            string norm = CUEToolsLocalDBEntry.NormalizePath(folder);
            if (norm.Length != 0 && norm[norm.Length - 1] != System.IO.Path.DirectorySeparatorChar) norm = norm + System.IO.Path.DirectorySeparatorChar;

            ReportProgress("Checking known files", 0.0);
            int oldi = 0, oldn = _localDB.Count;
            foreach (var item in _localDB.ToArray())
            {
                bool matches = false;
                oldi++;
                if (item.AudioPaths != null)
                {
                    foreach (var f in item.AudioPaths)
                        if (f.StartsWith(norm))
                        {
                            matches = true;
                            CheckStop();
                            if (!File.Exists(f))
                            {
                                _localDB.Remove(item);
                                _localDB.Dirty = true;
                                continue;
                            }
                        }
                }

                if (item.InputPaths != null)
                {
                    foreach (var f in item.InputPaths.ToArray())
                        if (f.StartsWith(norm))
                        {
                            CheckStop();
                            ReportProgress("Checking " + f, (double)oldi / oldn);
                            matches = true;
                            if (!File.Exists(f))
                            {
                                item.InputPaths.Remove(f);
                                _localDB.Dirty = true;
                            }
                            else
                            {
                                var cueSheet = new CUESheet(_config);
                                cueSheet.UseLocalDB(_localDB);
                                try
                                {
                                    cueSheet.Open(f);
                                    List<string> fullAudioPaths = cueSheet._sourcePaths == null ? null : cueSheet._sourcePaths.ConvertAll(p => CUEToolsLocalDBEntry.NormalizePath(p));
                                    if (!item.Equals(cueSheet._toc, fullAudioPaths))
                                    {
                                        item.InputPaths.Remove(f);
                                        _localDB.Dirty = true;
                                    }
                                }
                                catch (Exception)
                                {
                                    item.InputPaths.Remove(f);
                                    _localDB.Dirty = true;
                                }
                                cueSheet.Close();
                            }
                        }

                    if (matches && item.InputPaths.Count == 0)
                    {
                        _localDB.Remove(item);
                        _localDB.Dirty = true;
                        continue;
                    }
                }
            }

            // Add new files
            ReportProgress("Scanning for new files", 0.0);
            var results = new List<string>();

            int n = 2, j = 0;
            foreach (var fmt in _config.formats)
                if (fmt.Value.allowLossless)
                    n++;

            CheckStop();
            ReportProgress("Scanning *.cue", (double)(j++) / n);
            results.AddRange(Directory.GetFiles(folder, "*.cue", SearchOption.AllDirectories));

            CheckStop();
            ReportProgress("Scanning *.m3u", (double)(j++) / n);
            results.AddRange(Directory.GetFiles(folder, "*.m3u", SearchOption.AllDirectories));

            foreach (var fmt in _config.formats)
                if (fmt.Value.allowLossless)
                {
                    CheckStop();
                    ReportProgress("Scanning *." + fmt.Key, (double)(j++) / n);
                    results.AddRange(Directory.GetFiles(folder, "*." + fmt.Key, SearchOption.AllDirectories));
                }

            ReportProgress("Checking new files", 0.0);
            int i = 0;
            foreach (var result in results)
            {
                CheckStop();

                var path = CUEToolsLocalDBEntry.NormalizePath(result);
                var pathextension = Path.GetExtension(path).ToLower();
                bool skip = false;
                if (_localDB.Find(
                        item => item.HasPath(path) ||
                            (item.AudioPaths != null &&
                            item.AudioPaths.Count > 1 &&
                            item.AudioPaths.Contains(path))
                    ) != null)
                    skip = true;
                if (!skip && pathextension == ".m3u")
                {
                    var contents = new List<string>();
                    using (StreamReader m3u = new StreamReader(path))
                    {
                        do
                        {
                            string line = m3u.ReadLine();
                            if (line == null) break;
                            if (line == "" || line[0] == '#') continue;
                            //if (line.IndexOfAny(Path.GetInvalidPathChars()) >= 0) 
                            //    continue;
                            try
                            {
                                string extension = Path.GetExtension(line);
                                CUEToolsFormat fmt1;
                                if (!extension.StartsWith(".") || !_config.formats.TryGetValue(extension.ToLower().Substring(1), out fmt1) || !fmt1.allowLossless)
                                {
                                    skip = true;
                                    break;
                                }
                                string fullpath = CUEToolsLocalDBEntry.NormalizePath(Path.Combine(Path.GetDirectoryName(path), line));
                                if (!File.Exists(fullpath))
                                {
                                    skip = true;
                                    break;
                                }
                                contents.Add(fullpath);
                            }
                            catch
                            {
                                skip = true;
                                break;
                            }
                        } while (!skip);
                    }
                    if (!skip && _localDB.Find(item => item.EqualAudioPaths(contents)) != null)
                        skip = true;
                }
                if (!skip && pathextension != ".cue" && pathextension != ".m3u")
                {
                    if (_localDB.Find(item =>
                            item.AudioPaths != null &&
                            item.AudioPaths.Count == 1 &&
                            item.AudioPaths[0] == path
                        ) != null)
                    {
                        CUEToolsFormat fmt;
                        if (!pathextension.StartsWith(".") || !_config.formats.TryGetValue(pathextension.Substring(1), out fmt) || !fmt.allowLossless || !fmt.allowEmbed)
                            skip = true;
                        else
                        {
                            TagLib.File fileInfo;
                            TagLib.UserDefined.AdditionalFileTypes.Config = _config;
                            TagLib.File.IFileAbstraction file = new TagLib.File.LocalFileAbstraction(path);
                            fileInfo = TagLib.File.Create(file);
                            NameValueCollection tags = Tagging.Analyze(fileInfo);
                            if (tags.Get("CUESHEET") == null)
                                skip = true;
                        }
                    }
                }
                if (skip)
                {
                    ReportProgress("Skipping " + path, (double)(i++) / results.Count);
                }
                else
                {
                    ReportProgress("Checking " + path, (double)(i++) / results.Count);
                    var cueSheet = new CUESheet(_config);
                    cueSheet.UseLocalDB(_localDB);
                    //cueSheet.PasswordRequired += new EventHandler<CompressionPasswordRequiredEventArgs>(PasswordRequired);
                    //cueSheet.CUEToolsProgress += new EventHandler<CUEToolsProgressEventArgs>(SetStatus);
                    //cueSheet.CUEToolsSelection += new EventHandler<CUEToolsSelectionEventArgs>(MakeSelection);
                    try
                    {
                        cueSheet.Open(path);
                        cueSheet.OpenLocalDBEntry();
                    }
                    catch (Exception)
                    {
                    }
                    cueSheet.Close();
                }
            }
            _localDB.Save();
        }
Esempio n. 4
0
		internal void LoadDeck(int row)
		{
			CUEConfig _config = (MdiParent as frmCUEPlayer).Config;
			DataSet1 dataSet = (MdiParent as frmCUEPlayer).DataSet;
			Playlist playlist = (MdiParent as frmCUEPlayer).wndPlaylist;
			string path = dataSet.Playlist[row].path;
			int track = dataSet.Playlist[row].track;

			try
			{
				playingCue = new CUESheet(_config);
				playingCue.Open(path);
				playingSource = new CUESheetAudio(playingCue);
				playingSource.Position = (long)playingCue.TOC[track].Start * 588;
				playingSource = new AudioPipe(playingSource, 0x2000);
				playingStart = playingSource.Position;
				playingFinish = playingStart + (long)playingCue.TOC[track].Length * 588;
				playingRow = row;
				//playlist.List.Items[playingRow].BackColor = Color.AliceBlue;
				needUpdate = true;
				UpdateDeck();
			}
			catch (Exception ex)
			{
				playingStart = playingFinish = 0;
				playingCue = null;
				playingSource = null;
				return;
			}
		}
Esempio n. 5
0
 private void editMetadataToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var node = contextMenuStripFileTree.Tag as CUEControls.FileSystemTreeNode;
     string path = null;
     if (node != null && node is FileSystemTreeNodeLocalDBEntry)
         path = node.Path;
     if (node != null && node is FileSystemTreeNodeLocalDBCollision)
         path = (node as FileSystemTreeNodeLocalDBCollision).Group[0].Path;
     if (path == null)
         return;
     var CueSheet = new CUESheet(_profile._config);
     CueSheet.PasswordRequired += new EventHandler<CompressionPasswordRequiredEventArgs>(PasswordRequired);
     CueSheet.CUEToolsProgress += new EventHandler<CUEToolsProgressEventArgs>(SetStatus);
     //cueSheet.CUEToolsSelection += new EventHandler<CUEToolsSelectionEventArgs>(MakeSelection);
     try
     {
         CueSheet.Open(path);
     }
     catch (Exception ex)
     {
         ShowErrorMessage(ex);
         return;
     }
     CueSheet.UseLocalDB(_localDB);
     frmChoice dlg = new frmChoice();
     if (_choiceWidth != 0 && _choiceHeight != 0)
         dlg.Size = new Size(_choiceWidth, _choiceHeight);
     if (_choiceMaxed)
         dlg.WindowState = FormWindowState.Maximized;
     dlg.CUE = CueSheet;
     dlg.LookupAlbumInfo(true, node is FileSystemTreeNodeLocalDBEntry, true, CTDBMetadataSearch.Default);
     var dlgRes = dlg.ShowDialog(this);
     _choiceMaxed = dlg.WindowState == FormWindowState.Maximized;
     if (!_choiceMaxed)
     {
         _choiceHeight = dlg.Height;
         _choiceWidth = dlg.Width;
     }
     if (dlgRes == DialogResult.OK && dlg.ChosenRelease != null)
     {
         if (node is FileSystemTreeNodeLocalDBCollision)
         {
             var group = (node as FileSystemTreeNodeLocalDBCollision).Group;
             foreach (var item in group)
                 item.Metadata.CopyMetadata(dlg.ChosenRelease.metadata);
         }
         else if (node is FileSystemTreeNodeLocalDBEntry)
         {
             var item = (node as FileSystemTreeNodeLocalDBEntry).Item;
             item.Metadata.CopyMetadata(dlg.ChosenRelease.metadata);
         }
         node.Text = node.DisplayName;
         _localDB.Dirty = true;
         SaveDatabase();
     }
     CueSheet.Close();
 }
Esempio n. 6
0
		private void listViewTracks_DragDrop(object sender, DragEventArgs e)
		{
			if (e.Data.GetDataPresent(DataFormats.FileDrop))
			{
				string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
				if (files.Length == 1)
				{
					string path = files[0];
					try
					{
						CUESheet cue = new CUESheet(_config);
						cue.Open(path);
						for (int iTrack = 0; iTrack < cue.TrackCount; iTrack++)
						{
							DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
								path,
								cue.Metadata.Artist,
								cue.Metadata.Tracks[iTrack].Title,
								cue.Metadata.Title,
								(int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
								iTrack + 1);
							listViewTracks.Items.Add(ToItem(row));
						}
						cue.Close();
						return;
					}
					catch (Exception ex)
					{
						Trace.WriteLine(ex.Message);
					}

					FileInfo fi = new FileInfo(path);
					if (fi.Extension != ".cue")
					{
						DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
							path,
							null, // cue.Artist,
							null, // cue.Tracks[iTrack].Title,
							null, // cue.Title,
							0, // (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
							0);
						listViewTracks.Items.Add(ToItem(row));
					}
				}
			}
		}
Esempio n. 7
0
		public void OpenOneTrackCD()
		{
			// test one-track CD
			CUESheet target = new CUESheet(new CUEConfig());
			target.Open("Amarok\\Amarok.cue");
			Assert.AreEqual<string>("00041f6d-00083ece-020e1201", AccurateRipVerify.CalculateAccurateRipId(target.TOC), "Wrong TOC");
		}
Esempio n. 8
0
		public void OpenEnhancedCD()
		{
			// test Enhanced-CD
			CUESheet target = new CUESheet(new CUEConfig());
			target.Open("No Man's Land\\1.cue");
			Assert.AreEqual<string>("0015c42c-00d1e13f-ba0fe50d", AccurateRipVerify.CalculateAccurateRipId(target.TOC), "Wrong TOC");
		}