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
5944a4126d
@ -7,7 +7,12 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString
|
|||||||
|
|
||||||
|
|
||||||
class TheIndependentNew(BasicNewsRecipe):
|
class TheIndependentNew(BasicNewsRecipe):
|
||||||
|
|
||||||
|
#used for converting rating to stars
|
||||||
|
_STAR_URL = 'http://www.independent.co.uk/skins/ind/images/rating_star.png'
|
||||||
|
_NO_STAR_URL = 'http://www.independent.co.uk/skins/ind/images/rating_star_grey.png'
|
||||||
|
|
||||||
|
|
||||||
title = u'The Independent'
|
title = u'The Independent'
|
||||||
__author__ = 'Will'
|
__author__ = 'Will'
|
||||||
description = 'The latest in UK News and World News from The \
|
description = 'The latest in UK News and World News from The \
|
||||||
@ -44,12 +49,26 @@ class TheIndependentNew(BasicNewsRecipe):
|
|||||||
h1{font-family: Georgia,serif }
|
h1{font-family: Georgia,serif }
|
||||||
body{font-family: Verdana,Arial,Helvetica,sans-serif}
|
body{font-family: Verdana,Arial,Helvetica,sans-serif}
|
||||||
img{margin-bottom: 0.4em; display:block}
|
img{margin-bottom: 0.4em; display:block}
|
||||||
.byline,.image,.dateline{font-size: x-small; color:#888888}
|
.starRating img {float: left}
|
||||||
|
.starRating {margin-top:0.4em; display: block}
|
||||||
|
.image {clear:left; font-size: x-small; color:#888888;}
|
||||||
|
.articleByTimeLocation {font-size: x-small; color:#888888;
|
||||||
|
margin-bottom:0.2em ; margin-top:0.2em ; display:block}
|
||||||
|
.subtitle {clear:left}
|
||||||
|
.column-1 h1 { color: #191919}
|
||||||
|
.column-1 h2 { color: #333333}
|
||||||
|
.column-1 h3 { color: #444444}
|
||||||
|
.column-1 p { color: #777777}
|
||||||
|
.column-1 p,a,h1,h2,h3 { margin: 0; }
|
||||||
|
.column-1 div{color:#888888; margin: 0;}
|
||||||
|
.articleContent {display: block; clear:left;}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
oldest_article = 1
|
oldest_article = 1
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for item in soup.findAll(attrs={'class' : re.compile("widget.*")}):
|
for item in soup.findAll(attrs={'class' : re.compile("widget.*")}):
|
||||||
remove = True
|
remove = True
|
||||||
@ -115,13 +134,40 @@ class TheIndependentNew(BasicNewsRecipe):
|
|||||||
subtitle.extract()
|
subtitle.extract()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#replace rating numbers with stars
|
||||||
|
for item in soup.findAll('div',attrs={ 'class' : 'starRating'}):
|
||||||
|
if item is not None:
|
||||||
|
soup2 = self._insertRatingStars(soup,item)
|
||||||
|
if soup2 is not None:
|
||||||
|
soup = soup2
|
||||||
|
|
||||||
|
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def _insertRatingStars(self,soup,item):
|
||||||
|
if item.contents is None:
|
||||||
|
return
|
||||||
|
rating = item.contents[0]
|
||||||
|
if not rating.isdigit():
|
||||||
|
return None
|
||||||
|
rating = int(item.contents[0])
|
||||||
|
for i in range(1,6):
|
||||||
|
star = Tag(soup,'img')
|
||||||
|
if i <= rating:
|
||||||
|
star['src'] = self._STAR_URL
|
||||||
|
else:
|
||||||
|
star['src'] = self._NO_STAR_URL
|
||||||
|
star['alt'] = 'star number ' + str(i)
|
||||||
|
item.insert(i,star)
|
||||||
|
#item.contents[0] = NavigableString('(' + str(rating) + ')')
|
||||||
|
item.contents[0] = ''
|
||||||
|
|
||||||
def postprocess_html(self,soup, first_fetch):
|
def postprocess_html(self,soup, first_fetch):
|
||||||
#find broken images and remove captions
|
#find broken images and remove captions
|
||||||
for item in soup.findAll('div', attrs={'class' : 'byline'}):
|
for item in soup.findAll('div', attrs={'class' : 'image'}):
|
||||||
img = item.findNext('img')
|
img = item.findNext('img')
|
||||||
if img is not None and img['src'] is not None:
|
if img is not None and img['src'] is not None:
|
||||||
# broken images still point to remote url
|
# broken images still point to remote url
|
||||||
|
@ -66,4 +66,6 @@ Various things that require other things before they can be migrated:
|
|||||||
functionality.
|
functionality.
|
||||||
2. Catching DatabaseException and sqlite.Error when creating new
|
2. Catching DatabaseException and sqlite.Error when creating new
|
||||||
libraries/switching/on calibre startup.
|
libraries/switching/on calibre startup.
|
||||||
|
3. From refresh in the legacy interface: Rember to flush the composite
|
||||||
|
column template cache.
|
||||||
'''
|
'''
|
||||||
|
@ -48,6 +48,7 @@ class Cache(object):
|
|||||||
self.read_lock, self.write_lock = create_locks()
|
self.read_lock, self.write_lock = create_locks()
|
||||||
self.record_lock = RecordLock(self.read_lock)
|
self.record_lock = RecordLock(self.read_lock)
|
||||||
self.format_metadata_cache = defaultdict(dict)
|
self.format_metadata_cache = defaultdict(dict)
|
||||||
|
self.formatter_template_cache = {}
|
||||||
|
|
||||||
# Implement locking for all simple read/write API methods
|
# Implement locking for all simple read/write API methods
|
||||||
# An unlocked version of the method is stored with the name starting
|
# An unlocked version of the method is stored with the name starting
|
||||||
@ -89,7 +90,7 @@ class Cache(object):
|
|||||||
return self.backend.format_abspath(book_id, fmt, name, path)
|
return self.backend.format_abspath(book_id, fmt, name, path)
|
||||||
|
|
||||||
def _get_metadata(self, book_id, get_user_categories=True): # {{{
|
def _get_metadata(self, book_id, get_user_categories=True): # {{{
|
||||||
mi = Metadata(None)
|
mi = Metadata(None, template_cache=self.formatter_template_cache)
|
||||||
author_ids = self._field_ids_for('authors', book_id)
|
author_ids = self._field_ids_for('authors', book_id)
|
||||||
aut_list = [self._author_data(i) for i in author_ids]
|
aut_list = [self._author_data(i) for i in author_ids]
|
||||||
aum = []
|
aum = []
|
||||||
|
@ -233,7 +233,7 @@ class TREKSTOR(USBMS):
|
|||||||
|
|
||||||
VENDOR_NAME = 'TREKSTOR'
|
VENDOR_NAME = 'TREKSTOR'
|
||||||
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['EBOOK_PLAYER_7',
|
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['EBOOK_PLAYER_7',
|
||||||
'EBOOK_PLAYER_5M']
|
'EBOOK_PLAYER_5M', 'EBOOK-READER_3.0']
|
||||||
|
|
||||||
class EEEREADER(USBMS):
|
class EEEREADER(USBMS):
|
||||||
|
|
||||||
|
@ -173,6 +173,8 @@ def get_components(template, mi, id, timefmt='%b %Y', length=250,
|
|||||||
tsorder = tweaks['save_template_title_series_sorting']
|
tsorder = tweaks['save_template_title_series_sorting']
|
||||||
format_args = FORMAT_ARGS.copy()
|
format_args = FORMAT_ARGS.copy()
|
||||||
format_args.update(mi.all_non_none_fields())
|
format_args.update(mi.all_non_none_fields())
|
||||||
|
if mi.is_null('author_sort'):
|
||||||
|
format_args['author_sort'] = _('Unknown')
|
||||||
if mi.title:
|
if mi.title:
|
||||||
if tsorder == 'strictly_alphabetic':
|
if tsorder == 'strictly_alphabetic':
|
||||||
v = mi.title
|
v = mi.title
|
||||||
|
Loading…
x
Reference in New Issue
Block a user