Exemple #1
0
    def query_with_refresh(self, text, sort=None, star=STAR):
        """Queries Soundcloud for some (more) relevant results, then filters"""
        current = self._contents.values()

        query = SoundcloudQuery(text, star=star)
        if not query.is_parsable:
            return current
        self.client.get_tracks(query.terms)
        filtered = query.filter(current)
        print_d("Filtered %d results to %d" % (len(current), len(filtered)))
        return filtered
Exemple #2
0
    def query_with_refresh(self, text, sort=None, star=STAR):
        """Queries Soundcloud for some (more) relevant results, then filters"""
        current = self._contents.values()

        query = SoundcloudQuery(text, star=star)
        if not query.is_parsable:
            return current
        self.client.get_tracks(query.terms)
        filtered = query.filter(current)
        print_d("Filtered %d results to %d" % (len(current), len(filtered)))
        return filtered
Exemple #3
0
 def query_with_refresh(self, text, sort=None, star=STAR):
     """Queries Soundcloud for some (more) relevant results, then filters"""
     current = self._contents.values()
     try:
         query = SoundcloudQuery(text, star=star)
         self.client.get_tracks(query.terms)
     except SoundcloudQuery.error as e:
         print_w("Couldn't filter for query '%s' (%s)" % (text, e))
         return current
     filtered = query.filter(current)
     print_d("Filtered %d results to %d" % (len(current), len(filtered)))
     return filtered
Exemple #4
0
 def query_with_refresh(self, text, sort=None, star=STAR):
     """Queries Soundcloud for some (more) relevant results, then filters"""
     current = self._contents.values()
     try:
         query = SoundcloudQuery(text, star=star)
         self.client.get_tracks(query.terms)
     except SoundcloudQuery.error as e:
         print_w("Couldn't filter for query '%s' (%s)" % (text, e))
         return current
     filtered = query.filter(current)
     print_d("Filtered %d results to %d" % (len(current), len(filtered)))
     return filtered
 def verify(self, text, expected, term='q'):
     print_d("Trying '%s'..." % text)
     terms = SoundcloudQuery(text).terms
     self.failUnlessEqual(terms[term],
                          expected,
                          msg="terms[%s] wasn't %r. Full terms: %r" %
                          (term, expected, terms))
Exemple #6
0
 def test_parse(self):
     lib = self.lib
     lib.query_with_refresh(SoundcloudQuery("dummy search"))
     songs = list(lib._contents.values())
     assert len(songs) == 1
     s = songs[0]
     assert s("artist") == "ANDY C ram"
     assert s("date") == "2015-06-29"
     assert s("~year") == "2015"
     assert s("~#download_count") == 0
     assert s("~#playback_count") == 363310
     assert s("~#favoritings_count") == 10061
     assert s("~#rating") == 1.0
     assert s("~#playcount") == 4
     assert int(s("~#bitrate")) == 128
 def test_extract_date(self):
     now = int(time.time())
     terms = SoundcloudQuery("#(date>today)", clock=lambda: now).terms
     self.failUnlessEqual(terms['created_at[from]'].pop(),
                          convert_time(now - 86400))
Exemple #8
0
 def test_artwork_url(self):
     lib = SoundcloudLibrary(self.FakeClient())
     lib.query_with_refresh(SoundcloudQuery(""))
     s = list(lib._contents.values())[0]
     url = s("artwork_url")
     assert url == "https://i1.sndcdn.com/artworks-000121689963-0b0pdr-t500x500.jpg"
Exemple #9
0
 def query(self, text, sort=None, star=STAR):
     values = self._contents.values()
     try:
         return SoundcloudQuery(text).filter(values)
     except SoundcloudQuery.error:
         return values
 def test_extract_unsupported(self):
     self.failUnlessEqual(
         SoundcloudQuery("musicbrainz_discid=12345").type,
         QueryType.INVALID)