plugins, parsing threads list with BeautifulSoup
[chanspy.git] / daemon.shit / plugins / plugin_wakaba.py
blob954b324d8ea9076e02f965deb1df318ee2f035ad
1 import dbus.service
3 from board import Board
4 from plugins.wakaba_thread import WakabaThread
6 import urllib
7 import re
9 INTERFACE = 'py.chans.dbus'
11 class MetaBoard(Board):
12 """Wakaba board class."""
14 def __init__(self, bus_name, obj_path, name, base_uri):
15 Board.__init__(self, bus_name, obj_path, name, base_uri)
17 #TODO: _normal_ parsing needs
18 @dbus.service.method(dbus_interface=INTERFACE, in_signature='', out_signature='')
19 def refresh(self):
20 """Parsing board threads."""
22 def get_threads_ids():
23 data = urllib.urlopen(self.board_uri).read()
24 threads = re.findall('<hr />.*?<a name="([0-9]+)"', data)
25 return threads
27 threads_ids = get_threads_ids()
28 for thread_id in threads_ids:
29 if not thread_id in self.get_threads():
30 self.threads.append( WakabaThread(bus_name=self.bus_name, obj_path=self.obj_path +'/'+ thread_id, board=self, id=thread_id) )