from calibre.customize.ui import metadata_readers, metadata_writers
from calibre.ebooks.metadata.meta import get_metadata, set_metadata
from calibre.ebooks.metadata import string_to_authors, authors_to_sort_string, title_sort, MetaInformation
from calibre.ebooks.lrf.meta import LRFMetaFile
from calibre import prints
from calibre.utils.date import parse_date
USAGE = '%%prog ebook_file [' + _('options') + ']\n' + _('\nRead/Write metadata from/to ebook files.\n\nSupported formats for reading metadata: %s\n\nSupported formats for writing metadata: %s\n\nDifferent file types support different kinds of metadata. If you try to set\nsome metadata on a file type that does not support it, the metadata will be\nsilently ignored.\n')
def config():
c = StringConfig('')
c.add_opt('title', [
'-t',
'--title'], help = _('Set the title.'))
c.add_opt('authors', [
'-a',
'--authors'], help = _('Set the authors. Multiple authors should be separated by the & character. Author names should be in the order Firstname Lastname.'))
c.add_opt('title_sort', [
'--title-sort'], help = _('The version of the title to be used for sorting. If unspecified, and the title is specified, it will be auto-generated from the title.'))
c.add_opt('author_sort', [
'--author-sort'], help = _('String to be used when sorting by author. If unspecified, and the author(s) are specified, it will be auto-generated from the author(s).'))
c.add_opt('cover', [
'--cover'], help = _('Set the cover to the specified file.'))
c.add_opt('comments', [
'-c',
'--comments'], help = _('Set the ebook description.'))
c.add_opt('publisher', [
'-p',
'--publisher'], help = _('Set the ebook publisher.'))
c.add_opt('category', [
'--category'], help = _('Set the book category.'))
c.add_opt('series', [
'-s',
'--series'], help = _('Set the series this ebook belongs to.'))
c.add_opt('series_index', [
'-i',
'--index'], help = _('Set the index of the book in this series.'))
c.add_opt('rating', [
'-r',
'--rating'], help = _('Set the rating. Should be a number between 1 and 5.'))
c.add_opt('isbn', [
'--isbn'], help = _('Set the ISBN of the book.'))
c.add_opt('tags', [
'--tags'], help = _('Set the tags for the book. Should be a comma separated list.'))
c.add_opt('book_producer', [
'-k',
'--book-producer'], help = _('Set the book producer.'))
c.add_opt('language', [
'-l',
'--language'], help = _('Set the language.'))
c.add_opt('pubdate', [
'-d',
'--date'], help = _('Set the published date.'))
c.add_opt('get_cover', [
'--get-cover'], help = _('Get the cover from the ebook and save it at as the specified file.'))
c.add_opt('to_opf', [
'--to-opf'], help = _('Specify the name of an OPF file. The metadata will be written to the OPF file.'))
c.add_opt('from_opf', [
'--from-opf'], help = _('Read metadata from the specified OPF file and use it to set metadata in the ebook. Metadata specified on the command line will override metadata read from the OPF file'))
c.add_opt('lrf_bookid', [
'--lrf-bookid'], help = _('Set the BookID in LRF files'))