diff --git a/.gitignore b/.gitignore index 88f2554..15813be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -node_modules package-lock.json -*.mp4 -*.mp3 +node_modules/ diff --git a/LICENSE b/LICENSE index 1e05c1f..3476190 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Benjamin Kyd +Copyright (c) 2020 Benjamin Kyd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/index.js b/index.js index a62267f..7120b8a 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -require('./src/index').main(); +import('./src/index').main(); \ No newline at end of file diff --git a/legacy/.gitignore b/legacy/.gitignore index ad46b30..88f2554 100644 --- a/legacy/.gitignore +++ b/legacy/.gitignore @@ -1,61 +1,4 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# next.js build output -.next +node_modules +package-lock.json +*.mp4 +*.mp3 diff --git a/legacy/index.js b/legacy/index.js index 921a7a3..a62267f 100644 --- a/legacy/index.js +++ b/legacy/index.js @@ -1,40 +1 @@ -const fs = require('fs'); -const ytdl = require('ytdl-core'); - -let videos = []; - -if (!fs.existsSync('./videos.txt')) { - console.log('Could not find videos.txt, make sure it exists and has youtube links, each on new lines'); - process.exit(); -} - -let text = fs.readFileSync('./videos.txt').toString(); -text.split('\n').forEach((line) => { - videos.push(line.replace(/\r/, '')); -}); - -videos.forEach((url) => { - if (ytdl.validateURL(url)) { - ytdl.getInfo(url, (err, info) => { - if (err) { - console.log(`An error occured while downloading '${url}'`) - } else { - let title = info.title; - - try { - let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`)); - stream.on('finish', () => console.log(`Finish downloading ${title}`)); - } catch (e) { - console.log(`An error occured while downloaing '${title}' retrying`) - try { - let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`)); - stream.on('finish', () => console.log(`Finished downloading '${title}'`)); - } catch (e) { - console.log(`Unable to download '${title}'`) - } - } - console.log(`Downloading '${title}'`); - } - }) - } else console.log(`Video ${url} was not found`); -}); +require('./src/index').main(); diff --git a/legacy/.gitattributes b/legacy/legacy/.gitattributes similarity index 100% rename from legacy/.gitattributes rename to legacy/legacy/.gitattributes diff --git a/legacy/legacy/.gitignore b/legacy/legacy/.gitignore new file mode 100644 index 0000000..ad46b30 --- /dev/null +++ b/legacy/legacy/.gitignore @@ -0,0 +1,61 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next diff --git a/legacy/LICENSE b/legacy/legacy/LICENSE similarity index 100% rename from legacy/LICENSE rename to legacy/legacy/LICENSE diff --git a/legacy/legacy/index.js b/legacy/legacy/index.js new file mode 100644 index 0000000..921a7a3 --- /dev/null +++ b/legacy/legacy/index.js @@ -0,0 +1,40 @@ +const fs = require('fs'); +const ytdl = require('ytdl-core'); + +let videos = []; + +if (!fs.existsSync('./videos.txt')) { + console.log('Could not find videos.txt, make sure it exists and has youtube links, each on new lines'); + process.exit(); +} + +let text = fs.readFileSync('./videos.txt').toString(); +text.split('\n').forEach((line) => { + videos.push(line.replace(/\r/, '')); +}); + +videos.forEach((url) => { + if (ytdl.validateURL(url)) { + ytdl.getInfo(url, (err, info) => { + if (err) { + console.log(`An error occured while downloading '${url}'`) + } else { + let title = info.title; + + try { + let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`)); + stream.on('finish', () => console.log(`Finish downloading ${title}`)); + } catch (e) { + console.log(`An error occured while downloaing '${title}' retrying`) + try { + let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`)); + stream.on('finish', () => console.log(`Finished downloading '${title}'`)); + } catch (e) { + console.log(`Unable to download '${title}'`) + } + } + console.log(`Downloading '${title}'`); + } + }) + } else console.log(`Video ${url} was not found`); +}); diff --git a/legacy/legacy/package.json b/legacy/legacy/package.json new file mode 100644 index 0000000..2b8be26 --- /dev/null +++ b/legacy/legacy/package.json @@ -0,0 +1,15 @@ +{ + "name": "youtube-dowloader", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Ben (plane000)", + "license": "MIT", + "dependencies": { + "fs": "0.0.1-security", + "ytdl-core": "^0.21.1" + } +} diff --git a/legacy/videos.txt b/legacy/legacy/videos.txt similarity index 100% rename from legacy/videos.txt rename to legacy/legacy/videos.txt diff --git a/legacy/package-lock.json b/legacy/package-lock.json deleted file mode 100644 index 06a5410..0000000 --- a/legacy/package-lock.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "youtube-dowloader", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "fs": { - "version": "0.0.1-security", - "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", - "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" - }, - "html-entities": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", - "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" - }, - "m3u8stream": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.3.0.tgz", - "integrity": "sha512-0tvjXDIa6BolPEGo9zioQiPqfQhjopZXN3L7vZH/rZQCOLd4rPXNZc1UBMdW3TRpjNBoD0+F1X41/f0iY23rlQ==", - "requires": { - "miniget": "1.2.0" - } - }, - "miniget": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz", - "integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE=" - }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, - "ytdl-core": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.21.1.tgz", - "integrity": "sha512-K6ysXuHW0X3MgeLpO4IHvHp5gdF2DDrgFPP7kQODBSpeaq4+/y8lvWy6ZpxtJdQGE0+GUaBZ2H1/kYcP327UdQ==", - "requires": { - "html-entities": "1.2.1", - "m3u8stream": "0.3.0", - "miniget": "1.2.0", - "sax": "1.2.4" - } - } - } -} diff --git a/legacy/package.json b/legacy/package.json index 2b8be26..f449945 100644 --- a/legacy/package.json +++ b/legacy/package.json @@ -1,15 +1,19 @@ { - "name": "youtube-dowloader", + "name": "youtube-downloader", "version": "1.0.0", "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "main": "main.js", + "repository": { + "type": "git", + "url": "git+https://github.com/plane000/youtube-downloader.git" }, "author": "Ben (plane000)", "license": "MIT", + "devDependencies": {}, "dependencies": { - "fs": "0.0.1-security", - "ytdl-core": "^0.21.1" + "express": "^4.16.4", + "moment": "^2.23.0", + "socket.io": "^2.2.0", + "ytdl-core": "^0.28.3" } } diff --git a/public/favicon.ico b/legacy/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to legacy/public/favicon.ico diff --git a/public/index.html b/legacy/public/index.html similarity index 100% rename from public/index.html rename to legacy/public/index.html diff --git a/public/index.js b/legacy/public/index.js similarity index 100% rename from public/index.js rename to legacy/public/index.js diff --git a/public/resources/YouTube Logo.png b/legacy/public/resources/YouTube Logo.png similarity index 100% rename from public/resources/YouTube Logo.png rename to legacy/public/resources/YouTube Logo.png diff --git a/public/style.css b/legacy/public/style.css similarity index 100% rename from public/style.css rename to legacy/public/style.css diff --git a/resources/YouTube Logo.png b/legacy/resources/YouTube Logo.png similarity index 100% rename from resources/YouTube Logo.png rename to legacy/resources/YouTube Logo.png diff --git a/legacy/src/index.js b/legacy/src/index.js new file mode 100644 index 0000000..c393c27 --- /dev/null +++ b/legacy/src/index.js @@ -0,0 +1,13 @@ +const server = require('./server'); + +let config = { + serverPort: 8080, + downloadLocation: './' +}; + +module.exports.config = config; + +module.exports.main = async () => { + await server.init(); + await server.listen(); +} diff --git a/src/server.js b/legacy/src/server.js similarity index 100% rename from src/server.js rename to legacy/src/server.js diff --git a/src/youtubehelper.js b/legacy/src/youtubehelper.js similarity index 100% rename from src/youtubehelper.js rename to legacy/src/youtubehelper.js diff --git a/package.json b/package.json index f449945..807bf3b 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,22 @@ { "name": "youtube-downloader", "version": "1.0.0", - "description": "", - "main": "main.js", + "description": "Simple to use youtube downloader, simply run the index javascript file with node and then go to localhost on your browser, by default the video will download to this folder but can be changed in src/index.js", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, "repository": { "type": "git", "url": "git+https://github.com/plane000/youtube-downloader.git" }, - "author": "Ben (plane000)", + "author": "Ben (benjaminkyd@gmail.com)", "license": "MIT", - "devDependencies": {}, + "bugs": { + "url": "https://github.com/plane000/youtube-downloader/issues" + }, + "homepage": "https://github.com/plane000/youtube-downloader#readme", "dependencies": { - "express": "^4.16.4", - "moment": "^2.23.0", - "socket.io": "^2.2.0", - "ytdl-core": "^0.28.3" + "moment": "^2.26.0" } } diff --git a/src/index.js b/src/index.js index c393c27..9c99ce9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,13 +1,6 @@ -const server = require('./server'); -let config = { - serverPort: 8080, - downloadLocation: './' -}; -module.exports.config = config; - -module.exports.main = async () => { - await server.init(); - await server.listen(); +module.exports.main = async function() +{ + }