Пример #1
0
        private string FileSafeFileName(UGTab tab)
        {
            string fileName = $"{tab.artist} - {tab.title}({tab.rating}star).txt";

            foreach (var c in Path.GetInvalidFileNameChars())
            {
                fileName = fileName.Replace(c, '-');
            }
            return(fileName);
        }
Пример #2
0
        public List <UGTab> GetAllTabs(List <BasicSong> allTracks, UGType type)
        {
            Directory.CreateDirectory(DIR_NAME);
            Console.WriteLine($"Getting {allTracks.Count} tabs");
            List <UGTab> tabs = new List <UGTab>();

            try
            {
                foreach (BasicSong track in allTracks)
                {
                    string fullTrack = $"{track.artist} - {track.title}";
                    Console.WriteLine($"Searching for tabs for {fullTrack}");
                    UGSearch       searchResults = this.GetSearchResult(track, type);
                    UGSearchResult bestCandidate = searchResults.GetBestResult();
                    Console.WriteLine($"Getting tab for {fullTrack}");
                    if (bestCandidate == null)
                    {
                        Console.WriteLine($"No tab found for {fullTrack}");
                        File.AppendAllText($"{DIR_NAME}/NOT_FOUND.txt", fullTrack + "\n");
                    }
                    else
                    {
                        UGTab tab = this.GetTab(bestCandidate);
                        tabs.Add(tab);
                        File.WriteAllText($"{DIR_NAME}/{this.FileSafeFileName(tab)}", tab.tab);
                    }
                }
                browser.Quit();
                return(tabs);
            }
            catch
            {
                browser.Quit();
                throw;
            }
        }