Пример #1
0
        /// <summary>
        /// returns a list of directories found in all sources that match either the artist, or the work
        /// Note that a directory will match if the name matches ignoring accents or case
        /// </summary>
        /// <param name="musicStyle"></param>
        /// <param name="musicOptions"></param>
        /// <param name="artistName"></param>
        /// <param name="workName"></param>
        /// <returns></returns>

        /// <summary>
        /// Reads all the tags in the audio file and adds them to the database
        /// (Not all the tags are used)
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static async Task UpdateTagsAsync(this MusicDb db, MusicFile mf /*, bool force = false*/)
        {
            if (/*force == true*/
                /*||*/ mf.ParsingStage == MusicFileParsingStage.Unknown ||
                mf.ParsingStage == MusicFileParsingStage.Initial ||
                (mf.FileLastWriteTimeUtc != new IO.FileInfo(mf.File).LastWriteTimeUtc))
            {
                // for western classical the important tags are:
                //      ArtistName, WorkName, Year, Composition, Orchestra, Conductor, Performers, TrackNumber, Title
                //      what about cover art?? can I assume that there will always be an image file on disk somewhere??
                var oldTags = mf.IdTags.ToArray();
                mf.IdTags.Clear();
                db.IdTags.RemoveRange(oldTags);
                switch (mf.Encoding)
                {
                case EncodingType.flac:
                    db.UpdateFlacTagsAsync(mf);
                    break;

                default:
                    await db.UpdateMp3TagsAsync(mf);

                    break;
                }
                mf.ParsingStage = MusicFileParsingStage.IdTagsComplete;
            }
        }