Beispiel #1
0
exports.vidinfo = function (req, res, next) {
  var ytBaseurl = "http://www.youtube.come/watch?v="
    , url = req.body.url || "Tnm2jirXsT4" || null;
  ytdl.getInfo(ytBaseurl+url, function (err, info) {
    if (err) return console.log(err);
    res.send(info);
  });
};
Beispiel #2
0
function dlyt(path, convertToMp3){
  ytdl.getInfo(path, function(err, info) {
    var fileName = err ? "ytmp3.flv" : sanatize(info.title.trim() + ".flv");
    var stream = fs.createWriteStream(fileName);
    ytdl(path).pipe(stream).on('close', function() {
      console.log("----- Download complete -----");
      if(convertToMp3) {
        stream.end();
        console.log("----- converting to mp3 -----");
        var fileEnd = /\.flv$/;
        convert(fileName, fileName.replace(fileEnd, '.mp3'));
      }
    });
  });
}
Beispiel #3
0
yt.getVideoInfos = function (video_link,num,total,upnp,ext,settings, cb){
	if (total === 1) {
	    videos_responses = new Array();
	}
    var video = {};
    video.num = num;
    video.total = total;
    video.link = video_link;
    video.cb = cb;
    yt.upnp = upnp;
    yt.extPlayer = ext;
    try {
        ytdl.getInfo(video.link, video, function(err, video, info){
            if(err) {
                console.log("YTDL ERROR : " + err);
                videos_responses[num]=video;
                return;
            } else {
				try {
					video.id = info.video_id;
					video.title = info.title;
					video.views = info.view_count;
					video.thumb =  info.thumbnail_url;
					video.author = info.author;
					video.duration = info.length_seconds;
					if ( parseInt(info.formats.length) === 0) {
						return;
					}
					var resolutions = {};
					var res = [];
					var count = 0;
                    console.log(info.formats)
					Iterator.iterate(info.formats).forEach(function (format,i) {
						try {
                            var resolution = format.resolution;
    						if(resolution == null) {
    							return;
    						}
    						var container = format.container;
    						var encoding = format.encoding;
    						if(yt.upnp || yt.extPlayer) {
    							if (in_array(resolution,res) || container == 'flv' || container == '3gp' || container == "webm" ) {
    								return;
    							}
    						} else {
    							if (in_array(resolution,res) || container == 'flv' || container == '3gp' || container == "m4a" ) {
    								return;
    							}
    						}
    						res.push(resolution);
    						resolutions[resolution] = [];
    						resolutions[resolution]['itag'] = format.itag;
                            resolutions[resolution]['resolution'] = format.resolution;
    						resolutions[resolution]['container'] = container;
    						resolutions[resolution]['cypher'] = true;
                            resolutions[resolution]['upnp'] = upnp;
    						video.resolutions = {};
    						if (info.formats.use_cipher_signature === false) {
    							resolutions[resolution]['cypher'] = false;
    							resolutions[resolution]['link'] = format.url;
    						}
                        } catch(err) {
                            console.log(err)
                        }
					});
					analyseRes(resolutions,video,info,settings);
				} catch(err) {
					console.log(err)
				}
			}
		});
    } catch(err) {
        console.log('getVideoInfos err: '+ err);
    }
}