Giter Club home page Giter Club logo

switchtube-dl's Introduction

switchtube-dl

A simple CLI for downloading videos from SwitchTube.

This makes it a lot more convenient to consume the videos on-demand when you're offline.

contributions welcome Release CI

Features

  • Download videos by their video id
  • Videos from channels can be downloaded selectively with interactive mode (default)
  • All videos can be downloaded from channels non interactively
  • Videos that are already downloaded can be skipped

Installation Powered By: dotnet-releaser

Linux

Arch Linux

Install it with your favourite AUR helper. For example:

pamac install switchtube-dl-bin
# or:
yay -S switchtube-dl-bin

Debian

Download the .deb package for your architecture from the latest release and install it with your package manager.

macOS

brew install panmona/panmona/switchtube-dl

Windows

Download the latest windows release zip for your architecture. If you aren't sure about your architecture, you're most likely going to have success with win-x64.zip.

Unzip it and put the .exe in an appropriate place. For easier access, make sure that this place is contained in your PATH variable.

If Emoji are not displaying correctly in your terminal refer to this documentation.

Getting Started

After installation generate an API Token from your SwitchTube Profile and save it to an appropriate place.

You will need this token for every download that you run.

Usage

Please note that you should be gentle when downloading videos in parallel as noted in the official API docs:

Please be gentle with the servers because hammering the web service will also decrease performance of the web site.


USAGE: switchtube-dl [--help] [--video <video id>] [--channel <channel id>] [--token <token>] [--path <path>] [--skip]
                     [--force] [--all] [--version]

OPTIONS:

    --video, -v <video id>
                          Download type. Downloads a specific video. Prioritized if multiple download types are given
    --channel, -c <channel id>
                          Download type. Download videos from this channel. Starts in interactive mode if no filter
                          option is given
    --token, -t <token>   Token to access the SwitchTube API. Generate a token at
                          https://tube.switch.ch/access_tokens
    --path, -p <path>     Paths to download videos to (defaults to current dir). The path must already exist.
    --skip, -s            Existing file handling option. Skip download of already existing files. Prioritized if
                          multiple existing file options are given
    --force, -f           Existing file handling option. Overwrite already existing files
    --all, -a             Filter option. Downloads all videos in a channel
    --version             Display the current version.
    --help                display this list of options.

Download a video

switchtube-dl -v 123456

Channel download

switchtube-dl -c 123456

It will per default start in interactive mode and output a table of all videos in this channel:

Index │ Title              │ Duration │    Date
──────┼────────────────────┼──────────┼────────────
    1 │ Video A            │ 00:09:39 │ 2020-07-08
    2 │ Video B            │ 00:09:39 │ 2020-09-09
    3 │ Video C            │ 00:15:16 │ 2020-09-09
    4 │ Video D            │ 00:11:45 │ 2020-09-09
    5 │ Video E            │ 00:06:04 │ 2020-09-09
    6 │ Video F            │ 00:08:16 │ 2020-09-09
    7 │ Video G            │ 00:12:25 │ 2021-11-30
    8 │ Video H            │ 00:11:12 │ 2022-02-07
    9 │ Video I            │ 01:03:00 │ 2022-02-09

To choose which videos to download, specify indices of the videos separated by commas like: 1,4,5,6 if you want to download the videos indexed 1,4,5,6 of the channel.

You can specify a range, for example 1-3,5,7-9 will download the videos at index 1, 2, 3, 5, 7, 8 and 9.

Filter options

If you don't want to use interactive mode for the channel download there are the following filter options:

All videos

With -a or --all all videos in the channel are downloaded.

Global options

Existing file handling

Per default the CLI exits when it notices that a file already exists under the same name. If you want a different behavior there are two strategies defined.

Overwrite

If already existing files should be overwritten use -f or --force.

Skip

If already existing files should be skipped use -s or --skip. If both options are provided skip is prioritized.

