Pull from trunk

This commit is contained in:
Kovid Goyal 2010-05-28 14:26:10 -06:00
commit a67f410ab3
15 changed files with 227 additions and 109 deletions

View File

@ -1,38 +1,47 @@
#!/usr/bin/env python
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
''' '''
bbc.co.uk news.bbc.co.uk
''' '''
from calibre.web.feeds.news import BasicNewsRecipe import re
from calibre.web.feeds.recipes import BasicNewsRecipe
class BBC(BasicNewsRecipe): class BBC(BasicNewsRecipe):
title = u'The BBC' title = 'The BBC'
__author__ = 'Kovid Goyal ans Sujata Raman' __author__ = 'Darko Miletic'
description = 'Global news and current affairs from the British Broadcasting Corporation' description = 'Global news and current affairs from the British Broadcasting Corporation'
language = 'en' oldest_article = 2
max_articles_per_feed = 100
no_stylesheets = True
#delay = 1
use_embedded_content = False
encoding = 'utf8'
publisher = 'BBC'
category = 'news, UK, world'
language = 'en_GB'
publication_type = 'newsportal'
extra_css = ' body{ font-family: Verdana,Helvetica,Arial,sans-serif } .introduction{font-weight: bold} .story-feature{display: block; padding: 0; border: 1px solid; width: 40%; font-size: small} .story-feature h2{text-align: center; text-transform: uppercase} '
preprocess_regexps = [(re.compile(r'<!--.*?-->', re.DOTALL), lambda m: '')]
no_stylesheets = True conversion_options = {
remove_tags = [dict(name='div', attrs={'class':'footer'}), 'comments' : description
{'id' : ['popstory','blq-footer']}, ,'tags' : category
{'class' : ['arrup','links','relatedbbcsites','arr','promobottombg','bbccom_visibility_hidden', 'sharesb', 'sib606', 'mvtb', 'storyextra', 'sidebar1', 'bbccom_text','promotopbg', 'gppromo','promotopbg','bbccom_display_none']}, ,'language' : language
] ,'publisher' : publisher
,'linearize_tables': True
}
keep_only_tags = [dict(name='div', attrs={'class':'mainwrapper'})] keep_only_tags = [
dict(attrs={'id' :['meta-information','story-body']})
extra_css = ''' ,dict(attrs={'class':['mxb' ,'storybody' ]})
body{font-family:Arial,Helvetica,sans-serif; font-size:small; align:left} ]
h1{font-size:large;} remove_tags = [
.sh{font-size:large; font-weight:bold} dict(name=['object','link','table'])
.cap{font-size:xx-small; } ,dict(attrs={'class':['caption','caption full-width','story-actions','hidden','sharesb','audioInStoryC']})
.lu{font-size:xx-small; } ]
.ds{font-size:xx-small; } remove_tags_after = dict(attrs={'class':'sharesb'})
.mvb{font-size:xx-small;} remove_attributes = ['width','height']
.by1{font-size:x-small; color:#666666}
.byd{font-size:x-small;}
'''
feeds = [ feeds = [
('News Front Page', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'), ('News Front Page', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'),
@ -50,22 +59,3 @@ class BBC(BasicNewsRecipe):
('Africa', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml'), ('Africa', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml'),
] ]
def postprocess_html(self, soup, first):
for tag in soup.findAll(name= 'img', alt=""):
tag.extract()
for item in soup.findAll(align = "right"):
del item['align']
for tag in soup.findAll(name=['table', 'tr', 'td']):
tag.name = 'div'
return soup
# def print_version(self, url):
# return url.replace('http://', 'http://newsvote.bbc.co.uk/mpapps/pagetools/print/')

View File

@ -3,7 +3,7 @@ __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
''' '''
news.bbc.co.uk news.bbc.co.uk
''' '''
import re
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
class BBC(BasicNewsRecipe): class BBC(BasicNewsRecipe):
@ -18,22 +18,28 @@ class BBC(BasicNewsRecipe):
encoding = 'utf8' encoding = 'utf8'
publisher = 'BBC' publisher = 'BBC'
category = 'news, UK, world' category = 'news, UK, world'
language = 'en' language = 'en_GB'
extra_css = ' body{ font-family: sans-serif; } .headline{font-size: xx-large; font-weight: bold} .ibox{display: block; margin: 20px 50px; padding: 10px; border: 1px solid } ' publication_type = 'newsportal'
extra_css = ' body{ font-family: Verdana,Helvetica,Arial,sans-serif } .introduction{font-weight: bold} .story-feature{display: block; padding: 0; border: 1px solid; width: 40%; font-size: small} .story-feature h2{text-align: center; text-transform: uppercase} '
preprocess_regexps = [(re.compile(r'<!--.*?-->', re.DOTALL), lambda m: '')]
conversion_options = { conversion_options = {
'comments' : description 'comments' : description
,'tags' : category ,'tags' : category
,'language' : language ,'language' : language
,'publisher' : publisher ,'publisher' : publisher
,'linearize_tables': True
} }
remove_tags_before = dict(name='div',attrs={'class':'headline'}) keep_only_tags = [
remove_tags_after = dict(name='div', attrs={'class':'footer'}) dict(attrs={'id' :['meta-information','story-body']})
remove_tags = [ ,dict(attrs={'class':['mxb' ,'storybody' ]})
dict(name=['object','link','script','iframe'])
,dict(name='div', attrs={'class':'footer'})
] ]
remove_tags = [
dict(name=['object','link','table','img'])
,dict(attrs={'class':['caption','caption full-width','story-actions','hidden','sharesb','audioInStoryC']})
]
remove_tags_after = dict(attrs={'class':'sharesb'})
remove_attributes = ['width','height']
feeds = [ feeds = [
('News Front Page', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'), ('News Front Page', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'),
@ -51,10 +57,3 @@ class BBC(BasicNewsRecipe):
('Africa', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml'), ('Africa', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml'),
] ]
def print_version(self, url):
emp,sep,rstrip = url.partition('http://')
return 'http://newsvote.bbc.co.uk/mpapps/pagetools/print/' + rstrip
def get_article_url(self, article):
return article.get('guid', None)

View File

@ -0,0 +1,24 @@
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1274742400(BasicNewsRecipe):
title = u'Las Vegas Review Journal'
__author__ = 'Joel'
language = 'en'
oldest_article = 7
max_articles_per_feed = 100
feeds = [
(u'News', u'http://www.lvrj.com/news.rss'),
(u'Business', u'http://www.lvrj.com/business.rss'),
(u'Living', u'http://www.lvrj.com/living.rss'),
(u'Opinion', u'http://www.lvrj.com/opinion.rss'),
(u'Neon', u'http://www.lvrj.com/neon.rss'),
(u'Image', u'http://www.lvrj.com/image.rss'),
(u'Home & Garden', u'http://www.lvrj.com/home_and_garden.rss'),
(u'Furniture & Design', u'http://www.lvrj.com/furniture_and_design.rss'),
(u'Drive', u'http://www.lvrj.com/drive.rss'),
(u'Real Estate', u'http://www.lvrj.com/real_estate.rss'),
(u'Sports', u'http://www.lvrj.com/sports.rss')]

View File

@ -9,14 +9,13 @@ import re
import time import time
from calibre import entity_to_unicode from calibre import entity_to_unicode
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString, \ from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString, Comment
Comment, BeautifulStoneSoup
class NYTimes(BasicNewsRecipe): class NYTimes(BasicNewsRecipe):
title = 'New York Times Top Stories' title = 'New York Times Top Stories'
__author__ = 'GRiker' __author__ = 'GRiker'
language = 'en' language = _('English')
description = 'Top Stories from the New York Times' description = 'Top Stories from the New York Times'
# List of sections typically included in Top Stories. Use a keyword from the # List of sections typically included in Top Stories. Use a keyword from the
@ -257,6 +256,7 @@ class NYTimes(BasicNewsRecipe):
# Fetch the outer table # Fetch the outer table
table = soup.find('table') table = soup.find('table')
previousTable = table previousTable = table
contentTable = None
# Find the deepest table containing the stories # Find the deepest table containing the stories
while True : while True :
@ -388,6 +388,10 @@ class NYTimes(BasicNewsRecipe):
return ans return ans
def preprocess_html(self, soup): def preprocess_html(self, soup):
# Skip ad pages before actual article
skip_tag = soup.find(True, {'name':'skip'})
if skip_tag is not None:
soup = self.index_to_soup(skip_tag.parent['href'])
return self.strip_anchors(soup) return self.strip_anchors(soup)
def postprocess_html(self,soup, True): def postprocess_html(self,soup, True):

View File

@ -82,6 +82,7 @@ class NYTimes(BasicNewsRecipe):
'articleExtras', 'articleExtras',
'articleInline', 'articleInline',
'blog_sidebar', 'blog_sidebar',
'businessSearchBar',
'cCol', 'cCol',
'entertainmentSearchBar', 'entertainmentSearchBar',
'footer', 'footer',
@ -286,9 +287,14 @@ class NYTimes(BasicNewsRecipe):
raw = self.browser.open('http://www.nytimes.com'+content).read() raw = self.browser.open('http://www.nytimes.com'+content).read()
return BeautifulSoup(raw.decode('cp1252', 'replace')) return BeautifulSoup(raw.decode('cp1252', 'replace'))
''' '''
# Skip ad pages before actual article
skip_tag = soup.find(True, {'name':'skip'})
if skip_tag is not None:
soup = self.index_to_soup(skip_tag.parent['href'])
return self.strip_anchors(soup) return self.strip_anchors(soup)
def postprocess_html(self,soup, True): def postprocess_html(self,soup, True):
print "\npostprocess_html()\n"
if self.one_picture_per_article: if self.one_picture_per_article:
# Remove all images after first # Remove all images after first
@ -411,6 +417,7 @@ class NYTimes(BasicNewsRecipe):
return soup return soup
def postprocess_book(self, oeb, opts, log) : def postprocess_book(self, oeb, opts, log) :
print "\npostprocess_book()\n"
def extract_byline(href) : def extract_byline(href) :
# <meta name="byline" content= # <meta name="byline" content=

View File

@ -0,0 +1,31 @@
__license__ = 'GPL v3'
__copyright__ = '2010, Vadim Dyadkin dyadkin@lns.pnpi.spb.ru'
from calibre.web.feeds.news import BasicNewsRecipe
class Trv(BasicNewsRecipe):
title = u'\u0422\u0440\u043e\u0438\u0446\u043a\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442'
language = 'ru'
__author__ = 'Vadim Dyadkin'
oldest_article = 30
max_articles_per_feed = 100
recursion = 4
no_stylesheets = True
simultaneous_downloads = 1
keep_only_tags = [dict(name='h1'),
dict(name='div', attrs={'id' : 'content'})
]
remove_tags = [dict(name='div', attrs={'class' : ['dateright',
'postmeta', 'adsense-post', 'comments', 'nocomments', 'widgetarea',
'breadcrumb']}), {'id' : ['sidebar', 'l_sidebar', 'r_sidebar', 'footer',
'homepageright0']}, {'style' : 'clear:both;'},
dict(name='ul'),
dict(name='h2')
]
feeds = [(u'\u0422\u0440\u043e\u0438\u0446\u043a\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442',
u'http://trv-science.ru/feed/')]

View File

@ -16,13 +16,15 @@ class Wired(BasicNewsRecipe):
publisher = 'Conde Nast Digital' publisher = 'Conde Nast Digital'
category = 'news, games, IT, gadgets' category = 'news, games, IT, gadgets'
oldest_article = 32 oldest_article = 32
delay = 1
max_articles_per_feed = 100 max_articles_per_feed = 100
no_stylesheets = True no_stylesheets = True
encoding = 'utf-8' encoding = 'utf-8'
use_embedded_content = False use_embedded_content = False
masthead_url = 'http://www.wired.com/images/home/wired_logo.gif' masthead_url = 'http://www.wired.com/images/home/wired_logo.gif'
language = 'en' language = 'en'
extra_css = ' body{font-family: sans-serif} .entryDescription li {display: inline; list-style-type: none} ' publication_type = 'magazine'
extra_css = ' body{font-family: Arial,Verdana,sans-serif} .entryDescription li {display: inline; list-style-type: none} '
index = 'http://www.wired.com/magazine/' index = 'http://www.wired.com/magazine/'
preprocess_regexps = [(re.compile(r'<meta name="Title".*<title>', re.DOTALL|re.IGNORECASE),lambda match: '<title>')] preprocess_regexps = [(re.compile(r'<meta name="Title".*<title>', re.DOTALL|re.IGNORECASE),lambda match: '<title>')]
@ -38,6 +40,8 @@ class Wired(BasicNewsRecipe):
remove_tags = [ remove_tags = [
dict(name=['object','embed','iframe','link']) dict(name=['object','embed','iframe','link'])
,dict(name='div', attrs={'class':['podcast_storyboard','tweetmeme_button']}) ,dict(name='div', attrs={'class':['podcast_storyboard','tweetmeme_button']})
,dict(attrs={'id':'ff_bottom_nav'})
,dict(name='a',attrs={'href':'http://www.wired.com/app'})
] ]
remove_attributes = ['height','width'] remove_attributes = ['height','width']
@ -72,17 +76,18 @@ class Wired(BasicNewsRecipe):
farticles = [] farticles = []
for item in features.findAll('div',attrs={'class':'section'}): for item in features.findAll('div',attrs={'class':'section'}):
divurl = item.find('div',attrs={'class':'feature-header'}) divurl = item.find('div',attrs={'class':'feature-header'})
divdesc = item.find('div',attrs={'class':'feature-text'}) if divurl:
url = 'http://www.wired.com' + divurl.a['href'] divdesc = item.find('div',attrs={'class':'feature-text'})
title = self.tag_to_string(divurl.a) url = 'http://www.wired.com' + divurl.a['href']
description = self.tag_to_string(divdesc) title = self.tag_to_string(divurl.a)
date = strftime(self.timefmt) description = self.tag_to_string(divdesc)
farticles.append({ date = strftime(self.timefmt)
'title' :title farticles.append({
,'date' :date 'title' :title
,'url' :url ,'date' :date
,'description':description ,'url' :url
}) ,'description':description
})
totalfeeds.append(('Featured Articles', farticles)) totalfeeds.append(('Featured Articles', farticles))
#department feeds #department feeds
departments = ['rants','start','test','play','found'] departments = ['rants','start','test','play','found']

View File

@ -444,7 +444,7 @@ from calibre.devices.kindle.driver import KINDLE, KINDLE2, KINDLE_DX
from calibre.devices.nook.driver import NOOK from calibre.devices.nook.driver import NOOK
from calibre.devices.prs505.driver import PRS505 from calibre.devices.prs505.driver import PRS505
from calibre.devices.android.driver import ANDROID, S60 from calibre.devices.android.driver import ANDROID, S60
from calibre.devices.nokia.driver import N770, N810 from calibre.devices.nokia.driver import N770, N810, E71X
from calibre.devices.eslick.driver import ESLICK from calibre.devices.eslick.driver import ESLICK
from calibre.devices.nuut2.driver import NUUT2 from calibre.devices.nuut2.driver import NUUT2
from calibre.devices.iriver.driver import IRIVER_STORY from calibre.devices.iriver.driver import IRIVER_STORY
@ -453,8 +453,9 @@ from calibre.devices.hanvon.driver import N516, EB511, ALEX, AZBOOKA, THEBOOK
from calibre.devices.edge.driver import EDGE from calibre.devices.edge.driver import EDGE
from calibre.devices.teclast.driver import TECLAST_K3, NEWSMY, IPAPYRUS from calibre.devices.teclast.driver import TECLAST_K3, NEWSMY, IPAPYRUS
from calibre.devices.sne.driver import SNE from calibre.devices.sne.driver import SNE
from calibre.devices.misc import PALMPRE, KOBO, AVANT from calibre.devices.misc import PALMPRE, AVANT
from calibre.devices.folder_device.driver import FOLDER_DEVICE_FOR_CONFIG from calibre.devices.folder_device.driver import FOLDER_DEVICE_FOR_CONFIG
from calibre.devices.kobo.driver import KOBO
from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon from calibre.ebooks.metadata.fetch import GoogleBooks, ISBNDB, Amazon
from calibre.library.catalog import CSV_XML, EPUB_MOBI from calibre.library.catalog import CSV_XML, EPUB_MOBI
@ -513,6 +514,7 @@ plugins += [
ANDROID, ANDROID,
S60, S60,
N770, N770,
E71X,
N810, N810,
COOL_ER, COOL_ER,
ESLICK, ESLICK,

View File

@ -0,0 +1,9 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'

View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.devices.usbms.driver import USBMS
class KOBO(USBMS):
name = 'Kobo Reader Device Interface'
gui_name = 'Kobo Reader'
description = _('Communicate with the Kobo Reader')
author = 'Kovid Goyal'
supported_platforms = ['windows', 'osx', 'linux']
# Ordered list of supported formats
FORMATS = ['epub', 'pdf']
VENDOR_ID = [0x2237]
PRODUCT_ID = [0x4161]
BCD = [0x0110]
VENDOR_NAME = 'KOBO_INC'
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = '.KOBOEREADER'
EBOOK_DIR_MAIN = ''
SUPPORTS_SUB_DIRS = True

View File

@ -28,27 +28,6 @@ class PALMPRE(USBMS):
EBOOK_DIR_MAIN = 'E-books' EBOOK_DIR_MAIN = 'E-books'
class KOBO(USBMS):
name = 'Kobo Reader Device Interface'
gui_name = 'Kobo Reader'
description = _('Communicate with the Kobo Reader')
author = 'Kovid Goyal'
supported_platforms = ['windows', 'osx', 'linux']
# Ordered list of supported formats
FORMATS = ['epub', 'pdf']
VENDOR_ID = [0x2237]
PRODUCT_ID = [0x4161]
BCD = [0x0110]
VENDOR_NAME = 'KOBO_INC'
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = '.KOBOEREADER'
EBOOK_DIR_MAIN = ''
SUPPORTS_SUB_DIRS = True
class AVANT(USBMS): class AVANT(USBMS):
name = 'Booq Avant Device Interface' name = 'Booq Avant Device Interface'

View File

@ -45,3 +45,25 @@ class N810(N770):
WINDOWS_MAIN_MEM = 'N810' WINDOWS_MAIN_MEM = 'N810'
MAIN_MEMORY_VOLUME_LABEL = 'N810 Main Memory' MAIN_MEMORY_VOLUME_LABEL = 'N810 Main Memory'
class E71X(USBMS):
name = 'Nokia E71X device interface'
gui_name = 'Nokia E71X'
description = 'Communicate with the Nokia E71X'
author = 'Kovid Goyal'
supported_platforms = ['windows', 'linux', 'osx']
VENDOR_ID = [0x421]
PRODUCT_ID = [0x1a0]
BCD = [0x100]
FORMATS = ['mobi', 'prc']
EBOOK_DIR_MAIN = 'eBooks'
SUPPORTS_SUB_DIRS = True
VENDOR_NAME = 'NOKIA'
WINDOWS_MAIN_MEM = 'S60'

View File

@ -117,7 +117,7 @@ class EPUBInput(InputFormatPlugin):
encfile = os.path.abspath(os.path.join('META-INF', 'encryption.xml')) encfile = os.path.abspath(os.path.join('META-INF', 'encryption.xml'))
opf = None opf = None
for f in walk(u'.'): for f in walk(u'.'):
if f.lower().endswith('.opf'): if f.lower().endswith('.opf') and '__MACOSX' not in f:
opf = os.path.abspath(f) opf = os.path.abspath(f)
break break
path = getattr(stream, 'name', 'stream') path = getattr(stream, 'name', 'stream')
@ -146,6 +146,10 @@ class EPUBInput(InputFormatPlugin):
self.rationalize_cover(opf, log) self.rationalize_cover(opf, log)
self.optimize_opf_parsing = opf self.optimize_opf_parsing = opf
for x in opf.itermanifest():
if x.get('media-type', '') == 'application/x-dtbook+xml':
raise ValueError(
'EPUB files with DTBook markup are not supported')
with open('content.opf', 'wb') as nopf: with open('content.opf', 'wb') as nopf:
nopf.write(opf.render()) nopf.write(opf.render())

View File

@ -106,7 +106,7 @@ class EPUBOutput(OutputFormatPlugin):
recommendations = set([('pretty_print', True, OptionRecommendation.HIGH)]) recommendations = set([('pretty_print', True, OptionRecommendation.HIGH)])
def workaround_webkit_quirks(self): def workaround_webkit_quirks(self): # {{{
from calibre.ebooks.oeb.base import XPath from calibre.ebooks.oeb.base import XPath
for x in self.oeb.spine: for x in self.oeb.spine:
root = x.data root = x.data
@ -120,8 +120,9 @@ class EPUBOutput(OutputFormatPlugin):
for pre in XPath('//h:pre')(body): for pre in XPath('//h:pre')(body):
if not pre.text and len(pre) == 0: if not pre.text and len(pre) == 0:
pre.tag = 'div' pre.tag = 'div'
# }}}
def upshift_markup(self): def upshift_markup(self): # {{{
'Upgrade markup to comply with XHTML 1.1 where possible' 'Upgrade markup to comply with XHTML 1.1 where possible'
from calibre.ebooks.oeb.base import XPath from calibre.ebooks.oeb.base import XPath
for x in self.oeb.spine: for x in self.oeb.spine:
@ -135,6 +136,7 @@ class EPUBOutput(OutputFormatPlugin):
for u in XPath('//h:u')(root): for u in XPath('//h:u')(root):
u.tag = 'span' u.tag = 'span'
u.set('style', 'text-decoration:underline') u.set('style', 'text-decoration:underline')
# }}}
def convert(self, oeb, output_path, input_plugin, opts, log): def convert(self, oeb, output_path, input_plugin, opts, log):
self.log, self.opts, self.oeb = log, opts, oeb self.log, self.opts, self.oeb = log, opts, oeb
@ -161,8 +163,10 @@ class EPUBOutput(OutputFormatPlugin):
self.workaround_sony_quirks() self.workaround_sony_quirks()
if self.oeb.toc.count() == 0: if self.oeb.toc.count() == 0:
self.log.warn('This EPUB file has no Table of Contents. It will ' self.log.warn('This EPUB file has no Table of Contents. '
'not validate via epubcheck') 'Creating a default TOC')
first = iter(self.oeb.spine).next()
self.oeb.toc.add(_('Start'), first.href)
from calibre.ebooks.oeb.base import OPF from calibre.ebooks.oeb.base import OPF
identifiers = oeb.metadata['identifier'] identifiers = oeb.metadata['identifier']
@ -202,7 +206,7 @@ class EPUBOutput(OutputFormatPlugin):
self.log.info('EPUB extracted to', opts.extract_to) self.log.info('EPUB extracted to', opts.extract_to)
epub.close() epub.close()
def encrypt_fonts(self, uris, tdir, uuid): def encrypt_fonts(self, uris, tdir, uuid): # {{{
from binascii import unhexlify from binascii import unhexlify
key = re.sub(r'[^a-fA-F0-9]', '', uuid) key = re.sub(r'[^a-fA-F0-9]', '', uuid)
@ -247,6 +251,7 @@ class EPUBOutput(OutputFormatPlugin):
ans += (u'\n'.join(fonts)).encode('utf-8') ans += (u'\n'.join(fonts)).encode('utf-8')
ans += '\n</encryption>' ans += '\n</encryption>'
return ans return ans
# }}}
def condense_ncx(self, ncx_path): def condense_ncx(self, ncx_path):
if not self.opts.pretty_print: if not self.opts.pretty_print:
@ -259,7 +264,7 @@ class EPUBOutput(OutputFormatPlugin):
compressed = etree.tostring(tree.getroot(), encoding='utf-8') compressed = etree.tostring(tree.getroot(), encoding='utf-8')
open(ncx_path, 'wb').write(compressed) open(ncx_path, 'wb').write(compressed)
def workaround_ade_quirks(self): def workaround_ade_quirks(self): # {{{
''' '''
Perform various markup transforms to get the output to render correctly Perform various markup transforms to get the output to render correctly
in the quirky ADE. in the quirky ADE.
@ -388,8 +393,9 @@ class EPUBOutput(OutputFormatPlugin):
else: else:
self.oeb.log.warn('No stylesheet found') self.oeb.log.warn('No stylesheet found')
# }}}
def workaround_sony_quirks(self): def workaround_sony_quirks(self): # {{{
''' '''
Perform toc link transforms to alleviate slow loading. Perform toc link transforms to alleviate slow loading.
''' '''
@ -436,3 +442,6 @@ class EPUBOutput(OutputFormatPlugin):
if self.oeb.toc: if self.oeb.toc:
simplify_toc_entry(self.oeb.toc) simplify_toc_entry(self.oeb.toc)
# }}}

View File

@ -21,7 +21,9 @@ from calibre.utils.logging import Log
from calibre import guess_type, prints from calibre import guess_type, prints
from calibre.ebooks.oeb.transforms.cover import CoverManager from calibre.ebooks.oeb.transforms.cover import CoverManager
TITLEPAGE = CoverManager.SVG_TEMPLATE.decode('utf-8').replace('__ar__', 'none') TITLEPAGE = CoverManager.SVG_TEMPLATE.decode('utf-8').replace(\
'__ar__', 'none').replace('__viewbox__', '0 0 600 800'
).replace('__width__', '600').replace('__height__', '800')
def character_count(html): def character_count(html):
''' '''