mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Pull from trunk
This commit is contained in:
commit
82f577452b
BIN
resources/images/news/boortz.png
Normal file
BIN
resources/images/news/boortz.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 652 B |
43
resources/recipes/boortz.recipe
Normal file
43
resources/recipes/boortz.recipe
Normal file
@ -0,0 +1,43 @@
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
class AdvancedUserRecipe1282101454(BasicNewsRecipe):
|
||||
title = 'Nealz Nuze'
|
||||
language = 'en'
|
||||
__author__ = 'TonytheBookworm'
|
||||
description = 'Neal Boortz Show Radio Notes'
|
||||
publisher = 'Neal Boortz'
|
||||
category = 'news, politics, USA, talkshow'
|
||||
oldest_article = 1
|
||||
max_articles_per_feed = 100
|
||||
linearize_tables = True
|
||||
no_stylesheets = True
|
||||
remove_javascript = True
|
||||
|
||||
masthead_url = 'http://boortz.com/images/nuze_logo.gif'
|
||||
keep_only_tags = [
|
||||
dict(name='div', attrs={'id':['SiteContent']})
|
||||
#,dict(attrs={'id':['cxArticleText']})
|
||||
]
|
||||
remove_tags = [
|
||||
dict(name='a', attrs={'class':['blogPermalink']}),
|
||||
dict(name='span', attrs={'class':['blogBylineSeparator']}),
|
||||
dict(name='td', attrs={'id':['nealztitle']}),
|
||||
]
|
||||
remove_tags_after = [dict(name='div', attrs={'class':'blogEntryBody'}),]
|
||||
feeds = [
|
||||
('NUZE', 'http://boortz.com/nealz_nuze_rss/rss.xml')
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,6 +19,10 @@ class Book(Book_):
|
||||
self.authors = ['']
|
||||
else:
|
||||
self.authors = [authors]
|
||||
|
||||
if not title:
|
||||
self.title = _('Unknown')
|
||||
|
||||
self.mime = mime
|
||||
|
||||
self.size = size # will be set later if None
|
||||
|
@ -1696,11 +1696,12 @@ class MobiWriter(object):
|
||||
header.write(pack('>I', 1))
|
||||
|
||||
# 0x1c - 0x1f : Text encoding ?
|
||||
# GR: Language encoding for NCX entries (latin_1)
|
||||
header.write(pack('>I', 0x4e4))
|
||||
# header.write(pack('>I', 650001))
|
||||
# GR: This needs to be either 0xFDE9 or 0x4E4
|
||||
header.write(pack('>I', 0xFDE9))
|
||||
|
||||
# 0x20 - 0x23 : Mimicking kindleGen
|
||||
header.write(pack('>I', 0xFFFFFFFF))
|
||||
# 0x20 - 0x23 : Language code?
|
||||
header.write(iana2mobi(str(self._oeb.metadata.language[0])))
|
||||
|
||||
# 0x24 - 0x27 : Number of TOC entries in INDX1
|
||||
header.write(pack('>I', indxt_count + 1))
|
||||
@ -1800,7 +1801,7 @@ class MobiWriter(object):
|
||||
text = text.strip()
|
||||
if not isinstance(text, unicode):
|
||||
text = text.decode('utf-8', 'replace')
|
||||
text = text.encode('cp1252','replace')
|
||||
text = text.encode('ascii','replace')
|
||||
return text
|
||||
|
||||
def _add_to_ctoc(self, ctoc_str, record_offset):
|
||||
@ -2150,26 +2151,6 @@ class MobiWriter(object):
|
||||
indxt.write(decint(self._ctoc_map[index]['titleOffset'], DECINT_FORWARD)) # vwi title offset in CNCX
|
||||
indxt.write(decint(0, DECINT_FORWARD)) # unknown byte
|
||||
|
||||
def _write_subchapter_node(self, indxt, indices, index, offset, length, count):
|
||||
# This style works without a parent chapter, mimicking what KindleGen does,
|
||||
# using a value of 0x0B for parentIndex
|
||||
# Writes an INDX1 NCXEntry of entryType 0x1F - subchapter
|
||||
if self.opts.verbose > 2:
|
||||
# *** GR: Turn this off while I'm developing my code
|
||||
#self._oeb.log.debug('Writing TOC node to IDXT:', node.title, 'href:', node.href)
|
||||
pass
|
||||
|
||||
pos = 0xc0 + indxt.tell()
|
||||
indices.write(pack('>H', pos)) # Save the offset for IDXTIndices
|
||||
name = "%04X"%count
|
||||
indxt.write(chr(len(name)) + name) # Write the name
|
||||
indxt.write(INDXT['subchapter']) # entryType [0x0F | 0xDF | 0xFF | 0x3F]
|
||||
indxt.write(decint(offset, DECINT_FORWARD)) # offset
|
||||
indxt.write(decint(length, DECINT_FORWARD)) # length
|
||||
indxt.write(decint(self._ctoc_map[index]['titleOffset'], DECINT_FORWARD)) # vwi title offset in CNCX
|
||||
indxt.write(decint(0, DECINT_FORWARD)) # unknown byte
|
||||
indxt.write(decint(0xb, DECINT_FORWARD)) # parentIndex - null
|
||||
|
||||
def _compute_offset_length(self, i, node, entries) :
|
||||
h = node.href
|
||||
if h not in self._id_offsets:
|
||||
|
@ -363,10 +363,10 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
return row[self.FIELD_MAP['path']].replace('/', os.sep)
|
||||
|
||||
|
||||
def abspath(self, index, index_is_id=False):
|
||||
def abspath(self, index, index_is_id=False, create_dirs=True):
|
||||
'Return the absolute path to the directory containing this books files as a unicode string.'
|
||||
path = os.path.join(self.library_path, self.path(index, index_is_id=index_is_id))
|
||||
if not os.path.exists(path):
|
||||
if create_dirs and not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
@ -657,7 +657,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
def has_cover(self, index, index_is_id=False):
|
||||
id = index if index_is_id else self.id(index)
|
||||
try:
|
||||
path = os.path.join(self.abspath(id, index_is_id=True), 'cover.jpg')
|
||||
path = os.path.join(self.abspath(id, index_is_id=True,
|
||||
create_dirs=False), 'cover.jpg')
|
||||
except:
|
||||
# Can happen if path has not yet been set
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user