又是一个MPD流浪汉(最后一个.fm!)
YAMScrobbler的Python项目详细描述
山药
又一个mpd scrobbler(用于last.fm)
山药正是它的名字所说的。
功能
山药只是一个普通的最后一个。但是,如果您really需要知道,它可以执行以下操作:
- 使用新的last.fmScrobbling API v2.0进行身份验证—无需在本地输入/存储用户名/密码。
- 通过last.fm的“Now Playing”API更新您的个人资料的“Now Playing”曲目
- 将失败的scrobble保存到磁盘并在以后上载。
- 计时配置(例如scrobble percentage、scrobbling的真实计时值等)。
- 防止倒带/回放重新启动时出现意外的重复搜索。
- 自动后台监控和配置文件生成。
要求
PyYAML
和python-mpd2
是必需的。yams只为python3
编写。
安装
通过PIP
运行pip3 install YAMScrobbler
(或者可能只是pip
,取决于您的系统)
通过AUR
如果您是arch linux用户,可以使用AUR中的python-yams包在本地安装yams。如果您不熟悉AUR软件包,请参阅here以获取说明。
来源于
克隆此repo并运行pip3 install -e <path_to_repo>
(如果不希望repo中的更改反映在本地安装中,请省略-e
标志)。
运行
该脚本包括一个由pip安装的yams
脚本。
yams
默认情况下作为守护进程运行(yams -N
将在前台运行)。
yams -k
将终止当前正在运行的实例。
yams -a
将附加到当前正在运行的实例的日志文件,允许您监视守护进程的输出。
yams -h
将打印所有选项(下面也提供)。
nb:(如果您无法访问yams
脚本,可能是因为pip的脚本安装目录不在您的$PATH
或其他目录中,python3 -m yams
也可以做到这一点。)
通过系统D
systemd用户服务单元文件包含在此存储库的根目录中(名为yams.service
)。这可用于为特定用户在启动时自动启动/停止yam。
若要安装,请将其复制到~/.config/systemd/user/
并运行systemctl --user enable --now yams
以启用/启动它。注意,您还应该start mpd as a Systemd service以确保在正确的时间加载yams。如果在/usr/bin/yams
以外的任何地方安装了yams二进制文件,则可能还需要编辑单元文件中yams二进制文件的路径。
设置
如果它们存在,山药将使用通常的< { > } > }和“环境变量”来连接到。运行yams
并按照打印的说明使用last.fm进行身份验证
配置文件
如果默认情况下找不到配置文件,yams将在$HOME/.config/yams
中创建默认配置文件、日志、缓存和会话文件,但是它也将接受$HOME/.yams
或./.yams
中的配置文件(理论上在$HOME
中配置,或者也可以读取当前工作目录)。
YAMS将只创建自己的目录/配置文件,如果没有以前的目录存在。
帮助
这里是--help
的输出:
usage: YAMS [-h] [-m 127.0.0.1] [-p 6600] [-s ./.lastfm_session]
[--api-key API_KEY] [--api-secret API_SECRET] [-t 50] [-r] [-d]
[-g] [-l /path/to/log] [-c /path/to/cache] [-C ~/my_config] [-N]
[-D] [-k] [--disable-log] [-a]
Yet Another Mpd Scrobbler, v0.5. Configuration directories are either
~/.config/yams, ~/.yams, or your current working directory. Create one of
these paths if need be.
optional arguments:
-h, --help show this help message and exit
-m 127.0.0.1, --mpd-host 127.0.0.1
Your MPD instance's host
-p 6600, --mpd-port 6600
Your MPD instance's port
-s ./.lastfm_session, --session-file-path ./.lastfm_session
Where to read in/save your session file to. Defaults
to inside your config directory.
--api-key API_KEY Your last.fm api key
--api-secret API_SECRET
Your last.fm api secret
-t 50, --scrobble-threshold 50
The minimum point at which to scrobble, defaults to 50
percent
-r, --real-time Use real times when calculating scrobble times? (e.g.
how long you've been running the app, not the track
time reported by mpd). Default: True
-d, --allow-duplicate-scrobbles
Allow the program to scrobble the same track multiple
times in a row? Default: False
-g, --generate-config
Save the entirety of the running configuration to the
config file, including command line arguments. Use
this if you always run yams a certain fashion and want
that to be the default. Default: False
-l /path/to/log, --log-file /path/to/log
Full path to a log file. If not set, a log file called
"yams.log" will be placed in the current config
directory.
-c /path/to/cache, --cache-file /path/to/cache
Full path to the scrobbles cache file. This stores
failed scrobbles for upload at a later date. If not
set, a log file called "scrobbles.cache" will be
placed in the current config directory.
-C ~/my_config, --config ~/my_config
Your config to read
-N, --no-daemon If set to true, program will not be run as a daemon
(e.g. it will run in the foreground) Default: False
-D, --debug Run in Debug mode. Default: False
-k, --kill-daemon Will kill the daemon if running - will fail otherwise.
Default: False
--disable-log Disable the log? Default: False
-a, --attach Runs "tail -F" on a running instance of yams' log
file. "Attaches" to it, for all intents and purposes.
NB: You will still need to kill it by hand. Default:
False
其他信息
- Yams将尝试在播放期间的每一分钟或在随后的每一次搜索中重新发送失败的搜索。Yams不会尝试重新发送失败的“正在播放”请求
- 当不播放曲目时,yams只会等待mpd的idle()命令。配置选项控制yams轮询当前播放曲目的mpd的速率(秒)。
- 当MPD连接丢失时,Yams不会崩溃,但会尝试每10秒重新连接一次。如果此行为不受欢迎,请终止守护进程,尽管重新连接行为不应显著影响系统资源。
- 默认情况下,yams抑制大多数错误消息,使用
--debug
运行以查看它们全部。 -g
非常有用,您应该使用它一次,这样就不必一直输入命令行参数。- 不保证Windows支持。yams在基本的os juno和os x mojave操作系统下运行良好(可能linux和os x python3的所有变体都应该运行良好)。
- yams是用python
3.7
开发的,如果遇到较低版本的bug,请报告它。
--debug
运行以查看它们全部。-g
非常有用,您应该使用它一次,这样就不必一直输入命令行参数。3.7
开发的,如果遇到较低版本的bug,请报告它。