#tui #youtube #terminal #subscription #api-client #cli

程序 ytsub

仅提供订阅功能的 TUI YouTube 客户端,使用 Invidious API

6 个版本 (3 个破坏性更新)

0.4.0 2023年2月6日
0.3.1 2022年10月16日
0.2.0 2022年5月31日
0.1.1 2022年5月13日

命令行工具 中排名第 2880

每月下载量 22

GPL-3.0 许可证

195KB
5K SLoC

ytsub

ytsub 是一个仅提供订阅功能的 TUI YouTube 客户端,使用 Invidious API。

demo

依赖关系

mpvyt-dlp 是可选的依赖关系,用于播放视频。

sqlite 是必需的依赖关系。如果系统上不可用,可以在使用 cargo 构建时启用 bundled_sqlite 功能来编译和链接。

cargo build --features bundled_sqlite

安装

Cargo

cargo install ytsub

# or
cargo install ytsub --features bundled_sqlite

Arch Linux

ytsub 在 AUR 中作为 稳定源代码包稳定二进制包最新开发包 提供。您可以使用您喜欢的 AUR 辅助程序进行安装。

# stable source package
paru -S ytsub

# stable binary package
paru -S ytsub-bin

# latest development package
paru -S ytsub-git

用法

Usage: ytsub [OPTIONS] [COMMAND]

Commands:
  import  Import subscriptions
  export  Export subscriptions
  help    Print this message or the help of the given subcommand(s)

Options:
  -c, --config <FILE>                       Path to configuration file
  -n, --no-config <no_config>               Ignore configuration file
  -d, --database <FILE>                     Path to database file
  -s, --instances <FILE>                    Path to instances file
  -g, --gen-instances <gen_instances_list>  Generate Invidious instances file
      --video-player <VIDEO PLAYER>         Path to video player
  -h, --help                                Print help information
  -V, --version                             Print version information

要获取默认键绑定,请在应用程序中按 ctrl-h,或参考 示例 config.toml 文件

配置

配置文件的默认目录是 $HOME/.config/ytsub

文件 描述
config.toml 选项、键绑定和主题配置
instances Invidious 实例列表

config.toml

可以使用 - 标志指定配置文件的路径。

带有默认值的示例 config.toml

# Options

database = "/home/username/.local/share/ytsub/videos.db" # Path to database file
instances = "/home/username/.config/ytsub/instances" # Path to instances file
tabs = ["videos"] # Tabs to fetch videos from [possible values: videos, shorts, streams]
api = "invidious" # API to be used for fetching videos [possible values: invidious, local]
refresh_threshold = 600 # Time in seconds that needs to pass before refreshing a channel using the refresh_channels command
rss_threshold = 125 # Use RSS if the number of channels being refreshed or being subscribed to exceeds the specified amount
tick_rate = 200 # Tick rate in milliseconds
request_timeout = 5 # Request timeout in seconds
highlight_symbol = "" # Symbol to highlight selected items
video_player = "mpv" # Path to video player
hide_watched = false # Hide watched videos by default

# Theme

# fg and bg fields can be set with rgb (ex: "255, 255, 255"),
# hex (ex: "#ffffff") or named colors.
# Valid color names are Black, Red, Green, Yellow, Blue, Magenta
# Cyan, Gray, DarkGray, LightRed, LightGreen, LightGreen,
# LightYellow, LightBlue, LightMagenta, LightCyan, White and Reset.

# Valid modifiers are bold, dim, italic, underlined,
# slow_blink, rapid_blink, reversed, hidden and crossed_out.

# Example:
# [title]
# fg = "#123456"
# bg = "10, 250, 99"
# modifiers = "bold reversed italic"

# Example with alternative syntax:
# title = { fg = "#123456", bg = "10, 250, 99", modifiers = "bold reversed italic" }

