Inheritance: Response
        private async void objShows_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((objShows.SelectedIndex != -1) && (_lastshowindex != objShows.SelectedIndex))
            {
                SetBusy(objEpisode, true);
                Show s = (Show)objShows.SelectedObject;
                labShowDescription.Text = s.Description;
                _selected_episodes = await DownloadPluginHandler.Instance.Episodes(s.PluginName, s);
                if (_selected_episodes.Status == ResponseStatus.Ok)
                {
                    objEpisode.Items.Clear();
                    _lastepisodeindex = -1;
                    labEpisodeDescription.Text = string.Empty;
                    pictEpisode.Image = null;
                    if ((_selected_episodes.Items.Any(a => a.SeasonAlpha != string.Empty)))
                    {
                        objEpisode.ShowGroups = true;
                        colEpisodeSeason.IsVisible = true;
                        objEpisode.RebuildColumns();
                        objEpisode.SetObjects(_selected_episodes.Items);
                        objEpisode.BuildGroups(colEpisodeSeason, SortOrder.Ascending);
                        objEpisode.BuildList(true);
                    }
                    else
                    {
                        colEpisodeSeason.IsVisible = false;
                        objEpisode.Groups.Clear();
                        objEpisode.ShowGroups = false;
                        objEpisode.RebuildColumns();
                        objEpisode.SetObjects(_selected_episodes.Items);
                        objEpisode.BuildList(true);
                    }
                    if (_selected_episodes.ImageUri != null)
                        picShow.LoadAsync(_selected_episodes.ImageUri.ToString());
                    if (_selected_episodes.Items.Count > 0)
                        objEpisode.SelectedIndex = 0;

                }
                SetBusy(objEpisode, false);

            }
        }
 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);
             }
         }
     }
 }
Esempio n. 3
0
 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;
         }
     }
 }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 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};
     }
     
 }
Esempio n. 6
0
        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 };
            }
        }