mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
c3a8776229
commit
ea876907e9
@ -22,7 +22,8 @@ class Economist(BasicNewsRecipe):
|
||||
' perspective. Best downloaded on Friday mornings (GMT)')
|
||||
extra_css = '.headline {font-size: x-large;} \n h2 { font-size: small; } \n h1 { font-size: medium; }'
|
||||
oldest_article = 7.0
|
||||
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||
cover_url = 'http://media.economist.com/sites/default/files/imagecache/print-cover-thumbnail/print-covers/currentcoverus_large.jpg'
|
||||
#cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||
remove_tags = [
|
||||
dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
||||
dict(attrs={'class':['dblClkTrk', 'ec-article-info', 'share_inline_header']}),
|
||||
|
@ -16,7 +16,8 @@ class Economist(BasicNewsRecipe):
|
||||
' Much slower than the print edition based version.')
|
||||
extra_css = '.headline {font-size: x-large;} \n h2 { font-size: small; } \n h1 { font-size: medium; }'
|
||||
oldest_article = 7.0
|
||||
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||
cover_url = 'http://media.economist.com/sites/default/files/imagecache/print-cover-thumbnail/print-covers/currentcoverus_large.jpg'
|
||||
#cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||
remove_tags = [
|
||||
dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
||||
dict(attrs={'class':['dblClkTrk', 'ec-article-info',
|
||||
|
@ -7,7 +7,9 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, subprocess, tempfile
|
||||
import os, subprocess, tempfile, shutil
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from calibre.constants import iswindows
|
||||
from calibre.customize.ui import plugin_for_output_format
|
||||
@ -18,11 +20,24 @@ from calibre import CurrentDir
|
||||
exe = 'kindlegen.exe' if iswindows else 'kindlegen'
|
||||
|
||||
def refactor_opf(opf, is_periodical):
|
||||
pass
|
||||
with open(opf, 'rb') as f:
|
||||
root = etree.fromstring(f.read())
|
||||
if is_periodical:
|
||||
metadata = root.xpath('//*[local-name() = "metadata"]')[0]
|
||||
xm = etree.SubElement(metadata, 'x-metadata')
|
||||
xm.tail = '\n'
|
||||
xm.text = '\n\t'
|
||||
mobip = etree.SubElement(xm, attrib={'encoding':"utf-8",
|
||||
'content-type':"application/x-mobipocket-subscription-magazine"})
|
||||
mobip.tail = '\n'
|
||||
with open(opf, 'wb') as f:
|
||||
f.write(etree.tostring(root, method='xml', encodin='utf-8',
|
||||
xml_declaration=True))
|
||||
|
||||
|
||||
def refactor_guide(oeb):
|
||||
for key in list(oeb.guide):
|
||||
if key not in ('toc', 'start'):
|
||||
if key not in ('toc', 'start', 'masthead'):
|
||||
oeb.guide.remove(key)
|
||||
|
||||
def run_kindlegen(opf, log):
|
||||
@ -50,5 +65,14 @@ def kindlegen(oeb, opts, input_plugin, output_path):
|
||||
opf = [x for x in os.listdir(tdir) if x.endswith('.opf')][0]
|
||||
refactor_opf(opf, is_periodical)
|
||||
with CurrentDir(tdir):
|
||||
run_kindlegen(opf, oeb.log)
|
||||
oname = run_kindlegen(opf, oeb.log)
|
||||
shutil.copyfile(oname, output_path)
|
||||
|
||||
try:
|
||||
if os.path.exists('/tmp/kindlegen'):
|
||||
shutil.rmtree('/tmp/kindlegen')
|
||||
shutil.copytree(tdir, '/tmp/kindlegen')
|
||||
oeb.log('kindlegen intermediate output stored in: /tmp/kindlegen')
|
||||
except:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user