public static IWebProxy ProxyFromGlobalRequirements(this DownloadPluginInfo pinfo, Dictionary <string, object> globalmetadata) { if (globalmetadata == null) { return(null); } NetworkCredential nt = null; bool?enabled = globalmetadata.GetBoolFromMetadata(DownloadPluginInfo.ProxyEnabled); if (enabled.HasValue && enabled.Value) { string proxyaddress = globalmetadata.GetStringFromMetadata(DownloadPluginInfo.ProxyAddress); int? proxyport = globalmetadata.GetIntFromMetadata(DownloadPluginInfo.ProxyPort); string proxyusername = globalmetadata.GetStringFromMetadata(DownloadPluginInfo.ProxyUsername); string proxypassword = globalmetadata.GetStringFromMetadata(DownloadPluginInfo.ProxyPassword); if (!string.IsNullOrEmpty(proxyusername) || !string.IsNullOrEmpty(proxypassword)) { nt = new NetworkCredential(proxyusername, proxypassword); } UriBuilder bld = new UriBuilder(proxyaddress); bld.Port = proxyport.Value; return(new WebProxy(bld.Uri, false, null, nt)); } return(null); }
public static async Task <Response> VerifyBaseAuthentication(this DownloadPluginInfo pinfo, Dictionary <string, object> authmetadata) { return(await Task.Run(() => { Response r = VerifyRequiredKeys(authmetadata, pinfo.AuthenticationRequirements); if (r.Status != ResponseStatus.Ok) { return r; } if (VerifyRequirementsList(pinfo.AuthenticationRequirements, DownloadPluginInfo.Username, DownloadPluginInfo.Password)) { string username = authmetadata.GetStringFromMetadata(DownloadPluginInfo.Username); if (string.IsNullOrEmpty(username)) { return new Response { ErrorMessage = "'" + DownloadPluginInfo.Username + "' is required", Status = ResponseStatus.MissingRequirement } } ; string password = authmetadata.GetStringFromMetadata(DownloadPluginInfo.Password); if (string.IsNullOrEmpty(password)) { return new Response { ErrorMessage = "'" + DownloadPluginInfo.Password + "' is required", Status = ResponseStatus.MissingRequirement } } ; } return r; })); }
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); }
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 async Task <Response> SetRequirements(Dictionary <string, object> globalmetadata) { try { Response r = await _info.VerifyGlobalRequirements(globalmetadata); if (r.Status == ResponseStatus.Ok) { string FFMPEGPath = globalmetadata.GetStringFromMetadata(DaiSukiPluginInfo.FFMPEGPath); string RTMPDumpPath = globalmetadata.GetStringFromMetadata(DaiSukiPluginInfo.RTMPDumpPath); if (string.IsNullOrEmpty(FFMPEGPath)) { r.Status = ResponseStatus.MissingRequirement; r.ErrorMessage = "'" + DaiSukiPluginInfo.FFMPEGPath + "' Path is missing."; return(r); } if (string.IsNullOrEmpty(RTMPDumpPath)) { r.Status = ResponseStatus.MissingRequirement; r.ErrorMessage = "'" + DaiSukiPluginInfo.RTMPDumpPath + "' Path is missing."; return(r); } if (!File.Exists(FFMPEGPath)) { r.Status = ResponseStatus.InvalidArgument; r.ErrorMessage = "'" + DaiSukiPluginInfo.FFMPEGPath + "' Path is not valid."; } if (!File.Exists(RTMPDumpPath)) { r.Status = ResponseStatus.InvalidArgument; r.ErrorMessage = "'" + DaiSukiPluginInfo.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 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 }; 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 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 static async Task <Response> VerifyGlobalRequirements(this DownloadPluginInfo pinfo, Dictionary <string, object> globalmetadata) { Response r = VerifyRequiredKeys(globalmetadata, pinfo.GlobalRequirements); if (r.Status != ResponseStatus.Ok) { return(r); } if (VerifyRequirementsList(pinfo.GlobalRequirements, DownloadPluginInfo.ProxyEnabled, DownloadPluginInfo.ProxyAddress, DownloadPluginInfo.ProxyPort, DownloadPluginInfo.ProxyUsername, DownloadPluginInfo.ProxyPassword)) { bool?enabled = globalmetadata.GetBoolFromMetadata(DownloadPluginInfo.ProxyEnabled); if (enabled.HasValue && enabled.Value) { string address = globalmetadata.GetStringFromMetadata(DownloadPluginInfo.ProxyAddress); if (string.IsNullOrEmpty(address)) { return new Response { ErrorMessage = "'" + DownloadPluginInfo.ProxyAddress + "' is invalid", Status = ResponseStatus.MissingRequirement } } ; int?port = globalmetadata.GetIntFromMetadata(DownloadPluginInfo.ProxyPort); if (!port.HasValue) { return new Response { ErrorMessage = "'" + DownloadPluginInfo.ProxyPort + "' is invalid", Status = ResponseStatus.MissingRequirement } } ; if (port.Value < 1 || port.Value > 65534) { return new Response { ErrorMessage = "'" + DownloadPluginInfo.ProxyPort + "' is invalid", Status = ResponseStatus.InvalidArgument } } ; IpInfo ipnfo = null; IWebProxy proxy = pinfo.ProxyFromGlobalRequirements(globalmetadata); if (proxy == null) { return new Response { ErrorMessage = "Unable to create proxy", Status = ResponseStatus.InvalidArgument } } ; WebStream s = await WebStream.Get("http://ipinfo.io/json", null, null, null, null, 10000, false, null, proxy); if (s != null && s.StatusCode == HttpStatusCode.OK) { StreamReader reader = new StreamReader(s, Encoding.UTF8); string json = reader.ReadToEnd(); ipnfo = JsonConvert.DeserializeObject <IpInfo>(json); reader.Dispose(); } s?.Dispose(); if ((s == null) || (s.StatusCode != HttpStatusCode.OK)) { return new Response { ErrorMessage = "Unable to Connect", Status = ResponseStatus.InvalidArgument } } ; r.ErrorMessage = "IP: " + ipnfo.ip + " " + ipnfo.city + "/" + ipnfo.country; } } return(r); }
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; }