mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-01 12:13:11 +02:00
Sync to trunk.
This commit is contained in:
commit
adb0b90554
25 changed files with 252 additions and 21 deletions
BIN
recipes/icons/prostamerika.png
Normal file
BIN
recipes/icons/prostamerika.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 561 B |
BIN
recipes/icons/sb_nation.png
Normal file
BIN
recipes/icons/sb_nation.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
BIN
recipes/icons/wvhooligan.png
Normal file
BIN
recipes/icons/wvhooligan.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
68
recipes/prostamerika.recipe
Normal file
68
recipes/prostamerika.recipe
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = 'zotzo'
|
||||
|
||||
"""
|
||||
http://www.prostamerika.com/
|
||||
"""
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
|
||||
class ProstAmerika(BasicNewsRecipe):
|
||||
title = 'Prost Amerika'
|
||||
language = 'en'
|
||||
__author__ = 'rylsfan'
|
||||
#authors =
|
||||
description = 'Seattle soccer with a European accent. News, features, and match reports.'
|
||||
publisher = 'ProstAmerika' # 4464 fremont avenue n, # 209, Seattle, 98103, United States
|
||||
category = 'Sports'
|
||||
|
||||
oldest_article = 7
|
||||
max_articles_per_feed = 100
|
||||
|
||||
cover_url = 'http://img17.imageshack.us/img17/9498/prostamerika.jpg'
|
||||
masthead_url = 'http://www.prostamerika.com/soundersfc/wp-content/uploads/2011/02/PASoccer_taglinewhole.jpg'
|
||||
|
||||
encoding = 'utf-8'
|
||||
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
remove_javascript = True
|
||||
|
||||
feeds =[
|
||||
(u'Cascadia', u'http://www.prostamerika.com/category/localfootball/feed/' ),
|
||||
(u'MLS', u'http://www.prostamerika.com/category/mls/feed/'),
|
||||
(u'EPL', u'http://www.prostamerika.com/category/epl/feed/'),
|
||||
(u'World', u'http://www.prostamerika.com/category/international-soccer/feed/'),
|
||||
(u'Fan Culture',u'http://www.prostamerika.com/category/fan-culture/feed/')
|
||||
|
||||
]
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'id':'maincontent'})]
|
||||
remove_tags = [
|
||||
{'class':'tweetmeme_button'},
|
||||
{'class':'wp-caption-text'}
|
||||
]
|
||||
|
||||
|
||||
remove_tags_after =[
|
||||
{'class':'tweetmeme_button'}
|
||||
]
|
||||
|
||||
extra_css = '''
|
||||
h1{font-family:Didot,Helvetica,sans-serif; font-weight:bold;font-size:large;}
|
||||
h2{font-family:Arial,Helvetica,sans-serif; font-weight:normal;font-size:small;}
|
||||
p{font-family:Arial,Helvetica,sans-serif;font-size:small;}
|
||||
body{font-family:Helvetica,Arial,sans-serif;font-size:small;}
|
||||
'''
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
return self.adeify_images(soup)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
56
recipes/sb_nation.recipe
Normal file
56
recipes/sb_nation.recipe
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = 'Zotzo'
|
||||
'''
|
||||
http://www.stumptownfooty.com/
|
||||
http://www.eightysixforever.com
|
||||
http://www.sounderatheart.com
|
||||
http://www.dailysoccerfix.com/
|
||||
|
||||
'''
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class SBNation(BasicNewsRecipe):
|
||||
title = u'SBNation'
|
||||
__author__ = 'rylsfan'
|
||||
description = u"More than 290 individual communities, each offering high quality year-round coverage and conversation led by fans who are passionate."
|
||||
oldest_article = 3
|
||||
language = 'en'
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
|
||||
#cover_url = 'http://img132.imageshack.us/img132/4913/2hyggjegqqdywzn9.png'
|
||||
|
||||
keep_only_tags = [
|
||||
dict(name='h2', attrs={'class':'title'})
|
||||
,dict(name='div', attrs={'class':'entry-body'})
|
||||
]
|
||||
|
||||
remove_tags_after = dict(name='div', attrs={'class':'footline entry-actions'})
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'class':'footline entry-actions'}),
|
||||
{'class': 'extend-divide'}
|
||||
]
|
||||
# SBNation has 300 special blogs to choose from. These are just a couple!
|
||||
feeds = [
|
||||
(u'Daily Fix', u'http://www.dailysoccerfix.com/rss/'),
|
||||
(u"Stumptown Footy", u'http://www.stumptownfooty.com/rss/'),
|
||||
(u'Sounders', u'http://www.sounderatheart.com/rss/'),
|
||||
(u'Whitecaps', u'http://www.eightysixforever.com/rss/'),
|
||||
]
|
||||
|
||||
extra_css = """
|
||||
h1{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;}
|
||||
h2{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;}
|
||||
p{font-family:Helvetica,sans-serif; display: block; text-align: left; text-decoration: none; text-indent: 0%;}
|
||||
body{font-family:Helvetica,Arial,sans-serif;font-size:small;}
|
||||
"""
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
return self.adeify_images(soup)
|
||||
|
||||
def populate_article_metadata(self, article, soup, first):
|
||||
h2 = soup.find('h2')
|
||||
h2.replaceWith(h2.prettify() + '<p><em> By ' + article.author + '</em></p>')
|
||||
61
recipes/wvhooligan.recipe
Normal file
61
recipes/wvhooligan.recipe
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = 'zotzo'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
'''
|
||||
http://wvhooligan.com/
|
||||
'''
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
#import re
|
||||
|
||||
class wvHooligan(BasicNewsRecipe):
|
||||
authors = u'Drew Epperley'
|
||||
__author__ = 'rylsfan'
|
||||
language = 'en'
|
||||
version = 2
|
||||
|
||||
title = u'WV Hooligan'
|
||||
publisher = u'Drew Epperley'
|
||||
publication_type = 'Blog'
|
||||
category = u'Soccer'
|
||||
description = u'A look at Major League Soccer (MLS) through the eyes of a MLS writer and fan.'
|
||||
|
||||
cover_url = 'http://wvhooligan.com/wp-content/themes/urbanelements/images/logo3.png'
|
||||
|
||||
oldest_article = 15
|
||||
max_articles_per_feed = 150
|
||||
use_embedded_content = True
|
||||
no_stylesheets = True
|
||||
remove_javascript = True
|
||||
encoding = 'utf8'
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
, 'tags' : category
|
||||
, 'publisher' : publisher
|
||||
, 'language' : language
|
||||
}
|
||||
|
||||
remove_tags = [
|
||||
{'class': 'feedflare'},
|
||||
{'class': 'tweetmeme_button'},
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
return self.adeify_images(soup)
|
||||
|
||||
feeds =[
|
||||
(u'Stories', u'http://feeds2.feedburner.com/wvhooligan'),
|
||||
(u'MLS', u'http://wvhooligan.com/category/mls/feed/'),
|
||||
(u'MLS Power Rankings', u'http://wvhooligan.com/category/power-rankings/feed/'),
|
||||
(u'MLS Expansion', u'http://wvhooligan.com/category/mls/expansion-talk/feed/'),
|
||||
(u'US National Team', u'http://wvhooligan.com/category/us-national-team/feed/'),
|
||||
(u'College', u'http://wvhooligan.com/category/college-soccer/feed/'),
|
||||
]
|
||||
|
||||
extra_css = '''
|
||||
h1{font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:large;}
|
||||
h2{font-family:Arial,Helvetica,sans-serif; font-weight:normal;font-size:small;}
|
||||
p{font-family:Arial,Helvetica,sans-serif;font-size:small;}
|
||||
body{font-family:Helvetica,Arial,sans-serif;font-size:small;}
|
||||
'''
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import ctypes, uuid, hashlib, os, sys
|
||||
from threading import Event, Lock
|
||||
from calibre.constants import iswindows, islinux, isosx
|
||||
from calibre.constants import iswindows
|
||||
from calibre import load_library
|
||||
|
||||
try:
|
||||
|
|
@ -29,12 +29,9 @@
|
|||
except:
|
||||
lib_handle = None
|
||||
|
||||
text_encoding = 'utf-8'
|
||||
if iswindows:
|
||||
text_encoding = 'mbcs'
|
||||
elif islinux:
|
||||
text_encoding = 'utf-8'
|
||||
elif isosx:
|
||||
text_encoding = 'utf-8'
|
||||
|
||||
def is_bambook_lib_ready():
|
||||
return lib_handle != None
|
||||
|
|
|
|||
|
|
@ -483,7 +483,6 @@ def download_cover(self, log, result_queue, abort, # {{{
|
|||
log.exception('Failed to download cover from:', cached_url)
|
||||
# }}}
|
||||
|
||||
|
||||
if __name__ == '__main__': # tests {{{
|
||||
# To run these test use: calibre-debug -e
|
||||
# src/calibre/ebooks/metadata/sources/amazon.py
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ def is_worker_alive(workers):
|
|||
return False
|
||||
|
||||
def identify(log, abort, title=None, authors=None, identifiers=[], timeout=30):
|
||||
start_time = time.time()
|
||||
plugins = list(metadata_plugins['identify'])
|
||||
|
||||
kwargs = {
|
||||
|
|
@ -105,3 +106,21 @@ def get_results():
|
|||
log(plog)
|
||||
log('\n'+'*'*80)
|
||||
|
||||
for i, result in enumerate(results):
|
||||
result.relevance_in_source = i
|
||||
result.has_cached_cover_url = \
|
||||
plugin.get_cached_cover_url(result.identifiers) is not None
|
||||
result.identify_plugin = plugin
|
||||
|
||||
log('The identify phase took %.2f seconds'%(time.time() - start_time))
|
||||
log('Merging results from different sources and finding earliest',
|
||||
'publication dates')
|
||||
start_time = time.time()
|
||||
merged_results = merge_identify_results(results, log)
|
||||
log('We have %d merged results, merging took: %.2f seconds' %
|
||||
(len(merged_results), time.time() - start_time))
|
||||
|
||||
def merge_identify_results(result_map, log):
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ def get_associated_isbns(self, isbn):
|
|||
xisbn = xISBN()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
import sys, pprint
|
||||
isbn = sys.argv[-1]
|
||||
print xisbn.get_data(isbn)
|
||||
print pprint.pprint(xisbn.get_data(isbn))
|
||||
print
|
||||
print xisbn.get_associated_isbns(isbn)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import gc
|
||||
|
||||
from PyQt4.Qt import Qt
|
||||
|
||||
from calibre.gui2 import Dispatcher
|
||||
|
|
@ -53,11 +55,11 @@ def download_scheduled_recipe(self, arg):
|
|||
|
||||
def scheduled_recipe_fetched(self, job):
|
||||
temp_files, fmt, arg = self.conversion_jobs.pop(job)
|
||||
pt = temp_files[0]
|
||||
fname = temp_files[0].name
|
||||
if job.failed:
|
||||
self.scheduler.recipe_download_failed(arg)
|
||||
return self.gui.job_exception(job)
|
||||
id = self.gui.library_view.model().add_news(pt.name, arg)
|
||||
id = self.gui.library_view.model().add_news(fname, arg)
|
||||
|
||||
# Arg may contain a "keep_issues" variable. If it is non-zero,
|
||||
# delete all but newest x issues.
|
||||
|
|
@ -81,5 +83,6 @@ def scheduled_recipe_fetched(self, job):
|
|||
self.gui.status_bar.show_message(arg['title'] + _(' fetched.'), 3000)
|
||||
self.gui.email_news(id)
|
||||
self.gui.sync_news()
|
||||
gc.collect()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -171,10 +171,11 @@ def do_config(self, parent=None):
|
|||
self.misc_config()
|
||||
self.after_load()
|
||||
|
||||
def __init__(self, shortcuts, parent=None):
|
||||
def __init__(self, shortcuts, parent=None, resize_callback=lambda: None):
|
||||
QWebPage.__init__(self, parent)
|
||||
self.setObjectName("py_bridge")
|
||||
self.debug_javascript = False
|
||||
self.resize_callback = resize_callback
|
||||
self.current_language = None
|
||||
self.loaded_javascript = False
|
||||
|
||||
|
|
@ -237,6 +238,12 @@ def load_javascript_libraries(self):
|
|||
if self.loaded_javascript:
|
||||
return
|
||||
self.loaded_javascript = True
|
||||
self.javascript(
|
||||
'''
|
||||
window.onresize = function(event) {
|
||||
window.py_bridge.window_resized();
|
||||
}
|
||||
''')
|
||||
if jquery is None:
|
||||
jquery = P('content_server/jquery.js', data=True)
|
||||
self.javascript(jquery)
|
||||
|
|
@ -298,6 +305,10 @@ def after_load(self):
|
|||
def debug(self, msg):
|
||||
prints(msg)
|
||||
|
||||
@pyqtSignature('')
|
||||
def window_resized(self):
|
||||
self.resize_callback()
|
||||
|
||||
def reference_mode(self, enable):
|
||||
self.javascript(('enter' if enable else 'leave')+'_reference_mode()')
|
||||
|
||||
|
|
@ -424,12 +435,19 @@ def window_width(self):
|
|||
def xpos(self):
|
||||
return self.mainFrame().scrollPosition().x()
|
||||
|
||||
@property
|
||||
@dynamic_property
|
||||
def scroll_fraction(self):
|
||||
try:
|
||||
return float(self.ypos)/(self.height-self.window_height)
|
||||
except ZeroDivisionError:
|
||||
return 0.
|
||||
def fget(self):
|
||||
try:
|
||||
return float(self.ypos)/(self.height-self.window_height)
|
||||
except ZeroDivisionError:
|
||||
return 0.
|
||||
def fset(self, val):
|
||||
npos = val * (self.height - self.window_height)
|
||||
if npos < 0:
|
||||
npos = 0
|
||||
self.scroll_to(x=self.xpos, y=npos)
|
||||
return property(fget=fget, fset=fset)
|
||||
|
||||
@property
|
||||
def hscroll_fraction(self):
|
||||
|
|
@ -493,7 +511,8 @@ def __init__(self, *args):
|
|||
self._size_hint = QSize(510, 680)
|
||||
self.initial_pos = 0.0
|
||||
self.to_bottom = False
|
||||
self.document = Document(self.shortcuts, parent=self)
|
||||
self.document = Document(self.shortcuts, parent=self,
|
||||
resize_callback=self.viewport_resized)
|
||||
self.setPage(self.document)
|
||||
self.manager = None
|
||||
self._reference_mode = False
|
||||
|
|
@ -630,9 +649,13 @@ def link_clicked(self, url):
|
|||
def sizeHint(self):
|
||||
return self._size_hint
|
||||
|
||||
@property
|
||||
@dynamic_property
|
||||
def scroll_fraction(self):
|
||||
return self.document.scroll_fraction
|
||||
def fget(self):
|
||||
return self.document.scroll_fraction
|
||||
def fset(self, val):
|
||||
self.document.scroll_fraction = float(val)
|
||||
return property(fget=fget, fset=fset)
|
||||
|
||||
@property
|
||||
def hscroll_fraction(self):
|
||||
|
|
@ -968,9 +991,11 @@ def keyPressEvent(self, event):
|
|||
def resizeEvent(self, event):
|
||||
ret = QWebView.resizeEvent(self, event)
|
||||
QTimer.singleShot(10, self.initialize_scrollbar)
|
||||
return ret
|
||||
|
||||
def viewport_resized(self):
|
||||
if self.manager is not None:
|
||||
self.manager.viewport_resized(self.scroll_fraction)
|
||||
return ret
|
||||
|
||||
def event(self, ev):
|
||||
typ = ev.type()
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ def __init__(self, pathtoebook=None, debug_javascript=False):
|
|||
self.connect(self.action_reference_mode, SIGNAL('triggered(bool)'),
|
||||
lambda x: self.view.reference_mode(x))
|
||||
self.connect(self.action_metadata, SIGNAL('triggered(bool)'), lambda x:self.metadata.setVisible(x))
|
||||
self.connect(self.action_table_of_contents, SIGNAL('toggled(bool)'), lambda x:self.toc.setVisible(x))
|
||||
self.action_table_of_contents.toggled[bool].connect(self.set_toc_visible)
|
||||
self.connect(self.action_copy, SIGNAL('triggered(bool)'), self.copy)
|
||||
self.connect(self.action_font_size_larger, SIGNAL('triggered(bool)'),
|
||||
self.font_size_larger)
|
||||
|
|
@ -310,6 +310,9 @@ def __init__(self, pathtoebook=None, debug_javascript=False):
|
|||
|
||||
self.restore_state()
|
||||
|
||||
def set_toc_visible(self, yes):
|
||||
self.toc.setVisible(yes)
|
||||
|
||||
def clear_recent_history(self, *args):
|
||||
vprefs.set('viewer_open_history', [])
|
||||
self.build_recent_menu()
|
||||
|
|
|
|||
Loading…
Reference in a new issue