mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update catalog timestamp/pubdate when re-generating
This commit is contained in:
parent
c32392b266
commit
3a6fb23646
@ -1,4 +1,4 @@
|
|||||||
import pickle, os, re, shutil, htmlentitydefs
|
import os, re, shutil, htmlentitydefs
|
||||||
|
|
||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
|
|
||||||
@ -412,11 +412,11 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
# Convert the upper 3 numbers - thousandsNumber
|
# Convert the upper 3 numbers - thousandsNumber
|
||||||
if thousandsNumber:
|
if thousandsNumber:
|
||||||
if number > 1099 and number < 2000:
|
if number > 1099 and number < 2000:
|
||||||
resultString = '%s %s' % (self.lessThanTwenty[number/100],
|
resultString = '%s %s' % (self.lessThanTwenty[number/100],
|
||||||
self.stringFromInt(number % 100))
|
self.stringFromInt(number % 100))
|
||||||
self.text = resultString.strip().capitalize()
|
self.text = resultString.strip().capitalize()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
thousandsString = self.stringFromInt(thousandsNumber)
|
thousandsString = self.stringFromInt(thousandsNumber)
|
||||||
|
|
||||||
# Concatenate the strings
|
# Concatenate the strings
|
||||||
@ -509,10 +509,10 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
self.__thumbs = None
|
self.__thumbs = None
|
||||||
self.__title = opts.catalog_title
|
self.__title = opts.catalog_title
|
||||||
self.__verbose = opts.verbose
|
self.__verbose = opts.verbose
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "CatalogBuilder(): Generating %s for %s" % (self.opts.fmt, self.opts.output_profile)
|
print "CatalogBuilder(): Generating %s for %s" % (self.opts.fmt, self.opts.output_profile)
|
||||||
|
|
||||||
# Accessors
|
# Accessors
|
||||||
'''
|
'''
|
||||||
@dynamic_property
|
@dynamic_property
|
||||||
@ -522,7 +522,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.__ = val
|
self.__ = val
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@dynamic_property
|
@dynamic_property
|
||||||
def authors(self):
|
def authors(self):
|
||||||
@ -538,7 +538,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.__basename = val
|
self.__basename = val
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
@dynamic_property
|
@dynamic_property
|
||||||
def booksByAuthor(self):
|
def booksByAuthor(self):
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return self.__booksByAuthor
|
return self.__booksByAuthor
|
||||||
@ -878,7 +878,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "fetchBooksByTitle(): %d books" % len(self.booksByTitle)
|
print "fetchBooksByTitle(): %d books" % len(self.booksByTitle)
|
||||||
for title in self.booksByTitle:
|
for title in self.booksByTitle:
|
||||||
print (u" %-50s %-25s" % (title['title'][0:45], title['title_sort'][0:20])).encode('utf-8')
|
print (u" %-50s %-25s" % (title['title'][0:45], title['title_sort'][0:20])).encode('utf-8')
|
||||||
print
|
print
|
||||||
|
|
||||||
def fetchBooksByAuthor(self):
|
def fetchBooksByAuthor(self):
|
||||||
@ -927,10 +927,10 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "\nfetchBooksByauthor(): %d unique authors" % len(unique_authors)
|
print "\nfetchBooksByauthor(): %d unique authors" % len(unique_authors)
|
||||||
for author in unique_authors:
|
for author in unique_authors:
|
||||||
print (u" %-50s %-25s %2d" % (author[0][0:45], author[1][0:20],
|
print (u" %-50s %-25s %2d" % (author[0][0:45], author[1][0:20],
|
||||||
author[2])).encode('utf-8')
|
author[2])).encode('utf-8')
|
||||||
print
|
print
|
||||||
|
|
||||||
self.authors = unique_authors
|
self.authors = unique_authors
|
||||||
|
|
||||||
def generateHTMLDescriptions(self):
|
def generateHTMLDescriptions(self):
|
||||||
@ -1676,7 +1676,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
cmTag['name'] = "author"
|
cmTag['name'] = "author"
|
||||||
cmTag.insert(0, NavigableString(self.formatNCXText(book['author'])))
|
cmTag.insert(0, NavigableString(self.formatNCXText(book['author'])))
|
||||||
navPointVolumeTag.insert(2, cmTag)
|
navPointVolumeTag.insert(2, cmTag)
|
||||||
|
|
||||||
# Add the description tag
|
# Add the description tag
|
||||||
if book['short_description']:
|
if book['short_description']:
|
||||||
cmTag = Tag(ncx_soup, '%s' % 'calibre:meta')
|
cmTag = Tag(ncx_soup, '%s' % 'calibre:meta')
|
||||||
@ -1816,7 +1816,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
nptc += 1
|
nptc += 1
|
||||||
|
|
||||||
# Create an NCX article entry for each populated author index letter
|
# Create an NCX article entry for each populated author index letter
|
||||||
# Loop over the sorted_authors list, find start of each letter,
|
# Loop over the sorted_authors list, find start of each letter,
|
||||||
# add description_preview_count artists
|
# add description_preview_count artists
|
||||||
# self.authors[0]:friendly [1]:author_sort [2]:book_count
|
# self.authors[0]:friendly [1]:author_sort [2]:book_count
|
||||||
master_author_list = []
|
master_author_list = []
|
||||||
@ -1868,7 +1868,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
contentTag['src'] = "%s#%sauthors" % (HTML_file, authors_by_letter[1])
|
contentTag['src'] = "%s#%sauthors" % (HTML_file, authors_by_letter[1])
|
||||||
|
|
||||||
navPointByLetterTag.insert(1,contentTag)
|
navPointByLetterTag.insert(1,contentTag)
|
||||||
|
|
||||||
if self.generateForKindle:
|
if self.generateForKindle:
|
||||||
cmTag = Tag(soup, '%s' % 'calibre:meta')
|
cmTag = Tag(soup, '%s' % 'calibre:meta')
|
||||||
cmTag['name'] = "description"
|
cmTag['name'] = "description"
|
||||||
@ -1903,7 +1903,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
file_ID = file_ID.replace(" ","")
|
file_ID = file_ID.replace(" ","")
|
||||||
navPointTag['id'] = "%s-ID" % file_ID
|
navPointTag['id'] = "%s-ID" % file_ID
|
||||||
navPointTag['playOrder'] = self.playOrder
|
navPointTag['playOrder'] = self.playOrder
|
||||||
#print "generateNCXByTags(section '%s'): self.playOrder: %d" % (tocTitle, self.playOrder)
|
#print "generateNCXByTags(section '%s'): self.playOrder: %d" % (tocTitle, self.playOrder)
|
||||||
self.playOrder += 1
|
self.playOrder += 1
|
||||||
navLabelTag = Tag(ncx_soup, 'navLabel')
|
navLabelTag = Tag(ncx_soup, 'navLabel')
|
||||||
textTag = Tag(ncx_soup, 'text')
|
textTag = Tag(ncx_soup, 'text')
|
||||||
@ -1943,19 +1943,19 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
cmTag = Tag(ncx_soup, '%s' % 'calibre:meta')
|
cmTag = Tag(ncx_soup, '%s' % 'calibre:meta')
|
||||||
cmTag['name'] = "author"
|
cmTag['name'] = "author"
|
||||||
# First - Last author
|
# First - Last author
|
||||||
|
|
||||||
if len(genre['titles_spanned']) > 1 :
|
if len(genre['titles_spanned']) > 1 :
|
||||||
author_range = "%s - %s" % (genre['titles_spanned'][0][0], genre['titles_spanned'][1][0])
|
author_range = "%s - %s" % (genre['titles_spanned'][0][0], genre['titles_spanned'][1][0])
|
||||||
else :
|
else :
|
||||||
author_range = "%s" % (genre['titles_spanned'][0][0])
|
author_range = "%s" % (genre['titles_spanned'][0][0])
|
||||||
|
|
||||||
cmTag.insert(0, NavigableString(author_range))
|
cmTag.insert(0, NavigableString(author_range))
|
||||||
navPointVolumeTag.insert(2, cmTag)
|
navPointVolumeTag.insert(2, cmTag)
|
||||||
|
|
||||||
# Build the description tag
|
# Build the description tag
|
||||||
cmTag = Tag(ncx_soup, '%s' % 'calibre:meta')
|
cmTag = Tag(ncx_soup, '%s' % 'calibre:meta')
|
||||||
cmTag['name'] = "description"
|
cmTag['name'] = "description"
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# Form 1: Titles spanned
|
# Form 1: Titles spanned
|
||||||
if len(genre['titles_spanned']) > 1:
|
if len(genre['titles_spanned']) > 1:
|
||||||
@ -1971,7 +1971,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
titles = sorted(titles, key=lambda x:(self.generateSortTitle(x),self.generateSortTitle(x)))
|
titles = sorted(titles, key=lambda x:(self.generateSortTitle(x),self.generateSortTitle(x)))
|
||||||
titles_list = self.generateShortDescription(" • ".join(titles))
|
titles_list = self.generateShortDescription(" • ".join(titles))
|
||||||
cmTag.insert(0, NavigableString(self.formatNCXText(titles_list)))
|
cmTag.insert(0, NavigableString(self.formatNCXText(titles_list)))
|
||||||
|
|
||||||
navPointVolumeTag.insert(3, cmTag)
|
navPointVolumeTag.insert(3, cmTag)
|
||||||
|
|
||||||
# Add this volume to the section tag
|
# Add this volume to the section tag
|
||||||
@ -2065,11 +2065,11 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
markerTags = []
|
markerTags = []
|
||||||
markerTags.extend(self.opts.exclude_tags.split(','))
|
markerTags.extend(self.opts.exclude_tags.split(','))
|
||||||
markerTags.extend(self.opts.note_tag.split(','))
|
markerTags.extend(self.opts.note_tag.split(','))
|
||||||
markerTags.extend(self.opts.read_tag.split(','))
|
markerTags.extend(self.opts.read_tag.split(','))
|
||||||
return markerTags
|
return markerTags
|
||||||
|
|
||||||
def filterDbTags(self, tags):
|
def filterDbTags(self, tags):
|
||||||
# Remove the special marker tags from the database's tag list,
|
# Remove the special marker tags from the database's tag list,
|
||||||
# return sorted list of tags representing valid genres
|
# return sorted list of tags representing valid genres
|
||||||
|
|
||||||
filtered_tags = []
|
filtered_tags = []
|
||||||
@ -2082,7 +2082,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
if re.search(self.opts.exclude_genre, tag):
|
if re.search(self.opts.exclude_genre, tag):
|
||||||
#print "skipping %s" % tag
|
#print "skipping %s" % tag
|
||||||
continue
|
continue
|
||||||
|
|
||||||
filtered_tags.append(tag)
|
filtered_tags.append(tag)
|
||||||
|
|
||||||
filtered_tags.sort()
|
filtered_tags.sort()
|
||||||
|
@ -1415,9 +1415,10 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
if matches:
|
if matches:
|
||||||
tag_matches = self.data.get_matches('tags', _('Catalog'))
|
tag_matches = self.data.get_matches('tags', _('Catalog'))
|
||||||
matches = matches.intersection(tag_matches)
|
matches = matches.intersection(tag_matches)
|
||||||
db_id = None
|
db_id, existing = None, False
|
||||||
if matches:
|
if matches:
|
||||||
db_id = list(matches)[0]
|
db_id = list(matches)[0]
|
||||||
|
existing = True
|
||||||
if db_id is None:
|
if db_id is None:
|
||||||
obj = self.conn.execute('INSERT INTO books(title, author_sort) VALUES (?, ?)',
|
obj = self.conn.execute('INSERT INTO books(title, author_sort) VALUES (?, ?)',
|
||||||
(title, 'calibre'))
|
(title, 'calibre'))
|
||||||
@ -1433,6 +1434,10 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
if not hasattr(path, 'read'):
|
if not hasattr(path, 'read'):
|
||||||
stream.close()
|
stream.close()
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
if existing:
|
||||||
|
t = datetime.utcnow()
|
||||||
|
self.set_timestamp(db_id, t, notify=False)
|
||||||
|
self.set_pubdate(db_id, t, notify=False)
|
||||||
self.data.refresh_ids(self, [db_id]) # Needed to update format list and size
|
self.data.refresh_ids(self, [db_id]) # Needed to update format list and size
|
||||||
return db_id
|
return db_id
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user