Added support for adding lyrics easily

This commit is contained in:
Norbi Peti 2019-07-24 01:18:15 +02:00
parent fb6246d563
commit ae18eea463
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 64 additions and 0 deletions

View file

@ -61,6 +61,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StoreLyrics.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />

View file

@ -15,6 +15,12 @@ namespace HiddenUpdater
public static async Task Main(string[] args) 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 auth = new CredentialsAuth("ce11c54b88cf41149e528de5ec73aa69", File.ReadAllText("secret.txt"));
var token = await auth.GetToken(); var token = await auth.GetToken();
var spotify = new SpotifyWebAPI var spotify = new SpotifyWebAPI

View file

@ -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);
}
}
}