Example #1
0
 public virtual void Init(Requirement r, Dictionary<string, object> meta)
 {
     Tag = new TagInfo {Req = r, Meta = meta};
     Text = meta.GetStringFromMetadata(r.Name) ?? string.Empty;
     Anchor = AnchorStyles.Left | AnchorStyles.Right;
     AutoSize = false;
     TextChanged += (a, b) =>
     {
         TagInfo m = (TagInfo) Tag;
         m.Meta[r.Name] = Text;
     };
 }
 public virtual void Init(Requirement r, Dictionary<string, object> meta)
 {
     Tag = new TagInfo { Req = r, Meta = meta };
     foreach (string op in r.Options)
         Items.Add(op);
     Anchor = AnchorStyles.Left | AnchorStyles.Right;
     AutoSize = false;
     DropDownStyle=ComboBoxStyle.DropDownList;
     SelectedIndexChanged += (a, b) =>
     {
         if (SelectedIndex != -1)
         {
             TagInfo m = (TagInfo)Tag;
             m.Meta[r.Name] = (string) SelectedItem;
         }
     };
     string def = meta.GetStringFromMetadata(r.Name);
     if (r.Options.Contains(def))
     {
         SelectedIndex = r.Options.IndexOf(def);
     }
 }
 public virtual void Init(Requirement r, Dictionary<string, object> meta)
 {
     Tag = new TagInfo { Req = r, Meta = meta };
     Anchor = AnchorStyles.Left | AnchorStyles.Right;
     AutoSize = false;
     Button but = new Button {Text = "...", Size = new Size(24, 23), Dock=DockStyle.Right};
     TextBox txt = new TextBox
     {
         Text = meta.GetStringFromMetadata(r.Name) ?? string.Empty,
         Anchor = AnchorStyles.Left | AnchorStyles.Right,
         Size = new Size(10, 20),
         Location = new Point(0, 2)
     };
     txt.TextChanged += (a, b) =>
     {
         TagInfo m = (TagInfo)Tag;
         m.Meta[m.Req.Name] = Text;
     };
     but.Click+=(a,b)=>
     {
         FolderBrowserDialog dialog=new FolderBrowserDialog();
         if (Directory.Exists(txt.Text))
             dialog.SelectedPath = txt.Text;
         DialogResult dl = dialog.ShowDialog();
         if (dl == DialogResult.OK)
         {
             if (Directory.Exists(dialog.SelectedPath))
                 txt.Text = dialog.SelectedPath;
         }
     };
     Panel fill = new Panel { Dock = DockStyle.Fill, Anchor = AnchorStyles.Left | AnchorStyles.Top, Size = new Size(10, 24) };
     fill.Controls.Add(txt);
     Panel spacer = new Panel { Size = new Size(10, 24), Dock = DockStyle.Right };
     Controls.Add(fill);
     Controls.Add(spacer);
     Controls.Add(but);
 }
        public async Task<Response> SetRequirements(Dictionary<string,object> globalmetadata)
        {
            try
            {
                Response r = await _info.VerifyGlobalRequirements(globalmetadata);
                if (r.Status == ResponseStatus.Ok)
                {
                    string FFMPEGPath = globalmetadata.GetStringFromMetadata(CrunchyPluginInfo.FFMPEGPath);
                    string RTMPDumpPath = globalmetadata.GetStringFromMetadata(CrunchyPluginInfo.RTMPDumpPath);
                    if (string.IsNullOrEmpty(FFMPEGPath))
                    {
                        r.Status = ResponseStatus.MissingRequirement;
                        r.ErrorMessage = "'" + CrunchyPluginInfo.FFMPEGPath + "' Path is missing.";
                        return r;
                    }
                    if (string.IsNullOrEmpty(RTMPDumpPath))
                    {
                        r.Status = ResponseStatus.MissingRequirement;
                        r.ErrorMessage = "'" + CrunchyPluginInfo.RTMPDumpPath + "' Path is missing.";
                        return r;
                    }
                    if (!File.Exists(FFMPEGPath))
                    {
                        r.Status = ResponseStatus.InvalidArgument;
                        r.ErrorMessage = "'" + CrunchyPluginInfo.FFMPEGPath + "' Path is not valid.";
                    }
                    if (!File.Exists(RTMPDumpPath))
                    {
                        r.Status = ResponseStatus.InvalidArgument;
                        r.ErrorMessage = "'" + CrunchyPluginInfo.RTMPDumpPath + "' Path is not valid.";
                    }
                }
                _global = r.Status == ResponseStatus.Ok ? globalmetadata : null;
                return r;
            }
            catch (Exception e)
            {
                return new Response {ErrorMessage = e.ToString(), Status = ResponseStatus.SystemError};
            }

        }
 public async Task<ISession> Authenticate(Dictionary<string,object> authenticationmetadata)
 {
     CrunchySession session = new CrunchySession();
     try
     {
         Response r = await _info.VerifyBaseAuthentication(authenticationmetadata);
         if (r.Status != ResponseStatus.Ok)
         {
             r.PropagateError(session);
             return session;
         }
         Dictionary<string, string> form = new Dictionary<string, string>();
         form.Add("formname", "RpcApiUser_Login");
         form.Add("fail_url", "http://www.crunchyroll.com/login");
         form.Add("name", authenticationmetadata.GetStringFromMetadata(DownloadPluginInfo.Username));
         form.Add("password", authenticationmetadata.GetStringFromMetadata(DownloadPluginInfo.Password));
         string postdata = form.PostFromDictionary();
         WebStream ws = await WebStream.Post("https://www.crunchyroll.com/?a=formhandler",form,null,LibSet[UserAgentS],null,null,SocketTimeout,false,null, _info.ProxyFromGlobalRequirements(_global));
         if (ws != null && ws.StatusCode == HttpStatusCode.Found)
         {
             ws.Cookies = await SetLocale(LocaleFromString(authenticationmetadata.GetStringFromMetadata(CrunchyPluginInfo.Language)), ws.Cookies);
             if (!VerifyLogin(ws.Cookies))
             {
                 session.Status = ResponseStatus.InvalidLogin;
                 session.ErrorMessage = "Invalid Account Information";
                 session.cookies = new Dictionary<string, string>();
             }
             else
             {
                 session.cookies = ws.Cookies.ToDictionary();
                 session.Status = ResponseStatus.Ok;
             }
         }
         else
         {
             SetWebError(session);
         }
         ws?.Dispose();
     }
     catch (Exception e)
     {
         session.Status=ResponseStatus.SystemError;
         session.ErrorMessage = e.ToString();
     }
     return session;
 }
        public async Task<ISession> Authenticate(Dictionary<string, object> authenticationmetadata)
        {
            _authmeta = authenticationmetadata;
            DaiSukiSession session = new DaiSukiSession();
            try
            {
                Response r = await _info.VerifyBaseAuthentication(authenticationmetadata);
                if (r.Status != ResponseStatus.Ok)
                {
                    r.PropagateError(session);
                    return session;
                }
                Dictionary<string, string> form = new Dictionary<string, string>();
                form.Add("emailAddress", authenticationmetadata.GetStringFromMetadata(DownloadPluginInfo.Username));
                form.Add("password", authenticationmetadata.GetStringFromMetadata(DownloadPluginInfo.Password));
                form.Add("keepLogin", "on");


                
                WebStream ws = await WebStream.Post("https://www.daisuki.net/bin/SignInServlet.html/input", form, null, LibSet[UserAgentS], null, null, SocketTimeout, true, "http://www.daisuki.net/", _info.ProxyFromGlobalRequirements(_global));
                if (ws != null && ws.StatusCode == HttpStatusCode.OK)
                {

                    if (!VerifyLogin(ws.Cookies))
                    {
                        session.Status = ResponseStatus.InvalidLogin;
                        session.ErrorMessage = "Invalid Account Information";
                        session.cookies = new Dictionary<string, string>();
                    }
                    else
                    {
                        session.cookies = ws.Cookies.ToDictionary();
                        session.Status = ResponseStatus.Ok;
                    }
                }
                else
                {
                    SetWebError(session);
                }
                ws?.Dispose();
            }
            catch (Exception e)
            {
                session.Status = ResponseStatus.SystemError;
                session.ErrorMessage = e.ToString();

            }
            return session;

        }