# Block titles
[title]
fg = "Cyan"
modifiers = "bold"
# Channel, Title, Length and Date headers
[header]
fg = "Yellow"
modifiers = "bold"
# Selected item in inactive block
[selected]
fg = "Blue"
modifiers = "bold"
# Selected item in active block
[focused]
fg = "Magenta"
modifiers = "bold"
# Watched videos
[watched]
fg = "DarkGray"
# Selected watched video in inactive block
# Overrides the modifiers of [selected]. If fg and bg are set, they are patched to [selected]
[selected_watched]
# Selected watched video in active block
# Overrides the modifiers of [focused]. If fg and bg are set, they are patched to [focused]
[focused_watched]
# Border of selected block
[selected_block]
fg = "Magenta"
# Error message
[error]
fg = "Red"
# Warning message
[warning]
fg = "Yellow"
# Key bindings in the help window
[help]
fg = "Green"

# Key Bindings

# Valid key codes are backspace, space, enter, left, right, up, down, home, end
# pageup, pagedown, tab, backtab, del, delete, insert, esc, escape and characters.

# Valid modifiers are ctrl, shift and alt.

# Multiple key bindings can be set in a single line.
# Example: "escape q ctrl-c" = "quit"

# A default binding can be removed by setting it to an empty string.
# Example: "q" = ""

[key_bindings]
"1" = "set_mode_subs" # Switch to subscriptions mode
"2" = "set_mode_latest_videos" # Switch to latest videos mode
"j down" = "on_down" # Go one line downward
"k up" = "on_up" # Go one line upward
"h left" = "on_left" # Switch to channels block
"l right" = "on_right" # Switch to videos block
"g" = "select_first" # Jump to the first line in the list
"G" = "select_last" # Jump to the last line in the list
"c" = "jump_to_channel" # Jump to the channel of the selected video from latest videos mode
"t" = "toggle_hide" # Hide/unhide watched videos
"i" = "subscribe" # Enter editing mode to enter channel id or url
"d" = "unsubscribe" # Open confirmation window to unsubcribe from the selected channel
"D" = "delete_video" # Delete the selected video from database
"/" = "search_forward" # Enter editing mode to make a forward search
"?" = "search_backward" # Enter editing mode to make a backward search
"n" = "repeat_last_search" # Search with the latest pattern and direction
"N" = "repeat_last_search_opposite" # Search with the latest pattern and opposite direction
"s" = "switch_api" # Switch between the available APIs
"r" = "refresh_channel" # Refresh videos of the selected channel
"R" = "refresh_channels" # Refresh videos of every channel
"F" = "refresh_failed_channels" # Refresh videos of channels which their latest refresh was a failure
"o" = "open_in_invidious" # Open channel or video Invidious page in browser
"O" = "open_in_youtube" # Open channel or video Youtube page in browser
"p" = "play_video" # Play selected video in a video player (default: mpv)
"m" = "toggle_watched" # Mark/unmark selected video as watched
"ctrl-h" = "toggle_help" # Toggle help window
"T" = "toggle_tag" # Toggle tag window
"q ctrl-c" = "quit" # Quit application

[key_bindings.import]
"space" = "toggle_selection" # Select/Unselect channel
"a" = "select_all" # Select all channels
"z" = "deselect_all" # Deselect all channels
"enter" = "import" # Import selected channels

[key_bindings.tag]
"i" = "create_tag"
"d" = "delete_tag"
"r" = "rename_tag"
"s" = "select_channels" # Pick channels for the tag
"space" = "toggle_selection" # Select/Unselect tag
"a" = "select_all" # Select all tags
"z" = "deselect_all" # Deselect all tags

[key_bindings.channel_selection]
"enter" = "confirm" # Confirm the selection of channels
"escape" = "abort" # Drop changes
"space" = "toggle_selection" # Select/Unselect channel
"a" = "select_all" # Select all channels
"z" = "deselect_all" # Deselect all channels

instances

可以使用 - 标志指定 instances 文件的路径。文件可以手动创建,添加启用了 API 的实例,或者通过使用 - 标志运行应用程序从 https://api.invidious.io 中的实例自动生成。每个实例条目由一行分隔。如果不存在 instances 文件,每次启动应用程序时,实例列表将从 https://api.invidious.io 构建。

示例 实例 文件

https://vid.puffyan.us
https://invidio.xamh.de
https://inv.riverside.rocks
https://yt.artemislena.eu

依赖关系

~35–51MB
~812K SLoC