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)
|
mi.series_index = int(si)
|
||||||
except IndexError, ValueError:
|
except IndexError, ValueError:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
si = match.group('isbn')
|
||||||
|
mi.isbn = si
|
||||||
|
except IndexError, ValueError:
|
||||||
|
pass
|
||||||
if not mi.title:
|
if not mi.title:
|
||||||
mi.title = name
|
mi.title = name
|
||||||
return mi
|
return mi
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>349</width>
|
<width>335</width>
|
||||||
<height>441</height>
|
<height>487</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
@ -39,6 +39,8 @@
|
|||||||
<widget class="QLineEdit" name="re" />
|
<widget class="QLineEdit" name="re" />
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
<zorder>re</zorder>
|
||||||
|
<zorder>label</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -46,7 +48,7 @@
|
|||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>&Test</string>
|
<string>&Test</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
@ -76,7 +78,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" name="gridLayout" >
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
@ -84,7 +86,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="title" >
|
<widget class="QLineEdit" name="title" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Regular expression group name (?P<title>)</string>
|
<string>Regular expression group name (?P<title>)</string>
|
||||||
@ -104,7 +106,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="authors" >
|
<widget class="QLineEdit" name="authors" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Regular expression group name (?P<authors>)</string>
|
<string>Regular expression group name (?P<authors>)</string>
|
||||||
@ -124,7 +126,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="2" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="series" >
|
<widget class="QLineEdit" name="series" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Regular expression group name (?P<series>)</string>
|
<string>Regular expression group name (?P<series>)</string>
|
||||||
@ -137,14 +139,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" >
|
<item rowspan="2" row="3" column="0" >
|
||||||
<widget class="QLabel" name="label_6" >
|
<widget class="QLabel" name="label_6" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Series index:</string>
|
<string>Series index:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" >
|
<item rowspan="2" row="3" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="series_index" >
|
<widget class="QLineEdit" name="series_index" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Regular expression group name (?P<series_index>)</string>
|
<string>Regular expression group name (?P<series_index>)</string>
|
||||||
@ -157,6 +159,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -14,7 +14,8 @@ from PyQt4.QtCore import QAbstractListModel, QVariant, Qt, QRect, SIGNAL, \
|
|||||||
from calibre.gui2.jobs import DetailView
|
from calibre.gui2.jobs import DetailView
|
||||||
from calibre.gui2 import human_readable, NONE, TableView, qstring_to_unicode, error_dialog
|
from calibre.gui2 import human_readable, NONE, TableView, qstring_to_unicode, error_dialog
|
||||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
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, \
|
from calibre.ebooks.metadata.meta import get_filename_pat, metadata_from_filename, \
|
||||||
set_filename_pat
|
set_filename_pat
|
||||||
|
|
||||||
@ -57,6 +58,9 @@ class FilenamePattern(QWidget, Ui_Form):
|
|||||||
else:
|
else:
|
||||||
self.series_index.setText(_('No match'))
|
self.series_index.setText(_('No match'))
|
||||||
|
|
||||||
|
self.isbn.setText(_('No match') if mi.isbn is None else str(mi.isbn))
|
||||||
|
|
||||||
|
|
||||||
def pattern(self):
|
def pattern(self):
|
||||||
pat = qstring_to_unicode(self.re.text())
|
pat = qstring_to_unicode(self.re.text())
|
||||||
return re.compile(pat)
|
return re.compile(pat)
|
||||||
@ -236,8 +240,7 @@ class FontFamilyModel(QAbstractListModel):
|
|||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QAbstractListModel.__init__(self, *args)
|
QAbstractListModel.__init__(self, *args)
|
||||||
self.family_map = get_font_families()
|
self.families = find_font_families()
|
||||||
self.families = self.family_map.keys()
|
|
||||||
self.families.sort()
|
self.families.sort()
|
||||||
self.families[:0] = ['None']
|
self.families[:0] = ['None']
|
||||||
|
|
||||||
@ -257,11 +260,6 @@ class FontFamilyModel(QAbstractListModel):
|
|||||||
return QVariant(QFont(family))
|
return QVariant(QFont(family))
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
def path_of(self, family):
|
|
||||||
if family != None:
|
|
||||||
return self.family_map[family]
|
|
||||||
return None
|
|
||||||
|
|
||||||
def index_of(self, family):
|
def index_of(self, family):
|
||||||
return self.families.index(family.strip())
|
return self.families.index(family.strip())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user