mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add ability to detect ISBN from filenames
This commit is contained in:
parent
4c4473a77d
commit
261bf8021a
@ -133,6 +133,11 @@ def metadata_from_filename(name, pat=None):
|
||||
mi.series_index = int(si)
|
||||
except IndexError, ValueError:
|
||||
pass
|
||||
try:
|
||||
si = match.group('isbn')
|
||||
mi.isbn = si
|
||||
except IndexError, ValueError:
|
||||
pass
|
||||
if not mi.title:
|
||||
mi.title = name
|
||||
return mi
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>349</width>
|
||||
<height>441</height>
|
||||
<width>335</width>
|
||||
<height>487</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -39,6 +39,8 @@
|
||||
<widget class="QLineEdit" name="re" />
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>re</zorder>
|
||||
<zorder>label</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -46,7 +48,7 @@
|
||||
<property name="title" >
|
||||
<string>&Test</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
@ -76,7 +78,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
@ -84,7 +86,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<item row="0" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="title" >
|
||||
<property name="toolTip" >
|
||||
<string>Regular expression group name (?P<title>)</string>
|
||||
@ -104,7 +106,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<item row="1" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="authors" >
|
||||
<property name="toolTip" >
|
||||
<string>Regular expression group name (?P<authors>)</string>
|
||||
@ -124,7 +126,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="series" >
|
||||
<property name="toolTip" >
|
||||
<string>Regular expression group name (?P<series>)</string>
|
||||
@ -137,14 +139,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<item rowspan="2" row="3" column="0" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
<property name="text" >
|
||||
<string>Series index:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<item rowspan="2" row="3" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="series_index" >
|
||||
<property name="toolTip" >
|
||||
<string>Regular expression group name (?P<series_index>)</string>
|
||||
@ -157,6 +159,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" >
|
||||
<widget class="QLabel" name="label_7" >
|
||||
<property name="text" >
|
||||
<string>ISBN:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<widget class="QLineEdit" name="isbn" >
|
||||
<property name="toolTip" >
|
||||
<string>Regular expression group name (?P<series_index>)</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>No match</string>
|
||||
</property>
|
||||
<property name="readOnly" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -14,7 +14,8 @@ from PyQt4.QtCore import QAbstractListModel, QVariant, Qt, QRect, SIGNAL, \
|
||||
from calibre.gui2.jobs import DetailView
|
||||
from calibre.gui2 import human_readable, NONE, TableView, qstring_to_unicode, error_dialog
|
||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||
from calibre import fit_image, get_font_families, Settings
|
||||
from calibre import fit_image, Settings
|
||||
from calibre.utils.fontconfig import find_font_families
|
||||
from calibre.ebooks.metadata.meta import get_filename_pat, metadata_from_filename, \
|
||||
set_filename_pat
|
||||
|
||||
@ -56,6 +57,9 @@ class FilenamePattern(QWidget, Ui_Form):
|
||||
self.series_index.setText(str(mi.series_index))
|
||||
else:
|
||||
self.series_index.setText(_('No match'))
|
||||
|
||||
self.isbn.setText(_('No match') if mi.isbn is None else str(mi.isbn))
|
||||
|
||||
|
||||
def pattern(self):
|
||||
pat = qstring_to_unicode(self.re.text())
|
||||
@ -236,8 +240,7 @@ class FontFamilyModel(QAbstractListModel):
|
||||
|
||||
def __init__(self, *args):
|
||||
QAbstractListModel.__init__(self, *args)
|
||||
self.family_map = get_font_families()
|
||||
self.families = self.family_map.keys()
|
||||
self.families = find_font_families()
|
||||
self.families.sort()
|
||||
self.families[:0] = ['None']
|
||||
|
||||
@ -257,11 +260,6 @@ class FontFamilyModel(QAbstractListModel):
|
||||
return QVariant(QFont(family))
|
||||
return NONE
|
||||
|
||||
def path_of(self, family):
|
||||
if family != None:
|
||||
return self.family_map[family]
|
||||
return None
|
||||
|
||||
def index_of(self, family):
|
||||
return self.families.index(family.strip())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user