private async Task <Config> GetStandardConfig(CrunchySession token, string epid, Quality qlty) { KeyValuePair <string, string> vf = QualityConvert(qlty); Dictionary <string, string> form = new Dictionary <string, string>(); form.Add("req", "RpcApiVideoPlayer_GetStandardConfig"); form.Add("media_id", epid); form.Add("video_format", vf.Value); form.Add("video_quality", vf.Key); form.Add("auto_play", "1"); form.Add("show_pop_out_controls", "1"); form.Add("current_page", "http://www.crunchyroll.com/"); WebStream ws = await WebStream.Post("http://www.crunchyroll.com/xml/", form, null, LibSet[UserAgentS], null, token.cookies.ToCookieCollection(), SocketTimeout, true, "http://www.crunchyroll.com/swf/StandardVideoPlayer.swf", _info.ProxyFromGlobalRequirements(_global)); string dta = null; if (ws != null && ws.StatusCode == HttpStatusCode.OK) { StreamReader reader = new StreamReader(ws); string str = reader.ReadToEnd(); int be = str.IndexOf("<stream_info>", StringComparison.InvariantCulture); int en = str.IndexOf("</default:preload>", StringComparison.InvariantCulture); str = "<config>" + str.Substring(be, en - be) + "</config>"; XmlSerializer ser = new XmlSerializer(typeof(Config)); reader.Dispose(); ws.Dispose(); return((Config)ser.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(str)))); } ws?.Dispose(); return(null); }
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 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); }
private async Task <CookieCollection> SetLocale(string locale, CookieCollection cookies) { Dictionary <string, string> form = new Dictionary <string, string>(); form.Add("req", "RpcApiTranslation_SetLang"); form.Add("locale", "enUS"); WebStream ws = await WebStream.Post("http://www.crunchyroll.com/ajax/", form, null, LibSet[UserAgentS], null, cookies, SocketTimeout, false, null, _info.ProxyFromGlobalRequirements(_global)); if (ws != null && ws.StatusCode == HttpStatusCode.OK) { return(ws.Cookies); } return(new CookieCollection()); }
private async Task <CrunchySubtitleInfo> GetSubtitle(CrunchySession token, int subid) { Dictionary <string, string> form = new Dictionary <string, string>(); form.Add("req", "RpcApiSubtitle_GetXml"); form.Add("subtitle_script_id", subid.ToString()); WebStream ws = await WebStream.Post("http://www.crunchyroll.com/xml/", form, null, LibSet[UserAgentS], null, token.cookies.ToCookieCollection(), SocketTimeout, true, "http://www.crunchyroll.com/swf/StandardVideoPlayer.swf", _info.ProxyFromGlobalRequirements(_global)); string dta = null; if (ws.StatusCode == HttpStatusCode.OK) { XmlSerializer ser = new XmlSerializer(typeof(Subtitle)); Subtitle s = (Subtitle)ser.Deserialize(ws); CrunchySubtitleInfo si = new CrunchySubtitleInfo(); DecodeSubtitle(int.Parse(s.Id), s.Iv, s.Data, ref si); si.Language = ADBaseLibrary.Subtitles.Languages.CodeFromOriginalLanguage(si.Title); ws.Dispose(); return(si); } ws?.Dispose(); return(null); }