From ae18eea4632b3ecd6eb8cde5ea460cb32bb5c8e7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 24 Jul 2019 01:18:15 +0200 Subject: [PATCH] Added support for adding lyrics easily --- HiddenUpdater/HiddenUpdater.csproj | 1 + HiddenUpdater/Program.cs | 6 ++++ HiddenUpdater/StoreLyrics.cs | 57 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 HiddenUpdater/StoreLyrics.cs diff --git a/HiddenUpdater/HiddenUpdater.csproj b/HiddenUpdater/HiddenUpdater.csproj index c0dfece..895ac32 100644 --- a/HiddenUpdater/HiddenUpdater.csproj +++ b/HiddenUpdater/HiddenUpdater.csproj @@ -61,6 +61,7 @@ + diff --git a/HiddenUpdater/Program.cs b/HiddenUpdater/Program.cs index 5902a60..1b7fcc3 100644 --- a/HiddenUpdater/Program.cs +++ b/HiddenUpdater/Program.cs @@ -15,6 +15,12 @@ namespace HiddenUpdater public static async Task Main(string[] args) { + Console.Write("Download (1) or lyrics (2): "); + if (int.Parse(Console.ReadLine()) != 1) + { + StoreLyrics.Store(); + return; + } var auth = new CredentialsAuth("ce11c54b88cf41149e528de5ec73aa69", File.ReadAllText("secret.txt")); var token = await auth.GetToken(); var spotify = new SpotifyWebAPI diff --git a/HiddenUpdater/StoreLyrics.cs b/HiddenUpdater/StoreLyrics.cs new file mode 100644 index 0000000..4a1afc1 --- /dev/null +++ b/HiddenUpdater/StoreLyrics.cs @@ -0,0 +1,57 @@ +using System; +using System.IO; +using System.Linq; +using System.Net; +using Newtonsoft.Json.Linq; + +namespace HiddenUpdater +{ + public class StoreLyrics + { + public static void Store() + { + do + { + Console.Write("One artist: "); + string artist = Console.ReadLine(); + if (artist.Length == 0) break; + Console.Write("Title: "); + string title = Console.ReadLine(); + if (artist.Length == 0) break; + var songs = JArray.Parse(File.ReadAllText("songs.json")); + foreach (var song in songs) + { + if (((string) song["sname"]).Contains(title)) + { + Console.WriteLine("Title matches: " + song["artists"] + " - " + song["sname"]); + if (song["artists"].Any(a => ((string) a).Contains(artist))) + { + Console.WriteLine("Artist matches"); + /*Console.WriteLine("Lyrics (type \"END\" when done):"); + string lyrics = ""; + do + { + var line = Console.ReadLine(); + Console.WriteLine("Line: " + line); + if (line == "END") break; + lyrics += " " + line + "\n"; + } while (true);*/ + File.WriteAllText("lyrics.txt", ""); + Console.WriteLine("Put the lyrics in lyrics.txt and press Enter"); + Console.ReadLine(); + + string lyrics = ""; + foreach(string line in File.ReadLines("lyrics.txt")) { + Console.WriteLine("Line: " + line); + lyrics += " " + line + "\n"; + } + + File.AppendAllText("songextra.yml", "- sid: " + song["sid"] + "\n lyrics: |\n" + lyrics); + break; + } + } + } + } while (true); + } + } +} \ No newline at end of file