From c1d2ecafc5160f54122606cc7091e9663bd651be Mon Sep 17 00:00:00 2001 From: mbrucedogs Date: Thu, 24 Jul 2025 13:22:03 -0500 Subject: [PATCH] Signed-off-by: mbrucedogs --- SongCrawler/Program.cs | 48 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/SongCrawler/Program.cs b/SongCrawler/Program.cs index f782aa0..a6ca135 100644 --- a/SongCrawler/Program.cs +++ b/SongCrawler/Program.cs @@ -33,10 +33,10 @@ namespace SongCrawler { DeleteSongs(args); } - else { + else + { CrawlSongs(args); } - } private static void CrawlSongs(string[] args) @@ -204,6 +204,46 @@ namespace SongCrawler client.Set(firepath, songs); } + + private static void fixNewSongs(FireSharp.FirebaseClient client, String controller) + { + string songsPath = string.Format("controllers/{0}/songs", controller); + string newSongsPath = string.Format("controllers/{0}/newSongs", controller); + + List songs = client.Get(songsPath).ResultAs>(); + List newSongs = client.Get(newSongsPath).ResultAs>(); + + List updated = new List(); + foreach (Song n in newSongs){ + var found = songs.First(s => s.Path == n.Path); + if(found != null) + { + updated.Add(found); + } + } + client.Set(newSongsPath, updated); + } + + private static void fixHistory(FireSharp.FirebaseClient client, String controller) + { + List history = null; + try + { + history = client.Get(string.Format("controllers/{0}/history", controller)).ResultAs>(); + } + catch + { + dynamic data = JsonConvert.DeserializeObject(client.Get(string.Format("controllers/{0}/history", controller)).Body); + history = new List(); + foreach (var itemDynamic in data) + { + var fjson = itemDynamic.Value.ToString(); + var f = JsonConvert.DeserializeObject(fjson); + history.Add(f); + } + } + client.Set(string.Format("controllers/{0}/history", controller), history); + } public class CreatedSong { public DateTime created { get; set; } @@ -379,7 +419,6 @@ namespace SongCrawler } CheckTitle(song); song.Path = filepath; - song.Guid = GuidFromString(filepath).ToString(); return song; } @@ -427,9 +466,6 @@ namespace SongCrawler tagFile = TagLib.File.Create(path); song.Title = tagFile.Tag.Title.Trim(); song.Artist = tagFile.Tag.FirstPerformer.Trim(); - if (tagFile.Tag.FirstGenre != null) { - song.Genre = tagFile.Tag.FirstGenre.Trim(); - } } catch {