protected Stream(StreamSubscription subscription) : base(subscription.Name) { this.ChatAvailable = false; this.ViewerCount = 0; this.Text = subscription.Name; this.Slug = subscription.Slug; this.Provider = subscription.Provider.ToLower(); this.Icon = new NodeIcon("stream", Assets.Images.Icons.Png._16.stream); this.RememberState = true; }
// creates a stream object based on it's provider public static Stream CreateStream(StreamSubscription subscription) { Stream stream=null; switch (subscription.Provider.ToLower()) // create the appr. stream object based on it's provider. { case "livestream": stream = new LiveStream(subscription); break; case "justintv": stream = new JustinTv(subscription); break; case "ustream": stream = new UStream(subscription); break; case "own3dtv": stream = new Own3Dtv(subscription); break; default: break; } if(stream==null) throw new NotImplementedException(string.Format("Stream provider not implemented: '{0}'", subscription.Provider)); // throw an exception if stream was not associated with a valid provider. return stream; // if we found a valid stream provider. }
public bool Add(StreamSubscription subscription) { if (this.Dictionary.ContainsKey(string.Format("{0}@{1}", subscription.Slug, subscription.Provider.ToLower()))) return false; base.Add(subscription); return true; }
public override bool AddSubscriptionFromUrl(string link) { foreach (KeyValuePair<string, Provider> pair in Providers.Instance.Dictionary) { if (!((StreamProvider) pair.Value).IsUrlValid(link)) continue; string slug = (pair.Value as StreamProvider).GetSlugFromUrl(link); var streamSubscription = new StreamSubscription { Slug = slug, Provider = pair.Value.Name, Name = pair.Value.Name.ToLower() == "own3dtv" ? (pair.Value as StreamProvider).GetNameFromUrl(link).Replace('_', ' ') : slug }; string streamKey = string.Format("{0}@{1}", streamSubscription.Slug, streamSubscription.Provider.ToLower()); if (Subscriptions.Instance.Dictionary.ContainsKey(streamKey)) { MessageBox.Show(string.Format(i18n.StreamSubscriptionAlreadyExistsMessage, Subscriptions.Instance.Dictionary[streamKey].Name), i18n.SubscriptionExists, MessageBoxButtons.OK, MessageBoxIcon.Error); return true; } using(var stream=StreamFactory.CreateStream(streamSubscription)) { if (!stream.IsValid()) continue; if (Subscriptions.Instance.Add(streamSubscription)) this.MenuRefresh(this, new EventArgs()); return true; } } return false; }
public void ConsumeSubscription(string entryUrl) { Match match = this._subscriptionConsumerRegex.Match(entryUrl); if (!match.Success) return; string name = match.Groups["Name"].Value; string provider = match.Groups["Provider"].Value; string slug = match.Groups["Slug"].Value; var subscription = new StreamSubscription {Name = name, Provider = provider, Slug = slug}; Subscriptions.Instance.Add(subscription); }