mirror of
				https://codeberg.org/ashley/poke
				synced 2025-07-17 16:52:11 +00:00 
			
		
		
		
	new version!
This commit is contained in:
		
							parent
							
								
									dbf91956f7
								
							
						
					
					
						commit
						68eee14649
					
				
							
								
								
									
										33
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								server.js
									
									
									
									
									
								
							| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|     Copyright (C) 2021-2022 POKETUBE CONTRUBUTORS (https://github.com/iamashley0/poketube)
 | ||||
|     Copyright (C) 2021-2022 POKETUBE (https://github.com/iamashley0/poketube)
 | ||||
|      | ||||
|     This program is free software: you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
| @ -17,10 +17,13 @@ | ||||
| const path = require("path"); | ||||
| const moment = require("moment"); | ||||
| const templateDir = path.resolve(`${process.cwd()}${path.sep}html`); | ||||
| 
 | ||||
| var express = require("express"); | ||||
| var app = express(); | ||||
| app.engine("html", require("ejs").renderFile); | ||||
| app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded
 | ||||
| var dislike_api = `https://returnyoutubedislikeapi.com/votes?videoId=` | ||||
| 
 | ||||
| app.set("view engine", "html"); | ||||
| const lyricsFinder = require("./src/lyrics.js"); | ||||
| const renderTemplate = async (res, req, template, data = {}) => { | ||||
| @ -29,6 +32,7 @@ const renderTemplate = async (res, req, template, data = {}) => { | ||||
|     Object.assign(data) | ||||
|   ); | ||||
| }; | ||||
| 
 | ||||
| const random_words = [ | ||||
|   "banana pie", | ||||
|   "how to buy an atom bomb", | ||||
| @ -42,6 +46,7 @@ const random_words = [ | ||||
| ] | ||||
| const fetch = require("node-fetch"); | ||||
| const fetcher = require("./src/fetcher.js"); | ||||
|   | ||||
| app.get("/watch", async function (req, res) { | ||||
|   var v = req.query.v; | ||||
|   var e = req.query.e; | ||||
| @ -69,20 +74,24 @@ if (j_.URL != undefined) | ||||
|     lyrics: lyrics.replace(/\n/g, " <br> "), | ||||
|   }); | ||||
| }); | ||||
|   | ||||
|   | ||||
| app.get("/", function (req, res) { | ||||
|   const things = random_words[Math.floor((Math.random()*random_words.length))]; | ||||
|   renderTemplate(res, req, "ytmain.ejs", { | ||||
|   random:things, | ||||
| });}); | ||||
| app.get("/channel", function (req, res) { | ||||
|   renderTemplate(res, req, "channel.ejs"); | ||||
|     const ID = req.query.id; | ||||
|   renderTemplate(res, req, "channel.ejs", { | ||||
|   ID:ID, | ||||
| });}); | ||||
| app.get("/privacy", function (req, res) { | ||||
|   renderTemplate(res, req, "priv.ejs"); | ||||
| }); | ||||
| app.get("/domains", function (req, res) { | ||||
|   renderTemplate(res, req, "domains.ejs"); | ||||
| }); | ||||
| app.get("/privacy", function (req, res) { | ||||
|   renderTemplate(res, req, "priv.ejs"); | ||||
| }); | ||||
| app.get("/api/search", async (req, res) => { | ||||
|   const query = req.query.query; | ||||
| 
 | ||||
| @ -94,15 +103,27 @@ app.get("/api/search", async (req, res) => { | ||||
| app.get("/css/:id", (req, res) => { | ||||
|   res.sendFile(__dirname + `/css/${req.params.id}`); | ||||
| }); | ||||
| app.get("/js/:id", (req, res) => { | ||||
|   res.sendFile(__dirname + `/js/${req.params.id}`); | ||||
| }); | ||||
| app.get("/video/upload", (req, res) => { | ||||
|            res.redirect("https://youtube.com/upload?from=poketube_utc"); | ||||
|  }); | ||||
| app.get("/api/video/download", async function (req, res) { | ||||
|   var v = req.query.v;var fetching = await fetcher(v);const url = fetching.video.Player.Formats.Format[1].URL;res.redirect(url) | ||||
|  }); | ||||
| app.get("/api/video/downloadjson", async function (req, res) { | ||||
|   var v = req.query.v;var fetching = await fetcher(v);const url = fetching.video.Player.Formats.Format[1].URL;res.json(url) | ||||
|  }); | ||||
| 
 | ||||
|   | ||||
|  app.get("*", function (req, res) { | ||||
| const things = random_words[Math.floor((Math.random()*random_words.length))]; | ||||
|   renderTemplate(res, req, "404.ejs", { | ||||
|   random:things, | ||||
| });}); | ||||
| const listener = app.listen(3000); | ||||
|   | ||||
| 
 | ||||
| 
 | ||||
| app.listen("3000", () => { | ||||
| }) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ashley
						Ashley