Example #1
0
def getMP():
    MP = []
    from htmldecode import htmlentitydecode, set_pretty_formatting, set_quote_and_code_in_color
    #html = open( os.path.join( CACHEDIR, "pm.html" ), "r" ).read()
    html = get_page( "http://passion-xbmc.org/pm/", filename='pm.html' )
    windowbg = re.compile( '<td colspan="2" class="windowbg(.*?)<td valign="bottom" class="smalltext" width="85%">', re.DOTALL ).findall( html )
    for mp in windowbg:
        auteur = re.findall( '<a href="http://passion-xbmc.org/profile.*?" title="Voir le profil.*?" style="color\:#(.*?)\;">(.*?)</a>', mp )
        auteur_avatar = re.findall( '<img src="(.*?)" alt="" class="avatar reflect" border="0" />', mp )
        if auteur_avatar: auteur_avatar = get_MP_avatar( auteur_avatar[ 0 ] )
        else: auteur_avatar = ""
        title, date = re.findall( '<td align="left" valign="middle">.*?<b>(.*?)</b>.*?<b> le:</b>(.*?) &#187;</div>', mp, re.DOTALL )[ 0 ]
        isread = re.findall( '<div class="smalltext">&#171; (.*?) &#187;</div>', mp, re.DOTALL )
        message = re.findall( '<div class="personalmessage">(.*?)</div>\n', mp, re.DOTALL )

        auteur = "[COLOR=FF%s]%s[/COLOR]" % ( auteur[ 0 ][ 0 ], auteur[ 0 ][ 1 ], )
        title = set_pretty_formatting( htmlentitydecode( unicode( title, 'utf-8' ) ) )
        date = set_pretty_formatting( htmlentitydecode( unicode( date, 'utf-8' ) ) )
        if len( isread ) >= 2:
            isread = htmlentitydecode( unicode( isread[ 1 ], 'utf-8' ) )
        else:
            isread = ""
        message = htmlentitydecode( decode_smileys( set_pretty_formatting( set_quote_and_code_in_color( unicode( message[ 0 ], 'utf-8' ) ) ) ) )#+"</div>"
        #le reste du nettoyage ce passe dans GUI/ForumDirectInfos.py
        #message = re.sub( "(?s)<[^>]*>", "", message )
        MP.append( ( auteur_avatar, auteur, title, date, isread, message ) )

    return MP
Example #2
0
def getMP():
    MP = []
    from htmldecode import htmlentitydecode, set_pretty_formatting, set_quote_and_code_in_color
    #html = open( os.path.join( CACHEDIR, "pm.html" ), "r" ).read()
    html = get_page("http://passion-xbmc.org/pm/", filename='pm.html')
    windowbg = re.compile(
        '<td colspan="2" class="windowbg(.*?)<td valign="bottom" class="smalltext" width="85%">',
        re.DOTALL).findall(html)
    for mp in windowbg:
        auteur = re.findall(
            '<a href="http://passion-xbmc.org/profile.*?" title="Voir le profil.*?" style="color\:#(.*?)\;">(.*?)</a>',
            mp)
        auteur_avatar = re.findall(
            '<img src="(.*?)" alt="" class="avatar reflect" border="0" />', mp)
        if auteur_avatar: auteur_avatar = get_MP_avatar(auteur_avatar[0])
        else: auteur_avatar = ""
        title, date = re.findall(
            '<td align="left" valign="middle">.*?<b>(.*?)</b>.*?<b> le:</b>(.*?) &#187;</div>',
            mp, re.DOTALL)[0]
        isread = re.findall('<div class="smalltext">&#171; (.*?) &#187;</div>',
                            mp, re.DOTALL)
        message = re.findall('<div class="personalmessage">(.*?)</div>\n', mp,
                             re.DOTALL)

        auteur = "[COLOR=FF%s]%s[/COLOR]" % (
            auteur[0][0],
            auteur[0][1],
        )
        title = set_pretty_formatting(htmlentitydecode(unicode(title,
                                                               'utf-8')))
        date = set_pretty_formatting(htmlentitydecode(unicode(date, 'utf-8')))
        if len(isread) >= 2:
            isread = htmlentitydecode(unicode(isread[1], 'utf-8'))
        else:
            isread = ""
        message = htmlentitydecode(
            decode_smileys(
                set_pretty_formatting(
                    set_quote_and_code_in_color(unicode(
                        message[0], 'utf-8')))))  #+"</div>"
        #le reste du nettoyage ce passe dans GUI/ForumDirectInfos.py
        #message = re.sub( "(?s)<[^>]*>", "", message )
        MP.append((auteur_avatar, auteur, title, date, isread, message))

    return MP
def _decode( text ):
    try: return htmlentitydecode( text )
    except: print_exc()
    return text
Example #4
0
def _decode(text):
    try:
        return htmlentitydecode(text)
    except:
        print_exc()
    return text