simplify and factorize code, remove dead code, follow conventions, use new-style classes
This commit is contained in:
parent
55a1574df5
commit
f1b3264a67
28 changed files with 202 additions and 251 deletions
|
|
@ -34,7 +34,7 @@ class FourChanBackend(BaseBackend, ICapMessages):
|
|||
EMAIL = 'romain@weboob.org'
|
||||
VERSION = '0.5'
|
||||
LICENSE = 'GPLv3'
|
||||
DESCRIPTION = "4chan website"
|
||||
DESCRIPTION = '4chan website'
|
||||
CONFIG = ValuesDict(Value('boards', label='Boards to fetch'))
|
||||
STORAGE = {'boards': {}}
|
||||
BROWSER = FourChan
|
||||
|
|
|
|||
|
|
@ -15,26 +15,27 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
|
||||
from .pages.board import BoardPage
|
||||
|
||||
|
||||
class FourChan(BaseBrowser):
|
||||
DOMAIN = 'boards.4chan.org'
|
||||
PAGES = {'http://boards.4chan.org/\w+/': BoardPage,
|
||||
'http://boards.4chan.org/\w+/res/\d+': BoardPage,
|
||||
}
|
||||
PAGES = {
|
||||
'http://boards.4chan.org/\w+/': BoardPage,
|
||||
'http://boards.4chan.org/\w+/res/\d+': BoardPage,
|
||||
}
|
||||
|
||||
def is_logged(self):
|
||||
return True
|
||||
|
||||
def get_threads(self, board):
|
||||
self.location('http://boards.4chan.org/%s/' % board)
|
||||
|
||||
return self.page.articles
|
||||
|
||||
def get_thread(self, board, id):
|
||||
self.location('http://boards.4chan.org/%s/res/%d' % (board, long(id)))
|
||||
|
||||
assert len(self.page.articles) == 1
|
||||
return self.page.articles[0]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,17 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import re
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['BoardPage']
|
||||
|
||||
|
||||
class Message(object):
|
||||
def __init__(self, browser, board, id, filename=u'', url=u''):
|
||||
self.id = id
|
||||
|
|
@ -42,6 +47,7 @@ class Message(object):
|
|||
def __repr__(self):
|
||||
return '<Message id=%s filename=%s url=%s comments=%d>' % (self.id, self.filename, self.url, len(self.comments))
|
||||
|
||||
|
||||
class BoardPage(BasePage):
|
||||
URL_REGEXP = re.compile('http://boards.4chan.org/(\w+)/')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue