diff --git a/resources/recipes/nytimes.recipe b/resources/recipes/nytimes.recipe
index 3b9d2858e6..b168113a79 100644
--- a/resources/recipes/nytimes.recipe
+++ b/resources/recipes/nytimes.recipe
@@ -9,7 +9,8 @@ import re
import time
from calibre import entity_to_unicode
from calibre.web.feeds.recipes import BasicNewsRecipe
-from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString, Comment
+from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString, \
+Comment, BeautifulStoneSoup
class NYTimes(BasicNewsRecipe):
@@ -256,7 +257,6 @@ class NYTimes(BasicNewsRecipe):
# Fetch the outer table
table = soup.find('table')
previousTable = table
- contentTable = None
# Find the deepest table containing the stories
while True :
diff --git a/resources/recipes/usatoday.recipe b/resources/recipes/usatoday.recipe
index 368437a709..5b036d145d 100644
--- a/resources/recipes/usatoday.recipe
+++ b/resources/recipes/usatoday.recipe
@@ -128,7 +128,6 @@ class USAToday(BasicNewsRecipe):
def parse_feeds(self, *args, **kwargs):
parsed_feeds = BasicNewsRecipe.parse_feeds(self, *args, **kwargs)
# Count articles for progress dialog
- content_feeds = []
article_count = 0
for feed in parsed_feeds:
article_count += len(feed)
@@ -297,7 +296,6 @@ class USAToday(BasicNewsRecipe):
if not headline_found:
# Monolithic
- restructure
- insert_loc = 0
tag = body.find(True)
while True:
insertLoc += 1
diff --git a/src/calibre/ebooks/metadata/mobi.py b/src/calibre/ebooks/metadata/mobi.py
index 7581b560cd..408bab828d 100644
--- a/src/calibre/ebooks/metadata/mobi.py
+++ b/src/calibre/ebooks/metadata/mobi.py
@@ -322,11 +322,13 @@ class MetadataUpdater(object):
recs = []
try:
- from calibre.ebooks.conversion.config import load_defaults
- prefs = load_defaults('mobi_output')
- pas = prefs.get('prefer_author_sort', False)
+ from calibre.ebooks.conversion.config import load_defaults
+ prefs = load_defaults('mobi_output')
+ pas = prefs.get('prefer_author_sort', False)
+ kindle_pdoc = prefs.get('personal_doc', None)
except:
pas = False
+ kindle_pdoc = None
if mi.author_sort and pas:
authors = mi.author_sort
update_exth_record((100, authors.encode(self.codec, 'replace')))
@@ -350,15 +352,8 @@ class MetadataUpdater(object):
subjects = '; '.join(mi.tags)
update_exth_record((105, subjects.encode(self.codec, 'replace')))
- # >>> Begin patch for ticket #4652 <<<
- kindle_doc_types = set([u'[kindle_ebok]',u'[kindle_pdoc]'])
- doc_type = list(kindle_doc_types.intersection(set(mi.tags)))[0]
- if doc_type:
- if doc_type == '[kindle_ebok]':
- update_exth_record((501,str('EBOK')))
- elif doc_type == '[kindle_pdoc]':
- update_exth_record((501, str('PDOC')))
- # >>> End patch
+ if kindle_pdoc and kindle_pdoc in mi.tags:
+ update_exth_record((501, str('PDOC')))
if mi.pubdate:
update_exth_record((106, str(mi.pubdate).encode(self.codec, 'replace')))
diff --git a/src/calibre/ebooks/metadata/topaz.py b/src/calibre/ebooks/metadata/topaz.py
index df25172531..4db3a7b955 100644
--- a/src/calibre/ebooks/metadata/topaz.py
+++ b/src/calibre/ebooks/metadata/topaz.py
@@ -83,7 +83,7 @@ class MetadataUpdater(object):
sig = self.data[:4]
if not sig.startswith('TPZ'):
- raise ValueError('Not a Topaz file')
+ raise ValueError("'%s': Not a Topaz file" % getattr(stream, 'name', 'Unnamed stream'))
offset = 4
self.header_records, consumed = self.decode_vwi(self.data[offset:offset+4])
@@ -92,13 +92,13 @@ class MetadataUpdater(object):
# First integrity test - metadata header
if not 'metadata' in self.topaz_headers:
- raise ValueError('Invalid Topaz format - no metadata record')
+ raise ValueError("'%s': Invalid Topaz format - no metadata record" % getattr(stream, 'name', 'Unnamed stream'))
# Second integrity test - metadata body
md_offset = self.topaz_headers['metadata']['blocks'][0]['offset']
md_offset += self.base
if self.data[md_offset+1:md_offset+9] != 'metadata':
- raise ValueError('Damaged metadata record')
+ raise ValueError("'%s': Damaged metadata record" % getattr(stream, 'name', 'Unnamed stream'))
def book_length(self):
''' convenience method for retrieving book length '''
diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py
index 451fe11e4f..c41a54165d 100644
--- a/src/calibre/ebooks/mobi/output.py
+++ b/src/calibre/ebooks/mobi/output.py
@@ -36,6 +36,9 @@ class MOBIOutput(OutputFormatPlugin):
recommended_value=False, level=OptionRecommendation.LOW,
help=_('Disable compression of the file contents.')
),
+ OptionRecommendation(name='personal_doc', recommended_value='[kindle_pdoc]',
+ help=_('Tag marking book to be filed with Personal Docs')
+ ),
])
def check_for_periodical(self):
diff --git a/src/calibre/gui2/convert/mobi_output.py b/src/calibre/gui2/convert/mobi_output.py
index 57cc3a2ac1..396078c48a 100644
--- a/src/calibre/gui2/convert/mobi_output.py
+++ b/src/calibre/gui2/convert/mobi_output.py
@@ -24,7 +24,7 @@ class PluginWidget(Widget, Ui_Form):
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent, 'mobi_output',
['prefer_author_sort', 'rescale_images', 'toc_title',
- 'dont_compress', 'no_inline_toc', 'masthead_font']
+ 'dont_compress', 'no_inline_toc', 'masthead_font','personal_doc']
)
self.db, self.book_id = db, book_id
diff --git a/src/calibre/gui2/convert/mobi_output.ui b/src/calibre/gui2/convert/mobi_output.ui
index 9c3ec9e68e..176ce681c0 100644
--- a/src/calibre/gui2/convert/mobi_output.ui
+++ b/src/calibre/gui2/convert/mobi_output.ui
@@ -6,8 +6,8 @@
0
0
- 421
- 300
+ 521
+ 331
@@ -64,13 +64,27 @@
-
- Masthead font:
+ Periodical masthead font:
-
+ -
+
+
-
+
+
+ Personal Doc tag:
+
+
+
+ -
+
+
+
+
-
@@ -79,7 +93,7 @@
20
- 55
+ 40