Giter Club home page Giter Club logo

Comments (35)

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

`ytdl(results, { filter: function(f) {
return f.container === 'mp4' && !f.encoding; } })
.pipe(fs.createWriteStream(audioOutput))
.on('finish', function() {
ffmpeg()
.input(ytdl(urlm, { filter: function(f) {
return f.container === 'mp4' && !f.audioEncoding; } }))
.videoCodec('copy')
.input(audioOutput)
.audioCodec('copy')
.save(path.resolve(__dirname, 'output.mp4'))
.on('error', console.error)
.on('progress', function(progress) {

  }).on('end', function() {
    console.log();
  });` script which im using

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

Hard to tell what is going on from your code snippet. Are you passing the results of the youtube search to ytdl? If so just pass results.link instead and not the entire object. If this does not solve you problem can you please submit a small working example which demonstrates the problem?

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

yes is for a discord bot

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

@frankhale results.link does not work

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

Will you please provide a small example that shows the issue because it's difficult to tell what you are doing from the sample you posted.

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

want a bigger sample for more anallising

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

@frankhale

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

I don't know where 'url' is coming from in your error. 'url' isn't something returned from youtube-search results. The result object looks like this:

[ { id: 'UCYEK6xds6eo-3tr4xRdflmQ',
    link: 'https://www.youtube.com/channel/UCYEK6xds6eo-3tr4xRdflmQ',
    kind: 'youtube#channel',
    publishedAt: '2006-10-19T12:22:09.000Z',
    channelId: 'UCYEK6xds6eo-3tr4xRdflmQ',
    title: 'deadmau5',
    description: 'random carnage a la deadmau5.',
    thumbnails: { default: [Object], medium: [Object], high: [Object] } },
  { id: 'PKFcaXd5G8c',
    link: 'https://www.youtube.com/watch?v=PKFcaXd5G8c',
    kind: 'youtube#video',
    publishedAt: '2016-12-16T14:58:58.000Z',
    channelId: 'UCYEK6xds6eo-3tr4xRdflmQ',
    title: 'deadmau5 - Let Go Feat. Grabbitz (Cube 2.1)',
    description: 'http://www.lotsofshowsinarow.com W:/2016ALBUM/ out now: http://smarturl.it/2016album deadmau5 offers an exclusive Behind The Scenes look at the work that ...',
    thumbnails: { default: [Object], medium: [Object], high: [Object] } } ]

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

im trying to make it so people can do a command like this ^play (youtube search term here) @frankhale

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

I noticed that you are using the module https://github.com/fent/node-ytdl-core to download the YouTube video. Are you having an issue with that module or the youtube-search module?

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

youtube search @frankhale

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

If all you are trying to do is play the video you can use the YouTube IFrame API to do that.

https://developers.google.com/youtube/iframe_api_reference

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

im tying to get the url from the 1 result of the seacrh term

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

Have a look at the object returned by the results. It's an array of objects that look like this:

the URL is the 'link' string (see below)

{ id: 'PKFcaXd5G8c',
    link: 'https://www.youtube.com/watch?v=PKFcaXd5G8c',
    kind: 'youtube#video',
    publishedAt: '2016-12-16T14:58:58.000Z',
    channelId: 'UCYEK6xds6eo-3tr4xRdflmQ',
    title: 'deadmau5 - Let Go Feat. Grabbitz (Cube 2.1)',
    description: 'http://www.lotsofshowsinarow.com W:/2016ALBUM/ out now: http://smarturl.it/2016album deadmau5 offers an exclusive Behind The Scenes look at the work that ...',
    thumbnails: { default: [Object], medium: [Object], high: [Object] } }

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

ok one more thing is there any other youtube url grabbing thing

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

like youtube-api

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

npmjs.com lists a bunch of YouTube modules but still you haven't told us really what the issue is with this module. I use this module in my own YouTube player and it works very well for searching YouTube. I'm trying to understand what issue you are having but so far am not able to figure out what problem you are encountering.

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

ok let me put it easly ith the code sample and saying this im making a discord bot with a music function
and im trying to get the url aka link from the search term 1result link automatically here is the script i have in my ftp right now

