Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

move to client/

Christian Fei5a618e5f3efd
diff --git a/index.html b/client/index.html
similarity index 100%
rename from index.html
rename to client/index.html
diff --git a/main.css b/client/main.css
similarity index 100%
rename from main.css
rename to client/main.css
diff --git a/main.js b/client/main.js
similarity index 100%
rename from main.js
rename to client/main.js
diff --git a/lib/server.js b/lib/server.js
index 724b260..eb72ed5 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -34,16 +34,17 @@ export function createServer ({repo, port = 3000, connections = []}) {
if (parsedUrl.pathname.match('\/videos\/.*') && req.method === 'GET')
return watchVideoHandler(req, res)
if (parsedUrl.pathname === '/main.css')
- return fileHandler('main.css', 'text/css')
+ return fileHandler('client/main.css', 'text/css')(req, res)
if (parsedUrl.pathname === '/main.js')
- return fileHandler('main.js', 'application/javascript')
- return fileHandler('index.html', 'text/html')
+ return fileHandler('client/main.js', 'application/javascript')(req, res)
+ return fileHandler('client/index.html', 'text/html')(req, res)
})
function fileHandler (filePath, contentType) {
- res.writeHead(200, { 'Content-Type': contentType })
- res.end(fs.readFileSync(filePath, 'utf8'))
- return
+ return (req, res) => {
+ res.writeHead(200, { 'Content-Type': contentType })
+ res.end(fs.readFileSync(filePath, 'utf8'))
+ }
}
function addChannelHandler(req, res) {
diff --git a/lib/youtube.js b/lib/youtube.js
index 01e364b..9f51e60 100644
--- a/lib/youtube.js
+++ b/lib/youtube.js
@@ -1,4 +1,5 @@
import { execa } from 'execa'
+import fs from 'fs'
export async function downloadVideo(id, repo, callback = () => {}) {
try {