Ejemplo n.º 1
0
def release_description(Name):
    str = ""
    release = ReleaseInfo(name=Name)

    name = release.get_name()
    artist = ArtistInfo(uri=release.get_artist())
    tracks = release.get_tracks()
    cover = release.get_cover()

    str += """<table border="10" id="titletab"><tr id="row1">"""
    str += """<td rowspan="2" id="imagetd"> <img src="%s"/> </td>""" % (cover)
    str += """<td id="song_td"><div id="song_title">%s</div></td></tr>""" % name
    str += (
        """<tr id="row2"><td id="song_artist"><div id="song_artist">by <a href="artist.py?artist=%s">%s</a></div></td></tr>"""
        % (artist.get_name(), artist.get_name())
    )
    str += """<tr id="row3"><td class="section">Tracks</td><td class="element"></td></tr>"""
    pair = False
    for track in tracks:
        pair = not pair
        if pair:
            str += """<tr id="row_even"><td class="section"></td><td class="element">%s</td></tr>""" % (
                TrackInfo(uri=track).get_name()
            )
        else:
            str += """<tr id="row_odd"><td class="section"></td><td class="element">%s</td></tr>""" % (
                TrackInfo(uri=track).get_name()
            )
    str += """</table>"""
    return str
Ejemplo n.º 2
0
def artist_description(**keys):
    str = ""
    artist = ArtistInfo(**keys)
    name = artist.get_name()
    uri = artist.get_uri()
    tags = artist.get_tags()
    members = artist.get_members()

    str += """<table border="10" id="titletab"><tr id="row1">"""
    str += """<td rowspan="2" id="imagetd"> <img src="images/audio-volume-high.png"/> </td>"""
    str += """<td id="song_td"><div id="song_title">%s</div></td></tr>""" % name
    str += """<tr id="row2"><td id="song_artist"><div id="song_artist">"""
    if len(members) > 0:
        for nm in members[:-1]:
            str += """<a href="artist_info.py?artist=%s">%s</a>, """ % (nm.get_name(), nm.get_name())
        nm = members[-1]
        str += """<a href="artist_info.py?artist=%s">%s</a>""" % (nm.get_name(), nm.get_name())
    else:
        str += "</br>"
    str += """</div></td></tr>"""
    # Adding tags
    if len(tags) > 0:
        str += """<tr id="row3"><td class="section">Tags</td><td class="element"></td></tr>"""
        str += """<tr id="row_even"><td class="section"></td><td class="element">"""
        for tag in tags[:-1]:
            str += """%s, """ % tag.name
        str += """%s.""" % tags[-1].name
    # Adding similar artists

    sartists = artist.same_tagged_artists()
    if len(sartists) > 0:
        str += """<tr id="row3"><td class="section">Similar artists</td><td class="element"></td></tr>"""
    pair = False
    for sartist in sartists:
        pair = not pair
        link = "artist.py?artist=%s" % sartist.get_name()
        if pair:
            str += (
                """<tr id="row_even"><td class="section"></td><td class="element"><a href="%s">%s</a></td></tr>"""
                % (link, sartist.get_name())
            )
        else:
            str += """<tr id="row_odd"><td class="section"></td><td class="element"><a href="%s">%s</a></td></tr>""" % (
                link,
                sartist.get_name(),
            )
    str += """</td></tr><tr><td id="foot_cell"></td> <td class="element"></td></tr>"""
    str += """</table>"""
    return str
Ejemplo n.º 3
0
import sys, pprint
from artist_info import ArtistInfo

def usage():
    return 'Usage: %s [artist name]' % sys.argv[0]


if __name__ == '__main__':

    if len(sys.argv) == 1:
        print usage()
        quit(1)

    artist_info = ArtistInfo()
    pp = pprint.PrettyPrinter(depth=6)

    search = artist_info.search_artist(' '.join(sys.argv[1:]))

    i=1
    for r in search['artist-list']:
        if 'disambiguation' in r:
            print '%d\t - %s (%s)' % (i, r['name'], r['disambiguation'])
        else:
            print '%d\t - %s' % (i, r['name'])
        i += 1

    num = int(input('Selecione o numero do artista correto: '))
    if (len(search['artist-list']) > num-1):
        mbid = search['artist-list'][num-1]['id']
        name = search['artist-list'][num-1]['name'].decode('utf-8')