Path

Per default the files are downloaded to the directory from where the CLI is invoked. If you want to provide a different path use -p or --path. This path must be absolute and exist.

Related

Teletube: If you need upload access to SwitchTube

Contributing

Any type of feedback, pull request or issue is welcome.

See CONTRIBUTING.md for ways to get started.

License

MIT

switchtube-dl's People

Contributors

panmona avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

switchtube-dl's Issues

Specific video is downloaded with black video content

Information

  • OS: Linux
  • Version: 0.0.9
  • Terminal: bash, Tilix

Describe the bug
A specific video was downloaded with black video content, even though it displays normally on Switchtube.
This both happens with -c and -v.

To Reproduce
switchtube-dl -v "YZXIaohdhH" -t $SWITCHTUBE_TOKEN
(only reproducible with a token that has access to the channels of organization 86)

Expected behavior
The video is downloaded with the correct video content.

Screenshots
N/A

Additional context
N/A

Metadata download fails when video is not yet fully processed

Information

  • OS: Linux
  • Version: 0.0.7
  • Terminal: bash, Tilix

Describe the bug
The metadata download failed with the error that the duration_in_milliseconds field couldn't be found.

This field is apparently not present when the video is not yet fully processed (which isn't documented). More specific details about the video can't be fetched when this occurs.

To Reproduce
Try to download a channel that contains a published video, that is not yet fully processed.

Expected behavior
The metadata download works but doesn't include this video.

Program gets killed on Mac M1

Information

  • OS: MacOS M1
  • Version: 0.0.5
  • Terminal: Mac

The program does not seem to work on Mac M1. I installed it with homebrew.
% switchtube-dl --help
zsh: killed switchtube-dl

Make -t / --token optional

Is your feature request related to a problem? Please describe.
If the token is pasted as plain text into --token, it will appear in the bash_history.

Describe the solution you'd like
If -t / --token is not provided, the CLI should prompt for the token.

Describe alternatives you've considered
None

Additional context
https://spectreconsole.net/prompts/text#secrets

Find videos to skip based on video ids

Is your feature request related to a problem? Please describe.
Some channels do not consistently name their videos, this can result in incorrect ordering if one doesn't rename the videos. When it is renamed, the file will be not considered for --skip though.

Describe the solution you'd like
Files that are considered for skip should be based on the video id in the file name and not on an exact match.
A regex can be used for this. Something like: https://regex101.com/r/9owqbZ/5
Or even better: https://regex101.com/r/lmlBZZ/1 ( thanks @manrel )

Describe alternatives you've considered
None

Additional context
None

Reinstall switchtube-dl on macOS due to Homebrew tap change

Dear mac users (@YamashitaRen @iamfabio)

My GitHub name and tap name changed.
To keep receiving updates (like the newest 1.0 release) for this software you need to execute the following steps:

brew uninstall switchtube-dl
brew untap panmau/panmau
brew install panmona/panmona/switchtube-dl

If there are any questions, or you have any problems with these steps, let me know.

I am sorry for any inconveniences caused, and wish you a great start into the new semester! ✨

Add Date filter options

Is your feature request related to a problem? Please describe.
Downloading just recently uploaded videos requires interactive mode.

Describe the solution you'd like
Videos can be filtered by their upload date using the options --date, --datebefore or --dateafter. They accept dates in two formats:

  • Absolute dates: Dates in the format YYYYMMDD.
  • Relative dates: Dates in the format (now|today|-[1-9](day|week|month|year)(s)?) (e.g.: -2weeks, now)

These are additional filter options. If multiple conflicting ones are provided, follow the following prio:

  1. -a
  2. --date
  3. --datebefore / --dateafter (it should be possible to combine these)

Describe alternatives you've considered
Always using -a --skip is also possible for downloading all recently uploaded lectures when executing it in a regular interval. This seems to work well enough for now, which makes this feature a low priority.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.