Comments (35)
`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.
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.
yes is for a discord bot
from youtube-search.
@frankhale results.link does not work
from youtube-search.
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.
want a bigger sample for more anallising
from youtube-search.
from youtube-search.
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.
im trying to make it so people can do a command like this ^play (youtube search term here) @frankhale
from youtube-search.
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.
youtube search @frankhale
from youtube-search.
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.
im tying to get the url from the 1 result of the seacrh term
from youtube-search.
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.
ok one more thing is there any other youtube url grabbing thing
from youtube-search.
like youtube-api
from youtube-search.
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.
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.
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.
ok
from youtube-search.
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.
now got it semi working
from youtube-search.
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.
shows string like this ^^[object Object]^^
from youtube-search.
var r = results[0].link;
string for results
from youtube-search.
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.
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.
@frankhale got it working now
from youtube-search.
Awesome!
from youtube-search.
want to join my discord server and try it @frankhale
from youtube-search.
I don't have the discord app installed on this machine =(
from youtube-search.
@frankhale ok use online https://discord.gg/XH92D and discord made an improvement it works online
from youtube-search.
@frankhale they made it to work online now
from youtube-search.
@frankhale non expire link https://discord.gg/gxUkCvw
from youtube-search.
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)
- Getting error HOT 3
- WARNING: Critical dependency: the request of a dependency is an expression HOT 1
- Just read it... HOT 1
- TypeError: Cannot read property 'kind' of undefined HOT 2
- index.d.ts typescript error HOT 1
- Bad Request HOT 9
- Exposed key in tests/test-search.js HOT 1
- How to receive video duration? HOT 2
- Use axios as http client HOT 5
- Search fails while more than one word HOT 5
- get URL HOT 2
- Video details
- Optimize requests to use less quota units. HOT 1
- Error: Request failed with status code 403
- error 403 HOT 9
- Youtube pllaylist URL HOT 2
- Can't search with the package HOT 6
- Tape for testing?
- Need help HOT 10
- Uncaught TypeError: querystring.stringify is not a function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from youtube-search.