-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
48 lines (43 loc) · 1.39 KB
/
Main.cs
File metadata and controls
48 lines (43 loc) · 1.39 KB
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 System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace Wox.Plugin.UABMagic
{
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\\logo.png",
SubTitle = $"{currentSongInfo.Artist}",
Title = $"{currentSongInfo.Title}",
Action = _ => { return true; }
}
};
}
private CurrentTrack GetCurrentSongInfo()
{
using (var httpClient = new HttpClient())
{
var response = Task.Run(async () => await httpClient.GetStringAsync("https://uabmagic-api.vercel.app/api/songs/nowplaying")).Result;
var jsonObject = JObject.Parse(response);
return new CurrentTrack
{
Artist = (string) jsonObject["themeParkAndLand"],
Title = (string) jsonObject["attractionAndSong"]
};
}
}
}
public class CurrentTrack
{
public string Artist { get; set; }
public string Title { get; set; }
}
}