How to use the ytdl-core.getURLVideoID function in ytdl-core

To help you get started, we’ve selected a few ytdl-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github efoxbr / megacubo / assets / js / playback.js View on Github external
self.run = () => {
        console.log('run() called');
        if(typeof(ytdl)=='undefined'){
            ytdl = require('ytdl-core')
        }
        var id = ytdl.getURLVideoID(self.entry.url);
        console.log('run() id', id, self.entry.url);
        ytdl.getInfo(id, (err, info) => {
            if (err){
                console.log('YTDL error');
                self.error = 'connect';
                self.trigger('error')
                throw err;
            } else {
                console.log('YT Info', info);
                if(info.title) {
                    self.rename(info.title, info.thumbnail_url)
                }
                var live = [];
                for(var i=0;i
github efoxbr / megacubo / assets / js / playback.js View on Github external
} else if(!forceTranscode && (isHTML5Video(entry.url) || isM3U8(entry.url))){
        console.log('CREATEPLAYINTENT FOR HTML5/M3U8', entry.url);
        if(currentPlaybackTypePriotity == -1 || PlaybackManager.intentTypesPriorityOrder.indexOf('direct') < currentPlaybackTypePriotity){
            types.push('direct')
        }
    } else if(isMedia(entry.url)){
        console.log('CREATEPLAYINTENT FOR MEDIA', entry.url);
        if(currentPlaybackTypePriotity == -1 || PlaybackManager.intentTypesPriorityOrder.indexOf('ffmpeg') < currentPlaybackTypePriotity){
            types.push('ffmpeg')
        }
    } else if(isYT(entry.url)){
        console.log('CREATEPLAYINTENT FOR YT', entry.url);
        if(typeof(ytdl)=='undefined'){
            ytdl = require('ytdl-core')
        }
        var id = ytdl.getURLVideoID(entry.url);
        if(id && id != 'live_stream' && entry.url.indexOf('#yt-live') == -1){
            if(currentPlaybackTypePriotity == -1 || PlaybackManager.intentTypesPriorityOrder.indexOf('youtube') < currentPlaybackTypePriotity){
                types.push('youtube')
            }
        } else {
            if(currentPlaybackTypePriotity == -1 || PlaybackManager.intentTypesPriorityOrder.indexOf('frame') < currentPlaybackTypePriotity){
                types.push('frame')
            }
        }
    } else if(['html', 'htm'].indexOf(getExt(entry.url))!=-1) {
        console.log('CREATEPLAYINTENT FOR GENERIC', entry.url);
        if(allowWebPages){
            if(currentPlaybackTypePriotity == -1 || PlaybackManager.intentTypesPriorityOrder.indexOf('frame') < currentPlaybackTypePriotity){
                if(!options || !options.isSideload){
                    types.push('frame')
                }
github naomiaro / video-waveform-subtitle-editor / server / routes / media.js View on Github external
router.post('/', function(req, res, next) {
  const ytUri = req.body.ytUri;
  const srtFile = req.files.srt;
  let job;
  let mediaFilename;
  let filePromise = Promise.resolve();

  if (ytdl.validateURL(ytUri)) {
    mediaFilename = ytdl.getURLVideoID(ytUri);
    job = queue.createJob({
      videoItag: VIDEO_ITAG
    }).setId(mediaFilename);
  } else {
    const videoFile = req.files.video;
    mediaFilename = md5(req.files.video.data);
    job = queue.createJob({}).setId(mediaFilename);
    filePromise = filePromise.then(videoFile.mv(path.join(MEDIA_DIR, `${mediaFilename}.webm`)));
  }

  filePromise
    .then(srtFile.mv(path.join(MEDIA_DIR, `${mediaFilename}.srt`)))
    .then(job.save())
    .catch((err) => {
      console.log(`${err.message}`);
    });
github onhernandes / soundman / api / music / post.js View on Github external
async function _post (body) {
  if (!body.hasOwnProperty('url')) {
    throw new MusicError({
      error: 'URL not found'
    }, 400)
  }

  body.video_id = yt.getURLVideoID(body.url)

  if (!body.video_id) {
    throw new MusicError({
      error: 'Could not parse YoutubeID!'
    }, 400)
  }

  try {
    let song = await Music.create(body)
    return mongofilter(song.toObject())
  } catch (e) {
    if (e.code === 11000) {
      throw new MusicError({
        error: 'Music already exists'
      }, 409)
    } else {
github efoxbr / megacubo / assets / js / core / global.js View on Github external
function isYT(url){
    url = String(url);
    if(url.indexOf('youtube.com')==-1 && url.indexOf('youtu.be')==-1){
        return false;
    }
    if(typeof(ytdl)=='undefined'){
        ytdl = require('ytdl-core')
    }
    var id = ytdl.getURLVideoID(url);
    return typeof(id)=='string';
}
github onhernandes / soundman / api / lib / youtube / youtube.js View on Github external
function Youtube (music) {
  if (!yt.validateURL(music.url)) {
    throw new Error(`Given music URL is invalid!`)
  }

  this.url = music.url
  this.music = music
  this.video_id = yt.getURLVideoID(music.url)
}