public static bool channelExists(string url) { try { using (var client = new NewWebClient()) { client.HeadOnly = true; // fine, if channel exists // throws Exception on 404 client.DownloadString(url); } return(true); } catch (WebException) { return(false); } }
public static bool channelExists(string channel) { try { using (var client = new NewWebClient()) { client.HeadOnly = true; // fine, no content downloaded // throws 404 client.DownloadString("https://api.twitch.tv/kraken/channels/" + channel); } return(true); } catch { return(false); } }
public static bool channelExists(string channel) { try { using (var client = new NewWebClient()) { string s = client.DownloadString(String.Format(channelInfoUrl, channel)); if (s.Contains("mvc.js', null)")) { return(false); } } return(true); } catch { return(false); } }
public string getViewers() { JObject jObject; string info; try { using (NewWebClient cl = new NewWebClient()) { info = cl.DownloadString(String.Format(infoUrl, channelName)); } jObject = JsonConvert.DeserializeObject <JObject>(info); return(jObject["spectators"].ToString()); } catch (Exception ex) { Debug.WriteLine("Viewers exception: " + ex.Message); return("0"); } }