├── bin ├── permissions.sh └── youtube-exec.js ├── images └── logo.png ├── .github └── workflows │ └── node.js.yml ├── LICENSE ├── app ├── types │ └── index.d.ts ├── mjs │ └── index.mjs └── cjs │ └── index.js ├── src ├── types │ ├── audio.d.ts │ ├── video.d.ts │ ├── vid_aud.d.ts │ └── web.d.ts ├── mjs │ ├── web.mjs │ ├── video.mjs │ ├── audio.mjs │ └── vid_aud.mjs └── cjs │ ├── web.js │ ├── video.js │ ├── audio.js │ └── vid_aud.js ├── package.json ├── .npmignore ├── .gitignore ├── utils ├── logger.mjs ├── logger.js └── replace.js ├── test ├── audio.test.js ├── video.test.js ├── vid_aud.test.js └── web.test.js ├── client ├── audio.test.js ├── video.test.js ├── vid_aud.test.js └── web.test.js └── README.md /bin/permissions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod +x bin/youtube-exec.js -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magneum/youtube-exec/HEAD/images/logo.png -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ "main" ] 9 | pull_request: 10 | branches: [ "main" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [14.x, 16.x, 18.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v3 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | cache: 'npm' 29 | - run: npm ci 30 | - run: npm run build --if-present 31 | - run: npm test 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 magneum 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/types/index.d.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | /// 18 | /// 19 | /// 20 | /// 21 | -------------------------------------------------------------------------------- /app/mjs/index.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | import dlAudio from "../../src/mjs/audio.mjs"; 18 | import dlVideo from "../../src/mjs/video.mjs"; 19 | import streamAudio from "../../src/mjs/web.mjs"; 20 | import dlAudioVideo from "../../src/mjs/vid_aud.mjs"; 21 | 22 | export { dlAudio, streamAudio, dlAudioVideo, dlVideo }; 23 | -------------------------------------------------------------------------------- /src/types/audio.d.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | declare namespace dlAudio { 18 | type Quality = "best" | "low"; 19 | 20 | interface DownloadOptions { 21 | url: string; 22 | folder?: string; 23 | quality: Quality; 24 | filename?: string; 25 | } 26 | 27 | function dlAudio(options: DownloadOptions): Promise; 28 | } 29 | 30 | export = dlAudio; 31 | -------------------------------------------------------------------------------- /app/cjs/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const dlAudio = require("../../src/cjs/audio.js"); 18 | const dlVideo = require("../../src/cjs/video.js"); 19 | const streamAudio = require("../../src/cjs/web.js"); 20 | const dlAudioVideo = require("../../src/cjs/vid_aud.js"); 21 | 22 | module.exports = { 23 | dlAudio, 24 | streamAudio, 25 | dlVideo, 26 | dlAudioVideo, 27 | }; 28 | -------------------------------------------------------------------------------- /src/types/video.d.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | declare namespace dlVideo { 18 | type Resolution = 144 | 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320; 19 | 20 | interface DownloadOptions { 21 | url: string; 22 | folder?: string; 23 | filename?: string; 24 | resolution?: Resolution; 25 | } 26 | 27 | function dlVideo(options: DownloadOptions): Promise; 28 | } 29 | 30 | export = dlVideo; 31 | -------------------------------------------------------------------------------- /src/types/vid_aud.d.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | declare namespace dlAudioVideo { 18 | type Resolution = 144 | 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320; 19 | 20 | interface DownloadOptions { 21 | url: string; 22 | folder?: string; 23 | filename?: string; 24 | resolution?: Resolution; 25 | } 26 | 27 | function dlAudioVideo(options: DownloadOptions): Promise; 28 | } 29 | 30 | export = dlAudioVideo; 31 | -------------------------------------------------------------------------------- /src/types/web.d.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | declare namespace streamAudio { 18 | type Quality = "best" | "lowest"; 19 | 20 | interface StreamOptions { 21 | url: string; 22 | quality: Quality; 23 | res: any; 24 | } 25 | 26 | interface StreamResult { 27 | reqAudio: any; 28 | videoTitle: string; 29 | stream: any; 30 | } 31 | 32 | function streamAudio(options: StreamOptions): Promise; 33 | } 34 | 35 | export = streamAudio; 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "youtube-exec", 3 | "version": "1.0.3", 4 | "description": "YouTube-Exec is a versatile tool for downloading audio files from YouTube videos. It utilizes the youtube-dl-exec library to extract audio details and the fluent-ffmpeg library to download the audio files in MP3 format. With youtube-exec, you can easily fetch audio details, choose the desired audio quality, and download the audio file to your specified location.", 5 | "main": "./app/cjs/index.js", 6 | "module": "./app/mjs/index.mjs", 7 | "types": "./app/types/index.d.ts", 8 | "bin": { 9 | "youtube-exec": "./bin/youtube-exec.js" 10 | }, 11 | "scripts": { 12 | "postinstall": "chmod +x bin/permissions.sh", 13 | "clean": "rm -rf node_modules yarn.lock package-lock.json pnpm-lock.yaml", 14 | "test": "npx mocha test/audio.test.js && npx mocha test/vid_aud.test.js && test/web.test.js", 15 | "local": "npx mocha client/audio.test.js && npx mocha client/vid_aud.test.js && client/web.test.js", 16 | "prestart": "python --version 2>&1 >/dev/null || echo 'Python is not installed. Please install Python to run this code.'" 17 | }, 18 | "keywords": [ 19 | "youtube", 20 | "downloader", 21 | "audio", 22 | "video", 23 | "download", 24 | "exec", 25 | "stream", 26 | "ffmpeg" 27 | ], 28 | "author": { 29 | "name": "magneum", 30 | "url": "https://bit.ly/magneum", 31 | "email": "krakinzkon@gmail.com" 32 | }, 33 | "license": "MIT", 34 | "homepage": "https://github.com/magneum/youtube-exec#readme", 35 | "repository": { 36 | "type": "git", 37 | "url": "https://github.com/magneum/youtube-exec.git" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/magneum/youtube-exec/issues" 41 | }, 42 | "dependencies": { 43 | "@types/ws": "^8.5.4", 44 | "axios": "^1.3.4", 45 | "chalk": "^4.1.2", 46 | "cli-clear": "^1.0.4", 47 | "express": "^4.18.2", 48 | "fluent-ffmpeg": "^2.1.2", 49 | "moment": "^2.29.4", 50 | "node-fetch": "^2.6.1", 51 | "open": "^9.1.0", 52 | "path": "^0.12.7", 53 | "progress": "^2.0.3", 54 | "progress-estimator": "^0.3.1", 55 | "sinon": "^15.1.0", 56 | "socket.io": "^4.6.2", 57 | "url-regex": "^5.0.0", 58 | "uuid": "^9.0.0", 59 | "winston": "^3.9.0", 60 | "ws": "^8.13.0", 61 | "yargs": "^17.7.2", 62 | "youtube-dl-exec": "^2.4.4", 63 | "youtube-exec": "^1.0.3" 64 | }, 65 | "devDependencies": { 66 | "chai": "^4.3.7", 67 | "jest": "^29.5.0", 68 | "mocha": "^10.2.0", 69 | "nodemon": "^2.0.22" 70 | }, 71 | "engines": { 72 | "node": ">=16.0.0" 73 | }, 74 | "private": false, 75 | "publishConfig": { 76 | "access": "public" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | 133 | # downloads 134 | *.mp3 135 | *.mp4 136 | 137 | 138 | # installer 139 | yarn.lock 140 | pnpm-lock.yaml 141 | package-lock.json -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | 133 | # downloads 134 | *.mp3 135 | *.mp4 136 | 137 | 138 | # installer 139 | yarn.lock 140 | pnpm-lock.yaml 141 | package-lock.json -------------------------------------------------------------------------------- /utils/logger.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | import moment from "moment"; 18 | import winston from "winston"; 19 | import chalk from "chalk"; 20 | 21 | const logger = winston.createLogger({ 22 | level: "info", 23 | format: winston.format.combine( 24 | winston.format.printf(({ level, message }) => { 25 | let timestampColor; 26 | let timestamp = moment().format("HH:mm:ss"); 27 | switch (level) { 28 | case "info": 29 | timestampColor = chalk.bgGreen; 30 | level = chalk.bold(chalk.italic(level, ": ")); 31 | message = chalk.bold(chalk.green(chalk.italic(message))); 32 | break; 33 | case "debug": 34 | timestampColor = chalk.bgBlue; 35 | level = chalk.bold(chalk.italic(level, ": ")); 36 | message = chalk.bold(chalk.blue(chalk.italic(message))); 37 | break; 38 | case "error": 39 | timestampColor = chalk.bgRed; 40 | level = chalk.bold(chalk.italic(level, ": ")); 41 | message = chalk.bold(chalk.red(chalk.italic(message))); 42 | break; 43 | default: 44 | timestampColor = chalk.bgYellow; 45 | level = chalk.bold(chalk.italic(level), ": "); 46 | message = chalk.bold(chalk.yellow(chalk.italic(message))); 47 | break; 48 | } 49 | timestamp = timestampColor(timestamp); 50 | return `${timestamp} ${level} ${message}`; 51 | }) 52 | ), 53 | transports: [new winston.transports.Console()], 54 | }); 55 | 56 | export default logger; 57 | -------------------------------------------------------------------------------- /utils/logger.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const moment = require("moment"); 18 | const winston = require("winston"); 19 | const chalk = require("chalk"); 20 | 21 | const logger = winston.createLogger({ 22 | level: "info", 23 | format: winston.format.combine( 24 | winston.format.printf(({ level, message }) => { 25 | let timestampColor; 26 | let timestamp = moment().format("HH:mm:ss"); 27 | switch (level) { 28 | case "info": 29 | timestampColor = chalk.bgGreen; 30 | level = chalk.bold(chalk.italic(level, ": ")); 31 | message = chalk.bold(chalk.green(chalk.italic(message))); 32 | break; 33 | case "debug": 34 | timestampColor = chalk.bgBlue; 35 | level = chalk.bold(chalk.italic(level, ": ")); 36 | message = chalk.bold(chalk.blue(chalk.italic(message))); 37 | break; 38 | case "error": 39 | timestampColor = chalk.bgRed; 40 | level = chalk.bold(chalk.italic(level, ": ")); 41 | message = chalk.bold(chalk.red(chalk.italic(message))); 42 | break; 43 | default: 44 | timestampColor = chalk.bgYellow; 45 | level = chalk.bold(chalk.italic(level), ": "); 46 | message = chalk.bold(chalk.yellow(chalk.italic(message))); 47 | break; 48 | } 49 | timestamp = timestampColor(timestamp); 50 | return `${timestamp} ${level} ${message}`; 51 | }) 52 | ), 53 | transports: [new winston.transports.Console()], 54 | }); 55 | 56 | module.exports = logger; 57 | -------------------------------------------------------------------------------- /test/audio.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const sinon = require("sinon"); 18 | const assert = require("chai").assert; 19 | const { dlAudio } = require("youtube-exec"); 20 | 21 | describe("dlAudio", async function () { 22 | this.timeout(80000); 23 | beforeEach(() => { 24 | sinon.stub(console, "info"); 25 | sinon.stub(console, "error"); 26 | }); 27 | 28 | afterEach(() => { 29 | sinon.restore(); 30 | }); 31 | 32 | it("should download audio with all parameters provided", async function () { 33 | this.timeout(80000); 34 | const quality = "lowest"; 35 | const filename = "cutom-audio"; 36 | const folder = "downloads"; 37 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 38 | const params = { url, folder, quality, filename }; 39 | await dlAudio(params); 40 | assert.isTrue(true); 41 | }); 42 | 43 | it("should download audio without folder", async function () { 44 | this.timeout(80000); 45 | const quality = "lowest"; 46 | const filename = "cutom-audio"; 47 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 48 | const params = { url, quality, filename }; 49 | await dlAudio(params); 50 | assert.isTrue(true); 51 | }); 52 | 53 | it("should download audio without filename", async function () { 54 | this.timeout(80000); 55 | const quality = "lowest"; 56 | const folder = "downloads"; 57 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 58 | const params = { url, folder, quality }; 59 | await dlAudio(params); 60 | assert.isTrue(true); 61 | }); 62 | 63 | it("should download audio without folder and filename", async function () { 64 | this.timeout(80000); 65 | const quality = "lowest"; 66 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 67 | const params = { url, quality }; 68 | await dlAudio(params); 69 | assert.isTrue(true); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /client/audio.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const sinon = require("sinon"); 18 | const assert = require("chai").assert; 19 | const { dlAudio } = require("../app/cjs/index.js"); 20 | 21 | describe("dlAudio", async function () { 22 | this.timeout(80000); 23 | beforeEach(() => { 24 | sinon.stub(console, "info"); 25 | sinon.stub(console, "error"); 26 | }); 27 | 28 | afterEach(() => { 29 | sinon.restore(); 30 | }); 31 | 32 | it("should download audio with all parameters provided", async function () { 33 | this.timeout(80000); 34 | const quality = "lowest"; 35 | const filename = "cutom-audio"; 36 | const folder = "downloads"; 37 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 38 | const params = { url, folder, quality, filename }; 39 | await dlAudio(params); 40 | assert.isTrue(true); 41 | }); 42 | 43 | it("should download audio without folder", async function () { 44 | this.timeout(80000); 45 | const quality = "lowest"; 46 | const filename = "cutom-audio"; 47 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 48 | const params = { url, quality, filename }; 49 | await dlAudio(params); 50 | assert.isTrue(true); 51 | }); 52 | 53 | it("should download audio without filename", async function () { 54 | this.timeout(80000); 55 | const quality = "lowest"; 56 | const folder = "downloads"; 57 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 58 | const params = { url, folder, quality }; 59 | await dlAudio(params); 60 | assert.isTrue(true); 61 | }); 62 | 63 | it("should download audio without folder and filename", async function () { 64 | this.timeout(80000); 65 | const quality = "lowest"; 66 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 67 | const params = { url, quality }; 68 | await dlAudio(params); 69 | assert.isTrue(true); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /client/video.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const sinon = require("sinon"); 18 | const assert = require("chai").assert; 19 | const { dlVideo } = require("youtube-exec"); 20 | 21 | describe("dlVideo", async function () { 22 | this.timeout(80000); 23 | beforeEach(() => { 24 | sinon.stub(console, "info"); 25 | sinon.stub(console, "error"); 26 | }); 27 | 28 | afterEach(() => { 29 | sinon.restore(); 30 | }); 31 | 32 | it("should download video with audio with all parameters provided", async function () { 33 | this.timeout(80000); 34 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 35 | const folder = "downloads"; 36 | const filename = "cutom-video"; 37 | const resolution = 144; 38 | const params = { url, folder, filename, resolution }; 39 | await dlVideo(params); 40 | assert.isTrue(true); 41 | }); 42 | 43 | it("should download video with audio without folder", async function () { 44 | this.timeout(80000); 45 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 46 | const filename = "cutom-video"; 47 | const resolution = 144; 48 | const params = { url, filename, resolution }; 49 | await dlVideo(params); 50 | assert.isTrue(true); 51 | }); 52 | 53 | it("should download video with audio without filename", async function () { 54 | this.timeout(80000); 55 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 56 | const folder = "downloads"; 57 | const resolution = 144; 58 | const params = { url, folder, resolution }; 59 | await dlVideo(params); 60 | assert.isTrue(true); 61 | }); 62 | 63 | it("should download video with audio without folder and filename", async function () { 64 | this.timeout(80000); 65 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 66 | const resolution = 144; 67 | const params = { url, resolution }; 68 | await dlVideo(params); 69 | assert.isTrue(true); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /test/video.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const sinon = require("sinon"); 18 | const assert = require("chai").assert; 19 | const { dlVideo } = require("../app/cjs/index.js"); 20 | 21 | describe("dlVideo", async function () { 22 | this.timeout(80000); 23 | beforeEach(() => { 24 | sinon.stub(console, "info"); 25 | sinon.stub(console, "error"); 26 | }); 27 | 28 | afterEach(() => { 29 | sinon.restore(); 30 | }); 31 | 32 | it("should download video with audio with all parameters provided", async function () { 33 | this.timeout(80000); 34 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 35 | const folder = "downloads"; 36 | const filename = "cutom-video"; 37 | const resolution = 144; 38 | const params = { url, folder, filename, resolution }; 39 | await dlVideo(params); 40 | assert.isTrue(true); 41 | }); 42 | 43 | it("should download video with audio without folder", async function () { 44 | this.timeout(80000); 45 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 46 | const filename = "cutom-video"; 47 | const resolution = 144; 48 | const params = { url, filename, resolution }; 49 | await dlVideo(params); 50 | assert.isTrue(true); 51 | }); 52 | 53 | it("should download video with audio without filename", async function () { 54 | this.timeout(80000); 55 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 56 | const folder = "downloads"; 57 | const resolution = 144; 58 | const params = { url, folder, resolution }; 59 | await dlVideo(params); 60 | assert.isTrue(true); 61 | }); 62 | 63 | it("should download video with audio without folder and filename", async function () { 64 | this.timeout(80000); 65 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 66 | const resolution = 144; 67 | const params = { url, resolution }; 68 | await dlVideo(params); 69 | assert.isTrue(true); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /client/vid_aud.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const sinon = require("sinon"); 18 | const assert = require("chai").assert; 19 | const { dlAudioVideo } = require("youtube-exec"); 20 | 21 | describe("dlAudioVideo", async function () { 22 | this.timeout(80000); 23 | beforeEach(() => { 24 | sinon.stub(console, "info"); 25 | sinon.stub(console, "error"); 26 | }); 27 | 28 | afterEach(() => { 29 | sinon.restore(); 30 | }); 31 | 32 | it("should download video with audio with all parameters provided", async function () { 33 | this.timeout(80000); 34 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 35 | const folder = "downloads"; 36 | const filename = "cutom-video"; 37 | const resolution = 144; 38 | const params = { url, folder, filename, resolution }; 39 | await dlAudioVideo(params); 40 | assert.isTrue(true); 41 | }); 42 | 43 | it("should download video with audio without folder", async function () { 44 | this.timeout(80000); 45 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 46 | const filename = "cutom-video"; 47 | const resolution = 144; 48 | const params = { url, filename, resolution }; 49 | await dlAudioVideo(params); 50 | assert.isTrue(true); 51 | }); 52 | 53 | it("should download video with audio without filename", async function () { 54 | this.timeout(80000); 55 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 56 | const folder = "downloads"; 57 | const resolution = 144; 58 | const params = { url, folder, resolution }; 59 | await dlAudioVideo(params); 60 | assert.isTrue(true); 61 | }); 62 | 63 | it("should download video with audio without folder and filename", async function () { 64 | this.timeout(80000); 65 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 66 | const resolution = 144; 67 | const params = { url, resolution }; 68 | await dlAudioVideo(params); 69 | assert.isTrue(true); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /test/vid_aud.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const sinon = require("sinon"); 18 | const assert = require("chai").assert; 19 | const { dlAudioVideo } = require("../app/cjs/index.js"); 20 | 21 | describe("dlAudioVideo", async function () { 22 | this.timeout(80000); 23 | beforeEach(() => { 24 | sinon.stub(console, "info"); 25 | sinon.stub(console, "error"); 26 | }); 27 | 28 | afterEach(() => { 29 | sinon.restore(); 30 | }); 31 | 32 | it("should download video with audio with all parameters provided", async function () { 33 | this.timeout(80000); 34 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 35 | const folder = "downloads"; 36 | const filename = "cutom-video"; 37 | const resolution = 144; 38 | const params = { url, folder, filename, resolution }; 39 | await dlAudioVideo(params); 40 | assert.isTrue(true); 41 | }); 42 | 43 | it("should download video with audio without folder", async function () { 44 | this.timeout(80000); 45 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 46 | const filename = "cutom-video"; 47 | const resolution = 144; 48 | const params = { url, filename, resolution }; 49 | await dlAudioVideo(params); 50 | assert.isTrue(true); 51 | }); 52 | 53 | it("should download video with audio without filename", async function () { 54 | this.timeout(80000); 55 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 56 | const folder = "downloads"; 57 | const resolution = 144; 58 | const params = { url, folder, resolution }; 59 | await dlAudioVideo(params); 60 | assert.isTrue(true); 61 | }); 62 | 63 | it("should download video with audio without folder and filename", async function () { 64 | this.timeout(80000); 65 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 66 | const resolution = 144; 67 | const params = { url, resolution }; 68 | await dlAudioVideo(params); 69 | assert.isTrue(true); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /utils/replace.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const fs = require("fs"); 18 | const path = require("path"); 19 | const readline = require("readline"); 20 | 21 | const ignoredContentExtensions = [ 22 | ".jpg", 23 | ".jpeg", 24 | ".png", 25 | ".gif", 26 | ".bmp", 27 | ".svg", 28 | ".mp4", 29 | ".avi", 30 | ".mov", 31 | ".webm", 32 | ".db", 33 | ]; 34 | const ignoredFolders = [".git", "node_modules"]; 35 | const ignoredRenameExtensions = [ 36 | ".jpg", 37 | ".jpeg", 38 | ".png", 39 | ".gif", 40 | ".bmp", 41 | ".svg", 42 | ".mp4", 43 | ".avi", 44 | ".mov", 45 | ".webm", 46 | ".db", 47 | ]; 48 | 49 | function renameFilesAndFolders(dirPath, oldWord, newWord) { 50 | const files = fs.readdirSync(dirPath); 51 | 52 | files.forEach((file) => { 53 | const filePath = path.join(dirPath, file); 54 | const stats = fs.statSync(filePath); 55 | 56 | if (stats.isDirectory()) { 57 | if (!ignoredFolders.includes(file)) { 58 | renameFilesAndFolders(filePath, oldWord, newWord); 59 | } 60 | } else { 61 | const fileExtension = path.extname(file).toLowerCase(); 62 | if (ignoredContentExtensions.includes(fileExtension)) { 63 | const newFilePath = path.join( 64 | dirPath, 65 | replaceAll(file, oldWord, newWord) 66 | ); 67 | fs.renameSync(filePath, newFilePath); 68 | } else if (!ignoredRenameExtensions.includes(fileExtension)) { 69 | const fileContent = fs.readFileSync(filePath, "utf8"); 70 | const newContent = replaceAll(fileContent, oldWord, newWord); 71 | fs.writeFileSync(filePath, newContent, "utf8"); 72 | 73 | const newFilePath = path.join( 74 | dirPath, 75 | replaceAll(file, oldWord, newWord) 76 | ); 77 | fs.renameSync(filePath, newFilePath); 78 | } 79 | } 80 | }); 81 | 82 | rl.question("Enter the old word: ", (oldWord) => { 83 | rl.question("Enter the new word: ", (newWord) => { 84 | renameFilesAndFolders(".", oldWord, newWord); 85 | }); 86 | }); 87 | } 88 | 89 | function replaceAll(str, search, replacement) { 90 | return str.split(search).join(replacement); 91 | } 92 | 93 | const rl = readline.createInterface({ 94 | input: process.stdin, 95 | output: process.stdout, 96 | }); 97 | 98 | rl.question("Enter the old word: ", (oldWord) => { 99 | rl.question("Enter the new word: ", (newWord) => { 100 | renameFilesAndFolders(".", oldWord, newWord); 101 | }); 102 | }); 103 | -------------------------------------------------------------------------------- /client/web.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const chalk = require("chalk"); 18 | const express = require("express"); 19 | const { streamAudio } = require("youtube-exec"); 20 | 21 | const app = express(); 22 | const port = 8080; 23 | 24 | app.use((err, req, res, next) => { 25 | console.error(err); 26 | res.status(500).send("Internal Server Error"); 27 | }); 28 | 29 | app.get("/", async (req, res) => { 30 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 31 | const quality = req.query.quality || "best"; 32 | try { 33 | const { reqAudio, videoTitle, stream } = await streamAudio({ 34 | url, 35 | quality, 36 | res, 37 | }); 38 | stream.on("start", () => { 39 | console.log("📥 Audio streaming started..."); 40 | }); 41 | stream.on("end", () => { 42 | console.log(chalk.bold(chalk.green("✅ Audio streaming finished!"))); 43 | }); 44 | stream.on("error", (err) => { 45 | console.log( 46 | chalk.bold(chalk.red(`❌ Error streaming audio: ${err.message}`)) 47 | ); 48 | res.status(500).end(); 49 | }); 50 | } catch (err) { 51 | console.log(chalk.red(`❌ An error occurred: ${err.message}`)); 52 | res.status(500).end(); 53 | } 54 | }); 55 | 56 | app.listen(port, () => { 57 | console.log("http://localhost:8080"); 58 | }); 59 | 60 | // const express = require("express"); 61 | // const { streamAudio } = require("../app/cjs/index.js"); 62 | // const http = require("http"); 63 | // const socketIO = require("socket.io"); 64 | 65 | // const app = express(); 66 | // const server = http.createServer(app); 67 | // const io = socketIO(server); 68 | 69 | // const port = 8080; 70 | 71 | // app.use((err, req, res, next) => { 72 | // console.error(err); 73 | // res.status(500).send("Internal Server Error"); 74 | // }); 75 | 76 | // app.get("/", async (req, res) => { 77 | // const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 78 | // const quality = req.query.quality || "best"; 79 | // await streamAudio({ 80 | // url, 81 | // quality, 82 | // res, 83 | // }).theen(async (reqAudio, videoTitle, stream) => { 84 | // try { 85 | // stream.on("start", () => { 86 | // io.emit( 87 | // "streamStart", 88 | // `📥 Audio streaming started - Video Title: ${videoTitle}` 89 | // ); 90 | // res.send(`📥 Audio streaming started - Video Title: ${videoTitle}`); 91 | // }); 92 | // stream.on("end", () => { 93 | // io.emit( 94 | // "streamEnd", 95 | // `✅ Audio streaming finished - Video Title: ${videoTitle}` 96 | // ); 97 | // res.send(`✅ Audio streaming finished - Video Title: ${videoTitle}`); 98 | // }); 99 | // stream.on("error", (err) => { 100 | // io.emit( 101 | // "streamError", 102 | // `❌ Error streaming audio - Video Title: ${videoTitle}, Error: ${err.message}` 103 | // ); 104 | // res 105 | // .status(500) 106 | // .send( 107 | // `❌ Error streaming audio - Video Title: ${videoTitle}, Error: ${err.message}` 108 | // ); 109 | // }); 110 | // } catch (err) { 111 | // io.emit( 112 | // "errorOccurred", 113 | // `❌ An error occurred - Video Title: ${videoTitle}, Error: ${err.message}` 114 | // ); 115 | // res 116 | // .status(500) 117 | // .send( 118 | // `❌ An error occurred - Video Title: ${videoTitle}, Error: ${err.message}` 119 | // ); 120 | // } 121 | // }); 122 | // }); 123 | 124 | // io.on("connection", (socket) => { 125 | // console.log("A client connected"); 126 | 127 | // socket.on("disconnect", () => { 128 | // console.log("A client disconnected"); 129 | // }); 130 | // }); 131 | 132 | // server.listen(port, () => { 133 | // console.log("http://localhost:8080"); 134 | // }); 135 | -------------------------------------------------------------------------------- /test/web.test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const chalk = require("chalk"); 18 | const express = require("express"); 19 | const { streamAudio } = require("../app/cjs/index.js"); 20 | 21 | const app = express(); 22 | const port = 8080; 23 | 24 | app.use((err, req, res, next) => { 25 | console.error(err); 26 | res.status(500).send("Internal Server Error"); 27 | }); 28 | 29 | app.get("/", async (req, res) => { 30 | const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 31 | const quality = req.query.quality || "best"; 32 | try { 33 | const { reqAudio, videoTitle, stream } = await streamAudio({ 34 | url, 35 | quality, 36 | res, 37 | }); 38 | stream.on("start", () => { 39 | console.log("📥 Audio streaming started..."); 40 | }); 41 | stream.on("end", () => { 42 | console.log(chalk.bold(chalk.green("✅ Audio streaming finished!"))); 43 | }); 44 | stream.on("error", (err) => { 45 | console.log( 46 | chalk.bold(chalk.red(`❌ Error streaming audio: ${err.message}`)) 47 | ); 48 | res.status(500).end(); 49 | }); 50 | } catch (err) { 51 | console.log(chalk.red(`❌ An error occurred: ${err.message}`)); 52 | res.status(500).end(); 53 | } 54 | }); 55 | 56 | app.listen(port, () => { 57 | console.log("http://localhost:8080"); 58 | }); 59 | 60 | // const express = require("express"); 61 | // const { streamAudio } = require("../app/cjs/index.js"); 62 | // const http = require("http"); 63 | // const socketIO = require("socket.io"); 64 | 65 | // const app = express(); 66 | // const server = http.createServer(app); 67 | // const io = socketIO(server); 68 | 69 | // const port = 8080; 70 | 71 | // app.use((err, req, res, next) => { 72 | // console.error(err); 73 | // res.status(500).send("Internal Server Error"); 74 | // }); 75 | 76 | // app.get("/", async (req, res) => { 77 | // const url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; 78 | // const quality = req.query.quality || "best"; 79 | // await streamAudio({ 80 | // url, 81 | // quality, 82 | // res, 83 | // }).theen(async (reqAudio, videoTitle, stream) => { 84 | // try { 85 | // stream.on("start", () => { 86 | // io.emit( 87 | // "streamStart", 88 | // `📥 Audio streaming started - Video Title: ${videoTitle}` 89 | // ); 90 | // res.send(`📥 Audio streaming started - Video Title: ${videoTitle}`); 91 | // }); 92 | // stream.on("end", () => { 93 | // io.emit( 94 | // "streamEnd", 95 | // `✅ Audio streaming finished - Video Title: ${videoTitle}` 96 | // ); 97 | // res.send(`✅ Audio streaming finished - Video Title: ${videoTitle}`); 98 | // }); 99 | // stream.on("error", (err) => { 100 | // io.emit( 101 | // "streamError", 102 | // `❌ Error streaming audio - Video Title: ${videoTitle}, Error: ${err.message}` 103 | // ); 104 | // res 105 | // .status(500) 106 | // .send( 107 | // `❌ Error streaming audio - Video Title: ${videoTitle}, Error: ${err.message}` 108 | // ); 109 | // }); 110 | // } catch (err) { 111 | // io.emit( 112 | // "errorOccurred", 113 | // `❌ An error occurred - Video Title: ${videoTitle}, Error: ${err.message}` 114 | // ); 115 | // res 116 | // .status(500) 117 | // .send( 118 | // `❌ An error occurred - Video Title: ${videoTitle}, Error: ${err.message}` 119 | // ); 120 | // } 121 | // }); 122 | // }); 123 | 124 | // io.on("connection", (socket) => { 125 | // console.log("A client connected"); 126 | 127 | // socket.on("disconnect", () => { 128 | // console.log("A client disconnected"); 129 | // }); 130 | // }); 131 | 132 | // server.listen(port, () => { 133 | // console.log("http://localhost:8080"); 134 | // }); 135 | -------------------------------------------------------------------------------- /src/mjs/web.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | import progLogger from "progress-estimator"; 18 | import logger from "../../utils/logger.mjs"; 19 | import youtubedl from "youtube-dl-exec"; 20 | import ffmpeg from "fluent-ffmpeg"; 21 | import urlRegex from "url-regex"; 22 | import chalk from "chalk"; 23 | 24 | const plogger = progLogger(); 25 | 26 | const fetchAudioDetails = async ({ url, quality }) => { 27 | logger.info("🔍 Fetching audio details..."); 28 | try { 29 | const promise = youtubedl(url, { 30 | dumpSingleJson: true, 31 | noCheckCertificates: true, 32 | noWarnings: true, 33 | preferFreeFormats: true, 34 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 35 | }); 36 | const result = await plogger(promise, "⏳ Obtaining..."); 37 | const videoTitle = result.title; 38 | const reqAudio = findReqAudioFormat(result.formats, quality); 39 | return { reqAudio, videoTitle }; 40 | } catch (err) { 41 | logger.info(chalk.red(`❌ Error fetching audio details: ${err.message}`)); 42 | throw err; 43 | } 44 | }; 45 | 46 | const findReqAudioFormat = (formats, quality) => { 47 | let reqAudio = null; 48 | logger.info(`🔍 Fetching Audio Quality: ${quality}`); 49 | if (quality === "best") { 50 | let highestBitrate = 0; 51 | for (let i = 0; i < formats.length; i++) { 52 | const format = formats[i]; 53 | if (format.acodec === "none" || format.vcodec !== "none") { 54 | continue; 55 | } 56 | const bitrate = format.tbr || format.abr; 57 | if (bitrate && bitrate > highestBitrate) { 58 | highestBitrate = bitrate; 59 | reqAudio = format; 60 | } 61 | } 62 | return reqAudio; 63 | } else if (quality === "lowest") { 64 | let lowBitrate = Infinity; 65 | for (let i = 0; i < formats.length; i++) { 66 | const format = formats[i]; 67 | if (format.acodec === "none" || format.vcodec !== "none") { 68 | continue; 69 | } 70 | const bitrate = format.tbr || format.abr; 71 | if (bitrate && bitrate < lowBitrate) { 72 | lowBitrate = bitrate; 73 | reqAudio = format; 74 | } 75 | } 76 | return reqAudio; 77 | } else { 78 | logger.info(chalk.red("❌ Error: Audio Quality supported: best,lowest")); 79 | throw new Error("Error: Audio Quality supported: best,lowest"); 80 | } 81 | }; 82 | 83 | const validateUrl = (url) => { 84 | const regex = urlRegex({ strict: false }); 85 | return regex.test(url); 86 | }; 87 | 88 | const streamAudio = ({ url, quality, res }) => { 89 | return new Promise(async (resolve, reject) => { 90 | if (!validateUrl(url)) { 91 | logger.info(chalk.red("❌ Invalid URL format.")); 92 | reject(new Error("Invalid URL format.")); 93 | return; 94 | } 95 | 96 | try { 97 | const { reqAudio, videoTitle } = await fetchAudioDetails({ 98 | url, 99 | quality, 100 | }); 101 | if (!reqAudio) { 102 | logger.info(chalk.bold(chalk.yellow("⚠️ No audio details found."))); 103 | reject(new Error("No audio details found.")); 104 | return; 105 | } 106 | 107 | logger.info( 108 | chalk.bold(chalk.cyanBright(`🎥 Video Title: ${videoTitle}`)) 109 | ); 110 | Object.entries(reqAudio).forEach(([key, value]) => { 111 | logger.info( 112 | chalk.bold( 113 | chalk.yellow( 114 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 115 | ) 116 | ) 117 | ); 118 | }); 119 | 120 | res.setHeader("Content-Type", "audio/mpeg"); 121 | res.setHeader( 122 | "Content-Disposition", 123 | `attachment; filename="${videoTitle}.mp3"` 124 | ); 125 | 126 | const ffmpegCommand = ffmpeg(reqAudio.url) 127 | .audioBitrate(320) 128 | .format("mp3") 129 | .outputOptions("-f mp3"); 130 | 131 | ffmpegCommand.on("start", () => { 132 | logger.info("📥 Audio streaming started..."); 133 | }); 134 | 135 | ffmpegCommand.on("end", () => { 136 | logger.info(chalk.bold(chalk.green("✅ Audio streaming finished!"))); 137 | resolve({ reqAudio, videoTitle, stream: ffmpegCommand }); 138 | }); 139 | 140 | ffmpegCommand.on("error", (err) => { 141 | logger.info( 142 | chalk.bold(chalk.red(`❌ Error streaming audio: ${err.message}`)) 143 | ); 144 | reject(err); 145 | }); 146 | 147 | ffmpegCommand.pipe(res); 148 | } catch (err) { 149 | logger.info(chalk.red(`❌ An error occurred: ${err.message}`)); 150 | reject(err); 151 | } 152 | }); 153 | }; 154 | 155 | export default streamAudio; 156 | -------------------------------------------------------------------------------- /src/cjs/web.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const progLogger = require("progress-estimator"); 18 | const youtubedl = require("youtube-dl-exec"); 19 | const logger = require("../../utils/logger.js"); 20 | const ffmpeg = require("fluent-ffmpeg"); 21 | const urlRegex = require("url-regex"); 22 | const chalk = require("chalk"); 23 | 24 | const plogger = progLogger(); 25 | 26 | const fetchAudioDetails = async ({ url, quality }) => { 27 | logger.info("🔍 Fetching audio details..."); 28 | try { 29 | const promise = youtubedl(url, { 30 | dumpSingleJson: true, 31 | noCheckCertificates: true, 32 | noWarnings: true, 33 | preferFreeFormats: true, 34 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 35 | }); 36 | const result = await plogger(promise, "⏳ Obtaining..."); 37 | const videoTitle = result.title; 38 | const reqAudio = findReqAudioFormat(result.formats, quality); 39 | return { reqAudio, videoTitle }; 40 | } catch (err) { 41 | logger.info(chalk.red(`❌ Error fetching audio details: ${err.message}`)); 42 | throw err; 43 | } 44 | }; 45 | 46 | const findReqAudioFormat = (formats, quality) => { 47 | let reqAudio = null; 48 | logger.info(`🔍 Fetching Audio Quality: ${quality}`); 49 | if (quality === "best") { 50 | let highestBitrate = 0; 51 | for (let i = 0; i < formats.length; i++) { 52 | const format = formats[i]; 53 | if (format.acodec === "none" || format.vcodec !== "none") { 54 | continue; 55 | } 56 | const bitrate = format.tbr || format.abr; 57 | if (bitrate && bitrate > highestBitrate) { 58 | highestBitrate = bitrate; 59 | reqAudio = format; 60 | } 61 | } 62 | return reqAudio; 63 | } else if (quality === "lowest") { 64 | let lowBitrate = Infinity; 65 | for (let i = 0; i < formats.length; i++) { 66 | const format = formats[i]; 67 | if (format.acodec === "none" || format.vcodec !== "none") { 68 | continue; 69 | } 70 | const bitrate = format.tbr || format.abr; 71 | if (bitrate && bitrate < lowBitrate) { 72 | lowBitrate = bitrate; 73 | reqAudio = format; 74 | } 75 | } 76 | return reqAudio; 77 | } else { 78 | logger.info(chalk.red("❌ Error: Audio Quality supported: best,lowest")); 79 | throw new Error("Error: Audio Quality supported: best,lowest"); 80 | } 81 | }; 82 | 83 | const validateUrl = (url) => { 84 | const regex = urlRegex({ strict: false }); 85 | return regex.test(url); 86 | }; 87 | 88 | const streamAudio = ({ url, quality, res }) => { 89 | return new Promise(async (resolve, reject) => { 90 | if (!validateUrl(url)) { 91 | logger.info(chalk.red("❌ Invalid URL format.")); 92 | reject(new Error("Invalid URL format.")); 93 | return; 94 | } 95 | 96 | try { 97 | const { reqAudio, videoTitle } = await fetchAudioDetails({ 98 | url, 99 | quality, 100 | }); 101 | if (!reqAudio) { 102 | logger.info(chalk.bold(chalk.yellow("⚠️ No audio details found."))); 103 | reject(new Error("No audio details found.")); 104 | return; 105 | } 106 | 107 | logger.info( 108 | chalk.bold(chalk.cyanBright(`🎥 Video Title: ${videoTitle}`)) 109 | ); 110 | Object.entries(reqAudio).forEach(([key, value]) => { 111 | logger.info( 112 | chalk.bold( 113 | chalk.yellow( 114 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 115 | ) 116 | ) 117 | ); 118 | }); 119 | 120 | res.setHeader("Content-Type", "audio/mpeg"); 121 | res.setHeader( 122 | "Content-Disposition", 123 | `attachment; filename="${videoTitle}.mp3"` 124 | ); 125 | 126 | const ffmpegCommand = ffmpeg(reqAudio.url) 127 | .audioBitrate(320) 128 | .format("mp3") 129 | .outputOptions("-f mp3"); 130 | 131 | ffmpegCommand.on("start", () => { 132 | logger.info("📥 Audio streaming started..."); 133 | }); 134 | 135 | ffmpegCommand.on("end", () => { 136 | logger.info(chalk.bold(chalk.green("✅ Audio streaming finished!"))); 137 | resolve({ reqAudio, videoTitle, stream: ffmpegCommand }); 138 | }); 139 | 140 | ffmpegCommand.on("error", (err) => { 141 | logger.info( 142 | chalk.bold(chalk.red(`❌ Error streaming audio: ${err.message}`)) 143 | ); 144 | reject(err); 145 | }); 146 | 147 | ffmpegCommand.pipe(res); 148 | } catch (err) { 149 | logger.info(chalk.red(`❌ An error occurred: ${err.message}`)); 150 | reject(err); 151 | } 152 | }); 153 | }; 154 | 155 | module.exports = streamAudio; 156 | -------------------------------------------------------------------------------- /src/mjs/video.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | import progLogger from "progress-estimator"; 18 | import logger from "../../utils/logger.mjs"; 19 | import youtubedl from "youtube-dl-exec"; 20 | import ffmpeg from "fluent-ffmpeg"; 21 | import urlRegex from "url-regex"; 22 | import readline from "readline"; 23 | import chalk from "chalk"; 24 | import path from "path"; 25 | import fs from "fs"; 26 | 27 | const plogger = progLogger(); 28 | 29 | const log = (message) => { 30 | logger.info(message); 31 | }; 32 | 33 | const createFolderIfNotExists = (folder) => { 34 | if (!folder) { 35 | folder = "youtube-exec"; 36 | } 37 | const outputFolder = path.resolve(process.cwd(), folder); 38 | if (!fs.existsSync(outputFolder)) { 39 | fs.mkdirSync(outputFolder); 40 | logger.info(`📂 Created folder: ${outputFolder}`); 41 | } 42 | }; 43 | 44 | const fetchVideoDetails = async ({ url, requestedResolution }) => { 45 | log("🔍 Fetching video details..."); 46 | try { 47 | const promise = youtubedl(url, { 48 | dumpSingleJson: true, 49 | noCheckCertificates: true, 50 | noWarnings: true, 51 | preferFreeFormats: true, 52 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 53 | }); 54 | const result = await plogger(promise, "⏳ Obtaining..."); 55 | const videoTitle = result.title; 56 | const reqVideo = findReqVideoFormat(result.formats, requestedResolution); 57 | return { reqVideo, videoTitle }; 58 | } catch (err) { 59 | throw new Error(`❌ Error fetching video details: ${err.message}`); 60 | } 61 | }; 62 | 63 | const findReqVideoFormat = (formats, requestedResolution) => { 64 | let reqVideo = null; 65 | const availableFormats = formats.filter( 66 | (format) => format.ext === "mp4" && format.format_note !== "none" 67 | ); 68 | const sortedFormats = availableFormats.sort((a, b) => a.height - b.height); 69 | reqVideo = sortedFormats.find( 70 | (format) => format.height >= requestedResolution 71 | ); 72 | return reqVideo; 73 | }; 74 | 75 | const downloadVideoFile = async (videoUrl, outputFile, videoFormat) => { 76 | return new Promise((resolve, reject) => { 77 | const ffmpegCommand = ffmpeg() 78 | .input(videoUrl) 79 | .videoCodec("copy") 80 | .on("start", () => { 81 | log("📥 Video download started..."); 82 | }) 83 | .on("progress", (progress) => { 84 | readline.clearLine(process.stdout, 0); 85 | readline.cursorTo(process.stdout, 0); 86 | process.stdout.write(`⬇️ Downloading: ${progress.percent}%`); 87 | }) 88 | .on("end", () => { 89 | readline.clearLine(process.stdout, 0); 90 | readline.cursorTo(process.stdout, 0); 91 | log(chalk.bold(chalk.green("✅ Video downloaded successfully!"))); 92 | resolve(); 93 | }) 94 | .on("error", (err) => { 95 | readline.clearLine(process.stdout, 0); 96 | readline.cursorTo(process.stdout, 0); 97 | logger.error( 98 | chalk.bold( 99 | chalk.red(`❌ Error downloading video file: ${err.message}`) 100 | ) 101 | ); 102 | reject(err); 103 | }) 104 | .save(outputFile); 105 | ffmpegCommand.run(); 106 | }); 107 | }; 108 | 109 | const validateUrl = (url) => { 110 | const regex = urlRegex({ strict: false }); 111 | return regex.test(url); 112 | }; 113 | 114 | const displayVideoDetails = (reqVideo, videoTitle, url) => { 115 | log( 116 | chalk.bold( 117 | chalk.bgCyanBright("🎥 Video Title:"), 118 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 119 | ) 120 | ); 121 | Object.entries(reqVideo).forEach(([key, value]) => { 122 | switch (key) { 123 | case "url": 124 | url = value; 125 | break; 126 | default: 127 | log( 128 | chalk.bold( 129 | chalk.yellow( 130 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 131 | ) 132 | ) 133 | ); 134 | break; 135 | } 136 | }); 137 | return url; 138 | }; 139 | 140 | const dlVideo = async ({ url, folder, filename, resolution }) => { 141 | return new Promise(async (resolve, reject) => { 142 | try { 143 | if (!validateUrl(url)) { 144 | throw new Error("❌ Invalid URL format."); 145 | } 146 | const { reqVideo, videoTitle } = await fetchVideoDetails({ 147 | url, 148 | requestedResolution: resolution, 149 | }); 150 | if (reqVideo) { 151 | url = displayVideoDetails(reqVideo, videoTitle, url); 152 | if (!folder) { 153 | folder = "youtube-exec"; 154 | } 155 | createFolderIfNotExists(folder); 156 | const outputFilename = filename 157 | ? `${filename}.mp4` 158 | : `[${reqVideo.height}]${videoTitle}.mp4`; 159 | const outputPath = path.join(folder, outputFilename); 160 | await downloadVideoFile(reqVideo.url, outputPath, reqVideo); 161 | resolve(); 162 | } else { 163 | throw new Error("⚠️ No video details found."); 164 | } 165 | } catch (err) { 166 | reject(err); 167 | } 168 | }); 169 | }; 170 | 171 | export default dlVideo; 172 | -------------------------------------------------------------------------------- /src/cjs/video.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const progLogger = require("progress-estimator"); 18 | const youtubedl = require("youtube-dl-exec"); 19 | const logger = require("../../utils/logger.js"); 20 | const ffmpeg = require("fluent-ffmpeg"); 21 | const urlRegex = require("url-regex"); 22 | const readline = require("readline"); 23 | const chalk = require("chalk"); 24 | const path = require("path"); 25 | const fs = require("fs"); 26 | 27 | const plogger = progLogger(); 28 | 29 | const log = (message) => { 30 | logger.info(message); 31 | }; 32 | 33 | const createFolderIfNotExists = (folder) => { 34 | if (!folder) { 35 | folder = "youtube-exec"; 36 | } 37 | const outputFolder = path.resolve(process.cwd(), folder); 38 | if (!fs.existsSync(outputFolder)) { 39 | fs.mkdirSync(outputFolder); 40 | logger.info(`📂 Created folder: ${outputFolder}`); 41 | } 42 | }; 43 | 44 | const fetchVideoDetails = async ({ url, requestedResolution }) => { 45 | log("🔍 Fetching video details..."); 46 | try { 47 | const promise = youtubedl(url, { 48 | dumpSingleJson: true, 49 | noCheckCertificates: true, 50 | noWarnings: true, 51 | preferFreeFormats: true, 52 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 53 | }); 54 | const result = await plogger(promise, "⏳ Obtaining..."); 55 | const videoTitle = result.title; 56 | const reqVideo = findReqVideoFormat(result.formats, requestedResolution); 57 | return { reqVideo, videoTitle }; 58 | } catch (err) { 59 | throw new Error(`❌ Error fetching video details: ${err.message}`); 60 | } 61 | }; 62 | 63 | const findReqVideoFormat = (formats, requestedResolution) => { 64 | let reqVideo = null; 65 | const availableFormats = formats.filter( 66 | (format) => format.ext === "mp4" && format.format_note !== "none" 67 | ); 68 | const sortedFormats = availableFormats.sort((a, b) => a.height - b.height); 69 | reqVideo = sortedFormats.find( 70 | (format) => format.height >= requestedResolution 71 | ); 72 | return reqVideo; 73 | }; 74 | 75 | const downloadVideoFile = async (videoUrl, outputFile, videoFormat) => { 76 | return new Promise((resolve, reject) => { 77 | const ffmpegCommand = ffmpeg() 78 | .input(videoUrl) 79 | .videoCodec("copy") 80 | .on("start", () => { 81 | log("📥 Video download started..."); 82 | }) 83 | .on("progress", (progress) => { 84 | readline.clearLine(process.stdout, 0); 85 | readline.cursorTo(process.stdout, 0); 86 | process.stdout.write(`⬇️ Downloading: ${progress.percent}%`); 87 | }) 88 | .on("end", () => { 89 | readline.clearLine(process.stdout, 0); 90 | readline.cursorTo(process.stdout, 0); 91 | log(chalk.bold(chalk.green("✅ Video downloaded successfully!"))); 92 | resolve(); 93 | }) 94 | .on("error", (err) => { 95 | readline.clearLine(process.stdout, 0); 96 | readline.cursorTo(process.stdout, 0); 97 | logger.error( 98 | chalk.bold( 99 | chalk.red(`❌ Error downloading video file: ${err.message}`) 100 | ) 101 | ); 102 | reject(err); 103 | }) 104 | .save(outputFile); 105 | ffmpegCommand.run(); 106 | }); 107 | }; 108 | 109 | const validateUrl = (url) => { 110 | const regex = urlRegex({ strict: false }); 111 | return regex.test(url); 112 | }; 113 | 114 | const displayVideoDetails = (reqVideo, videoTitle, url) => { 115 | log( 116 | chalk.bold( 117 | chalk.bgCyanBright("🎥 Video Title:"), 118 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 119 | ) 120 | ); 121 | Object.entries(reqVideo).forEach(([key, value]) => { 122 | switch (key) { 123 | case "url": 124 | url = value; 125 | break; 126 | default: 127 | log( 128 | chalk.bold( 129 | chalk.yellow( 130 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 131 | ) 132 | ) 133 | ); 134 | break; 135 | } 136 | }); 137 | return url; 138 | }; 139 | 140 | const dlVideo = async ({ url, folder, filename, resolution }) => { 141 | return new Promise(async (resolve, reject) => { 142 | try { 143 | if (!validateUrl(url)) { 144 | throw new Error("❌ Invalid URL format."); 145 | } 146 | const { reqVideo, videoTitle } = await fetchVideoDetails({ 147 | url, 148 | requestedResolution: resolution, 149 | }); 150 | if (reqVideo) { 151 | url = displayVideoDetails(reqVideo, videoTitle, url); 152 | if (!folder) { 153 | folder = "youtube-exec"; 154 | } 155 | createFolderIfNotExists(folder); 156 | const outputFilename = filename 157 | ? `${filename}.mp4` 158 | : `[${reqVideo.height}]${videoTitle}.mp4`; 159 | const outputPath = path.join(folder, outputFilename); 160 | await downloadVideoFile(reqVideo.url, outputPath, reqVideo); 161 | resolve(); 162 | } else { 163 | throw new Error("⚠️ No video details found."); 164 | } 165 | } catch (err) { 166 | reject(err); 167 | } 168 | }); 169 | }; 170 | 171 | module.exports = dlVideo; 172 | -------------------------------------------------------------------------------- /bin/youtube-exec.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const yargs = require("yargs"); 18 | const chalk = require("chalk"); 19 | const { dlAudioVideo, dlAudio, dlVideo } = require("../app/cjs/index.js"); 20 | const winston = require("winston"); 21 | 22 | // Configure Winston logger 23 | const logger = winston.createLogger({ 24 | format: winston.format.combine( 25 | winston.format.timestamp({ format: "HH:mm:ss" }), 26 | winston.format.printf(({ level, message, timestamp }) => { 27 | return `${timestamp} ${level}: ${message}`; 28 | }) 29 | ), 30 | transports: [new winston.transports.Console()], 31 | }); 32 | 33 | const audioDescription = `${chalk.green( 34 | "🎵" 35 | )} Download audio from a YouTube video`; 36 | const videoWithAudioDescription = `${chalk.green( 37 | "🎥🎵" 38 | )} Download video with audio from a YouTube video`; 39 | const videoWithoutAudioDescription = `${chalk.green( 40 | "🎥" 41 | )} Download video without audio from a YouTube video`; 42 | 43 | yargs 44 | .scriptName(chalk.yellow("youtube-downloader")) 45 | .usage(chalk.bold("Usage: $0 [options]")) 46 | .command( 47 | "audio", 48 | audioDescription, 49 | (yargs) => { 50 | yargs 51 | .option("url", { 52 | describe: `${chalk.cyan("YouTube video URL")}`, 53 | demandOption: true, 54 | type: "string", 55 | }) 56 | .option("folder", { 57 | describe: `${chalk.cyan("Output folder name")}`, 58 | type: "string", 59 | }) 60 | .option("quality", { 61 | describe: `${chalk.cyan("Audio quality (best/lowest)")}`, 62 | type: "string", 63 | default: "best", 64 | }) 65 | .option("filename", { 66 | describe: `${chalk.cyan("Output filename (excluding extension)")}`, 67 | type: "string", 68 | }); 69 | }, 70 | async (argv) => { 71 | logger.info(audioDescription); 72 | 73 | try { 74 | await dlAudio(argv); 75 | 76 | logger.info(`${chalk.green("✅")} Audio download completed.`); 77 | } catch (err) { 78 | logger.error( 79 | `${chalk.red("❌")} Error downloading audio:`, 80 | err.message 81 | ); 82 | } 83 | } 84 | ) 85 | .command( 86 | "video-with-audio", 87 | videoWithAudioDescription, 88 | (yargs) => { 89 | yargs 90 | .option("url", { 91 | describe: `${chalk.cyan("YouTube video URL")}`, 92 | demandOption: true, 93 | type: "string", 94 | }) 95 | .option("folder", { 96 | describe: `${chalk.cyan("Output folder name")}`, 97 | type: "string", 98 | }) 99 | .option("filename", { 100 | describe: `${chalk.cyan("Output filename (excluding extension)")}`, 101 | type: "string", 102 | }) 103 | .option("resolution", { 104 | describe: `${chalk.cyan( 105 | "Available video resolution (144 | 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320)" 106 | )}`, 107 | type: "number", 108 | demandOption: true, 109 | default: 480, 110 | }); 111 | }, 112 | async (argv) => { 113 | logger.info(videoWithAudioDescription); 114 | 115 | try { 116 | await dlAudioVideo(argv); 117 | 118 | logger.info( 119 | `${chalk.green("✅")} Video with audio download completed.` 120 | ); 121 | } catch (err) { 122 | logger.error( 123 | `${chalk.red("❌")} Error downloading video with audio:`, 124 | err.message 125 | ); 126 | } 127 | } 128 | ) 129 | .command( 130 | "video", 131 | videoWithoutAudioDescription, 132 | (yargs) => { 133 | yargs 134 | .option("url", { 135 | describe: `${chalk.cyan("YouTube video URL")}`, 136 | demandOption: true, 137 | type: "string", 138 | }) 139 | .option("folder", { 140 | describe: `${chalk.cyan("Output folder name")}`, 141 | type: "string", 142 | }) 143 | .option("filename", { 144 | describe: `${chalk.cyan("Output filename (excluding extension)")}`, 145 | type: "string", 146 | }) 147 | .option("resolution", { 148 | describe: `${chalk.cyan( 149 | "Available video resolution (144 | 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320)" 150 | )}`, 151 | type: "number", 152 | demandOption: true, 153 | default: 480, 154 | }); 155 | }, 156 | async (argv) => { 157 | logger.info(videoWithoutAudioDescription); 158 | 159 | try { 160 | await dlVideo(argv); 161 | 162 | logger.info( 163 | `${chalk.green("✅")} Video without audio download completed.` 164 | ); 165 | } catch (err) { 166 | logger.error( 167 | `${chalk.red("❌")} Error downloading video without audio:`, 168 | err.message 169 | ); 170 | } 171 | } 172 | ) 173 | .demandCommand() 174 | .recommendCommands() 175 | .strict() 176 | .showHelpOnFail(true) 177 | .help().argv; 178 | 179 | // Show default values for options when not provided 180 | yargs.parse(process.argv.slice(2), (err, argv, output) => { 181 | if (output) { 182 | const defaultValuesRegex = /Default: (\S+)/g; 183 | const formattedOutput = output.replace( 184 | defaultValuesRegex, 185 | (match, defaultValue) => { 186 | return chalk.gray(`(Default: ${defaultValue})`); 187 | } 188 | ); 189 | console.log(formattedOutput); 190 | } 191 | }); 192 | -------------------------------------------------------------------------------- /src/mjs/audio.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | import progLogger from "progress-estimator"; 18 | import logger from "../../utils/logger.mjs"; 19 | import youtubedl from "youtube-dl-exec"; 20 | import ffmpeg from "fluent-ffmpeg"; 21 | import urlRegex from "url-regex"; 22 | import readline from "readline"; 23 | const plogger = progLogger(); 24 | import chalk from "chalk"; 25 | import path from "path"; 26 | import fs from "fs"; 27 | 28 | const createFolderIfNotExists = (folder) => { 29 | if (!folder) { 30 | folder = "youtube-exec"; 31 | } 32 | const outputFolder = path.resolve(process.cwd(), folder); 33 | if (!fs.existsSync(outputFolder)) { 34 | fs.mkdirSync(outputFolder); 35 | logger.info(`📂 Created folder: ${outputFolder}`); 36 | } 37 | }; 38 | 39 | const fetchAudioDetails = async ({ url, quality }) => { 40 | logger.info("🔍 Fetching audio details..."); 41 | try { 42 | const promise = youtubedl(url, { 43 | dumpSingleJson: true, 44 | noCheckCertificates: true, 45 | noWarnings: true, 46 | preferFreeFormats: true, 47 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 48 | }); 49 | const result = await plogger(promise, "⏳ Obtaining..."); 50 | const videoTitle = result.title; 51 | const reqAudio = findReqAudioFormat(result.formats, quality); 52 | return { reqAudio, videoTitle }; 53 | } catch (err) { 54 | logger.info(chalk.red(`❌ Error fetching audio details: ${err.message}`)); 55 | throw err; 56 | } 57 | }; 58 | 59 | const findReqAudioFormat = (formats, quality) => { 60 | let reqAudio = null; 61 | logger.info(`🔍 Fetching Audio Quality: ${quality}`); 62 | if (quality === "best") { 63 | let highestBitrate = 0; 64 | for (let i = 0; i < formats.length; i++) { 65 | const format = formats[i]; 66 | if (format.acodec === "none" || format.vcodec !== "none") { 67 | continue; 68 | } 69 | const bitrate = format.tbr || format.abr; 70 | if (bitrate && bitrate > highestBitrate) { 71 | highestBitrate = bitrate; 72 | reqAudio = format; 73 | } 74 | } 75 | return reqAudio; 76 | } else if (quality === "lowest") { 77 | let lowBitrate = Infinity; 78 | for (let i = 0; i < formats.length; i++) { 79 | const format = formats[i]; 80 | if (format.acodec === "none" || format.vcodec !== "none") { 81 | continue; 82 | } 83 | const bitrate = format.tbr || format.abr; 84 | if (bitrate && bitrate < lowBitrate) { 85 | lowBitrate = bitrate; 86 | reqAudio = format; 87 | } 88 | } 89 | return reqAudio; 90 | } else { 91 | logger.info(chalk.red("❌ Error: Audio Quality supported: best,lowest")); 92 | throw new Error("Error: Audio Quality supported: best,lowest"); 93 | } 94 | }; 95 | 96 | const downloadAudioFile = async (ffmpegUrl, outputFile, quality, filename) => { 97 | let outputFilename; 98 | if (filename) { 99 | outputFilename = filename; 100 | } else { 101 | const videoTitle = path.basename(ffmpegUrl, path.extname(ffmpegUrl)); 102 | outputFilename = `[${quality}]${videoTitle}`; 103 | } 104 | outputFile = path.join(outputFile, `${outputFilename}.mp3`); 105 | 106 | return new Promise((resolve, reject) => { 107 | const ffmpegCommand = ffmpeg() 108 | .input(ffmpegUrl) 109 | .audioBitrate(320) 110 | .toFormat("ipod") 111 | .on("start", () => { 112 | logger.info("📥 Audio download started..."); 113 | }) 114 | .on("progress", (progress) => { 115 | readline.clearLine(process.stdout, 0); 116 | readline.cursorTo(process.stdout, 0); 117 | process.stdout.write(`⬇️ Downloading: ${progress.percent}%`); 118 | }) 119 | .on("end", () => { 120 | readline.clearLine(process.stdout, 0); 121 | readline.cursorTo(process.stdout, 0); 122 | logger.info( 123 | chalk.bold(chalk.green("✅ Audio downloaded successfully!")) 124 | ); 125 | resolve(); 126 | }) 127 | .on("error", (err) => { 128 | readline.clearLine(process.stdout, 0); 129 | readline.cursorTo(process.stdout, 0); 130 | logger.info( 131 | chalk.bold( 132 | chalk.red(`❌ Error downloading audio file: ${err.message}`) 133 | ) 134 | ); 135 | reject(err); 136 | }) 137 | .saveToFile(outputFile); 138 | ffmpegCommand.run(); 139 | }); 140 | }; 141 | 142 | const validateUrl = (url) => { 143 | const regex = urlRegex({ strict: false }); 144 | return regex.test(url); 145 | }; 146 | 147 | const displayAudioDetails = (reqAudio, videoTitle, url) => { 148 | logger.info( 149 | chalk.bold( 150 | chalk.bgCyanBright("🎥 Video Title:"), 151 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 152 | ) 153 | ); 154 | Object.entries(reqAudio).forEach(([key, value]) => { 155 | switch (key) { 156 | case "url": 157 | url = value; 158 | break; 159 | case "fragments": 160 | logger.info(chalk.bold(`▶️ ${chalk.yellow(key)}:`)); 161 | value.forEach((fragment, index) => { 162 | logger.info(chalk.bold(chalk.yellow(`- Fragment no ${index + 1}:`))); 163 | Object.entries(fragment).forEach(([fKey, fValue]) => { 164 | logger.info( 165 | `${chalk.bold(chalk.yellow(fKey))}: ${chalk.bold( 166 | chalk.italic(chalk.white(fValue)) 167 | )}` 168 | ); 169 | }); 170 | }); 171 | break; 172 | default: 173 | logger.info( 174 | chalk.bold( 175 | chalk.yellow( 176 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 177 | ) 178 | ) 179 | ); 180 | break; 181 | } 182 | }); 183 | return url; 184 | }; 185 | 186 | const dlAudio = ({ url, folder, quality, filename }) => { 187 | return new Promise(async (resolve, reject) => { 188 | try { 189 | if (!validateUrl(url)) { 190 | logger.info(chalk.red("❌ Invalid URL format.")); 191 | throw new Error("Invalid URL format."); 192 | } 193 | const { reqAudio, videoTitle } = await fetchAudioDetails({ 194 | url, 195 | quality, 196 | }); 197 | if (reqAudio) { 198 | url = displayAudioDetails(reqAudio, videoTitle, url); 199 | if (!folder) { 200 | folder = "youtube-exec"; 201 | } 202 | createFolderIfNotExists(folder); 203 | let outputFilename; 204 | if (filename) { 205 | outputFilename = `${filename}`; 206 | } else { 207 | outputFilename = `[${quality}]${videoTitle}`; 208 | } 209 | await downloadAudioFile(url, folder, quality, outputFilename); 210 | } else { 211 | logger.info(chalk.bold(chalk.yellow("⚠️ No audio details found."))); 212 | } 213 | resolve(); 214 | } catch (err) { 215 | logger.info(chalk.red(`❌ An error occurred: ${err.message}`)); 216 | reject(err); 217 | } 218 | }); 219 | }; 220 | 221 | export default dlAudio; 222 | -------------------------------------------------------------------------------- /src/cjs/audio.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const progLogger = require("progress-estimator"); 18 | const youtubedl = require("youtube-dl-exec"); 19 | const logger = require("../../utils/logger.js"); 20 | const ffmpeg = require("fluent-ffmpeg"); 21 | const urlRegex = require("url-regex"); 22 | const readline = require("readline"); 23 | const chalk = require("chalk"); 24 | const path = require("path"); 25 | const fs = require("fs"); 26 | 27 | const plogger = progLogger(); 28 | const createFolderIfNotExists = (folder) => { 29 | if (!folder) { 30 | folder = "youtube-exec"; 31 | } 32 | const outputFolder = path.resolve(process.cwd(), folder); 33 | if (!fs.existsSync(outputFolder)) { 34 | fs.mkdirSync(outputFolder); 35 | logger.info(`📂 Created folder: ${outputFolder}`); 36 | } 37 | }; 38 | 39 | const fetchAudioDetails = async ({ url, quality }) => { 40 | logger.info("🔍 Fetching audio details..."); 41 | try { 42 | const promise = youtubedl(url, { 43 | dumpSingleJson: true, 44 | noCheckCertificates: true, 45 | noWarnings: true, 46 | preferFreeFormats: true, 47 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 48 | }); 49 | const result = await plogger(promise, "⏳ Obtaining..."); 50 | const videoTitle = result.title; 51 | const reqAudio = findReqAudioFormat(result.formats, quality); 52 | return { reqAudio, videoTitle }; 53 | } catch (err) { 54 | logger.info(chalk.red(`❌ Error fetching audio details: ${err.message}`)); 55 | throw err; 56 | } 57 | }; 58 | 59 | const findReqAudioFormat = (formats, quality) => { 60 | let reqAudio = null; 61 | logger.info(`🔍 Fetching Audio Quality: ${quality}`); 62 | if (quality === "best") { 63 | let highestBitrate = 0; 64 | for (let i = 0; i < formats.length; i++) { 65 | const format = formats[i]; 66 | if (format.acodec === "none" || format.vcodec !== "none") { 67 | continue; 68 | } 69 | const bitrate = format.tbr || format.abr; 70 | if (bitrate && bitrate > highestBitrate) { 71 | highestBitrate = bitrate; 72 | reqAudio = format; 73 | } 74 | } 75 | return reqAudio; 76 | } else if (quality === "lowest") { 77 | let lowBitrate = Infinity; 78 | for (let i = 0; i < formats.length; i++) { 79 | const format = formats[i]; 80 | if (format.acodec === "none" || format.vcodec !== "none") { 81 | continue; 82 | } 83 | const bitrate = format.tbr || format.abr; 84 | if (bitrate && bitrate < lowBitrate) { 85 | lowBitrate = bitrate; 86 | reqAudio = format; 87 | } 88 | } 89 | return reqAudio; 90 | } else { 91 | logger.info(chalk.red("❌ Error: Audio Quality supported: best,lowest")); 92 | throw new Error("Error: Audio Quality supported: best,lowest"); 93 | } 94 | }; 95 | 96 | const downloadAudioFile = async (ffmpegUrl, outputFile, quality, filename) => { 97 | let outputFilename; 98 | if (filename) { 99 | outputFilename = filename; 100 | } else { 101 | const videoTitle = path.basename(ffmpegUrl, path.extname(ffmpegUrl)); 102 | outputFilename = `[${quality}]${videoTitle}`; 103 | } 104 | outputFile = path.join(outputFile, `${outputFilename}.mp3`); 105 | 106 | return new Promise((resolve, reject) => { 107 | const ffmpegCommand = ffmpeg() 108 | .input(ffmpegUrl) 109 | .audioBitrate(320) 110 | .toFormat("ipod") 111 | .on("start", () => { 112 | logger.info("📥 Audio download started..."); 113 | }) 114 | .on("progress", (progress) => { 115 | readline.clearLine(process.stdout, 0); 116 | readline.cursorTo(process.stdout, 0); 117 | process.stdout.write(`⬇️ Downloading: ${progress.percent}%`); 118 | }) 119 | .on("end", () => { 120 | readline.clearLine(process.stdout, 0); 121 | readline.cursorTo(process.stdout, 0); 122 | logger.info( 123 | chalk.bold(chalk.green("✅ Audio downloaded successfully!")) 124 | ); 125 | resolve(); 126 | }) 127 | .on("error", (err) => { 128 | readline.clearLine(process.stdout, 0); 129 | readline.cursorTo(process.stdout, 0); 130 | logger.info( 131 | chalk.bold( 132 | chalk.red(`❌ Error downloading audio file: ${err.message}`) 133 | ) 134 | ); 135 | reject(err); 136 | }) 137 | .saveToFile(outputFile); 138 | ffmpegCommand.run(); 139 | }); 140 | }; 141 | 142 | const validateUrl = (url) => { 143 | const regex = urlRegex({ strict: false }); 144 | return regex.test(url); 145 | }; 146 | 147 | const displayAudioDetails = (reqAudio, videoTitle, url) => { 148 | logger.info( 149 | chalk.bold( 150 | chalk.bgCyanBright("🎥 Video Title:"), 151 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 152 | ) 153 | ); 154 | Object.entries(reqAudio).forEach(([key, value]) => { 155 | switch (key) { 156 | case "url": 157 | url = value; 158 | break; 159 | case "fragments": 160 | logger.info(chalk.bold(`▶️ ${chalk.yellow(key)}:`)); 161 | value.forEach((fragment, index) => { 162 | logger.info(chalk.bold(chalk.yellow(`- Fragment no ${index + 1}:`))); 163 | Object.entries(fragment).forEach(([fKey, fValue]) => { 164 | logger.info( 165 | `${chalk.bold(chalk.yellow(fKey))}: ${chalk.bold( 166 | chalk.italic(chalk.white(fValue)) 167 | )}` 168 | ); 169 | }); 170 | }); 171 | break; 172 | default: 173 | logger.info( 174 | chalk.bold( 175 | chalk.yellow( 176 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 177 | ) 178 | ) 179 | ); 180 | break; 181 | } 182 | }); 183 | return url; 184 | }; 185 | 186 | const dlAudio = ({ url, folder, quality, filename }) => { 187 | return new Promise(async (resolve, reject) => { 188 | try { 189 | if (!validateUrl(url)) { 190 | logger.info(chalk.red("❌ Invalid URL format.")); 191 | throw new Error("Invalid URL format."); 192 | } 193 | const { reqAudio, videoTitle } = await fetchAudioDetails({ 194 | url, 195 | quality, 196 | }); 197 | if (reqAudio) { 198 | url = displayAudioDetails(reqAudio, videoTitle, url); 199 | if (!folder) { 200 | folder = "youtube-exec"; 201 | } 202 | createFolderIfNotExists(folder); 203 | let outputFilename; 204 | if (filename) { 205 | outputFilename = `${filename}`; 206 | } else { 207 | outputFilename = `[${quality}]${videoTitle}`; 208 | } 209 | await downloadAudioFile(url, folder, quality, outputFilename); 210 | } else { 211 | logger.info(chalk.bold(chalk.yellow("⚠️ No audio details found."))); 212 | } 213 | resolve(); 214 | } catch (err) { 215 | logger.info(chalk.red(`❌ An error occurred: ${err.message}`)); 216 | reject(err); 217 | } 218 | }); 219 | }; 220 | 221 | module.exports = dlAudio; 222 | -------------------------------------------------------------------------------- /src/mjs/vid_aud.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | import progLogger from "progress-estimator"; 18 | import logger from "../../utils/logger.mjs"; 19 | import youtubedl from "youtube-dl-exec"; 20 | import ffmpeg from "fluent-ffmpeg"; 21 | import urlRegex from "url-regex"; 22 | import readline from "readline"; 23 | import chalk from "chalk"; 24 | import path from "path"; 25 | import fs from "fs"; 26 | 27 | const plogger = progLogger(); 28 | 29 | const log = (message) => { 30 | logger.info(message); 31 | }; 32 | const createFolderIfNotExists = (folder) => { 33 | if (!folder) { 34 | folder = "youtube-exec"; 35 | } 36 | const outputFolder = path.resolve(process.cwd(), folder); 37 | if (!fs.existsSync(outputFolder)) { 38 | fs.mkdirSync(outputFolder); 39 | logger.info(`📂 Created folder: ${outputFolder}`); 40 | } 41 | }; 42 | 43 | const fetchVideoAndAudioDetails = async ({ url, requestedResolution }) => { 44 | log("🔍 Fetching video and audio details..."); 45 | try { 46 | const promise = youtubedl(url, { 47 | dumpSingleJson: true, 48 | noCheckCertificates: true, 49 | noWarnings: true, 50 | preferFreeFormats: true, 51 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 52 | }); 53 | const result = await plogger(promise, "⏳ Obtaining..."); 54 | const videoTitle = result.title; 55 | const reqVideo = findReqVideoFormat(result.formats, requestedResolution); 56 | const reqAudio = findReqAudioFormat(result.formats); 57 | return { reqVideo, reqAudio, videoTitle }; 58 | } catch (err) { 59 | throw new Error( 60 | `❌ Error fetching video and audio details: ${err.message}` 61 | ); 62 | } 63 | }; 64 | 65 | const findReqVideoFormat = (formats, requestedResolution) => { 66 | let reqVideo = null; 67 | const availableFormats = formats.filter( 68 | (format) => format.ext === "mp4" && format.format_note !== "none" 69 | ); 70 | const sortedFormats = availableFormats.sort((a, b) => a.height - b.height); 71 | reqVideo = sortedFormats.find( 72 | (format) => format.height >= requestedResolution 73 | ); 74 | return reqVideo; 75 | }; 76 | 77 | const findReqAudioFormat = (formats) => { 78 | let reqAudio = null; 79 | const availableFormats = formats.filter( 80 | (format) => format.ext === "m4a" && format.format_note !== "none" 81 | ); 82 | const sortedFormats = availableFormats.sort((a, b) => b.abr - a.abr); 83 | reqAudio = sortedFormats[0]; 84 | return reqAudio; 85 | }; 86 | 87 | const downloadVideoAndAudioFiles = async ( 88 | videoUrl, 89 | audioUrl, 90 | outputFile, 91 | videoFormat 92 | ) => { 93 | return new Promise((resolve, reject) => { 94 | const ffmpegCommand = ffmpeg() 95 | .input(videoUrl) 96 | .input(audioUrl) 97 | .videoCodec("copy") 98 | .audioCodec("copy") 99 | .on("start", () => { 100 | log("📥 Video and audio download started..."); 101 | }) 102 | .on("progress", (progress) => { 103 | readline.clearLine(process.stdout, 0); 104 | readline.cursorTo(process.stdout, 0); 105 | process.stdout.write(`⬇️ Downloading: ${progress.percent}%`); 106 | }) 107 | .on("end", () => { 108 | readline.clearLine(process.stdout, 0); 109 | readline.cursorTo(process.stdout, 0); 110 | log( 111 | chalk.bold(chalk.green("✅ Video and audio downloaded successfully!")) 112 | ); 113 | resolve(); 114 | }) 115 | .on("error", (err) => { 116 | readline.clearLine(process.stdout, 0); 117 | readline.cursorTo(process.stdout, 0); 118 | logger.error( 119 | chalk.bold( 120 | chalk.red( 121 | `❌ Error downloading video and audio files: ${err.message}` 122 | ) 123 | ) 124 | ); 125 | reject(err); 126 | }) 127 | .save(outputFile); 128 | ffmpegCommand.run(); 129 | }); 130 | }; 131 | 132 | const validateUrl = (url) => { 133 | const regex = urlRegex({ strict: false }); 134 | return regex.test(url); 135 | }; 136 | 137 | const displayVideoAndAudioDetails = (reqVideo, reqAudio, videoTitle, url) => { 138 | log( 139 | chalk.bold( 140 | chalk.bgCyanBright("🎥 Video Title:"), 141 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 142 | ) 143 | ); 144 | if (reqVideo) { 145 | log( 146 | chalk.bold( 147 | chalk.yellow( 148 | `🎞️ Video Format: ${chalk.bold( 149 | chalk.italic(chalk.white(reqVideo.format_id)) 150 | )}` 151 | ) 152 | ) 153 | ); 154 | log( 155 | chalk.bold( 156 | chalk.yellow( 157 | `🖥️ Video Resolution: ${chalk.bold( 158 | chalk.italic(chalk.white(reqVideo.height)) 159 | )}` 160 | ) 161 | ) 162 | ); 163 | log( 164 | chalk.bold( 165 | chalk.yellow( 166 | `🔗 Video URL: ${chalk.bold(chalk.italic(chalk.white(reqVideo.url)))}` 167 | ) 168 | ) 169 | ); 170 | } else { 171 | log(chalk.bold(chalk.yellow("⚠️ No video details found."))); 172 | } 173 | if (reqAudio) { 174 | log( 175 | chalk.bold( 176 | chalk.yellow( 177 | `🔊 Audio Format: ${chalk.bold( 178 | chalk.italic(chalk.white(reqAudio.format_id)) 179 | )}` 180 | ) 181 | ) 182 | ); 183 | log( 184 | chalk.bold( 185 | chalk.yellow( 186 | `🔉 Audio Bitrate: ${chalk.bold( 187 | chalk.italic(chalk.white(reqAudio.abr)) 188 | )}kbps` 189 | ) 190 | ) 191 | ); 192 | log( 193 | chalk.bold( 194 | chalk.yellow( 195 | `🔗 Audio URL: ${chalk.bold(chalk.italic(chalk.white(reqAudio.url)))}` 196 | ) 197 | ) 198 | ); 199 | } else { 200 | log(chalk.bold(chalk.yellow("⚠️ No audio details found."))); 201 | } 202 | return url; 203 | }; 204 | 205 | const displayVideoDetails = (reqVideo, videoTitle, url) => { 206 | log( 207 | chalk.bold( 208 | chalk.bgCyanBright("🎥 Video Title:"), 209 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 210 | ) 211 | ); 212 | Object.entries(reqVideo).forEach(([key, value]) => { 213 | switch (key) { 214 | case "url": 215 | url = value; 216 | break; 217 | default: 218 | log( 219 | chalk.bold( 220 | chalk.yellow( 221 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 222 | ) 223 | ) 224 | ); 225 | break; 226 | } 227 | }); 228 | return url; 229 | }; 230 | 231 | const dlAudioVideo = async ({ url, folder, filename, resolution }) => { 232 | return new Promise(async (resolve, reject) => { 233 | try { 234 | if (!validateUrl(url)) { 235 | throw new Error("❌ Invalid URL format."); 236 | } 237 | const { reqVideo, reqAudio, videoTitle } = 238 | await fetchVideoAndAudioDetails({ 239 | url, 240 | requestedResolution: resolution, 241 | }); 242 | if (reqVideo && reqAudio) { 243 | url = displayVideoAndAudioDetails(reqVideo, reqAudio, videoTitle, url); 244 | url = displayVideoDetails(reqVideo, videoTitle, url); 245 | if (!folder) { 246 | folder = "youtube-exec"; 247 | } 248 | createFolderIfNotExists(folder); 249 | const outputFilename = filename 250 | ? `${filename}.mp4` 251 | : `[${reqVideo.height}]${videoTitle}.mp4`; 252 | const outputPath = path.join(folder, outputFilename); 253 | await downloadVideoAndAudioFiles( 254 | reqVideo.url, 255 | reqAudio.url, 256 | outputPath, 257 | reqVideo 258 | ); 259 | log(chalk.bold(chalk.green("✅ Video downloaded successfully!"))); 260 | resolve(); 261 | } else { 262 | throw new Error("⚠️ No video and audio details found."); 263 | } 264 | } catch (err) { 265 | reject(err); 266 | } 267 | }); 268 | }; 269 | 270 | export default dlAudioVideo; 271 | -------------------------------------------------------------------------------- /src/cjs/vid_aud.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // =====================================( youtube-exec: Unleash the Power of YouTube Downloads! )============================================= 3 | // 🌟 Once upon a time in the vast realm of the Internet, a remarkable tool was born: YOUTUBE-EXEC. 📽️✨ 4 | // 5 | // 🎥 Step into a world where you can effortlessly download the mesmerizing audio and captivating video content from YouTube. 🎵🎬💽 6 | // 💡 Powered by the mighty and ingenious "youtube-dl-exec" library, this tool possesses the uncanny ability to extract the finest details from YouTube's vast kingdom of videos. 📚🔍💡 7 | // ⚙️ Equipped with the seamless and reliable "fluent-ffmpeg" library, youtube-exec embarks on a quest to fetch files with utmost precision and grace. 8 | // With each step, it transforms the abstract bits and bytes into a symphony of sights and sounds. 🔄⚙️🔊 9 | // 🌟 Unlock the gates to a realm where your favorite audio harmonies and video treasures await. 10 | // Dive into the enchanting world of YouTube's vast library, and let your imagination soar. 🎉🔑💎 11 | // 🔓 Embrace the freedom to break free from limitations and embrace a world of boundless possibilities. 12 | // Bid farewell to the boundaries that once held you back and embark on an adventure beyond your wildest dreams. 🚫🌍🔓💫 13 | // 📖 This is the tale of youtube-exec, a tool that empowers you to shape your own narrative in the realm of YouTube. 14 | // Let your journey begin! 🚀🎬🔥 15 | // 16 | // =====================================( youtube-exec by magneum )============================================= 17 | const progLogger = require("progress-estimator"); 18 | const youtubedl = require("youtube-dl-exec"); 19 | const logger = require("../../utils/logger.js"); 20 | const ffmpeg = require("fluent-ffmpeg"); 21 | const urlRegex = require("url-regex"); 22 | const readline = require("readline"); 23 | const chalk = require("chalk"); 24 | const path = require("path"); 25 | const fs = require("fs"); 26 | 27 | const log = (message) => { 28 | logger.info(message); 29 | }; 30 | 31 | const plogger = progLogger(); 32 | const createFolderIfNotExists = (folder) => { 33 | if (!folder) { 34 | folder = "youtube-exec"; 35 | } 36 | const outputFolder = path.resolve(process.cwd(), folder); 37 | if (!fs.existsSync(outputFolder)) { 38 | fs.mkdirSync(outputFolder); 39 | logger.info(`📂 Created folder: ${outputFolder}`); 40 | } 41 | }; 42 | 43 | const fetchVideoAndAudioDetails = async ({ url, requestedResolution }) => { 44 | log("🔍 Fetching video and audio details..."); 45 | try { 46 | const promise = youtubedl(url, { 47 | dumpSingleJson: true, 48 | noCheckCertificates: true, 49 | noWarnings: true, 50 | preferFreeFormats: true, 51 | addHeader: ["referer:youtube.com", "user-agent:googlebot"], 52 | }); 53 | const result = await plogger(promise, "⏳ Obtaining..."); 54 | const videoTitle = result.title; 55 | const reqVideo = findReqVideoFormat(result.formats, requestedResolution); 56 | const reqAudio = findReqAudioFormat(result.formats); 57 | return { reqVideo, reqAudio, videoTitle }; 58 | } catch (err) { 59 | throw new Error( 60 | `❌ Error fetching video and audio details: ${err.message}` 61 | ); 62 | } 63 | }; 64 | 65 | const findReqVideoFormat = (formats, requestedResolution) => { 66 | let reqVideo = null; 67 | const availableFormats = formats.filter( 68 | (format) => format.ext === "mp4" && format.format_note !== "none" 69 | ); 70 | const sortedFormats = availableFormats.sort((a, b) => a.height - b.height); 71 | reqVideo = sortedFormats.find( 72 | (format) => format.height >= requestedResolution 73 | ); 74 | return reqVideo; 75 | }; 76 | 77 | const findReqAudioFormat = (formats) => { 78 | let reqAudio = null; 79 | const availableFormats = formats.filter( 80 | (format) => format.ext === "m4a" && format.format_note !== "none" 81 | ); 82 | const sortedFormats = availableFormats.sort((a, b) => b.abr - a.abr); 83 | reqAudio = sortedFormats[0]; 84 | return reqAudio; 85 | }; 86 | 87 | const downloadVideoAndAudioFiles = async ( 88 | videoUrl, 89 | audioUrl, 90 | outputFile, 91 | videoFormat 92 | ) => { 93 | return new Promise((resolve, reject) => { 94 | const ffmpegCommand = ffmpeg() 95 | .input(videoUrl) 96 | .input(audioUrl) 97 | .videoCodec("copy") 98 | .audioCodec("copy") 99 | .on("start", () => { 100 | log("📥 Video and audio download started..."); 101 | }) 102 | .on("progress", (progress) => { 103 | readline.clearLine(process.stdout, 0); 104 | readline.cursorTo(process.stdout, 0); 105 | process.stdout.write(`⬇️ Downloading: ${progress.percent}%`); 106 | }) 107 | .on("end", () => { 108 | readline.clearLine(process.stdout, 0); 109 | readline.cursorTo(process.stdout, 0); 110 | log( 111 | chalk.bold(chalk.green("✅ Video and audio downloaded successfully!")) 112 | ); 113 | resolve(); 114 | }) 115 | .on("error", (err) => { 116 | readline.clearLine(process.stdout, 0); 117 | readline.cursorTo(process.stdout, 0); 118 | logger.error( 119 | chalk.bold( 120 | chalk.red( 121 | `❌ Error downloading video and audio files: ${err.message}` 122 | ) 123 | ) 124 | ); 125 | reject(err); 126 | }) 127 | .save(outputFile); 128 | ffmpegCommand.run(); 129 | }); 130 | }; 131 | 132 | const validateUrl = (url) => { 133 | const regex = urlRegex({ strict: false }); 134 | return regex.test(url); 135 | }; 136 | 137 | const displayVideoAndAudioDetails = (reqVideo, reqAudio, videoTitle, url) => { 138 | log( 139 | chalk.bold( 140 | chalk.bgCyanBright("🎥 Video Title:"), 141 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 142 | ) 143 | ); 144 | if (reqVideo) { 145 | log( 146 | chalk.bold( 147 | chalk.yellow( 148 | `🎞️ Video Format: ${chalk.bold( 149 | chalk.italic(chalk.white(reqVideo.format_id)) 150 | )}` 151 | ) 152 | ) 153 | ); 154 | log( 155 | chalk.bold( 156 | chalk.yellow( 157 | `🖥️ Video Resolution: ${chalk.bold( 158 | chalk.italic(chalk.white(reqVideo.height)) 159 | )}` 160 | ) 161 | ) 162 | ); 163 | log( 164 | chalk.bold( 165 | chalk.yellow( 166 | `🔗 Video URL: ${chalk.bold(chalk.italic(chalk.white(reqVideo.url)))}` 167 | ) 168 | ) 169 | ); 170 | } else { 171 | log(chalk.bold(chalk.yellow("⚠️ No video details found."))); 172 | } 173 | if (reqAudio) { 174 | log( 175 | chalk.bold( 176 | chalk.yellow( 177 | `🔊 Audio Format: ${chalk.bold( 178 | chalk.italic(chalk.white(reqAudio.format_id)) 179 | )}` 180 | ) 181 | ) 182 | ); 183 | log( 184 | chalk.bold( 185 | chalk.yellow( 186 | `🔉 Audio Bitrate: ${chalk.bold( 187 | chalk.italic(chalk.white(reqAudio.abr)) 188 | )}kbps` 189 | ) 190 | ) 191 | ); 192 | log( 193 | chalk.bold( 194 | chalk.yellow( 195 | `🔗 Audio URL: ${chalk.bold(chalk.italic(chalk.white(reqAudio.url)))}` 196 | ) 197 | ) 198 | ); 199 | } else { 200 | log(chalk.bold(chalk.yellow("⚠️ No audio details found."))); 201 | } 202 | return url; 203 | }; 204 | 205 | const displayVideoDetails = (reqVideo, videoTitle, url) => { 206 | log( 207 | chalk.bold( 208 | chalk.bgCyanBright("🎥 Video Title:"), 209 | chalk.bold(chalk.italic(chalk.white(videoTitle))) 210 | ) 211 | ); 212 | Object.entries(reqVideo).forEach(([key, value]) => { 213 | switch (key) { 214 | case "url": 215 | url = value; 216 | break; 217 | default: 218 | log( 219 | chalk.bold( 220 | chalk.yellow( 221 | `${key}: ${chalk.bold(chalk.italic(chalk.white(value)))}` 222 | ) 223 | ) 224 | ); 225 | break; 226 | } 227 | }); 228 | return url; 229 | }; 230 | 231 | const dlAudioVideo = async ({ url, folder, filename, resolution }) => { 232 | return new Promise(async (resolve, reject) => { 233 | try { 234 | if (!validateUrl(url)) { 235 | throw new Error("❌ Invalid URL format."); 236 | } 237 | const { reqVideo, reqAudio, videoTitle } = 238 | await fetchVideoAndAudioDetails({ 239 | url, 240 | requestedResolution: resolution, 241 | }); 242 | if (reqVideo && reqAudio) { 243 | url = displayVideoAndAudioDetails(reqVideo, reqAudio, videoTitle, url); 244 | url = displayVideoDetails(reqVideo, videoTitle, url); 245 | if (!folder) { 246 | folder = "youtube-exec"; 247 | } 248 | createFolderIfNotExists(folder); 249 | const outputFilename = filename 250 | ? `${filename}.mp4` 251 | : `[${reqVideo.height}]${videoTitle}.mp4`; 252 | const outputPath = path.join(folder, outputFilename); 253 | await downloadVideoAndAudioFiles( 254 | reqVideo.url, 255 | reqAudio.url, 256 | outputPath, 257 | reqVideo 258 | ); 259 | log(chalk.bold(chalk.green("✅ Video downloaded successfully!"))); 260 | resolve(); 261 | } else { 262 | throw new Error("⚠️ No video and audio details found."); 263 | } 264 | } catch (err) { 265 | reject(err); 266 | } 267 | }); 268 | }; 269 | 270 | module.exports = dlAudioVideo; 271 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

📥🎥 YouTube-Exec 🎥📥

2 | 3 | ### **⭐️ If you find YouTube-Exec useful, give it a star on [GitHub](https://github.com/magneum/youtube-exec)** 4 | 5 |
6 | 7 |
8 | 9 | ## **Unleash the Power of YouTube Downloads!** 💪🔥💻 10 | 11 | - Effortlessly download audio and video content from YouTube. 🎵🎬💽 12 | - Utilizes the powerful `youtube-dl-exec` library for extracting details. 📚🔍💡 13 | - Seamless fetching of files using the reliable `fluent-ffmpeg` library. 🔄⚙️🔊 14 | - Access and download your favorite audio and video treasures from YouTube. 🎉🔑💎 15 | - Say goodbye to limitations and enjoy a world of boundless possibilities. 🚫🌍🔓💫 16 | 17 | | | | 18 | | -------------- | --------------------------------------------------------------------------------------------------- | 19 | | License | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) | 20 | | Latest Version | [![npm](https://img.shields.io/npm/v/youtube-exec.svg)](https://www.npmjs.com/package/youtube-exec) | 21 | 22 |

Installation: 📥💻🔧

23 | 24 | To embark on your YouTube downloading adventure with YouTube-Exec, you'll need to have Node.js installed on your system. Fear not! The installation process is as easy as a few simple commands: 25 | 26 | - Using yarn or npm or pnpm 27 | 28 | ``` 29 | $ yarn add youtube-exec 30 | $ npm install youtube-exec 31 | $ pnpm install youtube-exec 32 | ``` 33 | 34 |

Usage (w/o CLI): 🖥️🔧📚

35 | 36 |
37 | 🎵 Download Audio 🔊 38 | 39 | To download audio from YouTube, you can use the `dlAudio` function provided by YouTube-Exec. Here's an example of how to use it: 40 | 41 | ```javascript 42 | const { dlAudio } = require("youtube-exec"); 43 | 44 | // Using async/await 45 | try { 46 | await dlAudio({ 47 | url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 48 | folder: "downloads", // optional, default: "youtube-exec" 49 | filename: "filename", // optional, default: video title 50 | quality: "best", // or "lowest"; default: "best" 51 | }); 52 | console.log("Audio downloaded successfully! 🔊🎉"); 53 | } catch (err) { 54 | console.error("An error occurred:", err.message); 55 | } 56 | 57 | // Using Promises 58 | dlAudio({ 59 | url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 60 | folder: "downloads", // optional, default: "youtube-exec" 61 | filename: "filename", // optional, default: video title 62 | quality: "best", // or "lowest"; default: "best" 63 | }) 64 | .then(() => { 65 | console.log("Audio downloaded successfully! 🔊🎉"); 66 | }) 67 | .catch((err) => { 68 | console.error("An error occurred:", err.message); 69 | }); 70 | ``` 71 | 72 |
73 | 74 |
75 | 🎥🔊 Download Video with Audio 🎥🔊 76 | 77 | To download videos with audio from YouTube, you can use the `dlAudioVideo` function provided by YouTube-Exec. Here's an example of how to use it: 78 | 79 | ```javascript 80 | const { dlAudioVideo } = require("youtube-exec"); 81 | 82 | // Using async/await 83 | try { 84 | await dlAudioVideo({ 85 | url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 86 | folder: "downloads", // optional, default: "youtube-exec" 87 | filename: "filename", // optional, default: video title 88 | resolution: 720, // 144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320; default: 480 89 | }); 90 | console.log("Video downloaded successfully! 🎥🔊🎉"); 91 | } catch (err) { 92 | console.error("An error occurred:", err.message); 93 | } 94 | 95 | // Using Promises 96 | dlAudioVideo({ 97 | url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 98 | folder: "downloads", // optional, default: "youtube-exec" 99 | filename: "filename", // optional, default: video title 100 | resolution: 720, // 144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320; default: 480 101 | }) 102 | .then(() => { 103 | console.log("Video downloaded successfully! 🎥🔊🎉"); 104 | }) 105 | .catch((err) => { 106 | console.error("An error occurred:", err.message); 107 | }); 108 | ``` 109 | 110 |
111 | 112 |
113 | 🎥 Download Video w/o Audio 🎥 114 | 115 | To download videos without audio from YouTube, you can use the `dlVideo` function provided by YouTube-Exec. Here's an example of how to use it: 116 | 117 | ```javascript 118 | const { dlVideo } = require("youtube-exec"); 119 | 120 | // Using async/await 121 | try { 122 | await dlVideo({ 123 | url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 124 | folder: "downloads", // optional, default: "youtube-exec" 125 | filename: "filename", // optional, default: video title 126 | resolution: 720, // 144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320; default: 480 127 | }); 128 | console.log("Video downloaded successfully! 🎥🎉"); 129 | } catch (err) { 130 | console.error("An error occurred:", err.message); 131 | } 132 | 133 | // Using Promises 134 | dlVideo({ 135 | url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 136 | folder: "downloads", // optional, default: "youtube-exec" 137 | filename: "filename", // optional, default: video title 138 | resolution: 720, // 144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320; default: 480 139 | }) 140 | .then(() => { 141 | console.log("Video downloaded successfully! 🎥🎉"); 142 | }) 143 | .catch((err) => { 144 | console.error("An error occurred:", err.message); 145 | }); 146 | ``` 147 | 148 |
149 | 150 |

Usage (with CLI): 🖥️💻🔧📚

151 | 152 | - Install the package globally: 153 | 154 | ```bash 155 | $ npm install -g youtube-exec # sudo required for global install 156 | ``` 157 | 158 |
159 | Download Audio 🔊 (with CLI usage) 160 | 161 | The "audio" command allows you to download audio from a YouTube video. It accepts the following options: 162 | 163 | - `url`: The URL of the YouTube video (required). 164 | - `folder`: The output folder name (optional). 165 | - `filename`: The output filename (excluding extension) (optional, defaults to video title). 166 | - `quality`: The audio quality ("best" or "lowest") (optional, defaults to "best"). 167 | 168 | Here's an example of how to use the "audio" command: 169 | 170 | ```bash 171 | $ yarn global add youtube-exec # needs to be installed globally 172 | $ youtube-exec audio --url "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --folder "downloads" --filename "filename" --quality "best" 173 | ``` 174 | 175 |
176 | 177 |
178 | Download Video with Audio 🎥🔊 (with CLI usage) 179 | 180 | The "video-with-audio" command allows you to download video with audio from a YouTube video. It accepts the following options: 181 | 182 | - `url`: The URL of the YouTube video (required). 183 | - `folder`: The output folder name (optional). 184 | - `filename`: The output filename (excluding extension) (optional, defaults to video title). 185 | - `resolution`: The video resolution (144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320) (optional, defaults to 480). 186 | 187 | Here's an example of how to use the "video-with-audio" command: 188 | 189 | ```bash 190 | $ yarn global add youtube-exec # needs to be installed globally 191 | $ youtube-exec video-with-audio --url "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --folder "downloads" --filename "filename" --resolution 720 192 | ``` 193 | 194 |
195 | 196 |
197 | Download Video without Audio 🎥🔊 (with CLI usage) 198 | 199 | The "video" command allows you to download video without audio from a YouTube video. It accepts the following options: 200 | 201 | - `url`: The URL of the YouTube video (required). 202 | - `folder`: The output folder name (optional). 203 | - `filename`: The output filename (excluding extension) (optional, defaults to video title). 204 | - `resolution`: The video resolution (144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320) (optional, defaults to 480). 205 | 206 | Here's an example of how to use the "video" command: 207 | 208 | ```bash 209 | $ yarn global add youtube-exec # needs to be installed globally 210 | $ youtube-exec video --url "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --folder "downloads" --filename "filename" --resolution 720 211 | ``` 212 | 213 |
214 | 215 |

Features: 🎯🔥🌟

216 | 217 | - Extract video and audio details from YouTube effortlessly 218 | - Download audio files from YouTube videos 🎵🔊 219 | - Download videos with audio from YouTube 🎥🔊 220 | - Choose audio quality (best or lowest) 🔊🥇 221 | - Choose video resolution (144, 240, 360, 480, 720, 1080, 1440, 2160, or 4320) 🎥📺 222 | - Simple and intuitive API 🚀 223 | - CLI support for easy downloading 💻⚡ 224 | 225 |

License: 📜🔐

226 | 227 |

228 | YouTube-Exec is released under the MIT License. Feel free to use, modify, and distribute it as you like. 229 | The MIT License grants you the following permissions: 230 |

231 | 232 | - ✅ Permission is hereby granted, free of charge, to any person obtaining a copy of the YouTube-Exec software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 233 | 234 | - 📋 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 235 | 236 | - 🚀 The Software is provided "as is," without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Software or the use or other dealings in the Software. 237 | 238 | - 🔗 The Software may utilize third-party libraries, including but not limited to `youtube-dl-exec` and `fluent-ffmpeg`. Any such libraries are subject to their respective licenses and terms. 239 | 240 | - 🔒 Users of the Software acknowledge that the extraction and downloading of audio and video content from YouTube may be subject to legal restrictions and terms of use imposed by YouTube or other relevant entities. It is the responsibility of the users to comply with all applicable laws, regulations, and terms of use when using the Software. 241 | 242 | - 👥 The Software is intended for personal and non-commercial use only. Any commercial use of the Software requires explicit permission from the authors. 243 | --------------------------------------------------------------------------------