Example #1
0
 public CUESheet(CUEConfig config)
 {
     _config = config;
     _progress = new CUEToolsProgressEventArgs();
     _progress.cueSheet = this;
     _attributes = new List<CUELine>();
     _tracks = new List<TrackInfo>();
     _trackFilenames = new List<string>();
     _toc = new CDImageLayout();
     _sources = new List<SourceInfo>();
     _sourcePaths = new List<string>();
     _stop = false;
     _pause = false;
     _outputPath = null;
     _paddedToFrame = false;
     _truncated4608 = false;
     _usePregapForFirstTrackInSingleFile = false;
     _action = CUEAction.Encode;
     _appliedWriteOffset = false;
     _minDataTrackLength = null;
     hdcdDecoder = null;
     _hasEmbeddedCUESheet = false;
     _isArchive = false;
     _isCD = false;
     _useLocalDB = false;
     proxy = _config.GetProxy();
 }
Example #2
0
 public string GenerateUniqueOutputPath(string format, string ext, CUEAction action, string pathIn)
 {
     return GenerateUniqueOutputPath(_config, format, ext, action, new NameValueCollection(), pathIn, this);
 }
Example #3
0
        public static string GenerateUniqueOutputPath(CUEConfig _config, string format, string ext, CUEAction action, NameValueCollection vars, string pathIn, CUESheet cueSheet)
        {
            if (pathIn == "" || (pathIn == null && action != CUEAction.Encode) || (pathIn != null && !IsCDROM(pathIn) && !File.Exists(pathIn) && !Directory.Exists(pathIn)))
                return String.Empty;
            if (action == CUEAction.Verify && _config.arLogToSourceFolder)
                return Path.ChangeExtension(pathIn, ".cue");
            if (action == CUEAction.CreateDummyCUE)
                return Path.ChangeExtension(pathIn, ".cue");
            if (action == CUEAction.CorrectFilenames)
                return pathIn;

            if (_config.detectHDCD && _config.decodeHDCD && (!ext.StartsWith(".lossy.") || !_config.decodeHDCDtoLW16))
            {
                if (_config.decodeHDCDto24bit)
                    ext = ".24bit" + ext;
                else
                    ext = ".20bit" + ext;
            }

            if (pathIn != null)
            {
                vars.Add("path", pathIn);
                try
                {
                    vars.Add("filename", Path.GetFileNameWithoutExtension(pathIn));
                    vars.Add("filename_ext", Path.GetFileName(pathIn));
                    vars.Add("directoryname", General.EmptyStringToNull(Path.GetDirectoryName(pathIn)));
                }
                catch { }
            }
            vars.Add("music", Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));
            string artist = cueSheet == null ? "Artist" : cueSheet.Metadata.Artist == "" ? "Unknown Artist" : cueSheet.Metadata.Artist;
            string album = cueSheet == null ? "Album" : cueSheet.Metadata.Title == "" ? "Unknown Title" : cueSheet.Metadata.Title;
            vars.Add("artist", General.EmptyStringToNull(_config.CleanseString(artist)));
            vars.Add("album", General.EmptyStringToNull(_config.CleanseString(album)));

            if (cueSheet != null)
            {
                vars.Add("year", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.Year)));
                vars.Add("barcode", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.Barcode)));
                vars.Add("label", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.Label)));
                vars.Add("labelno", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.LabelNo)));
                vars.Add("labelandnumber", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.LabelAndNumber)));
                vars.Add("country", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.Country)));
                vars.Add("releasedate", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.ReleaseDate)));
                vars.Add("discname", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.DiscName)));
                vars.Add("discnumber", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.DiscNumber01)));
                vars.Add("totaldiscs", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.TotalDiscs)));
                vars.Add("releasedateandlabel", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.ReleaseDateAndLabel)));
                vars.Add("discnumberandname", General.EmptyStringToNull(_config.CleanseString(cueSheet.Metadata.DiscNumberAndName.Replace("/", " of "))));
                NameValueCollection tags = cueSheet.Tags;
                if (tags != null)
                    foreach (string tag in tags.AllKeys)
                    {
                        string key = tag.ToLower();
                        string val = tags[tag];
                        if (vars.Get(key) == null && val != null && val != "")
                            vars.Add(key, _config.CleanseString(val));
                    }
            }

            vars.Add("unique", null);

            string outputPath = "";
            for (int maxLen = 255; maxLen >= 8; maxLen--)
            {
                outputPath = General.ReplaceMultiple(format, vars, "unique", pathOut => File.Exists(Path.ChangeExtension(pathOut, ext)), maxLen);
                if (outputPath == "" || outputPath == null)
                    return "";
                try { outputPath = Path.ChangeExtension(outputPath, ext); }
                catch { return ""; }
                if (outputPath.Length < 255)
                    return outputPath;
            }
            return outputPath;
        }
Example #4
0
 private void SaveScripts(CUEAction action)
 {
     switch (action)
     {
         case CUEAction.Verify:
             _profile._config.defaultVerifyScript = SelectedScript;
             break;
         case CUEAction.Encode:
             _profile._config.defaultEncodeScript = SelectedScript;
             break;
     }
 }