Beispiel #1
0
        private string ExportLibrary()
        {
            string[] library = null;
            string[] tags    = null;
            mbApi.Library_QueryFilesEx("domain=Library", ref library);
            Array.Sort(library, (x, y) => String.Compare(x, y));

            MetaDataType[] meta = new MetaDataType[] { MetaDataType.TrackTitle, MetaDataType.TrackNo, MetaDataType.DiscNo, MetaDataType.Album, MetaDataType.Year, MetaDataType.AlbumArtist };

            List <string> artists = new List <string>();

            List <Band> bands = new List <Band>();

            foreach (var item in library.Select((value, index) => new { value, index }))
            {
                mbApi.Library_GetFileTags(item.value, meta, ref tags);
                if (artists.Find(c => c == tags[5]) == null)
                {
                    bands.Add(new Band {
                        Artist = tags[5], Albums = GetAlbums(tags[5])
                    });
                    artists.Add(tags[5]);
                }
            }
            return(JsonSerializer.ToJsonString(bands));
        }
        public string[] AllAudiobooks()
        {
            var audiobooks = new string[] { };

            _mbApiInterface.Library_QueryFilesEx(@"<Source Type=""32""></Source>", ref audiobooks);

            return(audiobooks);
        }
 public void IncrementPlayCount(object sender, EventArgs e)
 {
     string[] mySelectedFiles = new string[] { };
     mbApiInterface.Library_QueryFilesEx("domain=SelectedFiles", ref mySelectedFiles);
     foreach (string myfile in mySelectedFiles)
     {
         string currentValue = mbApiInterface.Library_GetFileTag(myfile, (MetaDataType)FilePropertyType.PlayCount);
         int    newValue     = Int32.Parse(currentValue) + 1;
         mbApiInterface.Library_SetFileTag(myfile, (MetaDataType)FilePropertyType.PlayCount, newValue.ToString());
         mbApiInterface.Library_CommitTagsToFile(myfile);
     }
     mbApiInterface.MB_RefreshPanels();
 }
Beispiel #4
0
        public void AverageFiles()
        {
            double avg = 0;

            string       temp, check = null;
            MetaDataType tag;

            configMgr = new ConfigMgr();
            Dictionary <int, string> DeserializedDict = configMgr.DeserializeIntoDict(_workingDirectory + @"\DRconfig.xml", new Dictionary <int, string>());

            DeserializedDict.TryGetValue(7, out check);


            DeserializedDict.TryGetValue(2, out temp);
            tagsDictionary.TryGetValue(temp, out tag);


            if (!mbApiInterface.Library_QueryFilesEx("domain=SelectedFiles", ref files))
            {
                files = new string[0];
            }


            if (files.Length == 0)
            {
                MessageBox.Show("No files selected.");
                return;
            }

            for (int i = 0; i < files.Length; i++)
            {
                string taggedVal = mbApiInterface.Library_GetFileTag(files[i], tag);

                try
                {
                    avg += Convert.ToDouble(Regex.Replace(taggedVal, @"[a-zA-Z /\s/g :]", ""), CultureInfo.GetCultureInfo("en-us"));
                }
                catch (System.FormatException e)
                {
                    MessageBox.Show("Please tag all of the files first!");
                    return;
                }
            }

            avg = (avg / files.Length);

            if (check == "None")
            {
                MessageBox.Show("[NO TAG CONFIGURED - Files Not Tagged] \n\nAverage DR of selected files: " + Convert.ToString(Math.Round(avg, 2)) + " LU");
                return;
            }


            //Write tag to files:
            for (int i = 0; i < files.Length; i++)
            {
                DeserializedDict.TryGetValue(7, out temp);
                tagsDictionary.TryGetValue(temp, out tag);

                mbApiInterface.Library_SetFileTag(files[i], tag, Math.Round(avg, 2) + " LU");
                mbApiInterface.Library_CommitTagsToFile(files[i]);
            }

            //MessageBox.Show("Temp: " + temp + "\nTag: " + tag + "\nData: " + data[i]);


            mbApiInterface.MB_RefreshPanels();

            MessageBox.Show("[FILES TAGGED] \n\nAverage DR of selected files: " + Convert.ToString(Math.Round(avg, 2)) + " LU");


            return;
        }