コード例 #1
0
        public static void Main(string[] args)
        {
            bool              fix_featuring = false;
            Int16             year          = 0;
            Func <Song, bool> compare;

            paramList.Add("debug", a => Top100Settings.Debug     = Boolean.Parse(a));
            paramList.Add("preview", a => Top100Settings.Preview = Boolean.Parse(a));
            paramList.Add("year", a => year = Int16.Parse(a));
            paramList.Add("fix_featuring", a => fix_featuring = Boolean.Parse(a));

            ParseArguments(args);

            var           timer          = Top100Timer.Start("Parsing iTunes library");
            List <Song>   iTunesSongList = new List <Song>();
            LibraryParser library        = new LibraryParser(LibraryParser.GetDefaultLibraryLocation());

            foreach (Playlist p in library.Playlists)
            {
                if (p.Name == "Music")
                {
                    foreach (Song s in p.Songs)
                    {
                        if (!s.AppleMusic)
                        {
                            iTunesSongList.Add(s);
                        }
                        else
                        {
                            Top100Util.Debug("Skipping AppleMusic file: " + s);
                        }
                    }
                }
            }
            timer.End();

            if (year > 0)
            {
                compare = (x) => x.Year == year;
            }
            else
            {
                compare = (x) => true;
            }

            using (var db = new Top100DB())
            {
                if (fix_featuring)
                {
                    db.ModifyFeaturing(compare);
                }
                db.UpdateDbOwnership(iTunesSongList, compare);
                db.FindMissingOwnership(iTunesSongList, compare);
                db.FindMissingTagsAndComments(iTunesSongList, compare);
            }
        }