mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
New recipes for New Scientist, B92 and Politika (thanks to Darko Miletic). Fix #1254 (Searching using the content server doesn't reset the start item to 1)
This commit is contained in:
parent
f8e1895196
commit
96d3777d40
@ -78,8 +78,9 @@ STANZA_TEMPLATE='''\
|
|||||||
<id>urn:calibre:${record['id']}</id>
|
<id>urn:calibre:${record['id']}</id>
|
||||||
<author><name>${record['authors']}</name></author>
|
<author><name>${record['authors']}</name></author>
|
||||||
<updated>${record['timestamp'].strftime('%Y-%m-%dT%H:%M:%SZ')}</updated>
|
<updated>${record['timestamp'].strftime('%Y-%m-%dT%H:%M:%SZ')}</updated>
|
||||||
<link type="application/epub+zip" href="${quote(record['fmt_epub'].replace(sep, '/'))}" />
|
<link type="application/epub+zip" href="${quote(record['fmt_epub'].replace(sep, '/')).replace('http%3A', 'http:')}" />
|
||||||
<link py:if="record['cover']" rel="x-stanza-cover-image" type="image/png" href="${quote(record['cover'].replace(sep, '/'))}" />
|
<link py:if="record['cover']" rel="x-stanza-cover-image" type="image/png" href="${quote(record['cover'].replace(sep, '/')).replace('http%3A', 'http:')}" />
|
||||||
|
<link py:if="record['cover']" rel="x-stanza-cover-image-thumbnail" type="image/png" href="${quote(record['cover'].replace(sep, '/')).replace('http%3A', 'http:')}" />
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml"><pre>${record['comments']}</pre></div>
|
<div xmlns="http://www.w3.org/1999/xhtml"><pre>${record['comments']}</pre></div>
|
||||||
</content>
|
</content>
|
||||||
|
@ -72,15 +72,15 @@ class LibraryServer(object):
|
|||||||
|
|
||||||
STANZA_ENTRY=MarkupTemplate(textwrap.dedent('''\
|
STANZA_ENTRY=MarkupTemplate(textwrap.dedent('''\
|
||||||
<entry xmlns:py="http://genshi.edgewall.org/">
|
<entry xmlns:py="http://genshi.edgewall.org/">
|
||||||
<title>${record['title']}</title>
|
<title>${record[FM['title']]}</title>
|
||||||
<id>urn:calibre:${record['id']}</id>
|
<id>urn:calibre:${record[FM['id']]}</id>
|
||||||
<author><name>${authors}</name></author>
|
<author><name>${authors}</name></author>
|
||||||
<updated>${record['timestamp'].strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
<updated>${record[FM['timestamp']].strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
||||||
<link type="application/epub+zip" href="http://${server}:${port}/get/epub/${record['id']}" />
|
<link type="application/epub+zip" href="http://${server}:${port}/get/epub/${record[FM['id']]}" />
|
||||||
<link rel="x-stanza-cover-image" type="image/jpeg" href="http://${server}:${port}/get/cover/${record['id']}" />
|
<link rel="x-stanza-cover-image" type="image/jpeg" href="http://${server}:${port}/get/cover/${record[FM['id']]}" />
|
||||||
<link rel="x-stanza-cover-image-thumbnail" type="image/jpeg" href="http://${server}:${port}/get/thumb/${record['id']}" />
|
<link rel="x-stanza-cover-image-thumbnail" type="image/jpeg" href="http://${server}:${port}/get/thumb/${record[FM['id']]}" />
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml"><pre>${record['comments']}</pre></div>
|
<div xmlns="http://www.w3.org/1999/xhtml">${record[FM['comments']]}</div>
|
||||||
</content>
|
</content>
|
||||||
</entry>
|
</entry>
|
||||||
'''))
|
'''))
|
||||||
@ -245,7 +245,7 @@ class LibraryServer(object):
|
|||||||
if 'EPUB' in record[FIELD_MAP['formats']].upper():
|
if 'EPUB' in record[FIELD_MAP['formats']].upper():
|
||||||
authors = ' & '.join([i.replace('|', ',') for i in record[2].split(',')])
|
authors = ' & '.join([i.replace('|', ',') for i in record[2].split(',')])
|
||||||
books.append(self.STANZA_ENTRY.generate(authors=authors,
|
books.append(self.STANZA_ENTRY.generate(authors=authors,
|
||||||
record=record,
|
record=record, FM=FIELD_MAP,
|
||||||
port=self.opts.port,
|
port=self.opts.port,
|
||||||
server=self.opts.hostname,
|
server=self.opts.hostname,
|
||||||
).render('xml').decode('utf8'))
|
).render('xml').decode('utf8'))
|
||||||
@ -254,7 +254,7 @@ class LibraryServer(object):
|
|||||||
cherrypy.response.headers['Last-Modified'] = self.last_modified(updated)
|
cherrypy.response.headers['Last-Modified'] = self.last_modified(updated)
|
||||||
cherrypy.response.headers['Content-Type'] = 'text/xml'
|
cherrypy.response.headers['Content-Type'] = 'text/xml'
|
||||||
|
|
||||||
return self.STANZA.generate(subtitle='', data=books,
|
return self.STANZA.generate(subtitle='', data=books, FM=FIELD_MAP,
|
||||||
updated=updated, id='urn:calibre:main').render('xml')
|
updated=updated, id='urn:calibre:main').render('xml')
|
||||||
|
|
||||||
@expose
|
@expose
|
||||||
@ -359,7 +359,7 @@ def main(args=sys.argv):
|
|||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
cherrypy.log.screen = True
|
cherrypy.log.screen = True
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
db = LibraryDatabase2(prefs['library_path'], row_factory=True)
|
db = LibraryDatabase2(prefs['library_path'])
|
||||||
server = LibraryServer(db, opts)
|
server = LibraryServer(db, opts)
|
||||||
server.start()
|
server.start()
|
||||||
return 0
|
return 0
|
||||||
|
@ -13,7 +13,7 @@ Search bar
|
|||||||
#search_box {
|
#search_box {
|
||||||
width: 201px;
|
width: 201px;
|
||||||
height: 31px;
|
height: 31px;
|
||||||
background: url(/static/bg_search_box.png);
|
background: url(bg_search_box.png);
|
||||||
top: 5px; right: 20px;
|
top: 5px; right: 20px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ function setup_count_bar() {
|
|||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
var search = $.trim($('#search_box * #s').val());
|
var search = $.trim($('#search_box * #s').val());
|
||||||
fetch_library_books(last_start, last_num, LIBRARY_FETCH_TIMEOUT,
|
fetch_library_books(0, last_num, LIBRARY_FETCH_TIMEOUT,
|
||||||
last_sort, last_sort_order, search);
|
last_sort, last_sort_order, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ recipes = [
|
|||||||
'wired', 'globe_and_mail', 'smh', 'espn', 'business_week',
|
'wired', 'globe_and_mail', 'smh', 'espn', 'business_week',
|
||||||
'ars_technica', 'upi', 'new_yorker', 'irish_times', 'iht',
|
'ars_technica', 'upi', 'new_yorker', 'irish_times', 'iht',
|
||||||
'discover_magazine', 'scientific_american', 'new_york_review_of_books',
|
'discover_magazine', 'scientific_american', 'new_york_review_of_books',
|
||||||
'daily_telegraph', 'guardian', 'el_pais',
|
'daily_telegraph', 'guardian', 'el_pais', 'new_scientist', 'b92', 'politika'
|
||||||
]
|
]
|
||||||
|
|
||||||
import re, imp, inspect, time, os
|
import re, imp, inspect, time, os
|
||||||
|
38
src/calibre/web/feeds/recipes/b92.py
Normal file
38
src/calibre/web/feeds/recipes/b92.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
b92.net
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class B92(BasicNewsRecipe):
|
||||||
|
title = u'B92'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'Dnevne vesti iz Srbije i sveta'
|
||||||
|
oldest_article = 7
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = False
|
||||||
|
|
||||||
|
remove_tags_after = dict(name='div', attrs={'class':'gas'})
|
||||||
|
remove_tags = [
|
||||||
|
dict(name='div' , attrs={'class':'interaction clearfix' })
|
||||||
|
,dict(name='div' , attrs={'class':'gas' })
|
||||||
|
,dict(name='ul' , attrs={'class':'comment-nav' })
|
||||||
|
,dict(name='table', attrs={'class':'pages-navigation-form'})
|
||||||
|
]
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
(u'Vesti' , u'http://www.b92.net/info/rss/vesti.xml' )
|
||||||
|
,(u'Kultura' , u'http://www.b92.net/info/rss/kultura.xml' )
|
||||||
|
,(u'Automobili', u'http://www.b92.net/info/rss/automobili.xml')
|
||||||
|
,(u'Zivot' , u'http://www.b92.net/info/rss/zivot.xml' )
|
||||||
|
,(u'Tehnopolis', u'http://www.b92.net/info/rss/tehnopolis.xml')
|
||||||
|
,(u'Biz' , u'http://www.b92.net/info/rss/biz.xml' )
|
||||||
|
]
|
||||||
|
|
||||||
|
def print_version(self, url):
|
||||||
|
return url + '&version=print'
|
36
src/calibre/web/feeds/recipes/new_scientist.py
Normal file
36
src/calibre/web/feeds/recipes/new_scientist.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
newscientist.com
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class NewScientist(BasicNewsRecipe):
|
||||||
|
title = u'New Scientist'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'Science news'
|
||||||
|
oldest_article = 7
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = False
|
||||||
|
|
||||||
|
keep_only_tags = [
|
||||||
|
dict(name='div' , attrs={'id':'pgtop' })
|
||||||
|
,dict(name='div' , attrs={'id':'maincol' })
|
||||||
|
]
|
||||||
|
remove_tags = [
|
||||||
|
dict(name='div' , attrs={'class':'hldBd' })
|
||||||
|
,dict(name='div' , attrs={'id':'compnl' })
|
||||||
|
,dict(name='div' , attrs={'id':'artIssueInfo' })
|
||||||
|
]
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
(u'Latest Headlines' , u'http://feeds.newscientist.com/science-news' )
|
||||||
|
,(u'Magazine' , u'http://www.newscientist.com/feed/magazine' )
|
||||||
|
,(u'Health' , u'http://www.newscientist.com/feed/view?id=2&type=channel' )
|
||||||
|
,(u'Life' , u'http://www.newscientist.com/feed/view?id=3&type=channel' )
|
||||||
|
,(u'Space' , u'http://www.newscientist.com/feed/view?id=6&type=channel' )
|
||||||
|
]
|
33
src/calibre/web/feeds/recipes/politika.py
Normal file
33
src/calibre/web/feeds/recipes/politika.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
politika.rs
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class Politika(BasicNewsRecipe):
|
||||||
|
title = u'Politika Online'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'Najstariji dnevni list na Balkanu'
|
||||||
|
oldest_article = 7
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
extra_css = '.content_center_border {text-align: left;}'
|
||||||
|
use_embedded_content = False
|
||||||
|
|
||||||
|
remove_tags_before = dict(name='div', attrs={'class':'content_center_border'})
|
||||||
|
remove_tags_after = dict(name='div', attrs={'class':'datum_item_details'})
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
(u'Politika' , u'http://www.politika.rs/rubrike/Politika/index.1.lt.xml' )
|
||||||
|
,(u'Svet' , u'http://www.politika.rs/rubrike/Svet/index.1.lt.xml' )
|
||||||
|
,(u'Redakcijski komentari', u'http://www.politika.rs/rubrike/redakcijski-komentari/index.1.lt.xml')
|
||||||
|
,(u'Pogledi' , u'http://www.politika.rs/pogledi/index.lt.xml' )
|
||||||
|
,(u'Pogledi sa strane' , u'http://www.politika.rs/rubrike/Pogledi-sa-strane/index.1.lt.xml' )
|
||||||
|
,(u'Tema dana' , u'http://www.politika.rs/rubrike/tema-dana/index.1.lt.xml' )
|
||||||
|
,(u'Kultura' , u'http://www.politika.rs/rubrike/Kultura/index.1.lt.xml' )
|
||||||
|
,(u'Zivot i stil' , u'http://www.politika.rs/rubrike/zivot-i-stil/index.1.lt.xml' )
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user