mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
1bfeb92135
35
resources/recipes/winnipeg_sun.recipe
Normal file
35
resources/recipes/winnipeg_sun.recipe
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class AdvancedUserRecipe1277647803(BasicNewsRecipe):
|
||||||
|
title = u'Winnipeg Sun'
|
||||||
|
__author__ = 'rty'
|
||||||
|
__version__ = '1.0'
|
||||||
|
oldest_article = 2
|
||||||
|
pubisher = 'www.winnipegsun.com'
|
||||||
|
description = 'Winnipeg Newspaper'
|
||||||
|
category = 'News, Winnipeg, Canada'
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
encoding = 'UTF-8'
|
||||||
|
remove_javascript = True
|
||||||
|
use_embedded_content = False
|
||||||
|
language = 'en_CA'
|
||||||
|
feeds = [
|
||||||
|
(u'News', u'http://www.winnipegsun.com/news/rss.xml'),
|
||||||
|
(u'Columnists', u'http://www.winnipegsun.com/columnists/rss.xml'),
|
||||||
|
(u'Editorial', u'http://www.winnipegsun.com/comment/editorial/rss.xml'),
|
||||||
|
(u'Entertainments', u'http://www.winnipegsun.com/entertainment/rss.xml'),
|
||||||
|
(u'Life', u'http://www.winnipegsun.com/life/rss.xml'),
|
||||||
|
(u'Money', u'http://www.winnipegsun.com/money/rss.xml')
|
||||||
|
]
|
||||||
|
keep_only_tags = [
|
||||||
|
dict(name='div', attrs={'id':'article'}),
|
||||||
|
]
|
||||||
|
remove_tags = [
|
||||||
|
dict(name='div', attrs={'class':['leftBox','bottomBox clear']}),
|
||||||
|
dict(name='ul', attrs={'class':'tabs dl contentSwap'}),
|
||||||
|
dict(name='div', attrs={'id':'commentsBottom'}),
|
||||||
|
]
|
||||||
|
remove_tags_after = [
|
||||||
|
dict(name='div', attrs={'class':'bottomBox clear'})
|
||||||
|
]
|
@ -13,7 +13,7 @@ from calibre import isbytestring
|
|||||||
|
|
||||||
class Book(MetaInformation):
|
class Book(MetaInformation):
|
||||||
|
|
||||||
BOOK_ATTRS = ['lpath', 'size', 'mime', 'device_collections']
|
BOOK_ATTRS = ['lpath', 'size', 'mime', 'device_collections', '_new_book']
|
||||||
|
|
||||||
JSON_ATTRS = [
|
JSON_ATTRS = [
|
||||||
'lpath', 'title', 'authors', 'mime', 'size', 'tags', 'author_sort',
|
'lpath', 'title', 'authors', 'mime', 'size', 'tags', 'author_sort',
|
||||||
@ -27,6 +27,7 @@ class Book(MetaInformation):
|
|||||||
|
|
||||||
MetaInformation.__init__(self, '')
|
MetaInformation.__init__(self, '')
|
||||||
self.device_collections = []
|
self.device_collections = []
|
||||||
|
self._new_book = False
|
||||||
|
|
||||||
self.path = os.path.join(prefix, lpath)
|
self.path = os.path.join(prefix, lpath)
|
||||||
if os.sep == '\\':
|
if os.sep == '\\':
|
||||||
|
@ -138,7 +138,7 @@ class CollectionsBookList(BookList):
|
|||||||
# The default: leave the book in all existing collections. Do not
|
# The default: leave the book in all existing collections. Do not
|
||||||
# add any new ones.
|
# add any new ones.
|
||||||
attrs = ['device_collections']
|
attrs = ['device_collections']
|
||||||
if book._new_book:
|
if getattr(book, '_new_book', False):
|
||||||
if prefs['preserve_user_collections']:
|
if prefs['preserve_user_collections']:
|
||||||
# Ensure that the book is in all the book's existing
|
# Ensure that the book is in all the book's existing
|
||||||
# collections plus all metadata collections
|
# collections plus all metadata collections
|
||||||
|
@ -126,7 +126,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.dbpath = os.path.join(library_path, 'metadata.db')
|
self.dbpath = os.path.join(library_path, 'metadata.db')
|
||||||
self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH',
|
self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH',
|
||||||
self.dbpath)
|
self.dbpath)
|
||||||
if isinstance(self.dbpath, unicode):
|
if isinstance(self.dbpath, unicode) and not iswindows:
|
||||||
self.dbpath = self.dbpath.encode(filesystem_encoding)
|
self.dbpath = self.dbpath.encode(filesystem_encoding)
|
||||||
|
|
||||||
self.connect()
|
self.connect()
|
||||||
|
@ -156,7 +156,7 @@ class RecursiveFetcher(object):
|
|||||||
|
|
||||||
replace = self.prepreprocess_html_ext(soup)
|
replace = self.prepreprocess_html_ext(soup)
|
||||||
if replace is not None:
|
if replace is not None:
|
||||||
soup = BeautifulSoup(xml_to_unicode(src, self.verbose, strip_encoding_pats=True)[0], markupMassage=nmassage)
|
soup = BeautifulSoup(xml_to_unicode(replace, self.verbose, strip_encoding_pats=True)[0], markupMassage=nmassage)
|
||||||
|
|
||||||
if self.keep_only_tags:
|
if self.keep_only_tags:
|
||||||
body = Tag(soup, 'body')
|
body = Tag(soup, 'body')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user