Code Monkey home page Code Monkey logo

node-yt-converter's Introduction

Hi, and Welcome!

Do you want to know about me?

When I was 13 years old, I was interested in web development, at that moment I had no idea how big it could be, and for that reason I began to learn in a self-taught way, advancing little by little, with the help of free and paid courses, I have been able to to make practice web by myself.

What characterizes me the most is my interest in continuing to learn, and I do not limit myself to being in my comfort zone.

๐Ÿ“šKnowledge

๐Ÿ† Achievements

๐Ÿ“Š Stats

node-yt-converter's People

Contributors

rogeliolb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

node-yt-converter's Issues

error, while running example

i tried to run code from example
yt.convertAudio({ url: "https://www.youtube.com/watch?v=JzbGrvkqV5w", itag: 140, directoryDownload: __dirname, title: "Your title here" },onData,onClose)
but i have error: "ReferenceError: onData is not defined"

Add possibility to add video title on save

We can set save path but we can't set video title on saving.

yt.convertVideo(
{
	url: videoId,
	itag: quality,
	directoryDownload: savePath,
	title: "Your title here"
}, onData, onClose);

Just add another param to set title, thank you.

Error: write EPIPE at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)

I am getting this error

Error: write EPIPE
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:94:16)
Emitted 'error' event on Socket instance at:
at Socket.onerror (internal/streams/readable.js:764:14)
at Socket.emit (events.js:376:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

This is my code

const post_SaveAsVideo = async (req, res) => {
try {
const url = req.body.url;
const title = req.body.title;
const itag = req.body.itag;
const qualityLabel = req.body.qualityLabel;

const newname = title.replace(/[\/\\:*?"'|]/g, "-");
const combinedname = newname + qualityLabel;

onData = (p) => {
  percentage = p;
  console.log(p);
};

onClose = async (c) => {
  close = c;
  if (close) {
    res.download(`./Mp4downloads/${combinedname}.mp4`);
    console.log(combinedname);
    console.log(title);

    const newVideoData = new videoSchema({
      url: url,
      itag: MainTag,
      title: combinedname,
    });
    await newVideoData.save();
  }
  console.log("Finish");
};
const downloadFolder = path.resolve(__dirname, "../Mp4downloads");
const MainTag = itag[0];

try {
  yt.convertVideo(
    {
      url: url,
      itag: MainTag,
      directoryDownload: downloadFolder,
      title: combinedname,
    },
    onData,
    onClose
  );

  console.log(MainTag);
  console.log(url);
  console.log(combinedname);
} catch (err) {
  console.log(err);
 
  throw err;
}

} catch (err) {
console.log(err);

res.status(500).send("Internal Server Error");

}
};

Error: read ECONNRESET at Pipe.onStreamRead (node:internal/stream_base_commons:217:20)

when I try to convert mp3/mp4 i got an error

$ node .
node:events:491                                                                                                                                                        
      throw er; // Unhandled 'error' event                                                                                                                             
      ^                                                                                                                                                                

Error: read ECONNRESET                                                                                                                                                 
    at Pipe.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Socket instance at:
    at Socket.onerror (node:internal/streams/readable:785:14)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}

my sc

const link = 'https://www.youtube.com/watch?v=fIkw_Rc7ZJA'

const getTitle = yt.getInfo(link).then(info => info.title);
const getIngfo = yt.getInfo(link).then(info => {
    return{
        title: info.title, author: info.author.name, likes: info.likes
    }
});
const getThumb = yt.getInfo(link).then(info => info.thumbnails[4]['url'])

async function tes(link){
    const title = await getTitle
    const ingfo = await getIngfo
    const thumb = await getThumb
    const thumbnails = thumb.split('?')
    // console.log(thumbnails[0])
    // console.log(title)
    yt.convertAudio({
        url: link,
        directoryDownload: './lib/',
        itag: 140,
        title: title
    }, (percentage, size) => {
        console.log(Math.floor(percentage), size.totalSize)
    }, () => {
        console.log(ingfo)
    })
}

tes(link)

how to fix this ?

if unable to fix, how can pass that error and log the error without stoping / crashed script if using nodemon

@RogelioLB

Error using convertAudio

I'm new with this library, so just used this

`
var yt = require('yt-converter');
var path = require('path');

var url = 'https://www.youtube.com/watch?v=4CAgg2qmaAY';

yt.convertAudio(url,140, path.join(__dirname), function(a){
console.log('CLOSE', a);
});
`

And I'm getting this error:

`
app_path\node_modules\ytdl-core\lib\url-utils.js:75
exports.validateID = id => idRegex.test(id.trim());
^

TypeError: Cannot read properties of undefined (reading 'trim')
at Object.exports.validateID (app_path\node_modules\ytdl-core\lib\url-utils.js:75:44)
at Object.exports.getVideoID (app_path\node_modules\ytdl-core\lib\url-utils.js:58:15)
at Function.exports. [as getInfo] (app_path\node_modules\ytdl-core\lib\info.js:484:29)
at app_path\node_modules\yt-converter\src\utils\getInfo.js:42:14
at new Promise ()
at getInfo (app_path\node_modules\yt-converter\src\utils\getInfo.js:40:26)
at Object.convertAudio (app_path\node_modules\yt-converter\src\utils\convertAudio.js:41:28)
at Object. (app_path\index3.js:37:4)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
`

Any clue on what is wrong?

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.