1.0.2 • Published 10 months ago
@h3mul/reuploader v1.0.2
Reuploader
A simple library to contain logic for uploading data streams to various destinations, with a consistent interface.
Implemented uploaders and supported features:
YoutubeUploader
Prerequisite: set up OAuth refresh token
Option Key | Description | Type |
---|---|---|
title* | youtube video title | string |
description* | youtube video description | string |
source* | arbitrary data stream | node:stream |
insertIntoPlaylist | an existing playlistId to insert the new video into after upload | string |
unlisted | whether the new upload should be marked as unlisted; false = public (default: false) | boolean |
* = required
import { Source, YoutubeUploader } from '@hemul/reuploader';
import token from './.token.json' assert { type: 'json' };
const exampleFileStream = Source.getFileStream({ path: './examples/test_video.mp4' });
const uploader = new YoutubeUploader({
token,
client_id: process.env.YOUTUBE_CLIENT_ID!,
client_secret: process.env.YOUTUBE_CLIENT_SECRET!,
});
logger.debug('Starting upload');
const { videoUrl } = await uploader.upload({
title: 'Test Video',
description: 'test video description',
source: exampleFileStream,
insertIntoPlaylist: '<playlist id>',
unlisted: true
});
logger.debug('Upload complete: ' + videoUrl);