youtube-to-twitter

1.1.0 • Public • Published

YouTube to Twitter

Download video from youtube channel and upload it twitter.

Install

npm install --save youtube-to-twitter

Example

See server.js

const express = require('express');
const { download, trim, tweet, upload, video } = require('youtube-to-twitter');
 
const app = express();
 
app.get('/', async (req, res) => {
  res.sendStatus(200);
 
  main()
    .then(console.log)
    .catch(console.error);
});
 
const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`listen on port ${port}`);
});
 
async function main() {
  const start = parseInt(process.env.VIDEO_START, 10) || 0;
  const duration = parseInt(process.env.VIDEO_DURATION, 10) || 30;
 
  const { title, url } = await video();
  const status =
    title.replace(/【ハックフォープレイ実況】/, ' #HackforPlay') +
    '\n\nつづきはこちら↓\n' +
    url;
  console.log('next tweet:\n', status);
 
  const source = await download(url);
  const output = await trim(source, start, start + duration);
 
  const mediaId = await upload(output);
  await tweet(mediaId, status);
}

Readme

Keywords

none

Package Sidebar

Install

npm i youtube-to-twitter

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

9.41 kB

Total Files

11

Last publish

Collaborators

  • teramotodaiki