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
|
- title: Editor and Publisher
|
||||||
author: XanthanGum
|
author: XanthanGum
|
||||||
|
|
||||||
|
- title: The Week (free)
|
||||||
|
author: Darko Miletic
|
||||||
|
|
||||||
improved recipes:
|
improved recipes:
|
||||||
- Physics Today
|
- Physics Today
|
||||||
- Wall Street Journal
|
- 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,7 +44,8 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
for opt in self.OPTION_FIELDS:
|
for opt in self.OPTION_FIELDS:
|
||||||
opt_value = unicode(getattr(self, opt[0]).text())
|
opt_value = unicode(getattr(self, opt[0]).text())
|
||||||
gprefs.set(self.name + '_' + opt[0], opt_value)
|
gprefs.set(self.name + '_' + opt[0], opt_value)
|
||||||
opt_value = opt_value.split(',')
|
if opt[0] != 'exclude_genre':
|
||||||
|
opt_value = opt_value.split(',')
|
||||||
opts_dict[opt[0]] = opt_value
|
opts_dict[opt[0]] = opt_value
|
||||||
|
|
||||||
opts_dict['output_profile'] = [load_defaults('page_setup')['output_profile']]
|
opts_dict['output_profile'] = [load_defaults('page_setup')['output_profile']]
|
||||||
|
@ -49,7 +49,10 @@ def gui_catalog(fmt, title, dbspec, ids, out_file_name, fmt_options,
|
|||||||
|
|
||||||
# Extract the option dictionary to comma-separated lists
|
# Extract the option dictionary to comma-separated lists
|
||||||
for option in fmt_options:
|
for option in fmt_options:
|
||||||
setattr(opts,option, ','.join(fmt_options[option]))
|
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
|
# Fetch and run the plugin for fmt
|
||||||
plugin = plugin_for_catalog_format(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',
|
self.title.setText(dynamic.get('catalog_last_used_title',
|
||||||
_('My Books')))
|
_('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 = [], []
|
self.fmts, self.widgets = [], []
|
||||||
|
|
||||||
from calibre.customize.builtins import plugins as builtin_plugins
|
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.customize import CatalogPlugin
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
from calibre.customize.conversion import OptionRecommendation, DummyReporter
|
from calibre.customize.conversion import OptionRecommendation, DummyReporter
|
||||||
|
from calibre import filesystem_encoding
|
||||||
|
|
||||||
FIELDS = ['all', 'author_sort', 'authors', 'comments',
|
FIELDS = ['all', 'author_sort', 'authors', 'comments',
|
||||||
'cover', 'formats', 'id', 'isbn', 'pubdate', 'publisher', 'rating',
|
'cover', 'formats', 'id', 'isbn', 'pubdate', 'publisher', 'rating',
|
||||||
@ -663,47 +663,47 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
|
|
||||||
# Methods
|
# Methods
|
||||||
def buildSources(self):
|
def buildSources(self):
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
if not self.booksByTitle:
|
if not self.booksByTitle:
|
||||||
self.fetchBooksByTitle()
|
self.fetchBooksByTitle()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.fetchBooksByAuthor()
|
self.fetchBooksByAuthor()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateHTMLDescriptions()
|
self.generateHTMLDescriptions()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateHTMLByTitle()
|
self.generateHTMLByTitle()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateHTMLByAuthor()
|
self.generateHTMLByAuthor()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateHTMLByTags()
|
self.generateHTMLByTags()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateThumbnails()
|
self.generateThumbnails()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateOPF()
|
self.generateOPF()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateNCXHeader()
|
self.generateNCXHeader()
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.generateNCXDescriptions("Descriptions")
|
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)
|
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)
|
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")
|
self.generateNCXByTags("Genres")
|
||||||
|
|
||||||
if self.reporter.cancel_requested: return 1
|
if getattr(self.reporter, 'cancel_requested', False): return 1
|
||||||
self.writeNCX()
|
self.writeNCX()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -1350,7 +1350,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
for (i,title) in enumerate(self.booksByTitle):
|
for (i,title) in enumerate(self.booksByTitle):
|
||||||
# Update status
|
# Update status
|
||||||
self.updateProgressMicroStep("generating thumbnails ...",
|
self.updateProgressMicroStep("generating thumbnails ...",
|
||||||
100*i/len(self.booksByTitle))
|
i/float(len(self.booksByTitle)))
|
||||||
# Check to see if source file exists
|
# Check to see if source file exists
|
||||||
if 'cover' in title and os.path.isfile(title['cover']):
|
if 'cover' in title and os.path.isfile(title['cover']):
|
||||||
# print "cover found for %s" % title['title']
|
# print "cover found for %s" % title['title']
|
||||||
@ -2456,42 +2456,38 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
|
|
||||||
def generateThumbnail(self, title, image_dir, thumb_file):
|
def generateThumbnail(self, title, image_dir, thumb_file):
|
||||||
import calibre.utils.PythonMagickWand as pw
|
import calibre.utils.PythonMagickWand as pw
|
||||||
try:
|
with pw.ImageMagick():
|
||||||
img = pw.NewMagickWand()
|
try:
|
||||||
if img < 0:
|
img = pw.NewMagickWand()
|
||||||
raise RuntimeError('generate_thumbnail(): Cannot create wand')
|
if img < 0:
|
||||||
# Read the cover
|
raise RuntimeError('generate_thumbnail(): Cannot create wand')
|
||||||
if not pw.MagickReadImage(img, title['cover']):
|
# Read the cover
|
||||||
print 'Failed to read cover image from: %s' % title['cover']
|
if not pw.MagickReadImage(img,
|
||||||
raise IOError
|
title['cover'].encode(filesystem_encoding)):
|
||||||
thumb = pw.CloneMagickWand(img)
|
print 'Failed to read cover image from: %s' % title['cover']
|
||||||
if thumb < 0:
|
raise IOError
|
||||||
print 'generate_thumbnail(): Cannot clone cover'
|
thumb = pw.CloneMagickWand(img)
|
||||||
raise RuntimeError
|
if thumb < 0:
|
||||||
# img, width, height
|
print 'generate_thumbnail(): Cannot clone cover'
|
||||||
pw.MagickThumbnailImage(thumb, 75, 100)
|
raise RuntimeError
|
||||||
pw.MagickWriteImage(thumb, os.path.join(image_dir, thumb_file))
|
# img, width, height
|
||||||
pw.DestroyMagickWand(thumb)
|
pw.MagickThumbnailImage(thumb, 75, 100)
|
||||||
except IOError:
|
pw.MagickWriteImage(thumb, os.path.join(image_dir, thumb_file))
|
||||||
print "generate_thumbnail() IOError with %s" % title['title']
|
pw.DestroyMagickWand(thumb)
|
||||||
except RuntimeError:
|
except IOError:
|
||||||
print "generate_thumbnail() RuntimeError with %s" % title['title']
|
print "generate_thumbnail() IOError with %s" % title['title']
|
||||||
|
except RuntimeError:
|
||||||
|
print "generate_thumbnail() RuntimeError with %s" % title['title']
|
||||||
|
|
||||||
def processSpecialTags(self, tags, this_title, opts):
|
def processSpecialTags(self, tags, this_title, opts):
|
||||||
tag_list = []
|
tag_list = []
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
tag = self.convertHTMLEntities(tag)
|
tag = self.convertHTMLEntities(tag)
|
||||||
if tag.startswith(opts.note_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:]
|
this_title['notes'] = tag[1:]
|
||||||
elif tag == opts.read_tag:
|
elif tag == opts.read_tag:
|
||||||
# if opts.verbose:
|
|
||||||
# print "%s marked as read" % this_title['title']
|
|
||||||
this_title['read'] = True
|
this_title['read'] = True
|
||||||
elif re.search(opts.exclude_genre, tag):
|
elif re.search(opts.exclude_genre, tag):
|
||||||
# if opts.verbose:
|
|
||||||
# print "'%s' matches exclude_genre regex, skipping" % tag
|
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tag_list.append(tag)
|
tag_list.append(tag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user