mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add support for date published field to edit metadata dialog. Also preferentially use ISBN13 numbers from ISBNDB
This commit is contained in:
parent
03dba92e8d
commit
119b154948
@ -49,7 +49,7 @@ class ISBNDBMetadata(MetaInformation):
|
||||
def __init__(self, book):
|
||||
MetaInformation.__init__(self, None, [])
|
||||
|
||||
self.isbn = book['isbn']
|
||||
self.isbn = book.get('isbn13', book.get('isbn'))
|
||||
self.title = book.find('titlelong').string
|
||||
if not self.title:
|
||||
self.title = book.find('title').string
|
||||
@ -74,7 +74,6 @@ class ISBNDBMetadata(MetaInformation):
|
||||
self.comments = 'SUMMARY:\n'+summ.string
|
||||
|
||||
|
||||
|
||||
def build_isbn(base_url, opts):
|
||||
return base_url + 'index1=isbn&value1='+opts.isbn
|
||||
|
||||
|
@ -14,6 +14,7 @@ from calibre.gui2.dialogs.fetch_metadata_ui import Ui_FetchMetadata
|
||||
from calibre.gui2 import error_dialog, NONE, info_dialog
|
||||
from calibre.gui2.widgets import ProgressIndicator
|
||||
from calibre.utils.config import prefs
|
||||
from calibre import strftime
|
||||
|
||||
class Fetcher(QThread):
|
||||
|
||||
@ -45,7 +46,7 @@ class Matches(QAbstractTableModel):
|
||||
return len(self.matches)
|
||||
|
||||
def columnCount(self, *args):
|
||||
return 5
|
||||
return 6
|
||||
|
||||
def headerData(self, section, orientation, role):
|
||||
if role != Qt.DisplayRole:
|
||||
@ -57,6 +58,7 @@ class Matches(QAbstractTableModel):
|
||||
elif section == 2: text = _("Author Sort")
|
||||
elif section == 3: text = _("Publisher")
|
||||
elif section == 4: text = _("ISBN")
|
||||
elif section == 5: text = _("Published")
|
||||
|
||||
return QVariant(text)
|
||||
else:
|
||||
@ -80,6 +82,9 @@ class Matches(QAbstractTableModel):
|
||||
res = book.publisher
|
||||
elif col == 4:
|
||||
res = book.isbn
|
||||
elif col == 5:
|
||||
if hasattr(book.pubdate, 'timetuple'):
|
||||
res = strftime('%b %Y', book.pubdate.timetuple())
|
||||
if not res:
|
||||
return NONE
|
||||
return QVariant(res)
|
||||
@ -126,7 +131,7 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
|
||||
prefs['isbndb_com_key'] = key
|
||||
else:
|
||||
key = None
|
||||
title = author = publisher = isbn = None
|
||||
title = author = publisher = isbn = pubdate = None
|
||||
if self.isbn:
|
||||
isbn = self.isbn
|
||||
if self.title:
|
||||
|
@ -10,8 +10,9 @@ import os
|
||||
import re
|
||||
import time
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt4.QtCore import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread
|
||||
from PyQt4.QtCore import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread, QDate
|
||||
from PyQt4.QtGui import QPixmap, QListWidgetItem, QErrorMessage, QDialog, QCompleter
|
||||
|
||||
from calibre.gui2 import qstring_to_unicode, error_dialog, file_icon_provider, \
|
||||
@ -234,6 +235,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
self.cover.setAcceptDrops(True)
|
||||
self._author_completer = AuthorCompleter(self.db)
|
||||
self.authors.setCompleter(self._author_completer)
|
||||
self.pubdate.setMinimumDate(QDate(100,1,1))
|
||||
self.connect(self.cover, SIGNAL('cover_changed()'), self.cover_dropped)
|
||||
QObject.connect(self.cover_button, SIGNAL("clicked(bool)"), \
|
||||
self.select_cover)
|
||||
@ -279,6 +281,9 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
comments = self.db.comments(row)
|
||||
self.comments.setPlainText(comments if comments else '')
|
||||
cover = self.db.cover(row)
|
||||
pubdate = db.pubdate(self.id, index_is_id=True)
|
||||
self.pubdate.setDate(QDate(pubdate.year, pubdate.month,
|
||||
pubdate.day))
|
||||
|
||||
exts = self.db.formats(row)
|
||||
if exts:
|
||||
@ -441,6 +446,9 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
if book.author_sort: self.author_sort.setText(book.author_sort)
|
||||
if book.publisher: self.publisher.setEditText(book.publisher)
|
||||
if book.isbn: self.isbn.setText(book.isbn)
|
||||
if book.pubdate:
|
||||
d = book.pubdate
|
||||
self.pubdate.setDate(QDate(d.year, d.month, d.day))
|
||||
summ = book.comments
|
||||
if summ:
|
||||
prefix = qstring_to_unicode(self.comments.toPlainText())
|
||||
@ -485,6 +493,9 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
self.db.set_series(self.id, qstring_to_unicode(self.series.currentText()), notify=False)
|
||||
self.db.set_series_index(self.id, self.series_index.value(), notify=False)
|
||||
self.db.set_comment(self.id, qstring_to_unicode(self.comments.toPlainText()), notify=False)
|
||||
d = self.pubdate.date()
|
||||
self.db.set_pubdate(self.id, datetime(d.year(), d.month(), d.day()))
|
||||
|
||||
if self.cover_changed:
|
||||
self.db.set_cover(self.id, pixmap_to_data(self.cover.pixmap()))
|
||||
QDialog.accept(self)
|
||||
|
@ -325,6 +325,19 @@
|
||||
<item row="8" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="isbn"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Publishe&d:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>pubdate</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="publisher">
|
||||
<property name="editable">
|
||||
@ -348,6 +361,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QDateEdit" name="pubdate">
|
||||
<property name="displayFormat">
|
||||
<string>MMM yyyy</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -632,6 +655,7 @@
|
||||
<tabstop>tag_editor_button</tabstop>
|
||||
<tabstop>remove_series_button</tabstop>
|
||||
<tabstop>isbn</tabstop>
|
||||
<tabstop>pubdate</tabstop>
|
||||
<tabstop>comments</tabstop>
|
||||
<tabstop>fetch_metadata_button</tabstop>
|
||||
<tabstop>fetch_cover_button</tabstop>
|
||||
|
Loading…
x
Reference in New Issue
Block a user