private void manualButton_Click(object sender, EventArgs e) { BaseCDNModule module = moduleCombo.SelectedItem as BaseCDNModule; ContentSeries show = module.GetContentList(manualBox.Text); ChangeListing(show); }
private void ChangeListing(ContentSeries show) { listingBox.Items.Clear(); foreach (SeriesInstallment episode in show.Installments) { listingBox.Items.Add(new InstallmentBinding(episode)); } }
public string Request(string path, NameValueCollection query) { string[] pathing = path.Split('/'); string requestPath = string.Join("/", pathing, 1, pathing.Length - 1); string result = ""; string moduleName = pathing[0]; if (Modules.ContainsKey(moduleName)) { BaseCDNModule module = Modules[moduleName]; switch (requestPath) { case "browse": string queryString = query["query"]; int page = Convert.ToInt32(query["page"]); ContentSeriesInfo[] infos = module.Browse(queryString, page); result = string.Join("\n", (object[])infos); break; case "get_list": string listPath = query["path"]; ContentSeries series = module.GetContentList(listPath); result = series.Name + "\n" + string.Join("\n", (object[])series.Installments); break; case "get_link": string linkPath = query["path"]; result = string.Join("\n", (object[])module.GetContentLink(linkPath)); break; default: Console.WriteLine("-> Bad request: " + requestPath); break; } } return(result); }
static void Main(string[] args) { //Console.OutputEncoding = System.Text.Encoding.Unicode; CommandConsole console = new CommandConsole() { Prefix = "", PrintTimestamp = false, VerboseLevel = VerboseTag.Info }; bool running = true; Dictionary <string, BaseCDNModule> modules = new Dictionary <string, BaseCDNModule>(); LinkedList <ScriptedProvider> dynModules = new LinkedList <ScriptedProvider>(); modules.Add("dailymotion", new DailymotionModule("dailymotion")); modules.Add("youtube", new YoutubeModule("youtube")); modules.Add("vimeo", new ScriptedProvider("vimeo", "Modules\\vimeo.lua")); dynModules.AddLast((ScriptedProvider)modules["vimeo"]); //TODO: Add more modules here //Commands (TODO: package this better than anonymous functions) console.RegisterCommand("quit", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { running = false; }))); //console.RegisterCommand("exec", console.RegisterCommand("help", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { console.Print("List of functions:\n ->" + string.Join("\n ->", console.GetCommandList())); }))); console.RegisterCommand("list_modules", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { console.Print("Modules:\n ->" + string.Join("\n ->", modules.Keys.ToArray())); }))); console.RegisterCommand("load_module", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { if (eventArgs.Arguments.Length == 2) { modules.Add(eventArgs.Arguments[0], new ScriptedProvider(eventArgs.Arguments[0], eventArgs.Arguments[1])); } else { console.Print("Usage: load_module [name] [module_file]"); } }))); console.RegisterCommand("reload_module", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { if (eventArgs.Arguments.Length == 1) { ScriptedProvider module = modules[eventArgs.Arguments[0]] as ScriptedProvider; if (module != null) { module.Reload(); } } else { console.Print("Usage: reload_module [module]"); } }))); console.RegisterCommand("browse", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { if (eventArgs.Arguments.Length == 3) { console.Print(string.Join("\n", modules[eventArgs.Arguments[0]].Browse(eventArgs.Arguments[1], Convert.ToInt32(eventArgs.Arguments[2])).GetEnumerator())); } else { console.Print("Usage: browse [module] [type] [page]"); } }))); console.RegisterCommand("get_list", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { if (eventArgs.Arguments.Length == 2) { ContentSeries show = modules[eventArgs.Arguments[0]].GetContentList(eventArgs.Arguments[1]); console.Print(show.Name + "\n" + string.Join("\n", show.Installments.GetEnumerator())); } else { console.Print("Usage: get_list [module] [relative_path]"); } }))); console.RegisterCommand("get_link", new EventCommand(new Action <object, EventCmdArgs>((sender, eventArgs) => { if (eventArgs.Arguments.Length == 2) { console.Print(string.Join("\n", modules[eventArgs.Arguments[0]].GetContentLink(eventArgs.Arguments[1]).GetEnumerator())); } else { console.Print("Usage: get_link [module] [relative_path]"); } }))); EventCommandValue val = new EventCommandValue() { Value = "0" }; val.OnValueChange += new EventHandler <ValueArgs>((sender, eventArgs) => { foreach (ScriptedProvider module in dynModules) { if (eventArgs.NewValue == "1") { module.AssertErrors = true; } else if (eventArgs.NewValue == "0") { module.AssertErrors = false; } else { break; } } }); console.RegisterCommand("debug_module", val); //Runs the CLI arguments if there are any arguments, else the console goes into interactive mode if (args.Length != 0) { console.Call(string.Join(" ", args), false, true); } else { while (running) { console.Call(Console.ReadLine(), false, true); } } }
public SeriesBinding(ContentSeries show) : this() { Show = show; }
static void OldMain(string[] args) { Dictionary <string, BaseCDNModule> modules = new Dictionary <string, BaseCDNModule>(); modules.Add("dailymotion", new DailymotionModule("dailymotion")); modules.Add("youtube", new YoutubeModule("youtube")); if (Directory.Exists(".\\Modules\\")) { foreach (string file in Directory.GetFiles(".\\Modules\\")) { string name = Path.GetFileNameWithoutExtension(file); modules.Add(name, new ScriptedProvider(name, file)); Console.WriteLine("Loaded Module: " + name); } } client = new WebClient(); client.Encoding = Encoding.UTF8; HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://*:6672/"); listener.Start(); char[] pathSplit = { '/' }; while (listener.IsListening) { HttpListenerContext webContext = listener.GetContext(); webContext.Response.ContentEncoding = Encoding.UTF8; string[] pathing = webContext.Request.Url.LocalPath.Split(pathSplit, StringSplitOptions.RemoveEmptyEntries); //string requestType = string.Join("/", pathing, 1, pathing.Length - 1); string requestPath = string.Join("/", pathing); string moduleName = pathing[0]; Console.WriteLine("{0} - {1}: {2}", DateTime.Now, webContext.Request.RemoteEndPoint.Address, requestPath); bool sucess = false; if (modules.ContainsKey(moduleName)) { requestPath = string.Join("/", pathing, 1, pathing.Length - 1); BaseCDNModule module = modules[moduleName]; Console.WriteLine("-> Module " + moduleName); string result = null;// module.Request(requestPath, webContext.Request.QueryString); switch (requestPath) { case "browse": string query = webContext.Request.QueryString["query"]; int page = Convert.ToInt32(webContext.Request.QueryString["page"]); ContentSeriesInfo[] infos = module.Browse(query, page); result = string.Join("\n", (object[])infos); break; case "get_list": string listPath = webContext.Request.QueryString["path"]; ContentSeries series = module.GetContentList(listPath); result = series.Name + "\n" + string.Join("\n", (object[])series.Installments); break; case "get_link": string linkPath = webContext.Request.QueryString["path"]; result = string.Join("\n", (object[])module.GetContentLink(linkPath)); break; default: Console.WriteLine("-> Bad request: " + requestPath); break; } if (result != null) { byte[] data = Encoding.UTF8.GetBytes(result); sucess = WriteToOutputStream(data, webContext); } } webContext.Response.OutputStream.Close(); } }