mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add recipe for The BBC
This commit is contained in:
parent
e799f2c76f
commit
9e23a43f15
@ -18,15 +18,15 @@
|
||||
Builtin recipes.
|
||||
'''
|
||||
recipes = ['newsweek', 'atlantic', 'economist', 'dilbert', 'portfolio',
|
||||
'nytimes', 'usatoday', 'outlook_india']
|
||||
'nytimes', 'usatoday', 'outlook_india', 'bbc']
|
||||
|
||||
import re, time
|
||||
from libprs500.web.feeds.news import BasicNewsRecipe, CustomIndexRecipe
|
||||
from libprs500.web.feeds.news import BasicNewsRecipe, CustomIndexRecipe, AutomaticNewsRecipe
|
||||
from libprs500.ebooks.lrf.web.profiles import DefaultProfile, FullContentProfile
|
||||
from libprs500.ebooks.lrf.web import builtin_profiles
|
||||
from libprs500.ebooks.BeautifulSoup import BeautifulSoup
|
||||
|
||||
basic_recipes = (BasicNewsRecipe, CustomIndexRecipe, DefaultProfile, FullContentProfile)
|
||||
basic_recipes = (BasicNewsRecipe, AutomaticNewsRecipe, CustomIndexRecipe, DefaultProfile, FullContentProfile)
|
||||
basic_recipe_names = (i.__name__ for i in basic_recipes)
|
||||
|
||||
|
||||
@ -87,4 +87,22 @@ def get_builtin_recipe(title):
|
||||
|
||||
_titles = list(frozenset([r.title for r in recipes] + [p.title for p in builtin_profiles]))
|
||||
_titles.sort()
|
||||
titles = _titles
|
||||
titles = _titles
|
||||
|
||||
def migrate_automatic_profile_to_automatic_recipe(profile):
|
||||
profile = compile_recipe(profile)
|
||||
if 'BasicUserProfile' not in profile.__name__:
|
||||
return profile
|
||||
return '''\
|
||||
class BasicUserRecipe%d(AutomaticNewsRecipe):
|
||||
|
||||
title = %s
|
||||
oldest_article = %d
|
||||
max_articles_per_feed = %d
|
||||
summary_length = %d
|
||||
|
||||
feeds = %s
|
||||
|
||||
'''%(int(time.time()), repr(profile.title), profile.oldest_article,
|
||||
profile.max_articles_per_feed, profile.summary_length, repr(profile.feeds))
|
||||
|
47
src/libprs500/web/feeds/recipes/bbc.py
Normal file
47
src/libprs500/web/feeds/recipes/bbc.py
Normal file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
## Copyright (C) 2008 Kovid Goyal kovid@kovidgoyal.net
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along
|
||||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
'''
|
||||
bbc.co.uk
|
||||
'''
|
||||
|
||||
from libprs500.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class BBC(BasicNewsRecipe):
|
||||
title = u'The BBC'
|
||||
no_stylesheets = True
|
||||
|
||||
remove_tags = [dict(name='div', attrs={'class':'footer'})]
|
||||
extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }'
|
||||
|
||||
feeds = [
|
||||
('News Front Page', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'),
|
||||
('Science/Nature', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/science/nature/rss.xml'),
|
||||
('Technology', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/technology/rss.xml'),
|
||||
('Enterntainment', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/entertainment/rss.xml'),
|
||||
('Magazine', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/uk_news/magazine/rss.xml'),
|
||||
('Business', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/business/rss.xml'),
|
||||
('Health', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/health/rss.xml'),
|
||||
('Americas', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss.xml'),
|
||||
('Europe', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/europe/rss.xml'),
|
||||
('South Asia', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/south_asia/rss.xml'),
|
||||
('UK', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/uk_news/rss.xml'),
|
||||
('Asia-Pacific', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/asia-pacific/rss.xml'),
|
||||
('Africa', 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/africa/rss.xml'),
|
||||
]
|
||||
|
||||
def print_version(self, url):
|
||||
return url.replace('http://', 'http://newsvote.bbc.co.uk/mpapps/pagetools/print/')
|
Loading…
x
Reference in New Issue
Block a user