updated for htmldecode
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
9135b489b7
commit
e40d840f62
@ -11,6 +11,7 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace BillboardPlaylistUpdater
|
namespace BillboardPlaylistUpdater
|
||||||
{
|
{
|
||||||
@ -25,7 +26,7 @@ namespace BillboardPlaylistUpdater
|
|||||||
BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
|
BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
|
||||||
};
|
};
|
||||||
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
||||||
string firepath = "SongList";
|
string firepath = "songList";
|
||||||
Console.WriteLine("Loading current library");
|
Console.WriteLine("Loading current library");
|
||||||
List<SongList> songList = client.Get(firepath).ResultAs<List<SongList>>();
|
List<SongList> songList = client.Get(firepath).ResultAs<List<SongList>>();
|
||||||
if (songList != null)
|
if (songList != null)
|
||||||
@ -114,8 +115,8 @@ namespace BillboardPlaylistUpdater
|
|||||||
if(title != null && artist != null && position != null)
|
if(title != null && artist != null && position != null)
|
||||||
{
|
{
|
||||||
SongListSong song = new SongListSong();
|
SongListSong song = new SongListSong();
|
||||||
song.Artist = artist.InnerHtml.Trim().Replace("\n","");
|
song.Artist = WebUtility.HtmlDecode(artist.InnerHtml.Trim().Replace("\n",""));
|
||||||
song.Title = title.InnerHtml.Trim().Replace("\n","");
|
song.Title = WebUtility.HtmlDecode(title.InnerHtml.Trim().Replace("\n",""));
|
||||||
song.Position = Int32.Parse(position.InnerHtml.Trim());
|
song.Position = Int32.Parse(position.InnerHtml.Trim());
|
||||||
songs.Add(song);
|
songs.Add(song);
|
||||||
} else
|
} else
|
||||||
|
|||||||
@ -20,53 +20,8 @@ namespace SongCrawler
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//FindDuplicates(args);
|
//FindDuplicates(args);
|
||||||
if (args.Last() == "-sl")
|
CrawlSongs(args);
|
||||||
{
|
|
||||||
UploadSongList(args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CrawlSongs(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void UploadSongList(string[] args)
|
|
||||||
{
|
|
||||||
string songlistpath = args[0];
|
|
||||||
if (args.Length != 2)
|
|
||||||
{
|
|
||||||
Console.WriteLine("usage: songcrawler jsonpath");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IFirebaseConfig config = new FirebaseConfig
|
|
||||||
{
|
|
||||||
AuthSecret = ConfigurationManager.AppSettings["Firebase.Secret"],
|
|
||||||
BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
|
|
||||||
};
|
|
||||||
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
|
||||||
string firepath = "SongList";
|
|
||||||
Console.WriteLine("Loading current library");
|
|
||||||
List<SongList> songList = client.Get(firepath).ResultAs<List<SongList>>();
|
|
||||||
if (songList != null)
|
|
||||||
Console.WriteLine(string.Format("{0} songList loaded", songList.Count));
|
|
||||||
else
|
|
||||||
songList = new List<SongList>();
|
|
||||||
|
|
||||||
List<SongList> localSongList = JsonConvert.DeserializeObject<List<SongList>>(File.ReadAllText(songlistpath));
|
|
||||||
|
|
||||||
foreach (SongList sl in localSongList)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.WriteLine(string.Format("Checking for {0}", sl.Title));
|
|
||||||
if (!songList.Any(s => s.Title.ToLower() == sl.Title.ToLower())) songList.Add(sl);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
client.Set(firepath, songList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CrawlSongs(string[] args)
|
private static void CrawlSongs(string[] args)
|
||||||
@ -86,8 +41,7 @@ namespace SongCrawler
|
|||||||
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
||||||
string firepath = string.Format("controllers/{0}/songs", controller);
|
string firepath = string.Format("controllers/{0}/songs", controller);
|
||||||
Console.WriteLine("Loading current library");
|
Console.WriteLine("Loading current library");
|
||||||
Dictionary<string, Song> dict = client.Get(firepath).ResultAs<Dictionary<string,Song>>();
|
List<Song> songs = client.Get(firepath).ResultAs<List<Song>>();
|
||||||
List<Song> songs = dict.Values.ToList();
|
|
||||||
if (songs != null)
|
if (songs != null)
|
||||||
Console.WriteLine(string.Format("{0} songs loaded", songs.Count));
|
Console.WriteLine(string.Format("{0} songs loaded", songs.Count));
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user