mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sync to pluginize
This commit is contained in:
commit
6b37352d09
@ -105,7 +105,7 @@ def debug_device_driver():
|
|||||||
prefix = logical_disk.DeviceID+os.sep
|
prefix = logical_disk.DeviceID+os.sep
|
||||||
drives.append((str(drive.PNPDeviceID), drive.Index, prefix))
|
drives.append((str(drive.PNPDeviceID), drive.Index, prefix))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
drives.append(str(drive.PNPDeviceID))
|
drives.append((str(drive.PNPDeviceID), 'No mount points found'))
|
||||||
for drive in drives:
|
for drive in drives:
|
||||||
print '\t', drive
|
print '\t', drive
|
||||||
from calibre.devices import devices
|
from calibre.devices import devices
|
||||||
|
@ -4,15 +4,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net> ' \
|
|||||||
'''
|
'''
|
||||||
Device driver for the SONY PRS-505
|
Device driver for the SONY PRS-505
|
||||||
'''
|
'''
|
||||||
import sys, os, shutil, time, subprocess, re
|
import os, time
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
from calibre.devices.usbms.cli import CLI
|
from calibre.devices.usbms.cli import CLI
|
||||||
from calibre.devices.usbms.device import Device
|
from calibre.devices.usbms.device import Device
|
||||||
from calibre.devices.errors import DeviceError, FreeSpaceError
|
from calibre.devices.errors import DeviceError, FreeSpaceError
|
||||||
from calibre.devices.prs505.books import BookList, fix_ids
|
from calibre.devices.prs505.books import BookList, fix_ids
|
||||||
from calibre import iswindows, islinux, isosx, __appname__
|
from calibre import __appname__
|
||||||
from calibre.devices.errors import PathError
|
|
||||||
|
|
||||||
class PRS505(CLI, Device):
|
class PRS505(CLI, Device):
|
||||||
|
|
||||||
@ -51,22 +50,29 @@ class PRS505(CLI, Device):
|
|||||||
try:
|
try:
|
||||||
cachep = os.path.join(prefix, self.CACHE_XML)
|
cachep = os.path.join(prefix, self.CACHE_XML)
|
||||||
if not os.path.exists(cachep):
|
if not os.path.exists(cachep):
|
||||||
|
try:
|
||||||
os.makedirs(os.path.dirname(cachep), mode=0777)
|
os.makedirs(os.path.dirname(cachep), mode=0777)
|
||||||
f = open(cachep, 'wb')
|
except:
|
||||||
|
time.sleep(5)
|
||||||
|
os.makedirs(os.path.dirname(cachep), mode=0777)
|
||||||
|
with open(cachep, 'wb') as f:
|
||||||
f.write(u'''<?xml version="1.0" encoding="UTF-8"?>
|
f.write(u'''<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<cache xmlns="http://www.kinoma.com/FskCache/1">
|
<cache xmlns="http://www.kinoma.com/FskCache/1">
|
||||||
</cache>
|
</cache>
|
||||||
'''.encode('utf8'))
|
'''.encode('utf8'))
|
||||||
f.close()
|
return True
|
||||||
except:
|
except:
|
||||||
self._card_prefix = None
|
self._card_prefix = None
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
if self._card_a_prefix is not None:
|
if self._card_a_prefix is not None:
|
||||||
write_cache(self._card_a_prefix)
|
if not write_cache(self._card_a_prefix):
|
||||||
|
self._card_a_prefix = None
|
||||||
if self._card_b_prefix is not None:
|
if self._card_b_prefix is not None:
|
||||||
write_cache(self._card_b_prefix)
|
if not write_cache(self._card_b_prefix):
|
||||||
|
self._card_b_prefix = None
|
||||||
|
|
||||||
def get_device_information(self, end_session=True):
|
def get_device_information(self, end_session=True):
|
||||||
return (self.__class__.__name__, '', '', '')
|
return (self.__class__.__name__, '', '', '')
|
||||||
|
@ -128,7 +128,7 @@ def add_pipeline_options(parser, plumber):
|
|||||||
[
|
[
|
||||||
'dont_split_on_page_breaks', 'chapter', 'chapter_mark',
|
'dont_split_on_page_breaks', 'chapter', 'chapter_mark',
|
||||||
'prefer_metadata_cover', 'remove_first_image',
|
'prefer_metadata_cover', 'remove_first_image',
|
||||||
'insert_comments', 'page_breaks_before',
|
'insert_metadata', 'page_breaks_before',
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -304,11 +304,11 @@ OptionRecommendation(name='remove_first_image',
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
OptionRecommendation(name='insert_comments',
|
OptionRecommendation(name='insert_metadata',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=False, level=OptionRecommendation.LOW,
|
||||||
help=_('Insert the comments/summary from the book metadata at the start of '
|
help=_('Insert the book metadata at the start of '
|
||||||
'the book. This is useful if your ebook reader does not support '
|
'the book. This is useful if your ebook reader does not support '
|
||||||
'displaying the comments from the metadata.'
|
'displaying/searching metadata directly.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ OptionRecommendation(name='list_recipes',
|
|||||||
fkey = map(float, fkey.split(','))
|
fkey = map(float, fkey.split(','))
|
||||||
|
|
||||||
from calibre.ebooks.oeb.transforms.jacket import Jacket
|
from calibre.ebooks.oeb.transforms.jacket import Jacket
|
||||||
Jacket()(self.oeb, self.opts)
|
Jacket()(self.oeb, self.opts, self.user_metadata)
|
||||||
pr(0.4)
|
pr(0.4)
|
||||||
|
|
||||||
if self.opts.extra_css and os.path.exists(self.opts.extra_css):
|
if self.opts.extra_css and os.path.exists(self.opts.extra_css):
|
||||||
|
@ -25,9 +25,13 @@ class Jacket(object):
|
|||||||
<title>%(title)s</title>
|
<title>%(title)s</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1 style="text-align: center">%(title)s</h1>
|
<div style="text-align:center">
|
||||||
<h2 style="text-align: center">%(jacket)s</h2>
|
<h1>%(title)s</h1>
|
||||||
<div>
|
<h2>%(jacket)s</h2>
|
||||||
|
<div>%(series)s</div>
|
||||||
|
<div>%(tags)s</div>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top:2em">
|
||||||
%(comments)s
|
%(comments)s
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
@ -46,21 +50,47 @@ class Jacket(object):
|
|||||||
img.getparent().remove(img)
|
img.getparent().remove(img)
|
||||||
return
|
return
|
||||||
|
|
||||||
def insert_comments(self, comments):
|
def insert_metadata(self, mi):
|
||||||
self.log('Inserting metadata comments into book...')
|
self.log('Inserting metadata into book...')
|
||||||
|
comments = mi.comments
|
||||||
|
if not comments:
|
||||||
|
try:
|
||||||
|
comments = unicode(self.oeb.metadata.description[0])
|
||||||
|
except:
|
||||||
|
comments = ''
|
||||||
|
if not comments.strip():
|
||||||
|
comments = ''
|
||||||
comments = comments.replace('\r\n', '\n').replace('\n\n', '<br/><br/>')
|
comments = comments.replace('\r\n', '\n').replace('\n\n', '<br/><br/>')
|
||||||
|
series = '<b>Series: </b>' + mi.series if mi.series else ''
|
||||||
|
if series and mi.series_index is not None:
|
||||||
|
series += ' [%s]'%mi.series_index
|
||||||
|
tags = mi.tags
|
||||||
|
if not tags:
|
||||||
|
try:
|
||||||
|
tags = map(unicode, self.oeb.metadata.subject)
|
||||||
|
except:
|
||||||
|
tags = []
|
||||||
|
tags = u'/'.join(tags)
|
||||||
|
if tags:
|
||||||
|
tags = '<b>Tags: </b>' + u'/%s/'%tags
|
||||||
|
else:
|
||||||
|
tags = ''
|
||||||
|
try:
|
||||||
|
title = mi.title if mi.title else unicode(self.oeb.metadata.title[0])
|
||||||
|
except:
|
||||||
|
title = _('Unknown')
|
||||||
html = self.JACKET_TEMPLATE%dict(xmlns=XPNSMAP['h'],
|
html = self.JACKET_TEMPLATE%dict(xmlns=XPNSMAP['h'],
|
||||||
title=self.opts.title, comments=comments,
|
title=title, comments=comments,
|
||||||
jacket=_('Book Jacket'))
|
jacket=_('Book Jacket'), series=series, tags=tags)
|
||||||
id, href = self.oeb.manifest.generate('jacket', 'jacket.xhtml')
|
id, href = self.oeb.manifest.generate('jacket', 'jacket.xhtml')
|
||||||
root = etree.fromstring(html)
|
root = etree.fromstring(html)
|
||||||
item = self.oeb.manifest.add(id, href, guess_type(href)[0], data=root)
|
item = self.oeb.manifest.add(id, href, guess_type(href)[0], data=root)
|
||||||
self.oeb.spine.insert(0, item, True)
|
self.oeb.spine.insert(0, item, True)
|
||||||
|
|
||||||
|
|
||||||
def __call__(self, oeb, opts):
|
def __call__(self, oeb, opts, metadata):
|
||||||
self.oeb, self.opts, self.log = oeb, opts, oeb.log
|
self.oeb, self.opts, self.log = oeb, opts, oeb.log
|
||||||
if opts.remove_first_image:
|
if opts.remove_first_image:
|
||||||
self.remove_fisrt_image()
|
self.remove_fisrt_image()
|
||||||
if opts.insert_comments and opts.comments:
|
if opts.insert_metadata:
|
||||||
self.insert_comments(opts.comments)
|
self.insert_metadata(metadata)
|
||||||
|
@ -40,7 +40,7 @@ recipe_modules = ['recipe_' + r for r in (
|
|||||||
'krstarica', 'krstarica_en', 'tanjug', 'laprensa_ni', 'azstarnet',
|
'krstarica', 'krstarica_en', 'tanjug', 'laprensa_ni', 'azstarnet',
|
||||||
'corriere_della_sera_it', 'corriere_della_sera_en', 'msdnmag_en',
|
'corriere_della_sera_it', 'corriere_della_sera_en', 'msdnmag_en',
|
||||||
'moneynews', 'der_standard', 'diepresse', 'nzz_ger', 'hna',
|
'moneynews', 'der_standard', 'diepresse', 'nzz_ger', 'hna',
|
||||||
'seattle_times', 'scott_hanselman', 'coding_horror',
|
'seattle_times', 'scott_hanselman', 'coding_horror', 'twitchfilms',
|
||||||
'stackoverflow', 'telepolis_artikel', 'zaobao', 'usnews',
|
'stackoverflow', 'telepolis_artikel', 'zaobao', 'usnews',
|
||||||
)]
|
)]
|
||||||
|
|
||||||
|
41
src/calibre/web/feeds/recipes/recipe_twitchfilms.py
Normal file
41
src/calibre/web/feeds/recipes/recipe_twitchfilms.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
twitchfilm.net/site/
|
||||||
|
'''
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
||||||
|
|
||||||
|
class Twitchfilm(BasicNewsRecipe):
|
||||||
|
title = 'Twitch Films'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'Twitch specializes in spreading the news on strange little films from around the world.'
|
||||||
|
oldest_article = 30
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = True
|
||||||
|
encoding = 'utf-8'
|
||||||
|
publisher = 'Twitch'
|
||||||
|
category = 'twitch, twitchfilm, movie news, movie reviews, cult cinema, independent cinema, anime, foreign cinema, geek talk'
|
||||||
|
language = _('English')
|
||||||
|
|
||||||
|
html2lrf_options = [
|
||||||
|
'--comment', description
|
||||||
|
, '--category', category
|
||||||
|
, '--publisher', publisher
|
||||||
|
]
|
||||||
|
|
||||||
|
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||||
|
|
||||||
|
remove_tags = [dict(name='div', attrs={'class':'feedflare'})]
|
||||||
|
|
||||||
|
feeds = [(u'News', u'http://feedproxy.google.com/TwitchEverything')]
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
mtag = Tag(soup,'meta',[('http-equiv','Content-Type'),('context','text/html; charset=utf-8')])
|
||||||
|
soup.head.insert(0,mtag)
|
||||||
|
soup.html['lang'] = 'en-US'
|
||||||
|
return soup
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user