Add recipe for The New Yorker

This commit is contained in:
Kovid Goyal 2008-07-01 14:32:52 -07:00
parent 75c3fa5a23
commit 0be7f76c12
5 changed files with 14 additions and 5 deletions

View File

@ -262,7 +262,7 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
self.cover_changed = True self.cover_changed = True
self.cpixmap = pix self.cpixmap = pix
except LibraryThingError, err: except LibraryThingError, err:
error_dialog(self, _('Could not fetch cover'), _('<b>Could not fetch cover.</b><br/>')+str(err)).exec_() error_dialog(self, _('Could not fetch cover'), _('<b>Could not fetch cover.</b><br/>')+unicode(err)).exec_()
finally: finally:
self.fetch_cover_button.setEnabled(True) self.fetch_cover_button.setEnabled(True)
self.unsetCursor() self.unsetCursor()

View File

@ -1112,7 +1112,7 @@ class Main(MainWindow, Ui_MainWindow):
msg = ' '.join(msgs) msg = ' '.join(msgs)
print >>file, msg print >>file, msg
def safe_unicode(self, arg): def safe_unicode(arg):
if not arg: if not arg:
arg = unicode(repr(arg)) arg = unicode(repr(arg))
if isinstance(arg, str): if isinstance(arg, str):

View File

@ -7,10 +7,10 @@ See ftp://ftp.rarlabs.com/rar/unrarsrc-3.7.5.tar.gz
""" """
import os, ctypes import os, ctypes
from ctypes import Structure, c_char_p, c_uint, c_void_p, POINTER, \ from ctypes import Structure, c_char_p, c_uint, c_void_p, POINTER, \
byref, c_wchar_p, CFUNCTYPE, c_int, c_long, c_char, c_wchar byref, c_wchar_p, c_int, c_char, c_wchar
from StringIO import StringIO from StringIO import StringIO
from calibre import iswindows, isosx, load_library from calibre import iswindows, load_library
_librar_name = 'libunrar' _librar_name = 'libunrar'
cdll = ctypes.cdll cdll = ctypes.cdll

View File

@ -9,6 +9,7 @@ __docformat__ = "restructuredtext en"
import logging, os, cStringIO, time, traceback, re, urlparse import logging, os, cStringIO, time, traceback, re, urlparse
from collections import defaultdict from collections import defaultdict
from functools import partial
from calibre import browser, __appname__, iswindows, LoggingInterface, strftime from calibre import browser, __appname__, iswindows, LoggingInterface, strftime
from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag
@ -812,6 +813,14 @@ class BasicNewsRecipe(object, LoggingInterface):
strings.append(item['alt']) strings.append(item['alt'])
return u''.join(strings) return u''.join(strings)
@classmethod
def soup(cls, raw):
entity_replace = [(re.compile(ur'&(\S+?);'), partial(entity_to_unicode,
exceptions=[]))]
nmassage = list(BeautifulSoup.MARKUP_MASSAGE)
nmassage.extend(entity_replace)
return BeautifulSoup(raw, markupMassage=nmassage)
class Profile2Recipe(BasicNewsRecipe): class Profile2Recipe(BasicNewsRecipe):
''' '''
Used to migrate the old news Profiles to the new Recipes. Uses the settings Used to migrate the old news Profiles to the new Recipes. Uses the settings

View File

@ -8,7 +8,7 @@ recipes = [
'newsweek', 'atlantic', 'economist', 'portfolio', 'newsweek', 'atlantic', 'economist', 'portfolio',
'nytimes', 'usatoday', 'outlook_india', 'bbc', 'greader', 'wsj', 'nytimes', 'usatoday', 'outlook_india', 'bbc', 'greader', 'wsj',
'wired', 'globe_and_mail', 'smh', 'espn', 'business_week', 'wired', 'globe_and_mail', 'smh', 'espn', 'business_week',
'ars_technica', 'upi', 'ars_technica', 'upi', 'new_yorker',
] ]
import re, imp, inspect, time import re, imp, inspect, time