“万物 ISBN”(国际标准书号)的应用程序和框架,包括元数据、描述、封面......
项目描述
信息
isbntools提供了几种有用的方法和函数来验证、清理、转换、断字和获取 ISBN 字符串的元数据。
对于最终用户,提供了几个脚本以从命令行使用:
$ to_isbn10 ISBN13
将 ISBN13 数字转换为 ISBN10。
$ to_isbn13 ISBN10
将 ISBN10 号码转换为 ISBN13。
$ isbn_info ISBN
为您提供 ISBN 的组标识符。
$ isbn_mask ISBN
掩码(连字符) ISBN(按标识符拆分)。
$ isbn_meta ISBN [goob|openl|merge] [bibtex|csl|msword|endnote|refworks|opf|json] [YOUR_APIKEY_TO_SERVICE]
为您提供与 ISBN 相关的主要元数据,goob使用Google 图书服务(无需密钥),并且是默认选项(您只需输入,例如isbn_meta 9780321534965), openl使用OpenLibrary.org api(无需密钥需要), wiki使用Wikipedia api(不需要密钥)。您可以在$HOME\.isbntools目录 (UNIX)的文件isbntools.conf中 输入 API 密钥并设置首选项。对于 Windows,您应该查看 %APPDATA%/isbntools/isbntools.conf. 输出可以格式化为bibtex、csl (CSL-JSON)、 msword、endnote、refworks、opf或json (BibJSON) 书目格式。
注意 您可以使用posix 管道将此命令应用于许多 ISBN (例如,在 Windows 中键入 FILE_WITH_ISBNs.txt | isbn_meta [SERVICE] [FORMAT] [APIKEY])
您可以通过安装isbnlib插件来添加更多元数据源: isbnlib- bnf 、 isbnlib-porbase、isbnlib-loc、isbnlib-mcues、isbnlib -dnb ……(检查pypi以获取可用插件)。
$ isbn_editions ISBN
给出代表给定书籍的 ISBN 集合(使用Wikipedia和LibraryThing).
$ isbn_validate ISBN
验证 ISBN10 和 ISBN13。
$ ... | isbn_validate
与posix 管道一起使用(例如OSX 或 Linux 中的cat FILE_WITH_ISBNs | isbn_validate)。
提示假设您要提取 pdf 电子书 (MYEBOOK.pdf) 的 ISBN。安装pdfminer,然后在命令行输入:
$ pdf2txt.py -m 5 MYEBOOK.pdf | isbn_validate
$ isbn_from_words "words from title and author name"
从一组单词中返回最可能的 ISBN的模糊脚本!(您可以使用isbn_meta验证结果)!
$ isbn_goom "words from title and author name" [bibtex|csl|msword|endnote|refworks|json]
从Google 图书多个参考文献返回的脚本。
$ isbn_doi ISBN
返回给定 ISBN 的 doi 的 ISBN-A 代码。
$ isbn_ean13 ISBN
返回给定 ISBN 的 EAN13 代码。
$ isbn_classify ISBN
返回给定 ISBN 的 OCLC 分类器。
$ isbn_ren FILENAME
重命名(使用元数据)当前目录中文件名中包含 ISBN 的文件(例如isbn_ren 1783559284_book.epub,isbn_ren "*.pdf")。
输入isbn_ren以查看许多其他选项。
$ isbntools
编写版本和版权声明并检查是否有更新。
和
$ isbn_repl
您将获得一个REPL,其中包含历史记录、自动完成、模糊选项、重定向和对 shell 的访问。
以下是一个典型的会话:
$ isbn_repl
Welcome to the isbntools 4.3.28 REPL.
** For help type 'help' or '?'
** To exit type 'exit' :)
** To run a shell command, type '!<shellcmnd>'
** Use '#' in place of the last ISBN
$ isbn> ?
Commands available (type ?<command> to get help):
-------------------------------------------------
BIBFORMATS classify desc ean13 from_words info to_isbn10
PROVIDERS conf doi editions goom mask to_isbn13
audit cover doi2tex exit help meta validate
$ isbn> meta 9780156001311 tex
@book{9780156001311,
title = {The Name Of The Rose},
author = {Umberto Eco},
isbn = {9780156001311},
year = {1994},
publisher = {Harcourt Brace}
}
$ isbn> meta 9780156001311 tex >>myreferences.bib
$ isbn> !ls
myreferences.bib
$ isbn> desc #
It is the year 1327. Franciscans in an Italian abbey are suspected of
heresy, but Brother William of Baskerville's investigation is suddenly
overshadowed by seven bizarre deaths. Translated by William Weaver. A Helen
and Kurt Wolff Book
$ isbn> cover #
thumbnail: http://books.google.com/books/content?id=PVVyuD1UY1wC&printsec=frontcover&img=1&zoom=1
smallThumbnail: http://books.google.com/books/content?id=PVVyuD1UY1wC&printsec=frontcover&img=1&zoom=5
$ isbn> PROVIDERS
bnf dnb goob kb loc mcues openl porbase wiki
$ isbn> exit
bye
在 REPL 中,许多操作更快。
可以使用isbntools和isbnlib库编写更多脚本,使用 ISBN 的提取、清理、验证和标准化方法。
只是为了好玩,假设我想要在他的标题中有某些词的最受关注的书。对于快速而简单的解决方案,请在文件中输入以下代码并将其另存为isbn_tmsa_book.py。
#!/usr/bin/env python
import sys
from isbntools.app import *
query = sys.argv[1].replace(' ', '+')
isbn = isbn_from_words(query)
print("The ISBN of the most `spoken-about` book with this title is %s" % isbn)
print("")
print("... and the book is:")
print("")
print(registry.bibformatters['labels'](meta(isbn)))
然后在命令行中(在同一目录中):
$ python isbn_tmsa_book.py 'noise'
就我而言,我得到:
The ISBN of the most `spoken-about` book with this title is 9780143105985 ... and the book is: Type: BOOK Title: White Noise Author: Don DeLillo ISBN: 9780670803736 Year: 1985 Publisher: Viking
玩得开心!
安装
从命令行输入(在某些情况下,您必须在命令前加上sudo):
$ pip install isbntools
如果您使用 linux 系统,您可以使用您的分发包管理器(包python-isbntools和python3-isbntools)进行安装,但是通常这些包非常旧并且不能再正常工作了!
对于开发人员
如果您只想将isbntools添加到项目的需求中,那么使用isbnlib可能会更好,它实现了isbntools的基本功能,而无需最终用户脚本和配置文件!
如果您认为这还不够,请至少阅读文档的这一页。
如果您想为该项目做出贡献,请阅读指南。
配置文件
您可以在$HOME/.isbntools目录 (UNIX)的文件isbntools.conf中 输入 API 密钥并设置首选项。对于 Windows,您应该查看 %APPDATA%/isbntools/isbntools.conf (创建这些、目录和文件,如果不存在[现在只需输入isbn_conf make!])。该文件应如下所示:
...
[MISC]
REN_FORMAT={firstAuthorLastName}{year}_{title}_{isbn}
DEBUG=False
[SYS]
URLOPEN_TIMEOUT=10
THREADS_TIMEOUT=12
LOAD_METADATA_PLUGINS=True
LOAD_FORMATTER_PLUGINS=True
[SERVICES]
DEFAULT_SERVICE=goob
VIAS_MERGE=parallel
...
这些值是不言自明的!
注意如果您在虚拟环境 中运行isbntools , isbntools.conf文件将 位于环境根目录下的文件夹isbntools中。
操作这些文件的更简单方法是使用脚本isbn_conf。在终端输入:
$ isbn_conf show
查看当前的 conf 文件。
该脚本有许多选项允许对 conf 文件进行受控编辑。只需输入isbn_conf寻求帮助。
已知的问题
元方法和isbn_meta脚本有时会给出错误的结果(这是由于所选服务的错误),或者您应该尝试其他服务之一。
isbntools在内部使用 unicode,但这并不能解决由于原始编码/解码错误而导致信息丢失的错误!
机构会定期发布新的 ISBN 块。这些块的范围在掩码 使用的数据库中。因此,如果您的isbntools版本太旧,则可能会发生这种情况,掩码不适用于有效(最近)发布的 ISBN。解决方案?经常更新 isbntools!
默认情况下会缓存对元数据服务的调用。如果您不想要此功能,只需输入isbn_conf setopt cache no。如果出于任何原因需要清除缓存,只需输入isbn_conf delcache 即可。
任何您想报告的问题,请在github 或带有标签isbntools的stackoverflow上报告。
阅读文档中的更多文档。