From 3d63ef67ddddb7d45c5c7044354976d0dc493b8f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Mar 2011 11:39:54 -0600 Subject: [PATCH] Implement #744020 (Add Publisher and Publication Date to Adding Books Possible Fields) --- src/calibre/ebooks/metadata/meta.py | 13 +++++++++ src/calibre/gui2/filename_pattern.ui | 40 ++++++++++++++++++++++++++++ src/calibre/gui2/widgets.py | 6 +++++ 3 files changed, 59 insertions(+) diff --git a/src/calibre/ebooks/metadata/meta.py b/src/calibre/ebooks/metadata/meta.py index cbd9db3f04..b0c43a8182 100644 --- a/src/calibre/ebooks/metadata/meta.py +++ b/src/calibre/ebooks/metadata/meta.py @@ -182,6 +182,19 @@ def metadata_from_filename(name, pat=None): mi.isbn = si except (IndexError, ValueError): pass + try: + publisher = match.group('publisher') + mi.publisher = publisher + except (IndexError, ValueError): + pass + try: + pubdate = match.group('published') + if pubdate: + from calibre.utils.date import parse_date + mi.pubdate = parse_date(pubdate) + except: + pass + if mi.is_null('title'): mi.title = name return mi diff --git a/src/calibre/gui2/filename_pattern.ui b/src/calibre/gui2/filename_pattern.ui index 68b3108e06..c8a9b4f6f6 100644 --- a/src/calibre/gui2/filename_pattern.ui +++ b/src/calibre/gui2/filename_pattern.ui @@ -206,6 +206,46 @@ + + + + Publisher: + + + + + + + Regular expression (?P<publisher>) + + + No match + + + true + + + + + + + Published: + + + + + + + Regular expression (?P<published>) + + + No match + + + true + + + diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index ea0509b51a..e5f1c94342 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -121,6 +121,12 @@ class FilenamePattern(QWidget, Ui_Form): else: self.series_index.setText(_('No match')) + if mi.publisher: + self.publisher.setText(mi.publisher) + + if mi.pubdate: + self.pubdate.setText(mi.pubdate.strftime('%Y-%m-%d')) + self.isbn.setText(_('No match') if mi.isbn is None else str(mi.isbn))