Пример #1
0
 def test_take_not_srt(self):
     matcher = search.TracksMatcher("foo", keyword_tags=['artist'])
     tracks = [track.Track(x) for x in ('foo', 'bar', 'baz', 'quux')]
     tracks[0].set_tag_raw('artist', 'foooo')
     tracks[2].set_tag_raw('artist', 'foooooo')
     gen = search.search_tracks(tracks, [matcher])
     self.assertEqual(gen.next().track, tracks[0])
     self.assertEqual(gen.next().track, tracks[2])
     self.assertRaises(StopIteration, gen.next)
Пример #2
0
 def test_take_not_srt(self):
     matcher = search.TracksMatcher("foo", keyword_tags=['artist'])
     tracks = [track.Track(x) for x in ('foo', 'bar', 'baz', 'quux')]
     tracks[0].set_tag_raw('artist', 'foooo')
     tracks[2].set_tag_raw('artist', 'foooooo')
     gen = search.search_tracks(tracks, [matcher])
     assert gen.next().track == tracks[0]
     assert gen.next().track == tracks[2]
     with pytest.raises(StopIteration):
         gen.next()
Пример #3
0
 def test_take_not_srt(self):
     matcher = search.TracksMatcher("foo", keyword_tags=['artist'])
     tracks = [track.Track(x) for x in ('foo', 'bar', 'baz', 'quux')]
     tracks[0].set_tag_raw('artist', 'foooo')
     tracks[2].set_tag_raw('artist', 'foooooo')
     gen = search.search_tracks(tracks, [matcher])
     assert gen.next().track == tracks[0]
     assert gen.next().track == tracks[2]
     with pytest.raises(StopIteration):
         gen.next()
Пример #4
0
 def test_search_tracks(self):
     matcher = search.TracksMatcher("foo", keyword_tags=['artist'])
     tracks = [track.Track(x) for x in ('foo', 'bar', 'baz', 'quux')]
     tracks = [search.SearchResultTrack(tr) for tr in tracks]
     tracks[0].track.set_tag_raw('artist', 'foooo')
     tracks[2].track.set_tag_raw('artist', 'foooooo')
     gen = search.search_tracks(tracks, [matcher])
     assert next(gen) == tracks[0]
     assert next(gen) == tracks[2]
     with pytest.raises(StopIteration):
         next(gen)
Пример #5
0
def get_album_tracks(tracksiter, track, artist_compilations=False):
    """
        Get any tracks from the given iterable that appear to be part of
        the same album as track. If track is in the iterable, it will be
        included in the result. If there is insufficient information to
        determine the album, the empty list will be returned, even if the
        track is in the iterable.
    """
    if not all(track.get_tag_raw(t) for t in ['artist', 'album']):
        return []
    matchers = map(lambda t: TracksMatcher(track.get_tag_search(t, artist_compilations=artist_compilations)), ['artist', 'album'])
    return (r.track for r in search_tracks(tracksiter, matchers))
Пример #6
0
def get_album_tracks(tracksiter, track, artist_compilations=False):
    """
        Get any tracks from the given iterable that appear to be part of
        the same album as track. If track is in the iterable, it will be
        included in the result. If there is insufficient information to
        determine the album, the empty list will be returned, even if the
        track is in the iterable.
    """
    if not all(track.get_tag_raw(t) for t in ['artist', 'album']):
        return []
    matchers = map(
        lambda t: TracksMatcher(
            track.get_tag_search(t, artist_compilations=artist_compilations)),
        ['artist', 'album'])
    return (r.track for r in search_tracks(tracksiter, matchers))