aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/ShiftOSAudioProvider.cs
diff options
context:
space:
mode:
authorpfg <[email protected]>2017-03-05 09:49:47 -0800
committerpfg <[email protected]>2017-03-05 09:49:47 -0800
commit99ba9c1f9c7b433b7defd09fdb110522f3a2b4c2 (patch)
tree7993b845cc8190b6287423beb37c9708bf22b842 /ShiftOS.WinForms/ShiftOSAudioProvider.cs
parentf3af198849c85a05cb402c1e2471387c7bcb9849 (diff)
downloadshiftos_thereturn-99ba9c1f9c7b433b7defd09fdb110522f3a2b4c2.tar.gz
shiftos_thereturn-99ba9c1f9c7b433b7defd09fdb110522f3a2b4c2.tar.bz2
shiftos_thereturn-99ba9c1f9c7b433b7defd09fdb110522f3a2b4c2.zip
ShiftSweeper right click flagging
Diffstat (limited to 'ShiftOS.WinForms/ShiftOSAudioProvider.cs')
-rw-r--r--ShiftOS.WinForms/ShiftOSAudioProvider.cs22
1 files changed, 17 insertions, 5 deletions
diff --git a/ShiftOS.WinForms/ShiftOSAudioProvider.cs b/ShiftOS.WinForms/ShiftOSAudioProvider.cs
index 27c0e5f..fccc76a 100644
--- a/ShiftOS.WinForms/ShiftOSAudioProvider.cs
+++ b/ShiftOS.WinForms/ShiftOSAudioProvider.cs
@@ -39,8 +39,13 @@ namespace ShiftOS.WinForms
{
get
{
- var wc = new System.Net.WebClient();
- return JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack")).Count;
+ System.Net.WebClient wc = new System.Net.WebClient();
+ try {
+ string result = wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack");
+ return JsonConvert.DeserializeObject<List<string>>(result).Count;
+ } catch {
+ return JsonConvert.DeserializeObject<List<string>>("[]").Count;
+ }
}
}
@@ -73,10 +78,17 @@ namespace ShiftOS.WinForms
public byte[] GetTrack(int index)
{
- var wc = new System.Net.WebClient();
- var st = JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack"));
+ System.Net.WebClient wc = new System.Net.WebClient();
+
+ try {
+ string result = wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack");
- return wc.DownloadData(st[index]);
+ var st = JsonConvert.DeserializeObject<List<string>>(result);
+
+ return wc.DownloadData(st[index]);
+ } catch {
+ return null;
+ }
}
}