Exemple #1
0
def list_titles(request, artist="Alle", album="Alle"):
    """Alle Titel eines Künstlers und oder eines Albums auflisten

       @param artist Name des Künstlers
       @param album Albumtitel
    """
    client = settings.XMMS2_CLIENT

    artist = smart_str(unquote_plus(artist))  # Vermeiden von UnicodeError
    album = smart_str(unquote_plus(album))

    if artist != "Alle":
        artist_coll = collections.Match(field="artist", value=artist)
    else:
        artist_coll = collections.Universe()

    if album != "Alle":
        album_coll = collections.Intersection(
            artist_coll, collections.Match(field="album", value=album))
    else:
        album_coll = collections.Intersection(artist_coll,
                                              collections.Universe())

    template = loader.get_template('concept/titlelist.html')
    context = RequestContext(
        request, {
            'selected_artist': artist,
            'albums': client.coll_query(['album'], artist_coll),
            'selected_album': album,
            'titles': client.coll_query(['id', 'title'], album_coll),
        })

    return HttpResponse(template.render(context))
Exemple #2
0
 def coll_query(self, keys, c = coll.Universe()):
     """Eintraginfos aus einer Collection abrufen
     Dabei ist keys eine liste
     Zurückgegeben wird eine Liste mit dictionarys
     """
     result = self.client.coll_query_infos(c, keys)
     result.wait()
     return result.value()
Exemple #3
0
def common(request, client=settings.XMMS2_CLIENT, artist='Alle', album='Alle'):
    """Rendert die Index-Seite
    
    @deprecated wird nur noch von der Funktion index benötigt und kann daher in diese integriert werden
    """
    if artist != "Alle":
        artist_coll = collections.Match(field="artist", value=artist)
    else:
        artist_coll = collections.Universe()

    if album != "Alle":
        album_coll = collections.Intersection(
            artist_coll, collections.Match(field="album", value=album))
    else:
        album_coll = collections.Intersection(artist_coll,
                                              collections.Universe())

    playlist = client.list()
    playtime = 0
    for entry in playlist:
        try:
            playtime += entry.get('duration')
        except TypeError:
            pass

    template = loader.get_template('concept/index.html')
    context = RequestContext(
        request, {
            'playlist_list': client.playlist_list(),
            'active_playlist': client.playlist_active(),
            'playlist': playlist,
            'playtime': playtime,
            'current': client.current(),
            'artists': client.coll_query(['artist']),
            'selected_artist': artist,
            'albums': client.coll_query(['album'], artist_coll),
            'titles': client.coll_query(['id', 'title'], album_coll),
        })

    return HttpResponse(template.render(context))
Exemple #4
0
def iphone(request):
    """Rendert eine Seite für das iPhone Interface
    """
    client = settings.XMMS2_CLIENT

    artist_coll = collections.Universe()

    template = loader.get_template('dj/iphone/index.html')
    context = RequestContext(
        request, {
            'artists': client.coll_query(['artist'], artist_coll),
        })
    return HttpResponse(template.render(context))
Exemple #5
0
def list_albums(request, artist="Alle"):
    """Alle Albem eines Künstlers auflisten
       
       @param artist Name des Künstlers/der Band
    """
    client = settings.XMMS2_CLIENT

    artist = unquote_plus(artist)
    artist = smart_str(artist)  # vermeidet UnicodeError bei xmms2-Funktionen

    if artist != "Alle":
        artist_coll = collections.Match(field="artist", value=artist)
    else:
        artist_coll = collections.Universe()

    template = loader.get_template('concept/albumlist.html')
    context = RequestContext(
        request, {
            'selected_artist': artist,
            'albums': client.coll_query(['album'], artist_coll),
        })

    return HttpResponse(template.render(context))
Exemple #6
0
def album_add(request, artist, album):
    """Alle Titel eines Albums zur Playlist hinzufügen

       @param artist Name des Künstlers
       @param album Albumname

       @remarks
         Name sollte evtl. nach "add_album" geändert werden
    """
    client = settings.XMMS2_CLIENT

    artist = unquote_plus(artist)
    album = unquote_plus(album)

    if artist != "Alle":
        artist_coll = collections.Match(field="artist", value=artist)
    else:
        artist_coll = collections.Universe()

    album_coll = collections.Intersection(
        artist_coll, collections.Match(field="album", value=album))
    client.playlist_add_collection(album_coll)

    return get_playlist(request)