public static bool TryGetSongByKey(string key, out Song song, bool searchOnline = true) { key = key.ToLower(); song = Songs.Values.Where(s => s.Key == key).FirstOrDefault(); if (song == null && searchOnline) { Logger.Info($"Song with key: {key}, not in scraped data, searching Beat Saver..."); song = OnlineSongSearch.GetSongByKeyAsync(key, CancellationToken.None).Result; if (song != null) { TryAddToScrapedData(song); } else { Logger.Warning($"Unable to find song with key {key} on Beat Saver, skipping."); } } return(song != null); }
public static bool TryGetSongByHash(string hash, out Song song, bool searchOnline = true) { hash = hash.ToUpper(); song = Songs.ContainsKey(hash) ? Songs[hash] : null; if (song == null && searchOnline) { Logger.Info($"Song with hash: {hash}, not in scraped data, searching Beat Saver..."); song = OnlineSongSearch.GetSongByHashAsync(hash, CancellationToken.None).Result; if (song != null) { song.ScrapedAt = DateTime.Now; TryAddToScrapedData(song); } else { Logger.Warning($"Unable to find song with hash {hash} on Beat Saver, skipping."); } } return(song != null); }