IF.Lastfm/IF.Lastfm.Console/Program.cs
2013-06-13 20:33:13 +01:00

59 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using IF.Lastfm.Core;
using IF.Lastfm.Core.Api;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace IF.Lastfm.Console
{
internal class Program
{
private static string _apiKey;
private static string _apiSecret;
private static string _username;
private static string _pass;
private static void Main(string[] args)
{
Run().Wait();
}
public static async Task Run()
{
await LoadSession();
var auth = new Auth(_apiKey, _apiSecret);
await auth.GetSessionTokenAsync(_username, _pass);
var albumApi = new AlbumApi(auth);
var album = await albumApi.GetAlbumInfoAsync("Grimes", "Visions", false);
System.Console.ReadLine();
}
private async static Task LoadSession()
{
const string path = @"C:\lastfm-wp-config.json";
string json;
using (var reader = new StreamReader(path))
{
json = await reader.ReadToEndAsync();
}
var jo = JsonConvert.DeserializeObject<JToken>(json);
_apiKey = jo.Value<string>("apikey");
_apiSecret = jo.Value<string>("apisecret");
_username = jo.Value<string>("username");
_pass = jo.Value<string>("pass");
}
}
}