Plugin CS: fixed forgotten debug stuff, CS plugin is now working again
User agent changed to "Salut à Toi XMPP/CS Plugin".
This commit is contained in:
parent
91d3d62dae
commit
2257e43d57
1 changed files with 6 additions and 19 deletions
|
|
@ -52,7 +52,7 @@ PLUGIN_INFO = {
|
|||
"description": _(u"""This plugin allow to manage your CouchSurfing account throught your SàT frontend""")
|
||||
}
|
||||
|
||||
AGENT = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3'
|
||||
AGENT = 'Salut à Toi XMPP/CS Plugin'
|
||||
|
||||
class CS_Plugin():
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class CS_Plugin():
|
|||
#parameters
|
||||
host.memory.importParams(CS_Plugin.params)
|
||||
#menu
|
||||
host.importMenu(_("Plugin"), "CouchSurfing", self.menuSelected, help_string = _("Launch CoushSurfing mangement interface"))
|
||||
host.importMenu(_("Plugin"), "CouchSurfing", self.menuSelected, help_string = _("Launch CoushSurfing management interface"))
|
||||
self.data=self.host.memory.getPrivate('plugin_cs_data') or {} #TODO: delete cookies/data after a while
|
||||
self.host.registerGeneralCB("plugin_CS_sendMessage", self.sendMessage)
|
||||
self.host.registerGeneralCB("plugin_CS_showUnreadMessages", self.showUnreadMessages)
|
||||
|
|
@ -99,27 +99,17 @@ class CS_Plugin():
|
|||
self.data[profile] = {'cookies':{}}
|
||||
else:
|
||||
self.data[profile]['cookies'] = {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#tmp
|
||||
"""f = open('/home/goffi/tmp/CS_principale.html','r')
|
||||
html = f.read()
|
||||
self.__connectionCB(html, id, profile)"""
|
||||
|
||||
|
||||
d = getPage('http://www.couchsurfing.org/login.html', method='POST', postdata=post_data, headers={'Content-Type':'application/x-www-form-urlencoded'} , agent=AGENT, cookies=self.data[profile]['cookies'])
|
||||
d.addCallback(self.__connectionCB, id, profile)
|
||||
d.addErrback(self.erroCB, id)
|
||||
|
||||
|
||||
#self.host.bridge.actionResult("SUPPRESS", id, {})
|
||||
#self.host.bridge.actionResult("SUPPRESS", id, {})
|
||||
|
||||
|
||||
#pages parsing callbacks
|
||||
def savePage(self, name, html):
|
||||
f = open ('/home/goffi/tmp/CS_'+name+'.html','w')
|
||||
f = open ('/tmp/CS_'+name+'.html','w')
|
||||
f.write(html)
|
||||
f.close()
|
||||
print "page [%s] sauvee" % name
|
||||
|
|
@ -127,7 +117,7 @@ class CS_Plugin():
|
|||
|
||||
def __connectionCB(self, html, id, profile):
|
||||
print 'Response received'
|
||||
self.savePage('principale',html)
|
||||
#self.savePage('principale',html)
|
||||
soup = BeautifulSoup(html)
|
||||
self.data[profile]['user_nick'] = soup.find('a','item_link',href='/home.html').contents[0]
|
||||
self.data[profile]['user_name'] = soup.html.head.title.string.split(' - ')[1]
|
||||
|
|
@ -145,9 +135,6 @@ class CS_Plugin():
|
|||
#if we have already the list of friend, no need to make new requests
|
||||
if not self.data[profile].has_key('friends'):
|
||||
self.data[profile]['friends'] = {}
|
||||
"""f = open('/home/goffi/tmp/CS_friends.html','r')
|
||||
html = f.read()
|
||||
self.__friendsPageCB(html, id, profile)"""
|
||||
d = getPage('http://www.couchsurfing.org/connections.html?type=myfriends&show=10000', agent=AGENT, cookies=self.data[profile]['cookies'])
|
||||
d.addCallback(self.__friendsPageCB, id=id, profile=profile)
|
||||
d.addErrback(self.erroCB, id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue