Skip to content

๐Ÿš€ GitHub Action and CLI to archive YouTube channels by uploading the channel's videos to archive.org

Notifications You must be signed in to change notification settings

Biodiversity-CatTracker2/internetarchive-youtube

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

51 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Internetarchive-YouTube

Poetry-build Supported Python versions PEP8

๐Ÿš€ GitHub Action and CLI to archive YouTube channels by uploading the channel's videos to archive.org.

CLI: Getting Started ๐Ÿง‘โ€๐Ÿ’ป

Requirements:

โฌ‡๏ธ Installation:

pip install internetarchive-youtube

# Install and login to internetarchive
pip install internetarchive
ia configure

๐Ÿ—ƒ๏ธ Backend database:

export MONGODB_CONNECTION_STRING=mongodb://username:password@host:port
  • If you choose JSONBin, export the master key as an environment variable:
export JSONBIN_KEY=xxxxxxxxxxxxxxxxx

โŒจ๏ธ Usage:

usage: ia-yt [-h] [-p PRIORITIZE] [-s SKIP_LIST] [-f] [-t TIMEOUT] [-n] [-a] [-c CHANNELS_FILE] [-S] [-C]

optional arguments:
  -h, --help            show this help message and exit
  -p PRIORITIZE, --prioritize PRIORITIZE
                        Comma-separated list of channel names to prioritize
                        when processing videos
  -s SKIP_LIST, --skip-list SKIP_LIST
                        Comma-separated list of channel names to skip
  -f, --force-refresh   Refresh the database after every video (Can slow down
                        the workflow significantly, but is useful when running
                        multiple concurrent jobs)
  -t TIMEOUT, --timeout TIMEOUT
                        Kill the job after n hours (default: 5.5)
  -n, --no-logs         Don't print any log messages
  -a, --add-channel     Add a channel interactively to the list of channels to
                        archive
  -c CHANNELS_FILE, --channels-file CHANNELS_FILE
                        Path to the channels list file to use if the
                        environment variable `CHANNELS` is not set (default:
                        ~/.yt_channels.txt)
  -S, --show-channels   Show the list of channels in the channels file
  -C, --create-collection
                        Creates/appends to the backend database from the
                        channels list

GitHub Action: Getting Started โšก๏ธ

  1. Fork this repository.
  2. Create a backend database (or JSON bin).
  3. Add your Archive.org credentials to the repository's Actions secrets:
  • ARCHIVE_USER_EMAIL
  • ARCHIVE_PASSWORD
  1. Add a list of the channels you want to archive to the repository's Actions secrets:

The CHANNELS secret should be formatted like this example:

CHANNEL_NAME: CHANNEL_URL
FOO: CHANNEL_URL
FOOBAR: CHANNEL_URL
SOME_CHANNEL: CHANNEL_URL

Don't add any quotes around the name or the URL, and make sure to keep one space between the colon and the URL.

  1. Add the database secret(s) to the repository's Actions secrets:

If you picked option 1 (MongoDB), add this additional secret:

  • MONGODB_CONNECTION_STRING

If you picked option 2 (JSON bin), add this additional secret:

  • JSONBIN_KEY
  1. Run the workflow under Actions manually with a workflow_dispatch, or wait for it to run automatically.

That's it!

๐Ÿ—๏ธ Creating A Backend Database

  • Option 1: MongoDB (recommended).
  • Option 2: JSON bin (if you want a quick start).
    • Sign up to JSONBin here.
    • Click on VIEW MASTER KEY, then copy the key.

๐Ÿ“ Notes

  • Information about the MONGODB_CONNECTION_STRING can be found here.
  • Jobs can run for a maximum of 6 hours, so if you're archiving a large channel, the job might die, but it will resume in a new job when it's scheduled to run.
  • Instead of raw text, you can pass a file path or a file URL with a list of channels formatted as CHANNEL_NAME: CHANNEL_URL or in JSON format {"CHANNEL_NAME": "CHANNEL_URL"}.

About

๐Ÿš€ GitHub Action and CLI to archive YouTube channels by uploading the channel's videos to archive.org

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.4%
  • Shell 0.6%