mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add recipe for the FInancial Times (tanks to Darko Miletic)
This commit is contained in:
parent
ada2c73837
commit
26a1562d48
@ -34,6 +34,9 @@ class Recipe(object):
|
||||
self.downloading = False
|
||||
self.builtin = builtin
|
||||
self.schedule = None
|
||||
self.author = getattr(recipe_class, '__author__', _('Unknown'))
|
||||
if self.author == _('Unknown') and not builtin:
|
||||
self.author = _('You')
|
||||
self.needs_subscription = getattr(recipe_class, 'needs_subscription', False)
|
||||
|
||||
def pickle(self):
|
||||
@ -269,6 +272,7 @@ class SchedulerDialog(QDialog, Ui_Dialog):
|
||||
recipe = self._model.data(index, Qt.UserRole)
|
||||
self.current_recipe = recipe
|
||||
self.title.setText(recipe.title)
|
||||
self.author.setText(_('Created by: ') + recipe.author)
|
||||
self.description.setText(recipe.description if recipe.description else '')
|
||||
self.schedule.setChecked(recipe.schedule is not None)
|
||||
self.interval.setValue(recipe.schedule if recipe.schedule is not None else 1)
|
||||
|
@ -80,6 +80,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="author" >
|
||||
<property name="text" >
|
||||
<string>author</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2" >
|
||||
<property name="orientation" >
|
||||
|
@ -16,7 +16,7 @@ recipe_modules = [
|
||||
'jpost', 'jutarnji', 'nasa', 'reuters', 'spiegelde', 'wash_post', 'zeitde',
|
||||
'blic', 'novosti', 'danas', 'vreme', 'times_online', 'the_scotsman',
|
||||
'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times',
|
||||
'clarin',
|
||||
'clarin', 'financial_times'
|
||||
]
|
||||
|
||||
import re, imp, inspect, time, os
|
||||
|
51
src/calibre/web/feeds/recipes/financial_times.py
Normal file
51
src/calibre/web/feeds/recipes/financial_times.py
Normal file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
ft.com
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class FinancialTimes(BasicNewsRecipe):
|
||||
title = u'Financial Times'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = 'Financial world news'
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
needs_subscription = True
|
||||
simultaneous_downloads= 1
|
||||
delay = 1
|
||||
LOGIN = 'https://registration.ft.com/registration/barrier/login'
|
||||
|
||||
def get_browser(self):
|
||||
br = BasicNewsRecipe.get_browser()
|
||||
if self.username is not None and self.password is not None:
|
||||
br.open(self.LOGIN)
|
||||
br.select_form(name='loginForm')
|
||||
br['username'] = self.username
|
||||
br['password'] = self.password
|
||||
br.submit()
|
||||
return br
|
||||
|
||||
keep_only_tags = [ dict(name='div', attrs={'id':'cont'}) ]
|
||||
remove_tags_after = dict(name='p', attrs={'class':'copyright'})
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'id':'floating-con'})
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'UK' , u'http://www.ft.com/rss/home/uk' )
|
||||
,(u'US' , u'http://www.ft.com/rss/home/us' )
|
||||
,(u'Asia' , u'http://www.ft.com/rss/home/asia' )
|
||||
,(u'Middle East', u'http://www.ft.com/rss/home/middleeast')
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
content_type = soup.find('meta', {'http-equiv':'Content-Type'})
|
||||
if content_type:
|
||||
content_type['content'] = 'text/html; charset=utf-8'
|
||||
return soup
|
Loading…
x
Reference in New Issue
Block a user