예제 #1
0
파일: vlc.py 프로젝트: iterati/silverlining
 def get_track(self, target):
     try:
         if utils.isint(target):
             return self.queue[int(target)]
         else:
             return utils.search_collection(self.queue, target)[0]
     except IndexError:
         return None
예제 #2
0
    def get(cls, query=None, user=None):
        if query and utils.isint(query):
            playlists = soundcloud_get('/playlists/%s' % query)
            if not playlists:
                raise PlaylistNotFoundError(query)
            return cls(playlists[0]).tracks

        if user:
            playlists = user.playlists
            if query:
                playlists = utils.search_collection(playlists, query)
        else:
            playlists = soundcloud_get('/playlists', q=query)
        return list(map(cls, playlists))
예제 #3
0
    def get(cls, query=None, user=None):
        if query and utils.isint(query):
            playlists = soundcloud_get('/playlists/%s' % query)
            if not playlists:
                raise PlaylistNotFoundError(query)
            return cls(playlists[0]).tracks

        if user:
            playlists = user.playlists
            if query:
                playlists = utils.search_collection(playlists, query)
        else:
            playlists = soundcloud_get('/playlists', q=query)
        return list(map(cls, playlists))
예제 #4
0
def get_search_results(username, category, query):
    if category == 'sllist':
        items = get_silverlining_playlist().tracks
        if query:
            items = utils.search_collection(items, query)
    elif category == 'stream':
        if username == 'me':
            items = models.Track.get_from_stream(query)
        else:
            user = models.User.get_one(username) if username else None
            items = user.stream
            if query:
                items = utils.search_collection(items, query)
    elif category == 'user':
        items = models.User.get(username)
    else:
        user = models.User.get_one(username) if username else None
        if category == 'track':
            items = models.Track.get(query, user)
        elif category == 'playlist':
            items = models.Playlist.get(query, user)

    return items
예제 #5
0
def get_search_results(username, category, query):
    if category == 'sllist':
        items = get_silverlining_playlist().tracks
        if query:
            items = utils.search_collection(items, query)
    elif category == 'stream':
        if username == 'me':
            items = models.Track.get_from_stream(query)
        else:
            user = models.User.get_one(username) if username else None
            items = user.stream
            if query:
                items = utils.search_collection(items, query)
    elif category == 'user':
        items = models.User.get(username)
    else:
        user = models.User.get_one(username) if username else None
        if category == 'track':
            items = models.Track.get(query, user)
        elif category == 'playlist':
            items = models.Playlist.get(query, user)

    return items
예제 #6
0
    def get(cls, query=None, user=None):
        if query and utils.isint(query):
            tracks = soundcloud_get('/tracks/%s' % query)
            if not tracks:
                raise TrackNotFoundError(query)
            track = cls(tracks[0])
            tracks.extend(track.get_related())
            return [cls(track) for track in tracks]

        if user:
            tracks = user.tracks
            if query:
                tracks = utils.search_collection(tracks, query)
        else:
            tracks = soundcloud_get('/tracks', q=query)
        return list(map(cls, tracks))
예제 #7
0
    def get(cls, query=None, user=None):
        if query and utils.isint(query):
            tracks = soundcloud_get('/tracks/%s' % query)
            if not tracks:
                raise TrackNotFoundError(query)
            track = cls(tracks[0])
            tracks.extend(track.get_related())
            return [cls(track) for track in tracks]

        if user:
            tracks = user.tracks
            if query:
                tracks = utils.search_collection(tracks, query)
        else:
            tracks = soundcloud_get('/tracks', q=query)
        return list(map(cls, tracks))
예제 #8
0
 def get_from_stream(cls, query=None):
     resp = soundcloud_get('/me/activities/tracks/affiliated')
     tracks = [cls(i['origin']) for i in resp[0]['collection']]
     if query:
         tracks = utils.search_collection(tracks, query)
     return tracks
예제 #9
0
 def get_from_stream(cls, query=None):
     resp = soundcloud_get('/me/activities/tracks/affiliated')
     tracks = [cls(i['origin']) for i in resp[0]['collection']]
     if query:
         tracks = utils.search_collection(tracks, query)
     return tracks