npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vidup

v1.0.6

Published

Synchronize a local directory of video files to remote streaming services.

Downloads

27

Readme

vidup

NPM Package vidup License: MIT

Synchronize a local directory of video files to remote streaming services.

[!WARNING]
This tool was built in haste and has been tested only against a relatively narrow use-case. If you use it, please review the docs, invoke with care, and make sure you have local copies of your remote videos and metadata.

Overview

Vidup is a CLI tool and Node library to automate one-way synchronization of local video files to remote video streaming CDN services.

It checks for differences between your local and remote videos, and automatically creates, updates, or deletes videos on the remote service so that it exactly mirrors the contents of a local directory.

Currently, only Bunny.net's Bunny Stream service is supported as a sync target. Adding support additional platforms like Mux and Cloudflare Stream wouldn't be too tricky.

Getting started

Dependencies

The vidup CLI tool requires Node 18+. The exported APIs are ESM-only and share the Node 18+ requirement. Vidup is implemented in TypeScript and bundles type definitions.

A Bunny Stream account, API key, and library ID are required.

Installation

Invoke directly:

npx vidup

Or, install locally to access the CLI commands in a single project or to import the provided APIs:

npm install vidup

Or, install globally for access across your system:

npm install --global vidup

Usage

Vidup treats local videos' file names as keys, and will look for a file with the same name / title on the remote streaming service.

Any video files present in the local folder that aren't matched to a video on the remote service will be uploaded.

If you change the name of a local video file, the remote video with the previous name will be deleted, and a new remote video (with a ne GUID) will be created.

Vidup tracks the content hash of each local video. If you replace a local video file with another of the same name, the change in content will be detected and the remote video will be updated. (Note that this is currently equivalent to deleting / creating a new remote video since Bunny.net doesn't support in-place video updates. The GUID will change, so you'll need to update any embeds accordingly.)

Any videos present on the remote service that aren't matched to a video file in the local folder will be deleted from the remote service.

CLI

Command: vidup

Run a vidup command.

This section lists top-level commands for vidup.

If no command is provided, vidup sync is run by default.

Usage:

vidup [command]

| Command | Argument | Description | | ------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | sync | <directory> [options] | Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory. (Default command.) |

See the sections below for more information on each subcommand.

Subcommand: vidup sync

Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.

Usage:

vidup sync <directory> [options]

| Positional Argument | Description | Type | | ------------------- | --------------------------------------------------------------------- | -------- | | directory | The path to the local directory of video files to sync. (Required.) | string |

| Option | Description | Type | Default | | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------- | | --service-s | Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time. | "bunny" "mux" "cloudflare" | | | --key | Streaming service API access key. | string | | | --library | Streaming service library ID. | string | | | --strip-metadata | Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place. | boolean | false | | --dry-run-d | Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the --json command. | boolean | false | | --json | Output the sync report as JSON. | boolean | false | | --verbose | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to stderr for ease of redirection. | boolean | false | | --help-h | Show help | boolean | | | --version-v | Show version number | boolean | |

Examples

Synchronize video files in the current folder to Bunny Stream:

vidup . --service bunny --key <BUNNY_API_KEY> --library <BUNNY_LIBRARY_ID>

Large uploads can take some time. Upon completion, a report summarizing the actions taken is printed to stdout:

None: an-already-uploaded-video.mov
Create: a-new-video.mov
Update: a-changed-video.mp4
Delete: a-remote-only-video.mp4

Perform a non-executive dry run and get the synchronization plan report as JSON:

vidup . --json --dry-run --service bunny --key <BUNNY_API_KEY> --library <BUNNY_LIBRARY_ID>

The JSON version of the output provides some extra info.

Library

API

Vidup's functionality is also provided in module form for use in TypeScript or JavaScript Node projects.

The library exports syncVideoInDirectory, which takes an options argument mirroring the arguments available via the command line and returns an object reporting the synchronization steps performed:

async function syncVideoInDirectory(
  directory: string,
  options: {
    service: Service
    credentials: {
      key: string
      library: string
    }
    dryRun?: boolean // defaults to false
    verbose?: boolean // defaults to false
  },
): Promise<SyncReport>

A stripVideoMetadataInDirectory function is also exported, which will remove metadata from all videos in the target directory. It returns a list of video filepaths with metadata:

export async function stripVideoMetadataInFiles(
  directory: string,
  options: {
    dryRun?: boolean // defaults to false
    verbose?: boolean // defaults to false
  },
): Promise<string[]>

Examples

import { syncVideoInDirectory } from 'vidup'

const syncReport = await syncVideoInDirectory(process.cwd(), {
  service: 'bunny',
  credentials: {
    key: BUNNY_API_KEY,
    library: BUNNY_LIBRARY_ID,
  },
})

console.log(JSON.stringify(syncReport, undefined, 2))

Background

Motivation

Video streaming providers have slow and clunky web UIs. I'd rather not maintain the remote collection by hand. The web these days makes Finder.app feel like a CRUD tour-de-force.

The future

  • [ ] Tests
  • [ ] Add Cosmiconfig
  • [ ] Synchronize thumbnails and other metadata
  • [ ] Remote collection / folder support
  • [ ] Mux support
  • [ ] Cloudflare Stream support
  • [ ] Support for additional streaming services

Maintainers

@kitschpatrol

Acknowledgments

Thanks to @dan-online for his super-helpful bunnycdn-stream library.

Contributing

Issues and pull requests are welcome.

License

MIT © Eric Mika