mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
ebook-meta: Add option to change published date
This commit is contained in:
parent
c82f3e4138
commit
8022663ac3
@ -15,6 +15,7 @@ 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' + \
|
||||
_('''
|
||||
@ -69,6 +70,8 @@ def config():
|
||||
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 '
|
||||
@ -132,6 +135,8 @@ def do_set_metadata(opts, mi, stream, stream_type):
|
||||
mi.series = opts.series.strip()
|
||||
if getattr(opts, 'series_index', None) is not None:
|
||||
mi.series_index = float(opts.series_index.strip())
|
||||
if getattr(opts, 'pubdate', None) is not None:
|
||||
mi.pubdate = parse_date(opts.pubdate, assume_utc=False, as_utc=False)
|
||||
|
||||
if getattr(opts, 'cover', None) is not None:
|
||||
ext = os.path.splitext(opts.cover)[1].replace('.', '').upper()
|
||||
|
@ -863,7 +863,8 @@ class OPF(object):
|
||||
def smart_update(self, mi):
|
||||
for attr in ('title', 'authors', 'author_sort', 'title_sort',
|
||||
'publisher', 'series', 'series_index', 'rating',
|
||||
'isbn', 'language', 'tags', 'category', 'comments'):
|
||||
'isbn', 'language', 'tags', 'category', 'comments',
|
||||
'pubdate'):
|
||||
val = getattr(mi, attr, None)
|
||||
if val is not None and val != [] and val != (None, None):
|
||||
setattr(self, attr, val)
|
||||
|
Loading…
x
Reference in New Issue
Block a user