Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically deploy changes to Vimeo #61

Open
wesbos opened this issue Sep 28, 2018 · 0 comments
Open

Automatically deploy changes to Vimeo #61

wesbos opened this issue Sep 28, 2018 · 0 comments

Comments

@wesbos
Copy link
Owner

wesbos commented Sep 28, 2018

Right now these changes have to be manually sync'd to vimeo.

I have a script I cobbled together that will push them up to vimeo, but its not automatic.

What I would like is that anytime a file changes, we push that to vimeo so the updated captions are up there.

This would require that we put the video ID in the title, or some sort of metadata.

Also I would like to do this with translated captions as well.

Not an immediate need, but something to think about @lfades

const Vimeo = require('vimeo').Vimeo;
const axios = require('axios');

const lib = new Vimeo(
  'nah',
  'nah',
  'nahhhhhhh'
);

const fs = require('fs');

const videoData = require('../../../Sites/bosmonster/site/data/videos-JS3');

const videos = videoData.videos.filter(video => video.caption).map(video => {
  video.texttrack = fs.readFileSync(`../../Wes-Bos-Captions/${video.caption}`);
  return video;
});

function uploadCaption(video) {
  return new Promise((resolve, reject) => {
    const path = `/videos/${video.id}/texttracks`;
    lib.request(
      {
        method: 'POST',
        path,
        query: {
          type: 'captions',
          language: 'en',
          name: `${video.title} Captions`,
        },
      },
      (err, body) => {
        axios
          .put(body.link, video.texttrack)
          .then(res => {
            resolve(`Finished ${video.title}`)
          })
          .catch(err => {
            reject(`error on video ${video.id}`)
            console.log(err);
          });
      }
    );
  });
}

let i = 1;

async function go() {
  const video = videos[i];
  console.log(`Starting ${video.title}`);
  const res = await uploadCaption(video);
  console.log(res);
  i++;
  if (videos[i]) {
    go();
  }
}

go().catch(console.error);

@lfades

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant