def set_user_authentification( self, connect=False ): self.connexion = None try: self.getControl( 200 ).setLabel( _( 201 ) ) self.getControl( 200 ).setSelected( False ) self.getControl( 201 ).setLabel( _( 23 ) ) self.getControl( 201 ).setVisible( False ) except: pass if connect: self.pseudo, self.connexion, self.avatar, self.mp = PassionXBMC.Connect() else: self.pseudo, self.connexion, self.avatar, self.mp = PassionXBMC.IsAuthenticated() if self.connexion: if self.mp == 0: notif = "%s %s,%s,5000,%s" % ( _( 209 ), self.pseudo, _( 210 ),self.avatar, ) else: notif = "%s %s,%s,5000,%s" % ( _( 209 ), self.pseudo, ( _( 211 ) % self.mp ), self.avatar, ) xbmc.executebuiltin( "XBMC.Notification(%s)" % notif.encode( "utf-8" ) ) try: self.getControl( 200 ).setLabel( self.pseudo ) self.getControl( 200 ).setSelected( bool( self.connexion ) ) except: pass try: self.getControl( 201 ).setVisible( True ) if ( self.mp > 0 ): self.getControl( 201 ).setLabel( "%s [%i]" % ( _( 23 ), self.mp ) ) except: pass
def load_infos( url, onerror=True ): try: html = PassionXBMC.get_page( url ) source = re.sub( "<!\[CDATA\[|\]\]>", "", html ) return HTB.parse( StringIO( source ), "utf-8" ).findall( "channel" )[ 0 ] except: if onerror: print_exc()
def set_list_container_191_for_pm( self ): try: #[( auteur_avatar, auteur, title, date, isread, message )] MP = PassionXBMC.getMP() if bool( MP ): self.category = _( 212 ) self.setProperty( "Category", self.category ) self.list_infos = list() total_items = len( MP ) or 1 diff = ( 100.0 / total_items ) percent = 0 self.getControl( self.CONTROL_FEEDS_LIST ).reset() for count, mp in enumerate( MP ): percent += diff imgs = set() slideshow = "" try: auteur_avatar, auteur, title, date, isread, message = mp for img in re.findall( '<a href=".*?" rel="highslide"><img src="(.*?)" alt="" width=".*?" height=".*?" border=".*?" /></a>', message, re.DOTALL ): if img and not EXCLUDE_IMGS( img.lower() ) and is_playable_media( img ): imgs.update( [ img ] ) slideshow = "true" #print message.encode( "ISO-8859-1" ) #print message = re.sub( "(?s)<[^>]*>", "", message ) except: print_exc() else: DIALOG_PROGRESS.update( int( percent ), "MP: %i / %i" % ( count + 1, total_items, ), title ) listitem = xbmcgui.ListItem( auteur + " - " + title, date, auteur_avatar, auteur_avatar ) listitem.setProperty( "Topic", message ) listitem.setProperty( "Slideshow", slideshow ) listitem.setProperty( "general_category", "" ) self.getControl( self.CONTROL_FEEDS_LIST ).addItem( listitem ) self.list_infos.append( ( None, list( imgs ) ) ) self.setFocusId( self.CONTROL_FEEDS_LIST ) else: xbmcgui.Dialog().ok( "Passion-XBMC", _( 213 ) % len( MP ), "%s [B]:)[/B]" % _( 214 ) ) except: print_exc() xbmcgui.Dialog().ok( "Passion-XBMC", "%s [B]:)[/B]" % _( 214 ) ) DIALOG_PROGRESS.close()
def onClick( self, controlID ): try: if controlID == self.CONTROL_RSS_LIST: pos = self.getControl( self.CONTROL_RSS_LIST ).getSelectedPosition() if pos >= 0: self.rss_id = pos self.set_list_container_191() elif controlID == self.CONTROL_FEEDS_LIST: pos = self.getControl( self.CONTROL_FEEDS_LIST ).getSelectedPosition() if pos >= 0: self._url_launcher( self.list_infos[ pos ][ 0 ] ) elif controlID == 200: if self.connexion: notif = "Passion-XBMC,%s %s,5000,%s" % ( _( 215 ), self.pseudo, self.avatar, ) self.pseudo, self.connexion, self.avatar, self.mp = PassionXBMC.Disconnect() if not self.connexion: self.getControl( 200 ).setLabel( _( 201 ) ) self.getControl( 200 ).setSelected( False ) self.getControl( 201 ).setLabel( _( 23 ) ) self.getControl( 201 ).setVisible( False ) xbmc.executebuiltin( "XBMC.Notification(%s)" % notif ) else: self.set_user_authentification( True ) DIALOG_PROGRESS.create( _( 199 ), _( 239 ), _( 110 ) ) self.rss_id = 0 self.set_list_container_150() self.set_list_container_191() elif controlID == 201: DIALOG_PROGRESS.create( "Passion-XBMC", _( 216 ), _( 110 ) ) self.set_list_container_191_for_pm() elif controlID == 5: self.set_list_container_191() elif controlID == 320: self._close_dialog() else: pass except: print_exc() DIALOG_PROGRESS.close()