mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
KG changes
This commit is contained in:
commit
6060faa574
@ -15,14 +15,14 @@ class Pagina12(BasicNewsRecipe):
|
|||||||
publisher = 'La Pagina S.A.'
|
publisher = 'La Pagina S.A.'
|
||||||
category = 'news, politics, Argentina'
|
category = 'news, politics, Argentina'
|
||||||
oldest_article = 2
|
oldest_article = 2
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 200
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
encoding = 'cp1252'
|
encoding = 'cp1252'
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
language = 'es'
|
language = 'es'
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
masthead_url = 'http://www.pagina12.com.ar/commons/imgs/logo-home.gif'
|
masthead_url = 'http://www.pagina12.com.ar/commons/imgs/logo-home.gif'
|
||||||
extra_css = ' body{font-family: Arial,Helvetica,sans-serif } h2{color: #028CCD} img{margin-bottom: 0.4em} .epigrafe{font-size: x-small; background-color: #EBEAE5; color: #565144 } .intro{font-size: 1.1em} '
|
extra_css = ' body{font-family: Arial,Helvetica,sans-serif } img{margin-bottom: 0.4em} #autor{font-weight: bold} #fecha,#epigrafe{font-size: 0.9em; margin: 5px} #imagen{border: 1px solid black; margin: 0 0 1.25em 1.25em; width: 232px } '
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comment' : description
|
'comment' : description
|
||||||
@ -45,7 +45,9 @@ class Pagina12(BasicNewsRecipe):
|
|||||||
,(u'NO' , u'http://www.pagina12.com.ar/diario/rss/no.xml' )
|
,(u'NO' , u'http://www.pagina12.com.ar/diario/rss/no.xml' )
|
||||||
,(u'Las/12' , u'http://www.pagina12.com.ar/diario/rss/las12.xml' )
|
,(u'Las/12' , u'http://www.pagina12.com.ar/diario/rss/las12.xml' )
|
||||||
,(u'Soy' , u'http://www.pagina12.com.ar/diario/rss/soy.xml' )
|
,(u'Soy' , u'http://www.pagina12.com.ar/diario/rss/soy.xml' )
|
||||||
,(u'M2' , u'http://www.pagina12.com.ar/diario/rss/futuro.xml' )
|
,(u'Futuro' , u'http://www.pagina12.com.ar/diario/rss/futuro.xml' )
|
||||||
|
,(u'M2' , u'http://www.pagina12.com.ar/diario/rss/m2.xml' )
|
||||||
|
,(u'Rosario/12' , u'http://www.pagina12.com.ar/diario/rss/rosario.xml' )
|
||||||
]
|
]
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
@ -60,3 +62,7 @@ class Pagina12(BasicNewsRecipe):
|
|||||||
return image['src']
|
return image['src']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for item in soup.findAll(style=True):
|
||||||
|
del item['style']
|
||||||
|
return soup
|
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
www.variety.com
|
www.variety.com
|
||||||
'''
|
'''
|
||||||
@ -20,6 +18,8 @@ class Variety(BasicNewsRecipe):
|
|||||||
publisher = 'Red Business Information'
|
publisher = 'Red Business Information'
|
||||||
category = 'Entertainment Industry News, Daily Variety, Movie Reviews, TV, Awards, Oscars, Cannes, Box Office, Hollywood'
|
category = 'Entertainment Industry News, Daily Variety, Movie Reviews, TV, Awards, Oscars, Cannes, Box Office, Hollywood'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
masthead_url = 'http://a330.g.akamai.net/7/330/23382/20090528190853/www.variety.com/graphics/variety/Variety_logo_green_tm.gif'
|
||||||
|
extra_css = ' body{font-family: Georgia,"Times New Roman",Times,Courier,serif } img{margin-bottom: 1em} '
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comments' : description
|
'comments' : description
|
||||||
@ -41,6 +41,6 @@ class Variety(BasicNewsRecipe):
|
|||||||
catid = catidr.partition('&')[0]
|
catid = catidr.partition('&')[0]
|
||||||
return 'http://www.variety.com/index.asp?layout=print_story&articleid=' + artid + '&categoryid=' + catid
|
return 'http://www.variety.com/index.asp?layout=print_story&articleid=' + artid + '&categoryid=' + catid
|
||||||
|
|
||||||
def get_article_url(self, article):
|
|
||||||
return article.get('feedburner_origlink', None)
|
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
return self.adeify_images(soup)
|
||||||
|
44
resources/recipes/wired_daily.recipe
Normal file
44
resources/recipes/wired_daily.recipe
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
class Wired_Daily(BasicNewsRecipe):
|
||||||
|
|
||||||
|
title = 'Wired Daily Edition'
|
||||||
|
__author__ = 'Kovid Goyal'
|
||||||
|
description = 'Technology news'
|
||||||
|
timefmt = ' [%Y%b%d %H%M]'
|
||||||
|
language = 'en'
|
||||||
|
|
||||||
|
no_stylesheets = True
|
||||||
|
|
||||||
|
remove_tags_before = dict(name='div', id='content')
|
||||||
|
remove_tags = [dict(id=['social_tools', 'outerWrapper', 'sidebar',
|
||||||
|
'footer', 'advertisement', 'blog_subscription_unit',
|
||||||
|
'brightcove_component']),
|
||||||
|
{'class':'entryActions'},
|
||||||
|
dict(name=['noscript', 'script'])]
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
('Top News', 'http://feeds.wired.com/wired/index'),
|
||||||
|
('Culture', 'http://feeds.wired.com/wired/culture'),
|
||||||
|
('Software', 'http://feeds.wired.com/wired/software'),
|
||||||
|
('Mac', 'http://feeds.feedburner.com/cultofmac/bFow'),
|
||||||
|
('Gadgets', 'http://feeds.wired.com/wired/gadgets'),
|
||||||
|
('Cars', 'http://feeds.wired.com/wired/cars'),
|
||||||
|
('Entertainment', 'http://feeds.wired.com/wired/entertainment'),
|
||||||
|
('Gaming', 'http://feeds.wired.com/wired/gaming'),
|
||||||
|
('Science', 'http://feeds.wired.com/wired/science'),
|
||||||
|
('Med Tech', 'http://feeds.wired.com/wired/medtech'),
|
||||||
|
('Politics', 'http://feeds.wired.com/wired/politics'),
|
||||||
|
('Tech Biz', 'http://feeds.wired.com/wired/techbiz'),
|
||||||
|
('Commentary', 'http://feeds.wired.com/wired/commentary'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def print_version(self, url):
|
||||||
|
return url.replace('http://www.wired.com/', 'http://www.wired.com/print/')
|
||||||
|
|
||||||
|
|
@ -6,17 +6,21 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import textwrap, os
|
import os
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
from calibre.customize import FileTypePlugin
|
from calibre.customize import FileTypePlugin
|
||||||
|
|
||||||
|
def is_comic(list_of_names):
|
||||||
|
extensions = set([x.rpartition('.')[-1].lower() for x in list_of_names])
|
||||||
|
return len(extensions) == 1 and iter(extensions).next() in ('jpg', 'jpeg', 'png')
|
||||||
|
|
||||||
class ArchiveExtract(FileTypePlugin):
|
class ArchiveExtract(FileTypePlugin):
|
||||||
name = 'Archive Extract'
|
name = 'Archive Extract'
|
||||||
author = 'Kovid Goyal'
|
author = 'Kovid Goyal'
|
||||||
description = textwrap.dedent(_('''\
|
description = _('Extract common e-book formats from archives '
|
||||||
Extract common e-book formats from archives (zip/rar) files.
|
'(zip/rar) files. Also try to autodetect if they are actually '
|
||||||
'''))
|
'cbz/cbr files.')
|
||||||
file_types = set(['zip', 'rar'])
|
file_types = set(['zip', 'rar'])
|
||||||
supported_platforms = ['windows', 'osx', 'linux']
|
supported_platforms = ['windows', 'osx', 'linux']
|
||||||
on_import = True
|
on_import = True
|
||||||
@ -35,6 +39,13 @@ class ArchiveExtract(FileTypePlugin):
|
|||||||
fnames = zf.namelist()
|
fnames = zf.namelist()
|
||||||
|
|
||||||
fnames = [x for x in fnames if '.' in x]
|
fnames = [x for x in fnames if '.' in x]
|
||||||
|
if is_comic(fnames):
|
||||||
|
ext = '.cbr' if is_rar else '.cbz'
|
||||||
|
of = self.temporary_file('_archive_extract'+ext)
|
||||||
|
with open(archive, 'rb') as f:
|
||||||
|
of.write(f.read())
|
||||||
|
of.close()
|
||||||
|
return of.name
|
||||||
if len(fnames) > 1 or not fnames:
|
if len(fnames) > 1 or not fnames:
|
||||||
return archive
|
return archive
|
||||||
fname = fnames[0]
|
fname = fnames[0]
|
||||||
|
@ -13,6 +13,9 @@ from calibre.ptempfile import PersistentTemporaryFile
|
|||||||
from calibre.libunrar import extract_member, names
|
from calibre.libunrar import extract_member, names
|
||||||
|
|
||||||
def get_metadata(stream):
|
def get_metadata(stream):
|
||||||
|
from calibre.ebooks.metadata.archive import is_comic
|
||||||
|
from calibre.ebooks.metadata.meta import get_metadata
|
||||||
|
|
||||||
path = getattr(stream, 'name', False)
|
path = getattr(stream, 'name', False)
|
||||||
if not path:
|
if not path:
|
||||||
pt = PersistentTemporaryFile('_rar-meta.rar')
|
pt = PersistentTemporaryFile('_rar-meta.rar')
|
||||||
@ -21,6 +24,8 @@ def get_metadata(stream):
|
|||||||
path = pt.name
|
path = pt.name
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
file_names = list(names(path))
|
file_names = list(names(path))
|
||||||
|
if is_comic(file_names):
|
||||||
|
return get_metadata(stream, 'cbr')
|
||||||
for f in file_names:
|
for f in file_names:
|
||||||
stream_type = os.path.splitext(f)[1].lower()
|
stream_type = os.path.splitext(f)[1].lower()
|
||||||
if stream_type:
|
if stream_type:
|
||||||
@ -29,7 +34,6 @@ def get_metadata(stream):
|
|||||||
'rb', 'imp', 'pdf', 'lrf'):
|
'rb', 'imp', 'pdf', 'lrf'):
|
||||||
data = extract_member(path, match=None, name=f)[1]
|
data = extract_member(path, match=None, name=f)[1]
|
||||||
stream = StringIO(data)
|
stream = StringIO(data)
|
||||||
from calibre.ebooks.metadata.meta import get_metadata
|
|
||||||
return get_metadata(stream, stream_type)
|
return get_metadata(stream, stream_type)
|
||||||
raise ValueError('No ebook found in RAR archive')
|
raise ValueError('No ebook found in RAR archive')
|
||||||
|
|
||||||
|
@ -8,15 +8,21 @@ from cStringIO import StringIO
|
|||||||
|
|
||||||
|
|
||||||
def get_metadata(stream):
|
def get_metadata(stream):
|
||||||
|
from calibre.ebooks.metadata.meta import get_metadata
|
||||||
|
from calibre.ebooks.metadata.archive import is_comic
|
||||||
stream_type = None
|
stream_type = None
|
||||||
zf = ZipFile(stream, 'r')
|
zf = ZipFile(stream, 'r')
|
||||||
for f in zf.namelist():
|
names = zf.namelist()
|
||||||
|
if is_comic(names):
|
||||||
|
# Is probably a comic
|
||||||
|
return get_metadata(stream, 'cbz')
|
||||||
|
|
||||||
|
for f in names:
|
||||||
stream_type = os.path.splitext(f)[1].lower()
|
stream_type = os.path.splitext(f)[1].lower()
|
||||||
if stream_type:
|
if stream_type:
|
||||||
stream_type = stream_type[1:]
|
stream_type = stream_type[1:]
|
||||||
if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub',
|
if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub',
|
||||||
'rb', 'imp', 'pdf', 'lrf'):
|
'rb', 'imp', 'pdf', 'lrf'):
|
||||||
from calibre.ebooks.metadata.meta import get_metadata
|
|
||||||
stream = StringIO(zf.read(f))
|
stream = StringIO(zf.read(f))
|
||||||
return get_metadata(stream, stream_type)
|
return get_metadata(stream, stream_type)
|
||||||
raise ValueError('No ebook found in ZIP archive')
|
raise ValueError('No ebook found in ZIP archive')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user