-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
48 lines (43 loc) · 1.41 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace Wox.Plugin.WDWNTunes
{
public class Main : IPlugin
{
public void Init(PluginInitContext context) { }
public List<Result> Query(Query query)
{
var currentSongInfo = GetCurrentSongInfo();
return new List<Result>
{
new Result
{
IcoPath = $"Images\\ntunes.png",
SubTitle = $"{currentSongInfo.Artist}",
Title = $"{currentSongInfo.Title}",
Action = _ => { return true; }
}
};
}
private NTunesCurrentTrack GetCurrentSongInfo()
{
using (var httpClient = new HttpClient())
{
var response = Task.Run(async () => await httpClient.GetStringAsync("http://fastpass.wdwnt.com/live365")).Result;
var jsonObject = JObject.Parse(response);
return new NTunesCurrentTrack
{
Artist = (string)jsonObject["current-track"]["artist"],
Title = (string)jsonObject["current-track"]["title"],
};
}
}
}
public class NTunesCurrentTrack
{
public string Artist { get; set; }
public string Title { get; set; }
}
}