GithubHelp home page GithubHelp logo

joshunrau / ytdl-mp3 Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 9.0 765 KB

An NPM package to facilitate downloading music from YouTube, including automatic retrieval of ID3 tags and album art via the iTunes public API

Home Page: https://www.npmjs.com/package/ytdl-mp3

License: MIT License

JavaScript 5.17% Shell 0.45% TypeScript 94.38%
youtube youtube-dl cli downloader mp3 music

ytdl-mp3's Introduction

ytdl-mp3

An NPM package to facilitate downloading music from YouTube, including automatic retrieval of ID3 tags and album art via the iTunes public API.
Report Bug · Request Feature

license version codecov


Installation

npm install -g ytdl-mp3

Usage

Command-Line

The easiest way to use ytdl-mp3 is through the command-line interface. Users must enter the URL of the YouTube video they wish to download. The title of the music video is then used to automatically retrieve ID3 tags (e.g., title, artist) and the associated cover art from iTunes. There is no need for the title of the YouTube video to follow a specific naming convention.

Usage: ytdl-mp3 [options] <url>

A NodeJS package and command-line tool for downloading music from YouTube, including automatic retrieval of ID3 tags and album art via iTunes.

Arguments:
url                     url of video to download

Options:
-V, --version           output the version number
-o --output-dir <path>  path to output directory
-n --no-get-tags        skip extracting/applying id3 tags
-v --verify-tags        verify id3 tags fetched from itunes
-h, --help              display help for command

ESM

import { Downloader } from 'ytdl-mp3';

const downloader = new Downloader({
  getTags: true
});

await downloader.downloadSong('https://www.youtube.com/watch?v=7jgnv0xCv-k');

CommonJS

const { Downloader } = require('ytdl-mp3');

async function main() {
  const downloader = new Downloader({
    getTags: true
  });
  await downloader.downloadSong('https://www.youtube.com/watch?v=7jgnv0xCv-k');
}

main();

ytdl-mp3's People

Contributors

dependabot[bot] avatar henrrysilva avatar joshunrau avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ytdl-mp3's Issues

Error: Invalid response

Hey, Joshua, the issue with downloading appeared a couple days ago. I updated the package for the newest version, here's the stack trace:

ytdl-mp3 https://www.youtube.com/watch?v=7TREIsVM08Q
Unable to extract all song tags from YouTube
Enter title:
C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\src\utils.js:26
reject(new Error('Invalid response: ' + response));
^

Error: Invalid response:
at C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\src\utils.js:26:24
at [_onLine] [as _onLine] (node:internal/readline/interface:422:7)
at [_line] [as _line] (node:internal/readline/interface:885:18)
at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1263:22)
at ReadStream.onkeypress (node:internal/readline/interface:272:20)
at ReadStream.emit (node:events:527:28)
at emitKeys (node:internal/readline/utils:358:14)
at emitKeys.next ()
at ReadStream.onData (node:internal/readline/emitKeypressEvents:64:36)
at ReadStream.emit (node:events:527:28)

Node.js v18.0.0

I use windows 10.

The error occurs if the "Enter title:" or "Enter artist:" is empty. Before that it worked like a charm if I left them empty. Do you have any suggestions about this problem?

new returns for downloadSong function

The DownloadSong function could return some options beyond of audio name, example an type ReadableStream.

example

const ytdlMp3 = new YtdlMp3(URL_VIDEL);

ytdlMp3.downloadSong();
ytdlMp3.readStream();

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for

Hey, Josh. I've updated the package for the recent version and now for every download attempt an error. Here's my stacktrace:
`λ ytdl-mp3 https://www.youtube.com/watch?v=ZAjKsE5MNeU
node:internal/errors:465
ErrorCaptureStackTrace(err);
^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\bin\ytdl-mp3. Loading extensionless files is not supported inside of "type":"module" package.json contexts. The package.json file C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\package.json caused this "type":"module" context. Try changing C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\bin\ytdl-mp3 to have a file extension. Note the "bin" field of package.json can point to a file with an extension, for example {"type":"module","bin":{"ytdl-mp3":".\bin\ytdl-mp3.js"}}
at new NodeError (node:internal/errors:372:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:80:11)
at defaultGetFormat (node:internal/modules/esm/get_format:122:38)
at defaultLoad (node:internal/modules/esm/load:21:20)
at ESMLoader.load (node:internal/modules/esm/loader:431:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:350:22)
at new ModuleJob (node:internal/modules/esm/module_job:66:26)
at #createModuleJob (node:internal/modules/esm/loader:369:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:328:34)
at async Promise.all (index 0) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'`

Node.js v18.0.0

Failed to fetch info for video with URL

Tried to update for the new version but without success. ytdl-mp3 is installed globally. It worked great 2 weeks ago at least. Do you have some thoughts what can be the problem?
Thanks in advance

ytdl-mp3 https://www.youtube.com/watch?v=PN-ih2G79TU
WARNING: ytdl-core is out of date! Update with "npm install ytdl-core@latest".
C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\dist\index.js:233
throw new Error(Failed to fetch info for video with URL: ${url});
^

Error: Failed to fetch info for video with URL: https://www.youtube.com/watch?v=PN-ih2G79TU
at C:\Users\admin\AppData\Roaming\npm\node_modules\ytdl-mp3\dist\index.js:233:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.0.0

Any way to remove console log?

It always outputting something like
```Done! Output file: tmp/music/m89GTfifrrM/spin_and_burst.mp3``

How can i get rid of this? Any options to disable logging to console?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.