boardgamegeek.com的命令行界面
bggcli的Python项目详细描述
简介
bggcli是一个命令行接口,为 BoardGameGeek(又名bgg)。它依赖于web ui而不是 official API不提供所有可用功能。
此时只执行3个操作:
- 从csv文件批量导入/更新游戏集合
- 从csv文件大容量删除
- 批量导出为CSV文件,带有版本信息(默认导出中缺少游戏版本)
警告:
- Use it at your own risks, you may damage your game collection by doing mistakes! Ensure you have a backup of you collection first!
- This tool is not supported by BoardGameGeek, this is an independent development
- Be respectful regarding BGG web site: this kind of automated tools can impact performance when used “aggressively” (plenty of requests per second). Provided features are intended to be used for one-shot needs. Also they rely on a real web browser, and should conform with their Terms of Services
安装
Python2.7是必需的。
pip install bggcli
用法
您需要firefox才能安装;firefox将由bggcli自动控制以执行操作 (通过硒库)。
键入bggcli获取有关可用命令的完整帮助。
下面是从帐户account1导出集合并将其导入到另一个帐户account2的示例:
$ bggcli -l mylogin1 -p mypassword1 collection-export mycollection.csv $ bggcli -l mylogin2 -p mypassword2 collection-import mycollection.csv
更新集合
以下是此操作可用于的一些用例:
- 在BGG上创建新帐户并转移您的托收:首先从旧帐户导出托收,然后使用 bggcli导入它
- 对所有或部分游戏进行批量更新:首先从帐户导出集合,在中修改详细信息 csv文件(使用文本编辑器、openoffice、ms-excel或其他工具)并使用bggcli导入文件
导出应使用此工具完成。你也可以在网上手动导出,但你不会有 关于每个游戏版本的信息。
示例:
$ bggcli -l mylogin -p mypassword collection-import mycollection.csv
注意:
- Column names are those exported by BGG. Any column not recognized will just be ignored
- When a game already exists in your collection, game is updated with provided CSV values only, other fields are not impacted. You could only update one field for all your game.
- Games are identified by their internal ID, named ^{tt5}$ in CSV file (name used by BGG). Having the ^{tt6}$ field (name of the game) is also recommended for logging.
从收藏中删除游戏
目标是从您的收藏中删除CSV文件中标识的所有游戏,您将提供作为输入。
示例:
$ bggcli -l mylogin -p mypassword collection-delete mycollection.csv
注意:
- Only the ^{tt5}$ column will be used for this operation: this is the internal ID managed by BGG. All other columns will just be ignored.
导出集合
将创建一个包含所有游戏的csv文件,就像使用ui一样。
示例:
$ bggcli -l mylogin -p mypassword collection-export mycollection.csv
注意:
- Only the ^{tt5}$ column will be used for this operation: this is the internal ID managed by BGG. All other columns will just be ignored.
限制
- 只支持Firefox这些工具依赖于selenium来控制浏览器,并且只支持firefox 硒的开箱即用(即无附加要求)。可以引入对其他浏览器的支持, 但我不确定是否值得。
- 性能:selenium+firefox关联不是自动化操作的最快方式,但是 在稳定性(没有javascript仿真,firefox可以工作)和简单性(不需要 安装其他任何东西),这在当前上下文中是最重要的。在我的笔记本电脑上,我看到了 1分钟打5场比赛。
- bgg不导出与游戏版本相关的一些字段:barcode和语言`。注意 虽然这只适用于您定义自己的自定义版本,但这应该非常罕见。
对未来版本的想法
以下是一些可以执行的附加任务的想法:
- 集合的通用导入,基于游戏名称而不是BGG内部标识符。确认是 每一个模棱两可的名字都需要在bgg提供的匹配游戏中进行选择
- 更新/删除播放内容
- 更新/删除论坛订阅
链接
- boardgamegeek:http://www.boardgamegeek.com
- Officiel XML API 2:https://www.boardgamegeek.com/wiki/page/BGG_XML_API2
- boardgamegeek-boardgamegeek.com的python api:https://github.com/lcosmin/boardgamegeek
最后说明
它真的值得这样的发展吗?可能不是,但我的第二个目标是发现python生态系统!