mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add poche recipe.
This commit is contained in:
parent
f570c84a68
commit
66b146381b
52
recipes/poche.recipe
Normal file
52
recipes/poche.recipe
Normal file
@ -0,0 +1,52 @@
|
||||
import string, re
|
||||
from calibre import strftime
|
||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||
|
||||
class NYTimes(BasicNewsRecipe):
|
||||
|
||||
appURL = 'http://app.inthepoche.com'
|
||||
title = 'Poche'
|
||||
__author__ = 'Xavier Detant'
|
||||
description = 'Get your poche form your poche account.'
|
||||
needs_subscription = True
|
||||
remove_tags_before = dict(id='article')
|
||||
remove_tags_after = dict(id='article')
|
||||
|
||||
def get_browser(self):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
if self.username is not None and self.password is not None:
|
||||
br.open(self.appURL + '/u/' + self.username)
|
||||
br.select_form(name='loginform')
|
||||
br['login'] = self.username
|
||||
br['password'] = self.password
|
||||
br.submit()
|
||||
return br
|
||||
|
||||
def parse_index(self):
|
||||
baseURL = self.appURL + '/u/'+self.username+'/'
|
||||
soup = self.index_to_soup(baseURL+'index.php')
|
||||
articles = {}
|
||||
key = None
|
||||
ans = []
|
||||
|
||||
for div in soup.findAll(True,attrs={'class':['entrie']}):
|
||||
|
||||
a = div.find('a', href=True)
|
||||
if not a:
|
||||
continue
|
||||
key = self.tag_to_string(div.find('a',attrs={'class':['reading-time']}))
|
||||
url = baseURL + a['href']
|
||||
title = self.tag_to_string(a, use_alt=False)
|
||||
description = ''
|
||||
pubdate = strftime('%a, %d %b')
|
||||
summary = div.find('p')
|
||||
if summary:
|
||||
description = self.tag_to_string(summary, use_alt=False)
|
||||
|
||||
feed = key if key is not None else 'Uncategorized'
|
||||
if not articles.has_key(feed):
|
||||
articles[feed] = []
|
||||
articles[feed].append(dict(title=title, url=url, date=pubdate,description=description,content=''))
|
||||
ans = [(key, articles[key]) for key in articles.keys()]
|
||||
return ans
|
Loading…
x
Reference in New Issue
Block a user