예제 #1
0
 private void Button_Refresh(object sender, RoutedEventArgs e)
 {
     Global.Instance.Logger.Info("Getting all beatmaps");
     Global.Instance.SongInfos.Clear();
     Task.Run(() =>
     {
         foreach (var directoryInfo in Global.Instance.InstallFolder.GetDirectories())
         {
             foreach (var fileInfo in directoryInfo.GetFiles("*.dat"))
             {
                 if (fileInfo.Name.ToLowerInvariant().Contains("info"))
                 {
                     var map = Global.CheckScriptFileInitialized(SongInfo.GetInfo(fileInfo));
                     Dispatcher.Invoke(() =>
                     {
                         Global.Instance.SongInfos.Add(map);
                     });
                 }
             }
         }
         Global.Instance.Logger.Info("Got all beatmaps");
     });
 }
예제 #2
0
파일: ApiKugou.cs 프로젝트: perichr/DGJv3
        protected override string GetLyric(SongInfo songInfo)
        {
            try
            {
                FetchConfig fc = new FetchConfig
                {
                    host    = API_HOST,
                    path    = API_PATH + $"/index.php?r=play/getdata&hash={songInfo.Id}&album_id={songInfo.GetInfo("albumid")}",
                    referer = "https://www.kugou.com/",
                    cookie  = COOKIES
                };
                var response = Fetch(fc);

                var json  = JObject.Parse(response);
                var lyric = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(json.SelectToken("data.lyrics")?.ToString()));
                return(lyric);
            }
            catch (Exception ex)
            {
                Log($"歌词下载错误:{songInfo.Name}(ex:{ex.Message})");
                return(null);
            }
        }