KaraokePC/SongCrawler/Program.cs

41 lines
1.3 KiB
C#

using FireSharp.Config;
using FireSharp.Interfaces;
using FireSharp.Response;
using Herse.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SongCrawler
{
class Program
{
static void Main(string[] args)
{
string controller = args[0];
string songpath = args[1];
IFirebaseConfig config = new FirebaseConfig
{
AuthSecret = "9BQHUEJhScgK2FP10hvlToxTlGQpXT94Cvx01piO",
BasePath = "https://herse.firebaseio.com/"
};
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
string firepath = string.Format("controllers/{0}/songs", controller);
string[] files = Directory.GetFiles(songpath, "*.mp3");
List<Song> songs = new List<Song>();
foreach (string file in files)
{
TagLib.File tagFile = TagLib.File.Create(file);
songs.Add(new Song() { Title = tagFile.Tag.Title, Artist = tagFile.Tag.FirstPerformer, Path = file, Genre = tagFile.Tag.FirstGenre, Year = (int)tagFile.Tag.Year });
}
SetResponse response = client.Set(firepath, songs);
}
}
}