`if (content.indexOf("^play ") == 0) {
const urlm = content.replace("^play ", "");
channel.sendMessage("debug: url/search term: " + urlm);
let vc = e.message.member.getVoiceChannel()
if(vc){vc.join();
} else {
}

   try{
var audioOutput = path.resolve(__dirname, e.message.guild.name + '.mp3');
ytdl(urlm, { filter: function(f) {
  return f.container === 'mp4' && !f.encoding; } })
    .pipe(fs.createWriteStream(audioOutput))
  .on('finish', function() {
    ffmpeg()
    .input(ytdl(urlm, { filter: function(f) {
      return f.container === 'mp4' && !f.audioEncoding; } }))
      .videoCodec('copy')
      .input(audioOutput)
      .audioCodec('copy')
      .save(path.resolve(__dirname, 'output.mp4'))
      .on('error', console.error)
      .on('progress', function(progress) {
        

      }).on('end', function() {
        console.log();
      });
channel.sendMessage("^^" + urlm + "^^ is downloaded and will now play :arrow_forward: ");
filenamee = e.message.guild.name + ".mp3";


play();


});
} catch(error) { 

var opts = {
  maxResults: 1,
  key: 'AIzaSyD1J1tnUlAxa0WxO9-XY6AwsuoBc7Dso1w'
};

search(urlm, opts, function(err, results) {
var audioOutput = path.resolve(__dirname, e.message.guild.name + '.mp3');
ytdl(results.link(), { filter: function(f) {
  return f.container === 'mp4' && !f.encoding; } })
    .pipe(fs.createWriteStream(audioOutput))
  .on('finish', function() {
    ffmpeg()
    .input(ytdl(results.link, { filter: function(f) {
      return f.container === 'mp4' && !f.audioEncoding; } }))
      .videoCodec('copy')
      .input(audioOutput)
      .audioCodec('copy')
      .save(path.resolve(__dirname, 'output.mp4'))
      .on('error', console.error)
      .on('progress', function(progress) {
        

      }).on('end', function() {
        console.log();
      });
channel.sendMessage("^^" + results + "^^ is downloaded and will now play  from youtube search :arrow_forward: ");
filenamee = e.message.guild.name + ".mp3";


});
});
}`

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

even though you specified maxResults of 1 you'll still get an array with 1 element. Trying to do this results.link will not work like that. Try results[0].link. Additionally it's not a function so you can't do results.link(). Link is a string that you can pass to the ytdl module like you are trying to do in your code sample.

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

ok

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

i get this error url.js:87
throw new TypeError('Parameter "url" must be a string, not ' + typeof url);
^

TypeError: Parameter "url" must be a string, not undefined
at Url.parse (url.js:87:11)
at Object.urlParse [as parse] (url.js:81:5)
at Object.exports.getVideoID (/var/www/html/bot/node_modules/ytdl-core/lib/util.js:225:20)
at getInfo (/var/www/html/bot/node_modules/ytdl-core/lib/info.js:39:17)
at ytdl (/var/www/html/bot/node_modules/ytdl-core/lib/index.js:18:3)
at WriteStream. (/var/www/html/bot/bot.js:285:12)
at emitNone (events.js:91:20)
at WriteStream.emit (events.js:185:7)
at finishMaybe (_stream_writable.js:515:14)
at afterWrite (_stream_writable.js:389:3)
at onwrite (_stream_writable.js:379:7)

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

now got it semi working

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

I don't think the issue is on the youtube-search module side. Looks like the error is coming from the ytdl-core module based on your sample code.

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

shows string like this ^^[object Object]^^

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

var r = results[0].link; string for results

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

I think for me or anyone to help further we'd need to see a small sample code that is complete (and something we could run locally) so we could do some more debugging.

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

image
what it shows in discord and sample code
search(urlm, opts, function(err, results) {
var audioOutput = path.resolve(__dirname, e.message.guild.name + '.mp3');
var r = results[0].link; //string
ytdl(r, { filter: function(f) {
return f.container === 'mp4' && !f.encoding; } })
.pipe(fs.createWriteStream(audioOutput))
.on('finish', function() {
ffmpeg()
.input(ytdl(r, { filter: function(f) {
return f.container === 'mp4' && !f.audioEncoding; } }))
.videoCodec('copy')
.input(audioOutput)
.audioCodec('copy')
.save(path.resolve(__dirname, 'output.mp4'))
.on('error', console.error)
.on('progress', function(progress) {

  }).on('end', function() {
    console.log();
  });

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

@frankhale got it working now

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

Awesome!

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

want to join my discord server and try it @frankhale

from youtube-search.

frankhale avatar frankhale commented on August 17, 2024

I don't have the discord app installed on this machine =(

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

@frankhale ok use online https://discord.gg/XH92D and discord made an improvement it works online

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

@frankhale they made it to work online now

from youtube-search.

bluethefoxyt avatar bluethefoxyt commented on August 17, 2024

@frankhale non expire link https://discord.gg/gxUkCvw

from youtube-search.

MaxGfeller avatar MaxGfeller commented on August 17, 2024

Please just use these issues for actual issues with the package. For more general questions you can always resort to sites like stackoverflow. @kessanro

from youtube-search.

Related Issues (20)

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.