mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GwR fix for options passable as lists or strings
This commit is contained in:
commit
e90d19775c
@ -122,6 +122,9 @@
|
||||
- title: Editor and Publisher
|
||||
author: XanthanGum
|
||||
|
||||
- title: The Week (free)
|
||||
author: Darko Miletic
|
||||
|
||||
improved recipes:
|
||||
- Physics Today
|
||||
- Wall Street Journal
|
||||
|
BIN
resources/images/news/the_week_magazine_free.png
Normal file
BIN
resources/images/news/the_week_magazine_free.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 301 B |
49
resources/recipes/the_week_magazine_free.recipe
Normal file
49
resources/recipes/the_week_magazine_free.recipe
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
www.theweek.com
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class TheWeekFree(BasicNewsRecipe):
|
||||
title = 'The Week Magazine - Free content'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = "The best of the US and international media. Daily coverage of commentary and analysis of the day's events, as well as arts, entertainment, people and gossip, and political cartoons."
|
||||
publisher = 'The Week Publications, Inc.'
|
||||
category = 'news, politics, USA'
|
||||
oldest_article = 7
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
encoding = 'utf-8'
|
||||
use_embedded_content = False
|
||||
language = 'en'
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
, 'tags' : category
|
||||
, 'publisher' : publisher
|
||||
, 'language' : language
|
||||
}
|
||||
|
||||
keep_only_tags = [
|
||||
dict(name=['h1','h2'])
|
||||
, dict(name='div', attrs={'class':'basefont'})
|
||||
, dict(name='div', attrs={'id':'slideshowLoader'})
|
||||
]
|
||||
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'id':['digg_dugg','articleRight','dateHeader']})
|
||||
,dict(name=['object','embed','iframe'])
|
||||
]
|
||||
|
||||
|
||||
feeds = [
|
||||
(u'News & Opinions' , u'http://www.theweek.com/section/index/news_opinion.rss')
|
||||
,(u'Arts & Leisure' , u'http://www.theweek.com/section/index/arts_leisure.rss')
|
||||
,(u'Business' , u'http://www.theweek.com/section/index/business.rss' )
|
||||
,(u'Cartoon & Short takes' , u'http://www.theweek.com/section/index/cartoons_wit.rss')
|
||||
]
|
||||
|
||||
|
@ -44,6 +44,7 @@ class PluginWidget(QWidget,Ui_Form):
|
||||
for opt in self.OPTION_FIELDS:
|
||||
opt_value = unicode(getattr(self, opt[0]).text())
|
||||
gprefs.set(self.name + '_' + opt[0], opt_value)
|
||||
if opt[0] != 'exclude_genre':
|
||||
opt_value = opt_value.split(',')
|
||||
opts_dict[opt[0]] = opt_value
|
||||
|
||||
|
@ -49,7 +49,10 @@ def gui_catalog(fmt, title, dbspec, ids, out_file_name, fmt_options,
|
||||
|
||||
# Extract the option dictionary to comma-separated lists
|
||||
for option in fmt_options:
|
||||
if isinstance(fmt_options[option],list):
|
||||
setattr(opts,option, ','.join(fmt_options[option]))
|
||||
else:
|
||||
setattr(opts,option, fmt_options[option])
|
||||
|
||||
# Fetch and run the plugin for fmt
|
||||
plugin = plugin_for_catalog_format(fmt)
|
||||
|
@ -36,9 +36,6 @@ class Catalog(QDialog, Ui_Dialog):
|
||||
self.title.setText(dynamic.get('catalog_last_used_title',
|
||||
_('My Books')))
|
||||
|
||||
# GwR *** Add option tabs for built-in formats
|
||||
# This code models #69 in calibre/gui2/dialogs/config/__init__.py
|
||||
|
||||
self.fmts, self.widgets = [], []
|
||||
|
||||
from calibre.customize.builtins import plugins as builtin_plugins
|
||||
|
@ -6,7 +6,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag,
|
||||
from calibre.customize import CatalogPlugin
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre.customize.conversion import OptionRecommendation, DummyReporter
|
||||
|
||||
from calibre import filesystem_encoding
|
||||
|
||||
FIELDS = ['all', 'author_sort', 'authors', 'comments',
|
||||
'cover', 'formats', 'id', 'isbn', 'pubdate', 'publisher', 'rating',
|
||||
@ -663,47 +663,47 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
|
||||
# Methods
|
||||
def buildSources(self):
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
if not self.booksByTitle:
|
||||
self.fetchBooksByTitle()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.fetchBooksByAuthor()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateHTMLDescriptions()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateHTMLByTitle()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateHTMLByAuthor()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateHTMLByTags()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateThumbnails()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateOPF()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateNCXHeader()
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateNCXDescriptions("Descriptions")
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateNCXByTitle("Titles", single_article_per_section=False)
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateNCXByAuthor("Authors", single_article_per_section=False)
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.generateNCXByTags("Genres")
|
||||
|
||||
if self.reporter.cancel_requested: return 1
|
||||
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||
self.writeNCX()
|
||||
|
||||
return 0
|
||||
@ -1350,7 +1350,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
for (i,title) in enumerate(self.booksByTitle):
|
||||
# Update status
|
||||
self.updateProgressMicroStep("generating thumbnails ...",
|
||||
100*i/len(self.booksByTitle))
|
||||
i/float(len(self.booksByTitle)))
|
||||
# Check to see if source file exists
|
||||
if 'cover' in title and os.path.isfile(title['cover']):
|
||||
# print "cover found for %s" % title['title']
|
||||
@ -2456,12 +2456,14 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
|
||||
def generateThumbnail(self, title, image_dir, thumb_file):
|
||||
import calibre.utils.PythonMagickWand as pw
|
||||
with pw.ImageMagick():
|
||||
try:
|
||||
img = pw.NewMagickWand()
|
||||
if img < 0:
|
||||
raise RuntimeError('generate_thumbnail(): Cannot create wand')
|
||||
# Read the cover
|
||||
if not pw.MagickReadImage(img, title['cover']):
|
||||
if not pw.MagickReadImage(img,
|
||||
title['cover'].encode(filesystem_encoding)):
|
||||
print 'Failed to read cover image from: %s' % title['cover']
|
||||
raise IOError
|
||||
thumb = pw.CloneMagickWand(img)
|
||||
@ -2482,16 +2484,10 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
for tag in tags:
|
||||
tag = self.convertHTMLEntities(tag)
|
||||
if tag.startswith(opts.note_tag):
|
||||
# if opts.verbose:
|
||||
# print "%s has a note: %s" % (this_title['title'], tag[1:])
|
||||
this_title['notes'] = tag[1:]
|
||||
elif tag == opts.read_tag:
|
||||
# if opts.verbose:
|
||||
# print "%s marked as read" % this_title['title']
|
||||
this_title['read'] = True
|
||||
elif re.search(opts.exclude_genre, tag):
|
||||
# if opts.verbose:
|
||||
# print "'%s' matches exclude_genre regex, skipping" % tag
|
||||
continue
|
||||
else:
|
||||
tag_list.append(tag)
|
||||
|
Loading…
x
Reference in New Issue
Block a user