private void objShows_CellClick(object sender, CellClickEventArgs e) { if ((e.ColumnIndex == olvDownAll.Index) && (objShows.SelectedIndex == e.RowIndex)) { ADBaseLibrary.Show s = (Show)objShows.SelectedObject; if (_selected_episodes != null && _selected_episodes.Items.Count > 0 && _selected_episodes.Items[0].ShowId == s.Id) { MultiSelect m = new MultiSelect(false, s.Name); m.FileFormats = Settings.Instance.DefaultFormat; m.FileQuality = Settings.Instance.DefaultQuality; m.Episodes = _selected_episodes; DialogResult f = m.ShowDialog(); if (f == DialogResult.OK) { foreach (Episode ep in m.Active) { AddDownloadEpisode(ep, m.FileQuality, m.FileFormats); } } } } else if ((e.ColumnIndex == olvFollow.Index) && (objShows.SelectedIndex == e.RowIndex)) { ADBaseLibrary.Show s = (Show)objShows.SelectedObject; if (Follows.Instance.IsFollow(s.Id, s.PluginName)) { DeleteFollow(s); } else { if (_selected_episodes != null && _selected_episodes.Items.Count > 0 && _selected_episodes.Items[0].ShowId == s.Id) { FollowRequester(s, _selected_episodes); } } RefreshStatus(s.Id, s.PluginName); } }
private void FollowRequester(Show s, Episodes eps) { MultiSelect m = new MultiSelect(true, s.Name); m.FileFormats = Settings.Instance.DefaultFormat; m.FileQuality = Settings.Instance.DefaultQuality; m.Episodes = eps; DialogResult f = m.ShowDialog(); if (f == DialogResult.OK) { if (Follows.Instance.IsFollow(s.Id, s.PluginName, m.FileQuality, m.FileFormats)) { Log(LogType.Warn, "You are already following '" + s.Name + "' with this settings"); } else { Follows.Instance.AddFollow(s.Id, s.PluginName, m.FileQuality, m.FileFormats); foreach (Episode ep in eps.Items) { Follows.Instance.AddDownload(EpisodeWithDownloadSettings.FromEpisode(ep, m.FileQuality, m.FileFormats)); } foreach (Episode ep in m.Active) { AddDownloadEpisode(ep, m.FileQuality, m.FileFormats); } } } }
private void DeleteFollow(Show s) { DialogResult r = MessageBox.Show("You want to stop following this show?", s.Name, MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { Follows.Instance.RemoveFollow(s.Id, s.PluginName); } }
private void AddEpisodes(Episodes ret, Show show, string data, string seasoname, int seasonnum, bool firstone = false) { MatchCollection col = epsregex.Matches(data); foreach (Match m in col) { if (m.Success) { Episode e = new Episode(); e.Id = int.Parse(m.Groups["id"].Value).ToString(); e.PluginMetadata["Url"]=new Uri("http://www.crunchyroll.com" + m.Groups["url"].Value).ToString(); e.Name = WebUtility.HtmlDecode(m.Groups["title"].Value).Trim(); e.EpisodeAlpha = WebUtility.HtmlDecode(m.Groups["episode"].Value).Trim(); e.SeasonNumeric = seasonnum; e.SeasonAlpha = seasoname; e.ShowName = show.Name; e.ShowId = show.Id; e.Type = show.Type; e.PluginName = show.PluginName; string number = Regex.Replace(e.EpisodeAlpha, "[^0-9]", string.Empty).Trim(); int n = 0; if (int.TryParse(number, out n)) e.EpisodeNumeric = n; else e.EpisodeNumeric = 0; string desc1 = m.Groups["description"].Value; e.ImageUri = new Uri(m.Groups["image"].Value); e.Description = Regex.Unescape(desc1.Substring(1, desc1.Length - 2)); if (!m.Groups["image"].Value.Contains("coming_soon")) ret.Items.Add(e); if (ret.Items.Count > 0 && firstone) return; } } }
private async Task<Episode> GetEpisodeUpdate(CrunchySession s, Episode placeholder, string datetime) { try { WebStream ws = await WebStream.Get(placeholder.PluginMetadata["Url"], null, LibSet[UserAgentS], null, s.cookies.ToCookieCollection(), SocketTimeout,true,null,_info.ProxyFromGlobalRequirements(_global)); if (ws != null && ws.StatusCode == HttpStatusCode.OK) { if (!VerifyLogin(ws.Cookies)) { ws?.Dispose(); return null; } StreamReader rd = new StreamReader(ws); string dta = rd.ReadToEnd(); rd.Dispose(); Episodes eps = new Episodes(); eps.Items = new List<Episode>(); Show show = new Show(); show.PluginName = placeholder.PluginName; show.Id = placeholder.ShowId; MatchCollection scol = seasonregex.Matches(dta); int seasonnum = scol.Count; if (scol.Count == 0) { AddEpisodes(eps, show, dta, String.Empty, 1, true); } else { Match sma = scol[0]; if (sma.Success) { string data = sma.Value; string seasoname = sma.Groups["season"].Value; AddEpisodes(eps, show, data, seasoname, seasonnum, true); } } if (eps.Items.Count == 0) { ws?.Dispose(); return null; } Episode ep = eps.Items[0]; placeholder.PluginMetadata["Url"] = ep.PluginMetadata["Url"]; placeholder.ImageUri = ep.ImageUri; placeholder.Description = ep.Description; placeholder.EpisodeAlpha = ep.EpisodeAlpha; placeholder.EpisodeNumeric = ep.EpisodeNumeric; placeholder.Id = ep.Id; placeholder.SeasonAlpha = ep.SeasonAlpha; placeholder.SeasonNumeric = ep.SeasonNumeric; placeholder.Name = ep.Name; placeholder.DateTime = datetime; UpdateHistory.Add(placeholder.UniqueTag, JsonConvert.SerializeObject(placeholder)); ws?.Dispose(); return placeholder; } } catch (Exception ) { return null; } return null; }
public async Task<Episodes> Episodes(ISession session, Show show) { try { CrunchySession s = session as CrunchySession; if (s == null) return new Episodes { ErrorMessage = "Invalid Session", Status = ResponseStatus.InvalidArgument }; if (!show.PluginMetadata.ContainsKey("Url")) return new Episodes { ErrorMessage = "Invalid Show", Status = ResponseStatus.InvalidArgument }; Episodes ret = new Episodes(); ret.Items = new List<Episode>(); WebStream ws = await WebStream.Get(show.PluginMetadata["Url"], null, LibSet[UserAgentS], null, s.cookies.ToCookieCollection(), SocketTimeout, true, null, _info.ProxyFromGlobalRequirements(_global)); if (ws != null && ws.StatusCode == HttpStatusCode.OK) { if (!VerifyLogin(ws.Cookies)) SetLoginError(ret); else { StreamReader rd = new StreamReader(ws); string dta = rd.ReadToEnd(); rd.Dispose(); ret.Status = ResponseStatus.Ok; ret.Items = new List<Episode>(); Match sm = epsshowimage.Match(dta); if (sm.Success) ret.ImageUri = new Uri(sm.Groups["image"].Value); MatchCollection scol = seasonregex.Matches(dta); int seasonnum = scol.Count; if (scol.Count == 0) { AddEpisodes(ret, show, dta, String.Empty, 1); } else { foreach (Match sma in scol) { if (sma.Success) { string data = sma.Value; string seasoname = sma.Groups["season"].Value; AddEpisodes(ret, show, data, seasoname, seasonnum); } seasonnum--; } } int index = ret.Items.Count; for (int x = 0; x < ret.Items.Count; x++) { ret.Items[x].Index = index; index--; } ret.Items.Reverse(); } } else { SetWebError(ret); } ws?.Dispose(); return ret; } catch (Exception e) { return new Episodes {ErrorMessage = e.ToString(), Status = ResponseStatus.SystemError}; } }
public async Task<Shows> Shows(ISession session, ShowType type) { try { CrunchySession s = session as CrunchySession; if (s == null) return new Shows { ErrorMessage = "Invalid Session", Status = ResponseStatus.InvalidArgument }; Shows ret = new Shows(); ret.Items = new List<Show>(); string url = string.Format(LibSet[ShowUrlS], ShowFromType(type)); WebStream ws = await WebStream.Get(url,null,LibSet[UserAgentS],null,s.cookies.ToCookieCollection(),SocketTimeout,true,null,_info.ProxyFromGlobalRequirements(_global)); if (ws != null && ws.StatusCode == HttpStatusCode.OK) { if (!VerifyLogin(ws.Cookies)) SetLoginError(ret); else { StreamReader rd = new StreamReader(ws); string dta = rd.ReadToEnd(); rd.Dispose(); MatchCollection col = showregex.Matches(dta); Dictionary<string, Show> ls = new Dictionary<string, Show>(); foreach (Match m in col) { if (m.Success) { Show cs = new Show(); cs.Id = int.Parse(m.Groups["id"].Value).ToString(); if (!ls.ContainsKey(cs.Id)) { cs.Name = m.Groups["title"].Value; cs.Type = type; cs.PluginName = CrunchyPluginInfo.PluginName; cs.PluginMetadata.Add("Url", new Uri("http://www.crunchyroll.com" + m.Groups["url"].Value).ToString()); ls.Add(cs.Id, cs); } } } col = show2regex.Matches(dta); foreach (Match m in col) { if (m.Success) { string id = int.Parse(m.Groups["id"].Value).ToString(); Show ccd = ls[id]; ccd.Description = Regex.Unescape(m.Groups["desc"].Value); } } ret.Items = ls.Values.OrderBy(a => a.Name).Cast<Show>().ToList(); ret.Status = ResponseStatus.Ok; } } else { SetWebError(ret); } ws?.Dispose(); return ret; } catch (Exception e) { return new Shows {ErrorMessage = e.ToString(), Status = ResponseStatus.SystemError}; } }
public async Task<Episodes> Episodes(ISession session, Show show) { try { DaiSukiSession s = session as DaiSukiSession; if (s == null) return new Episodes { ErrorMessage = "Invalid Session", Status = ResponseStatus.InvalidArgument }; if (!show.PluginMetadata.ContainsKey("Url")) return new Episodes { ErrorMessage = "Invalid Show", Status = ResponseStatus.InvalidArgument }; Episodes ret = new Episodes(); ret.Items = new List<Episode>(); WebStream ws = await WebStream.Get(show.PluginMetadata["Url"], null, LibSet[UserAgentS], null, s.cookies.ToCookieCollection(), SocketTimeout, true, null, _info.ProxyFromGlobalRequirements(_global)); if (ws != null && ws.StatusCode == HttpStatusCode.OK) { if (!VerifyLogin(ws.Cookies)) SetLoginError(ret); else { StreamReader rd = new StreamReader(ws); string dta = rd.ReadToEnd(); rd.Dispose(); ret.Status = ResponseStatus.Ok; ret.Items = new List<Episode>(); ret.ImageUri = new Uri(LibSet[ImageServerS] + "/img/series/" + show.Id + "/340_506.jpg"); Match sm = showregex.Match(dta); if (sm.Success) { ret.Items.Add(GetEpisode(show, sm)); } MatchCollection scol = show2regex.Matches(dta); foreach (Match sma in scol) { if (sma.Success) { ret.Items.Add(GetEpisode(show, sma)); } } ret.Items = ret.Items.OrderBy(a => a.EpisodeNumeric).ToList(); for (int x = 0; x < ret.Items.Count; x++) { ret.Items[x].Index = x + 1; } } } else { SetWebError(ret); } ws?.Dispose(); return ret; } catch (Exception e) { return new Episodes { ErrorMessage = e.ToString(), Status = ResponseStatus.SystemError }; } }
private Episode GetEpisode(Show s, Match m) { var ep=new Episode(); string imgurl = "http://www.daisuki.net/"+m.Groups["image"].Value; ep.ImageUri=new Uri(imgurl); int r = imgurl.LastIndexOf("/"); if (r >= 0) { int n = imgurl.LastIndexOf("/", r - 1); if (n >= 0) { ep.Id = imgurl.Substring(n + 1, r - n - 1); } } ep.EpisodeAlpha = m.Groups["episode"].Value; ep.SeasonNumeric = 0; ep.SeasonAlpha = string.Empty; ep.EpisodeNumeric = 0; int val = 0; if (int.TryParse(ep.EpisodeAlpha,out val)) ep.EpisodeNumeric = val; ep.Name = "Episode " + ep.EpisodeAlpha; ep.PluginName = DaiSukiPluginInfo.PluginName; string nam = s.PluginMetadata["Url"]; r = nam.LastIndexOf("/"); nam = nam.Substring(r + 1); string url = string.Format("http://www.daisuki.net/us/en/anime/watch.{0}.{1}.html",nam,ep.Id); ep.PluginMetadata.Add("Url", url); ep.ShowId = s.Id; ep.ShowName = s.Name; ep.Type = s.Type; return ep; }
private async Task<Shows> Shows(ISession session, bool order) { try { DaiSukiSession s = session as DaiSukiSession; if (s == null) return new Shows { ErrorMessage = "Invalid Session", Status = ResponseStatus.InvalidArgument }; Shows ret = new Shows(); ret.Items = new List<Show>(); WebStream ws = await WebStream.Get("http://www.daisuki.net/bin/wcm/searchAnimeAPI?api=anime_list&searchOptions=¤tPath=%2Fcontent%2Fdaisuki%2Fus%2Fen", null, LibSet[UserAgentS], null, s.cookies.ToCookieCollection(), SocketTimeout, true, null, _info.ProxyFromGlobalRequirements(_global)); if (ws != null && ws.StatusCode == HttpStatusCode.OK) { if (!VerifyLogin(ws.Cookies)) SetLoginError(ret); else { StreamReader rd = new StreamReader(ws); string dta = rd.ReadToEnd(); BaseResponse<Anime> animes = JsonConvert.DeserializeObject<BaseResponse<Anime>>(dta); rd.Dispose(); if (animes.Response == null || animes.Response.Count == 0) { if (animes.Error != null) { ret.ErrorMessage = animes.Error; ret.Status=ResponseStatus.WebError; return ret; } SetWebError(ret); ws?.Dispose(); return ret; } foreach (Anime a in animes.Response) { Show cs=new Show(); cs.PluginName = DaiSukiPluginInfo.PluginName; cs.Id = a.Id.ToString(); cs.Type=ShowType.Anime; cs.Description = a.Synopsis; cs.Name = a.Title; cs.PluginMetadata.Add("Url", new Uri("http://www.daisuki.net/anime/detail/"+a.AdId).ToString()); ret.Items.Add(cs); } if (order) ret.Items = ret.Items.OrderBy(a => a.Name).ToList(); ret.Status = ResponseStatus.Ok; } } else { SetWebError(ret); } ws?.Dispose(); return ret; } catch (Exception e) { return new Shows { ErrorMessage = e.ToString(), Status = ResponseStatus.SystemError }; } }
public async Task <Episodes> Episodes(string plugin, Show show) { return(await AuthWrapper(plugin, async (plg, session) => await plg.Episodes(session, show))); }