Skip to content

hitblast/trimsec

Repository files navigation

trimsec

Note

Want a very simple, basic version of it? Try trimsec.c.

Table of Contents

Overview

trimsec helps you plan your content consumption. It includes utility functions such as duration-trimming (AKA calculating how much time you'd have in hand after you've watched a video with a multiplier), playlist and video-trimming (same stuff but for YouTube), and other commands. It is still a work-in-progress project, and more commands are already planned!

It is oriented towards terminal-headed academic nerds (pun intended) who can't seem to get a grasp of their syllabus until the last night before the exam, when they already have hundreds of videos to cover. Theoretically impossible to cover - trimsec makes it easier.

Usage

(Optional) Enabling YouTube Capabilities

Note

This section is only needed if you're going to be passing in YouTube playlists/videos as arguments.

Steps:

  • Get your API key for the YouTube Data API (v3) from the Google Cloud Console.
  • Create a new .trimsecrc file at your $HOME (on Windows: C:\Users\<USERNAME>) directory with this structure:
    api_key = "YOUR_API_KEY_HERE"
  • Or, set it as TRIMSEC_YOUTUBE_KEY in your environment.
    • A good choice is to use direnv and create a .envrc file in your $HOME, then run direnv allow in your home directory from the terminal to set it as an isolated environment variable, although beware that the variable won't be available in any other directories.

1. Basic Trimming

For eyeballed durations:

To calculate saved time, you run the trim command as follows:

ts trim <duration> <speed>

# Example:
ts trim 1h 2x

This command outputs the time you saved by watching an hour-long video at 2x the speed. This works for any integer or floating-point combination on either the duration or the multiplier:

ts trim 1h30m 1.5x
ts trim 1.5h30m 1.5x  # equivalent to 2 hours

Combine multiple durations like this:

ts trim 1h30m+2h50m 1.25x

For YouTube videos/playlists:

Instead of using the trim command, you'll be using the yt (or y) command:

ts yt -l https://www.youtube.com/watch?v=D4iiKkjGJmU -m 1.25x

You can also throw in a YouTube playlist in (almost) any format you want, and it'd show the total time saved based on the multiplier:

ts yt -l "https://www.youtube.com/watch?v=rdXw7Ps9vxc&list=PLHXZ9OQGMqxersk8fUxiUMSIx0DBqsKZS" -m 1.8x

As you can see, the link strings are getting quite big. To solve this, a clipboard-fetcher comes included.

# reads from clipboard
ts yt -m 1.8x --clip

For traversing only a certain amount of items in a playlist (starting from the 1st item), use this:

ts yt --max-items 7 -l "SOME_PLAYLIST_URL" -m 1.8x

Fit-Checking

This feature can be used to check whether a certain YouTube video/playlist fits in the day, or a given duration. You basically run:

ts fitcheck [OPTIONS]

A number of use-cases could be listed as follows:

# link grabbed from clipboard; budget is today
ts fitcheck --clip

# same as above, but shorter
ts fc --clip

# link pasted manually; budget is today
ts fc --link "https://youtube.com/..."

# shortened param names; budget is 2 hours and 4 minutes
ts fc -l "https://youtube.com/..." -b 2h4m

# youtube playlist + item cap
ts fc -l "https://youtube.com/playlist?..." --max-items 5

# disable clipboard functionalities intentionally
ts fc --link "https://youtube.com/..." --no-clip

As you can see by now, most of the parameters and flags are the same as the trim command, so it is worthwhile to check both documentations and compare-contrast between what to use and what to not.

Utility Commands

Note

More such commands will be added with the following releases, as these are proportional to ideas coming in.

  • For listing the contents in a YouTube playlist:
ts list -l "https://youtube.com/..."
ts ls --clip            # shorter; grabs from clipboard
ts ls --max-items 5     # only traverses 5 items

Installation

Homebrew

brew tap hitblast/tap && brew trust hitblast/tap
brew install trimsec

cargo

cargo install trimsec

mise

mise use -g cargo:trimsec

Prebuilt Binaries

Get platform-based binaries here: https://github.com/hitblast/trimsec/releases

Manual Installation

git clone https://github.com/hitblast/trimsec.git
cd trimsec && cargo build --release

License

This project is licensed under the MIT License.

About

Speed up durations, save time, and plan your content intake.

Topics

Resources

License

Contributing

Stars

5 stars

Watchers

1 watching

Forks

Contributors