Example #1
0
        bool IsAssumedValueAnArtist(List <string> splitedTitle, out string assumedValue)
        {
            //bool yes = false;
            assumedValue = "";
            bool isAssumedValueAnArtist = false;

            Simile.DBProcess.MusicArtist musicArtist = new Simile.DBProcess.MusicArtist();

            if (splitedTitle.Count > 0)
            {
                assumedValue           = splitedTitle[0];
                isAssumedValueAnArtist = musicArtist.HasArtistInExistsInDB(assumedValue);
            }

            if (!isAssumedValueAnArtist)
            {
                if (splitedTitle.Count > 0)
                {
                    assumedValue           = splitedTitle[splitedTitle.Count() - 1];
                    isAssumedValueAnArtist = musicArtist.HasArtistInExistsInDB(assumedValue);
                }
            }

            return(isAssumedValueAnArtist);
        }
Example #2
0
        public void Process(FileInfo musicFile, out string newTitle, out string artistOrBandName, out Simile.SimileEnums.GroupCategory grpCategory)
        {
            newTitle         = "";
            artistOrBandName = "";
            grpCategory      = SimileEnums.GroupCategory.Unknown;

            Simile.DBProcess.MusicArtist musicArtist = new Simile.DBProcess.MusicArtist();


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

            foreach (char obsVal in this.obsoleteValues)
            {
                string[] tmp = musicFile.Name.Split(obsVal);
                if (tmp.Count() > 1)
                {
                    splitedTitle.AddRange(tmp.Where(r => !string.IsNullOrEmpty(r)));
                }
            }

            /*Most pbly artist/band will included, before or after the title. so to speed up the process
             * first get the word from start index of an array. if its not identified as artist/band in db, then took last index
             * from an array and check with db.
             * TODO:- at present i am assuming that artist/band will be first or last in array. If not find values in db then
             * i assume title contain no artist/band.
             */
            string assumedValue     = "";
            bool   isAssumedValueOk = false;

            isAssumedValueOk = IsAssumedValueAnArtist(splitedTitle, out assumedValue);

            if (isAssumedValueOk)
            {
                grpCategory = SimileEnums.GroupCategory.Artist;
                string temp  = "";
                int    index = musicFile.Name.IndexOf(assumedValue);
                if (index != -1)
                {
                    temp             = musicFile.Name.Remove(0, assumedValue.Length);
                    artistOrBandName = assumedValue.Trim();
                }
            }

            isAssumedValueOk = (!isAssumedValueOk) ? IsAssumedValueBand(splitedTitle, out assumedValue) : false;

            if (isAssumedValueOk)
            {
                grpCategory = SimileEnums.GroupCategory.Band;
                int index = musicFile.Name.IndexOf(assumedValue);
                if (index != -1)
                {
                    newTitle         = musicFile.Name.Remove(0, assumedValue.Length);
                    artistOrBandName = assumedValue.Trim();
                }
            }
        }
Example #3
0
        void IterateMusicFiles(FileInfo[] musicFiles)
        {
            TagLib.File   tagMusicFile = null;
            List <string> artists      = new List <string>();

            Simile.DBProcess.MusicArtist artist = new Simile.DBProcess.MusicArtist();

            bool isValueExistsInArtistTagValueArray = false;

            //Iterate music files.
            foreach (FileInfo musicFile in musicFiles)
            {
                if (corruptedFiles.Where(r => r == musicFile.FullName).Count() > 0)
                {
                    continue;
                }

                try
                {
                    //Create tag music file from music file.
                    tagMusicFile = TagLib.File.Create(musicFile.FullName);


                    artists = artist.GetArtist(tagMusicFile);

                    foreach (string val in artists)
                    {
                        if (this.artistsTagValue.Count() > 0)
                        {
                            isValueExistsInArtistTagValueArray = this.artistsTagValue.ConvertAll(r => r.Trim().ToUpper()).Contains(val.Trim().ToUpper());

                            //  IsFun(val);
                            //try
                            //{
                            //    lock (this)
                            //    {
                            //        isValueExistsInArtistTagValueArray = this.artistsTagValue.ConvertAll(r => r.Trim().ToUpper()).Contains(val.Trim().ToUpper());
                            //    }
                            //}
                            //catch (Exception errmsg)
                            //{
                            //    throw errmsg;
                            //}
                        }

                        if (!isValueExistsInArtistTagValueArray && !IsFun(val.Trim())) // !this.artistsTagValue.ConvertAll(r => r.Trim().ToUpper()).Contains(val.Trim().ToUpper()))
                        {
                            if (!IsAlreadyExistsInDB(val.Trim()))
                            {
                                this.artistsTagValue.Add(val.Trim());

                                lock (this)
                                {
                                    this.listOfMusicFileTagTempData.Add(
                                        new TemplateMusicFileTag()
                                    {
                                        ArtistTagVale = val.Trim(),
                                        IsAlbum       = false,
                                        IsArtist      = false,
                                        IsBand        = false,
                                        ErrorMessage  = "",
                                        FileName      = musicFile.FullName
                                    });
                                }
                            }
                        }
                    }
                }
                catch (TagLib.CorruptFileException errMsg)
                {
                    //if (errMsg.Message == "MPEG audio header not found.")
                    //{
                    //    this.listOfMusicFileTagTempData.Add(
                    //                new TemplateMusicFileTag() { ArtistTagVale = musicFile.FullName.Trim(), IsAlbum = false, IsArtist = false, IsBand = false,
                    //                ErrorMessage = errMsg.Message });
                    //}
                }
                catch (Exception errMsg)
                {
                    throw errMsg;
                }
            }
        }