1 个不稳定版本
0.3.0 | 2024年6月8日 |
---|
#2491 in 命令行工具
44KB
759 行
glaza
‘glaza’ 在俄语中意为‘眼睛’。这也是您用来观看节目的方式!
使用您的终端跟踪您正在观看的节目!
glaza
将创建一个目录,用于存储其文件。
每次您指定 --git
标志时,如果您对文件进行了写入操作,则您执行的操作将被提交。
如果您从未指定 --git
标志,数据目录将不会进行 git 初始化。
工作原理
glaza --git add 'One Piece Live Action'
将标题为 'One Piece Live Action' 的节目添加到稍后观看列表并提交更改。
提交信息将看起来像这样:wl add -> One Piece Live Action
glaza -g start --grab 'live action' -l 'https://website.com/one-piece-live-action-1-'
由于我们已经在稍后观看列表中有了完整的节目标题,因此我们不必再次完整地输入它。
通过使用 --grab
/-g
标志,我们使用模式 'live action' 匹配 'One Piece Live Action'。
与 --git
标志不同,我们使用短选项 -g
。这些是等效的。
使用 --link
/-l
标志,我们添加一个我们打算观看节目的链接。
如果您打算在 下载 节目的链接不同,您也可以使用 --dlink
/-d
标志添加它。
假设现在我们已下载了 6 集节目,并观看了 3 集。让我们使用 episode
和 download
子命令来标记这一点
glaza -g dn act 6
glaza -g ep act 3
几乎所有子命令都有一个您可以用其替代完整名称的别名。在这里,dn
代表 download
,而 ep
代表 episode
。要查看所有可用的子命令别名,请查看 glaza --help
(它也包含在此说明书的末尾中)。
此外,模式匹配字符串 'act' 应该仍然是唯一的,以匹配 'One Piece Live Action'!
在流媒体服务上,页面的 URL 通常以集数结尾。在这种情况下,在 glaza
中添加链接时,请删除集数。
在这里,链接通常是这个: https://website.com/one-piece-live-action-1-1
请将此提供给 --link
/-l
(或 --dlink
/-d
)标志: https://website.com/one-piece-live-action-1-
这将解锁 watch
和 save
子命令的功能,这些命令利用了这种通用模式。它们允许你在 $BROWSER
中打印/打开 下一个 要观看/下载的剧集。
我们已经用上面显示的命令标记了我们观看了3集。现在让我们在浏览器中打开第4集!
glaza watch 'live action' --web
由于我们这里没有写入任何数据文件,只是检索一些信息,所以我们不需要这里的 --git
/-g
标志。
如果我们没有使用 --web
/-w
标志,链接将只打印到控制台。
在这种情况下,你可能会看到这样的输出
successful case-insensitive substring match: 'One Piece Live Action'
https://website.com/one-piece-live-action-1-4
你可能觉得在这种情况下输出不是仅仅链接很烦人。但是,我很高兴宣布,那里的第一行实际上打印到了stderr,这意味着如果你只需要链接,你可以将它重定向到 /dev/null
glaza watch 'live action' 2>/dev/null
记住,我正在使用fish shell,所以你重定向stderr的方式可能与你使用的shell不同
如果你将输出管道传输到其他命令,stderr已经传输,所以你不用担心
glaza watch 'live action' | xclip -r -selection clipboard
由于我们标记了已下载6集,我们可以通过打开第7集的链接来下载更多
glaza save 'live action' --web
有时URL不会方便地以剧集编号结束,在这种情况下,watch
和 show
将不可用。
嗯,它们将是可用的,它们只是返回了一些乱码链接
在这种情况下,你应该使用 plink
/ pdlink
— 这些子命令只是打印/在浏览器中打开 literally 提供给 --link
/-l
/ --dlink
/-d
标志的链接,而不做任何魔法。
glaza plink 'live action' --web
glaza pdlink 'live action' --web
如果你想稍后更改流媒体链接,请使用 link
glaza -g link 'live action' 'https://my_new_link.com/show_title'
要更改下载链接,请使用 dlink
glaza -g dlink 'live action' 'https://my_new_link.com/show_title'
好吧,假设我们看完了整部系列,现在想要将其放入我们的观看列表中。
glaza -g finish 'live action'
就是这样!现在在我们的观看列表中,我们得到一条看起来像这样的行
23.09.03 - One Piece Live Action
日期格式是年.月.日
如果我们使用了 drop
子命令
glaza -g drop 'live action'
我们会得到这个
23.09.03 - (dropped) One Piece Live Action
这基本上就是所有区别!对于你不想看完的节目,你可以使用 drop
将它们放入你的观看列表,但标记你实际上没有完成它们。此外,提交消息将说 drop
而不是 finish
。
用法
`glaza` is a program for tracking the shows you watch.
All of the information is kept in three files in your data_directory/glaza, which is:
linux — $XDG_DATA_HOME/glaza
macos — $HOME/Library/Application Support/glaza
windows — %APPDATA%/glaza
`current.yml` contains the information about shows you're currently in the process of watching.
Every show has multiple properties you can set.
1. Show title
2. The episode number of the latest episode you finished watching
3. The episode number of the latest episode you *downloaded*
4. The link to where you watch (stream) the show
5. The link to where you *download* the show
Both the episode and link are separated for streaming / downloading this way, so that you can track both of those
separately. This is mostly useful with the `watch` and `save` subcommands, that let you open the next episode to
either watch, or download.
Only the show title is required, every other property is optional.
For example: if you don't need the link functionality, you can just use glaza to track the episodes.
Additionally, whenever a download link is expected but you don't have one set, the streaming link will be used as a
fallback. The opposite is true as well.
So you only really need to set both if you plan to both stream and download a show, on different websites.
`watched.txt` contains a list of all the shows you finished watching, or dropped, with timestamps. New shows appear in
this list thanks to `finish` and `drop` subcommands.
`watch-later.txt` contains a list of shows you plan to watch. You can use `add` to add new shows, and `discard` to
remove shows from that list. The `wl` will just print the contents of this file, letting you view what shows you plan
to watch.
A lot of subcommands take `show` as an argument.
`watch`, `save`, `plink`, `pdlink`, `remove`, `episode`, `save`, `link`, `discard` — all assume that the show already
exists.
The show argument is a pattern that is searched for in the show titles of current.yml (or watch-later.txt, if you use
the --grab flag in one of: `start`, `finish`, `drop`) in this order:
1. Case sensitive exact match.
2. Case insensitive exact match.
3. Case insensitive substring match.
4. Case sensitive substring match.
If after these steps no show matches, or too many shows match (more than one) — an error is printed, instead of doing
anything.
`glaza` supports git with the `--git` flag. Whenever you execute a subcommand that writes to one of the data files, if
you use the `--git` flag, a commit will be automatically created for you.
The commit messages are different per subcommand, and usually use the show title + extra information to make the git
log more useful and searchable.
The data directory is automatically `git init`ed if it isn't already.
This functionality is most useful for backing up your tracking and sharing it by uploading it to a git remote.
Usage: glaza [OPTIONS] <COMMAND>
Commands:
shows List all the shows you're currently watching, with their episode information [aliases: s]
watch Print the next episode's link. This works by appending the watched episode numer + 1 onto the link.
This won't work if a number appended on the link doesn't result in that episode's url [aliases: next,
go, w]
save Print the next download link. Works the same as the `watch` subcommand, except the `saved` episode is
appended instead [aliases: install, i]
plink Print the episode link of a show. This is most useful for shows that don't support `watch` due to
having non-standard urls
pdlink Print the download link of a show. This is most useful for shows that don't support `save` due to
having non-standard urls
episode Set the episode you just watched [aliases: ep]
download Set the episode you just downloaded [aliases: dn]
link Update the episode link of a show. It will be used for the `watch` and `plink` subcommands. And also,
as a fallback if you don't define a download link [aliases: ln]
dlink Update the download link of a show. It will be used for the `save` and `pdlink` subcommands. And also,
as a fallback if you don't define an episode link
start Start a new show, putting it in your ‘currently watching’ list [aliases: new, n]
finish Finish a show, putting it in your watched list [aliases: f]
drop Drop a show, putting it in your watched list. The distinction from `finish` is that to the left of the
show name in your watched list, there will be the `(dropped)` specifier. Also with the `--git` flag,
the commit message will say "drop" instead of "finish" [aliases: d]
remove Remove a show from the list without putting it in your watched list. This is useful if you
accidentally added a show you didn't mean to, possibly due to misspelling its title [aliases: rm,
delete]
add Add a new show to your watch later list [aliases: later, a]
discard Remove a show from your watch later list [aliases: c]
wl Print the entire contents of your watch later file
watched Print the entire contents of your watched list [aliases: past]
help Print this message or the help of the given subcommand(s)
Options:
-g, --git If the action writes to a file, commit that change
-h, --help Print help
-V, --version Print version
你还可以在每个单独的子命令上调用 --help
,以进一步检查它
glaza watch --help
Print the next episode's link. This works by appending the watched episode numer + 1 onto the link. This won't work if
a number appended on the link doesn't result in that episode's url
Usage: glaza watch [OPTIONS] <SHOW>
Arguments:
<SHOW>
Options:
-w, --web Open the link in your $BROWSER instead of printing it
-h, --help Print help
安装
cargo install glaza
cargo-binstall
和 cargo-quickinstall
也受支持。
卸载
cargo uninstall glaza
rm -fr ~/.local/share/glaza
依赖项
~5–15MB
~204K SLoC