def getReplies(self,threadid,forumid,page='',lastid='',pid='',callback=None,donecallback=None,page_data=None):
		if not callback: callback = self.fakeCallback
		url = None
		pagesURL = url
		fset, rules = util.loadForumSettings(self.getForumID(),get_both=True)
		self.postParser.addRules(rules)
		self.postParser.ignoreForumImages = fset.get('ignore_forum_images')
		self.postParser.setDomain(self._url)
		self.postParser.tid = threadid
		if self.threadParser.isGeneric:
			url = self._getGenericRepliesURL(threadid, url)
			pagesURL = url
			if page and not str(page).replace('-','').isdigit(): url = self._url + page
		if not url: url = self.getPageUrl(page,'replies',tid=threadid,fid=forumid,lastid=lastid,pid=pid,prefix=self.forumParser.getPrefix())
		util.LOG('Thread URL: ' + url)
		html = self.readURL(url,callback=callback,force_browser=True)
		if not html or not callback(80,util.T(32103)):
			return self.finish(FBData(error=html and 'CANCEL' or 'EMPTY HTML'),donecallback)
		replies = self.postParser.getPosts(html,pagesURL,callback=callback,filters=self.filters,page_url=url,progress_base=80,progress_range=20)
		util.LOG('Detected Posts Type: ' + self.postParser.forumType)
		#topic = re.search(self.filters.get('thread_topic','%#@+%#@'),html)
		#if not threadid:
		#	threadid = re.search(self.filters.get('thread_id','%#@+%#@'),html)
		#	threadid = threadid and threadid.group(1) or ''
		#topic = topic and topic.group(1) or ''
		sreplies = []
		for r in replies:
			try:
				post = self.getForumPost(r)
				post.tid = threadid
				post.fid = forumid
				#print post.message.encode('ascii','replace')
				sreplies.append(post)
			except:
				util.ERROR('ERROR CREATING POST - Using blank post')
				post = self.getForumPost()
				sreplies.append(post)
		pd = self.getPageInfo(html,page,page_type='replies',page_urls=self.postParser.pages)
		if pd: pd.setThreadData('',threadid)
		
		try:
			newtid = self.threadParser.linkRE.search(self.lastURL.rsplit('/',1)[-1]).groupdict().get('id')
			extra = newtid and {'newthreadid':newtid} or None
		except:
			extra = None
			
		callback(100,util.T(32052))
		
		return self.finish(FBData(sreplies,pd,extra=extra),donecallback)
Ejemplo n.º 2
0
	def getPassword(self):
		data = util.loadForumSettings(self.FB.getForumID())
		if data and data['password']: return data['password']
		return ''
Ejemplo n.º 3
0
	def checkForums(self):
		self.log('CHECKING FORUMS...')
		data = {}
		anyflag = False
		for forum in getNotifyList():
			fdata = {}
			flag = False
			if not self.setForumBrowser(forum):
				LOG('Failed to get browser for forum: %s' % forum)
				continue
			if not self.hasLogin():
				LOG('No login for forum: %s' % forum)
				continue
			self.FB.setLogin(self.getUsername(), self.getPassword(), always=True,rules=util.loadForumSettings(forum,get_rules=True))
			try:
				pmcounts = self.FB.getPMCounts()
				xbmc.sleep(300)
				subs = self.FB.getSubscriptions()
			except util.AbortRequestedException:
				self.stop = True
				return
			except:
				ERROR('Failed to get data for forum: %s' % forum)
				fdata = self.lastData.get(forum)
				continue
			
			log = self.FB.getDisplayName() + ': '
			
			if not pmcounts:
				log += 'ERROR: No PM counts'
				self.log(log)
				continue
			
			fdata['PM'] = pmcounts.get('unread',0) or 0
			pmtotal = pmcounts.get('total',0) or 0
			if fdata['PM']:
				if self.checkLast(forum, 'PM', fdata['PM']): flag = True
			
			ct = 0
			unread = 0
			if not subs:
				log += 'ERROR: %s' % subs.error
				self.log(log)
				continue
			
			for f in subs['forums'] or []:
				ID = 'F' + f.get('forumid')
				
				fdata[ID] = f.get('new_post')
				if f.get('new_post'):
					unread += 1
					if self.checkLast(forum, ID): flag = True
				ct += 1
			for t in subs.data:
				ID = 'T' + t.get('threadid')
				fdata[ID] = t.get('new_post')
				if t.get('new_post'):
					unread += 1
					if self.checkLast(forum, ID): flag = True
				ct += 1
			data[forum] = fdata
			log += 'Subs: %s/%s PMs: %s/%s' % (unread,ct,fdata['PM'],pmtotal)
			
			if flag:
				self.notify(log,ntype='single')
				self.log(log + ' - SHOWING NOTICE')
				anyflag = True
			else:
				self.log(log)
			
				
		self.setLastData(data)
		
		if anyflag:
			self.log('SHOWING DIALOG')
			self.notify()
		self.log('CHECKING FORUMS: FINISHED')
Ejemplo n.º 4
0
	def getUsername(self):
		data = util.loadForumSettings(self.FB.getForumID())
		if data and data['username']: return data['username']
		return ''