// The commented out areas are functional, but are never actually updated/changed via api or
        // other so they are currently pointless to update
        private void SaveMetadata()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            TagLibFile.Tag.Artists = new string[] { TagLibProps["Artist"].ToString() };
#pragma warning restore CS0618 // Type or member is obsolete
            TagLibFile.Tag.AlbumArtists = new string[] { TagLibProps["Artist"].ToString() };
            TagLibFile.Tag.Performers   = new string[] { TagLibProps["Artist"].ToString() };
            TagLibFile.Tag.Album        = TagLibProps["Album"].ToString();
            TagLibFile.Tag.Genres       = new string[] { TagLibProps["Genres"].ToString() };
            //TagLibFile.Tag.Lyrics = TagLibProps["Lyrics"].ToString();
            TagLibFile.Tag.Title = TagLibProps["Title"].ToString();
            TagLibFile.Tag.Track = Convert.ToUInt32(TagLibProps["Track"]);
            TagLibFile.Tag.Year  = Convert.ToUInt32(TagLibProps["Year"]);
            //try
            //{
            //    var tag = TagLibFile.GetTag(TagLib.TagTypes.Id3v2);
            //    var frame = TagLib.Id3v2.PopularimeterFrame.Get((TagLib.Id3v2.Tag)tag, "WindowsUser", true);
            //    frame.Rating = Convert.ToByte(TagLibProps["Rating"]);
            //}
            //catch (Exception ex)
            //{
            //    var log = new LogWriter($"Can not save rating metadata to {Filepath}. {ex.GetType()}: \"{ex.Message}\" " +
            //      "Possibly invalid tag type (Not Id3v2/Windows)");
            //}
            //try
            //{
            //    TagLibFile.Tag.Comment = (bool)TagLibProps["IsLive"] ? "Live" : "";
            //}
            //catch (Exception ex)
            //{
            //    var log = new LogWriter($"Can not save database comment data to {Filepath}. {ex.GetType()}: \"{ex.Message}\"");
            //}
            try
            {
                TagLibFile.Save();
            }
            catch (IOException ex)
            {
                var log = new LogWriter($"MasterFile.SaveMetadata() - Can not save taglib data to '{Filepath}'. {ex.GetType()}: \"{ex.Message}\"");
            }
        }
        /// <summary>
        /// Scans the specified path for music files.
        /// </summary>
        /// <param name="path"></param>
        /// <returns>A <see cref="Collection"/> with tag information.</returns>
        public static Collection ScanDirectory(string path)
        {
            Collection    collection = new Collection(path);
            DirectoryInfo directory  = new DirectoryInfo(path);

            foreach (var file in directory.EnumerateFiles("*.mp3", SearchOption.AllDirectories))
            {
                var         libFile    = new TagLibFile(file);
                TagLib.File tagLibFile = null;

                try
                {
                    tagLibFile = TagLib.File.Create(libFile);
                }
                catch (TagLib.CorruptFileException)
                {
                    File.Move(file.FullName, file.FullName + "_corrrupt_");
                    continue;
                }
                catch (TagLib.UnsupportedFormatException)
                {
                    continue;
                }
                catch (IOException)
                {
                    continue;
                }

                using (tagLibFile)
                {
                    Band  band  = null;
                    Album album = null;
                    Song  song  = null;

                    TagLib.Tag tag = tagLibFile.Tag;

                    TagInformation information = new TagInformation(tag);

                    if (information.Title == null)
                    {
                        information.Title = file.Name;
                    }

                    if (information.Album == null)
                    {
                        information.Album = information.Title;
                    }

                    band = collection.Bands.FirstOrDefault(b => b.Name == information.Band);
                    // If no band with that name found, make a new one
                    if (band == null)
                    {
                        band      = new Band();
                        band.Name = information.Band;
                        collection.Bands.Add(band);
                    }

                    album = band.Albums.FirstOrDefault(a => a.Name == information.Album);
                    // If no album with that name found, or its a new band
                    if (album == null)
                    {
                        album      = new Album();
                        album.Name = information.Album;
                        album.Year = tag.Year;
                        band.Albums.Add(album);
                    }

                    song = album.Songs.FirstOrDefault(s => s.Name == information.Title);
                    // If that song exists, add the song suffixing with '_'
                    if (song != null)
                    {
                        information.Title += "_";
                    }

                    song = new Song();
                    album.Songs.Add(song);

                    song.Name     = information.Title;
                    song.FilePath = file.FullName.Replace(path, "");
                    song.Duration = null;
                    song.Track    = information.Track;

                    band.Albums.Add(album);
                }
            }

            return(collection);
        }
        /// <summary>
        /// Scans the specified path for music files.
        /// </summary>
        /// <param name="path"></param>
        /// <returns>A <see cref="Collection"/> with tag information.</returns>
        public static Collection ScanDirectory(string path)
        {
            Collection collection = new Collection(path);
            DirectoryInfo directory = new DirectoryInfo(path);

            foreach (var file in directory.EnumerateFiles("*.mp3", SearchOption.AllDirectories))
            {
                var libFile = new TagLibFile(file);
                TagLib.File tagLibFile = null;

                try
                {
                    tagLibFile = TagLib.File.Create(libFile);
                }
                catch(TagLib.CorruptFileException)
                {
                    File.Move(file.FullName, file.FullName + "_corrrupt_");
                    continue;
                }
                catch(TagLib.UnsupportedFormatException)
                {
                    continue;
                }
                catch(IOException)
                {
                    continue;
                }

                using (tagLibFile)
                {
                    Band band = null;
                    Album album = null;
                    Song song = null;

                    TagLib.Tag tag = tagLibFile.Tag;

                    TagInformation information = new TagInformation(tag);

                    if (information.Title == null)
                    {
                        information.Title = file.Name;
                    }

                    if (information.Album == null)
                    {
                        information.Album = information.Title;
                    }

                    band = collection.Bands.FirstOrDefault(b => b.Name == information.Band);
                    // If no band with that name found, make a new one
                    if (band == null)
                    {
                        band = new Band();
                        band.Name = information.Band;
                        collection.Bands.Add(band);
                    }

                    album = band.Albums.FirstOrDefault(a => a.Name == information.Album);
                    // If no album with that name found, or its a new band
                    if (album == null)
                    {
                        album = new Album();
                        album.Name = information.Album;
                        album.Year = tag.Year;
                        band.Albums.Add(album);
                    }

                    song = album.Songs.FirstOrDefault(s => s.Name == information.Title);
                    // If that song exists, add the song suffixing with '_'
                    if (song != null)
                    {
                        information.Title += "_";
                    }

                    song = new Song();
                    album.Songs.Add(song);

                    song.Name = information.Title;
                    song.FilePath = file.FullName.Replace(path, "");
                    song.Duration = null;
                    song.Track = information.Track;

                    band.Albums.Add(album);

                }
               }

               return collection;
        }