mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Updated LifeHacker
This commit is contained in:
parent
f970ac5744
commit
a34e318107
@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from calibre.ebooks.BeautifulSoup import Tag,BeautifulSoup
|
from calibre.ebooks.BeautifulSoup import Tag,BeautifulSoup
|
||||||
@ -6,18 +5,17 @@ from calibre.utils.magick import Image, PixelWand
|
|||||||
from urllib2 import Request, urlopen, URLError
|
from urllib2 import Request, urlopen, URLError
|
||||||
|
|
||||||
class Estadao(BasicNewsRecipe):
|
class Estadao(BasicNewsRecipe):
|
||||||
THUMBALIZR_API = "0123456789abcdef01234567890" # ---->Get your at http://www.thumbalizr.com/
|
THUMBALIZR_API = '' # ---->Get your at http://www.thumbalizr.com/ and put here
|
||||||
LANGUAGE = 'pt_br'
|
LANGUAGE = 'pt_br'
|
||||||
language = 'pt'
|
language = 'pt'
|
||||||
LANGHTM = 'pt-br'
|
LANGHTM = 'pt-br'
|
||||||
ENCODING = 'utf'
|
ENCODING = 'utf'
|
||||||
ENCHTM = 'utf-8'
|
ENCHTM = 'utf-8'
|
||||||
directionhtm = 'ltr'
|
directionhtm = 'ltr'
|
||||||
requires_version = (0,8,47)
|
requires_version = (0,7,47)
|
||||||
news = True
|
news = True
|
||||||
publication_type = 'newsportal'
|
|
||||||
|
|
||||||
title = u'Estadao'
|
title = u'Estad\xe3o'
|
||||||
__author__ = 'Euler Alves'
|
__author__ = 'Euler Alves'
|
||||||
description = u'Brazilian news from Estad\xe3o'
|
description = u'Brazilian news from Estad\xe3o'
|
||||||
publisher = u'Estad\xe3o'
|
publisher = u'Estad\xe3o'
|
||||||
@ -33,14 +31,6 @@ class Estadao(BasicNewsRecipe):
|
|||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
timefmt = ' [%d %b %Y (%a)]'
|
timefmt = ' [%d %b %Y (%a)]'
|
||||||
|
|
||||||
html2lrf_options = [
|
|
||||||
'--comment', description
|
|
||||||
,'--category', category
|
|
||||||
,'--publisher', publisher
|
|
||||||
]
|
|
||||||
|
|
||||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
|
||||||
|
|
||||||
hoje = datetime.now()-timedelta(days=2)
|
hoje = datetime.now()-timedelta(days=2)
|
||||||
pubdate = hoje.strftime('%a, %d %b')
|
pubdate = hoje.strftime('%a, %d %b')
|
||||||
if hoje.hour<10:
|
if hoje.hour<10:
|
||||||
@ -69,6 +59,7 @@ class Estadao(BasicNewsRecipe):
|
|||||||
,dict(name='script')
|
,dict(name='script')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'\xDAltimas Not\xEDcias', u'http://www.estadao.com.br/rss/ultimas.xml')
|
(u'\xDAltimas Not\xEDcias', u'http://www.estadao.com.br/rss/ultimas.xml')
|
||||||
,(u'Manchetes', u'http://www.estadao.com.br/rss/manchetes.xml')
|
,(u'Manchetes', u'http://www.estadao.com.br/rss/manchetes.xml')
|
||||||
@ -109,6 +100,8 @@ class Estadao(BasicNewsRecipe):
|
|||||||
img.open(iurl)
|
img.open(iurl)
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
print 'img is: ', iurl, 'width is: ', width, 'height is: ', height
|
print 'img is: ', iurl, 'width is: ', width, 'height is: ', height
|
||||||
|
if img < 0:
|
||||||
|
raise RuntimeError('Out of memory')
|
||||||
pw = PixelWand()
|
pw = PixelWand()
|
||||||
if( width > height and width > 590) :
|
if( width > height and width > 590) :
|
||||||
print 'Rotate image'
|
print 'Rotate image'
|
||||||
@ -117,6 +110,7 @@ class Estadao(BasicNewsRecipe):
|
|||||||
return soup
|
return soup
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
|
if self.THUMBALIZR_API:
|
||||||
cover_url = self.CAPA
|
cover_url = self.CAPA
|
||||||
pedido = Request(self.CAPA)
|
pedido = Request(self.CAPA)
|
||||||
pedido.add_header('User-agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; '+self.LANGHTM+'; userid='+self.THUMBALIZR_API+') Calibre/0.8.47 (like Gecko)')
|
pedido.add_header('User-agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; '+self.LANGHTM+'; userid='+self.THUMBALIZR_API+') Calibre/0.8.47 (like Gecko)')
|
||||||
@ -132,3 +126,4 @@ class Estadao(BasicNewsRecipe):
|
|||||||
except URLError:
|
except URLError:
|
||||||
cover_url='http://api.thumbalizr.com/?api_key='+self.THUMBALIZR_API+'&url='+self.SCREENSHOT+'&width=600&quality=90'
|
cover_url='http://api.thumbalizr.com/?api_key='+self.THUMBALIZR_API+'&url='+self.SCREENSHOT+'&width=600&quality=90'
|
||||||
return cover_url
|
return cover_url
|
||||||
|
|
||||||
|
@ -5,16 +5,15 @@ from calibre.utils.magick import Image, PixelWand
|
|||||||
from urllib2 import Request, urlopen, URLError
|
from urllib2 import Request, urlopen, URLError
|
||||||
|
|
||||||
class FolhaOnline(BasicNewsRecipe):
|
class FolhaOnline(BasicNewsRecipe):
|
||||||
THUMBALIZR_API = "0123456789abcdef01234567890" # ---->Get your at http://www.thumbalizr.com/
|
THUMBALIZR_API = '' # ---->Get your at http://www.thumbalizr.com/ and put here
|
||||||
LANGUAGE = 'pt_br'
|
LANGUAGE = 'pt_br'
|
||||||
language = 'pt'
|
language = 'pt'
|
||||||
LANGHTM = 'pt-br'
|
LANGHTM = 'pt-br'
|
||||||
ENCODING = 'cp1252'
|
ENCODING = 'cp1252'
|
||||||
ENCHTM = 'iso-8859-1'
|
ENCHTM = 'iso-8859-1'
|
||||||
directionhtm = 'ltr'
|
directionhtm = 'ltr'
|
||||||
requires_version = (0,8,47)
|
requires_version = (0,7,47)
|
||||||
news = True
|
news = True
|
||||||
publication_type = 'newsportal'
|
|
||||||
|
|
||||||
title = u'Folha de S\xE3o Paulo'
|
title = u'Folha de S\xE3o Paulo'
|
||||||
__author__ = 'Euler Alves'
|
__author__ = 'Euler Alves'
|
||||||
@ -96,6 +95,7 @@ class FolhaOnline(BasicNewsRecipe):
|
|||||||
,(u'Valdo Cruz', u'http://http://feeds.folha.uol.com.br/folha/pensata/valdocruz/rss091.xml')
|
,(u'Valdo Cruz', u'http://http://feeds.folha.uol.com.br/folha/pensata/valdocruz/rss091.xml')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'title' : title
|
'title' : title
|
||||||
,'comments' : description
|
,'comments' : description
|
||||||
@ -124,6 +124,8 @@ class FolhaOnline(BasicNewsRecipe):
|
|||||||
img.open(iurl)
|
img.open(iurl)
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
print 'img is: ', iurl, 'width is: ', width, 'height is: ', height
|
print 'img is: ', iurl, 'width is: ', width, 'height is: ', height
|
||||||
|
if img < 0:
|
||||||
|
raise RuntimeError('Out of memory')
|
||||||
pw = PixelWand()
|
pw = PixelWand()
|
||||||
if( width > height and width > 590) :
|
if( width > height and width > 590) :
|
||||||
print 'Rotate image'
|
print 'Rotate image'
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 714 B |
BIN
recipes/icons/folhadesaopaulo.png
Normal file
BIN
recipes/icons/folhadesaopaulo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 392 B |
@ -1,37 +1,100 @@
|
|||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2010, NA'
|
|
||||||
'''
|
|
||||||
lifehacker.com
|
|
||||||
'''
|
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from datetime import datetime
|
||||||
|
from calibre.ebooks.BeautifulSoup import Tag
|
||||||
|
from calibre.utils.magick import Image, PixelWand
|
||||||
|
|
||||||
class Lifehacker(BasicNewsRecipe):
|
class LifeHacker(BasicNewsRecipe):
|
||||||
title = 'Lifehacker'
|
THUMBALIZR_API = '' # ---->Get your at http://www.thumbalizr.com/ and put here
|
||||||
__author__ = 'Kovid Goyal'
|
LANGUAGE = 'en'
|
||||||
description = "Computers make us more productive. Yeah, right. Lifehacker recommends the software downloads and web sites that actually save time. Don't live to geek; geek to live."
|
LANGHTM = 'en'
|
||||||
publisher = 'lifehacker.com'
|
|
||||||
category = 'news, IT, Internet, gadgets, tips and tricks, howto, diy'
|
|
||||||
oldest_article = 2
|
|
||||||
max_articles_per_feed = 100
|
|
||||||
no_stylesheets = True
|
|
||||||
encoding = 'utf-8'
|
|
||||||
use_embedded_content = True
|
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
ENCODING = 'utf'
|
||||||
|
ENCHTM = 'utf-8'
|
||||||
|
requires_version = (0,7,47)
|
||||||
|
news = True
|
||||||
|
|
||||||
|
title = u'LifeHacker'
|
||||||
|
__author__ = 'Euler Alves'
|
||||||
|
description = u'Tips, tricks, and downloads for getting things done.'
|
||||||
|
publisher = u'lifehacker.com'
|
||||||
|
author = u'Adam Pash & Kevin Purdy & Adam Dachis & Whitson Gordon & Gina Trapani'
|
||||||
|
category = 'news, rss'
|
||||||
|
|
||||||
|
oldest_article = 4
|
||||||
|
max_articles_per_feed = 20
|
||||||
|
summary_length = 1000
|
||||||
|
|
||||||
|
remove_javascript = True
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = True
|
||||||
|
remove_empty_feeds = True
|
||||||
|
timefmt = ' [%d %b %Y (%a)]'
|
||||||
|
|
||||||
|
hoje = datetime.now()
|
||||||
|
pubdate = hoje.strftime('%a, %d %b')
|
||||||
|
cover_url = 'http://api.thumbalizr.com/?api_key='+THUMBALIZR_API+'&url=http://lifehacker.com&width=600&quality=90'
|
||||||
|
cover_margins = (0,0,'white')
|
||||||
masthead_url = 'http://cache.gawkerassets.com/assets/lifehacker.com/img/logo.png'
|
masthead_url = 'http://cache.gawkerassets.com/assets/lifehacker.com/img/logo.png'
|
||||||
conversion_options = {
|
|
||||||
'comment' : description
|
|
||||||
, 'tags' : category
|
|
||||||
, 'publisher' : publisher
|
|
||||||
, 'language' : language
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
{'class': 'feedflare'},
|
{'class': 'feedflare'},
|
||||||
|
dict(name='div',
|
||||||
|
attrs={'class':[
|
||||||
|
'ad_container'
|
||||||
|
,'ad_300x250'
|
||||||
|
,'ad_interstitial'
|
||||||
|
,'share-wrap'
|
||||||
|
,'ad_300x600'
|
||||||
|
,'ad_perma-footer-adsense'
|
||||||
|
,'ad_perma-panorama'
|
||||||
|
,'ad panorama'
|
||||||
|
,'ad_container'
|
||||||
|
]})
|
||||||
|
,dict(name='div',
|
||||||
|
attrs={'id':[
|
||||||
|
'agegate_container'
|
||||||
|
,'agegate_container_rejected'
|
||||||
|
,'sharemenu-wrap'
|
||||||
|
]})
|
||||||
]
|
]
|
||||||
|
|
||||||
feeds = [(u'Articles', u'http://feeds.gawker.com/lifehacker/vip?format=xml')]
|
feeds = [(u'Articles', u'http://feeds.gawker.com/lifehacker/vip?format=xml')]
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
conversion_options = {
|
||||||
return self.adeify_images(soup)
|
'title' : title
|
||||||
|
,'comments' : description
|
||||||
|
,'publisher' : publisher
|
||||||
|
,'tags' : category
|
||||||
|
,'language' : LANGUAGE
|
||||||
|
,'linearize_tables': True
|
||||||
|
}
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for item in soup.findAll(style=True):
|
||||||
|
del item['style']
|
||||||
|
if not soup.find(attrs={'http-equiv':'Content-Language'}):
|
||||||
|
meta0 = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.LANGHTM)])
|
||||||
|
soup.head.insert(0,meta0)
|
||||||
|
if not soup.find(attrs={'http-equiv':'Content-Type'}):
|
||||||
|
meta1 = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset="+self.ENCHTM)])
|
||||||
|
soup.head.insert(0,meta1)
|
||||||
|
return soup
|
||||||
|
|
||||||
|
def postprocess_html(self, soup, first):
|
||||||
|
#process all the images. assumes that the new html has the correct path
|
||||||
|
for tag in soup.findAll(lambda tag: tag.name.lower()=='img' and tag.has_key('src')):
|
||||||
|
iurl = tag['src']
|
||||||
|
img = Image()
|
||||||
|
img.open(iurl)
|
||||||
|
width, height = img.size
|
||||||
|
print 'img is: ', iurl, 'width is: ', width, 'height is: ', height
|
||||||
|
if img < 0:
|
||||||
|
raise RuntimeError('Out of memory')
|
||||||
|
pw = PixelWand()
|
||||||
|
if( width > height and width > 590) :
|
||||||
|
print 'Rotate image'
|
||||||
|
img.rotate(pw, -90)
|
||||||
|
img.save(iurl)
|
||||||
|
return soup
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user