def test_people(self):
     q = AudioFile([("performer:vocals", "A"), ("performer:guitar", "B"),
                    ("performer", "C"), ("arranger", "A"),
                    ("albumartist", "B"), ("artist", "C")])
     self.failUnlessEqual(q.list("~people"), ["C", "B", "A"])
     self.failUnlessEqual(q.list("~people:roles"),
                      ["C", "B (Guitar)", "A (Arrangement, Vocals)"])
 def test_people(self):
     q = AudioFile([("performer:vocals", "A"), ("performer:guitar", "B"),
                    ("performer", "C"), ("arranger", "A"),
                    ("albumartist", "B"), ("artist", "C")])
     self.failUnlessEqual(q.list("~people"), ["C", "B", "A"])
     self.failUnlessEqual(q.list("~people:roles"),
                          ["C", "B (Guitar)", "A (Arrangement, Vocals)"])
    def test_people_individuals(self):
        q = AudioFile({"artist": "A\nX", "albumartist": "Various Artists"})
        self.failUnlessEqual(q.list("~people:real"), ["A", "X"])

        lonely = AudioFile({"artist": "various artists", "title": "blah"})
        self.failUnlessEqual(lonely.list("~people:real"), ["various artists"])

        lots = AudioFile({"artist": "Various Artists", "albumartist": "V.A."})
        self.failUnlessEqual(lots.list("~people:real"), ["Various Artists"])
    def test_performers_multi_value(self):
        q = AudioFile([("performer:vocals", "X\nA\nY"), ("performer:guitar", "Y\nB\nA"), ("performer", "C\nF\nB\nA")])

        self.failUnlessEqual(set(q.list("~performer")), {"A", "B", "C", "F", "X", "Y"})

        self.failUnlessEqual(
            set(q.list("~performer:roles")),
            {"A (Guitar, Vocals)", "C", "B (Guitar)", "X (Vocals)", "Y (Guitar, Vocals)", "F"},
        )
Example #5
0
    def test_people_individuals(self):
        q = AudioFile({"artist": "A\nX", "albumartist": "Various Artists"})
        self.failUnlessEqual(q.list("~people:real"), ["A", "X"])

        lonely = AudioFile({"artist": "various artists", "title": "blah"})
        self.failUnlessEqual(lonely.list("~people:real"), ["various artists"])

        lots = AudioFile({"artist": "Various Artists", "albumartist": "V.A."})
        self.failUnlessEqual(lots.list("~people:real"), ["Various Artists"])
 def test_people_mix(self):
     q = AudioFile([
         ("performer:arrangement", "A"),
         ("arranger", "A"),
         ("performer", "A"),
         ("performer:foo", "A"),
     ])
     self.failUnlessEqual(q.list("~people"), ["A"])
     self.failUnlessEqual(q.list("~people:roles"),
                          ["A (Arrangement, Arrangement, Foo)"])
 def test_people_mix(self):
     q = AudioFile([
         ("performer:arrangement", "A"),
         ("arranger", "A"),
         ("performer", "A"),
         ("performer:foo", "A"),
     ])
     self.failUnlessEqual(q.list("~people"), ["A"])
     self.failUnlessEqual(q.list("~people:roles"),
                          ["A (Arrangement, Arrangement, Foo)"])
Example #8
0
 def test_remove(self):
     song = AudioFile()
     song.add("foo", "bar")
     song.add("foo", "another")
     song.add("foo", "one more")
     song.remove("foo", "another")
     self.failUnlessEqual(song.list("foo"), ["bar", "one more"])
     song.remove("foo", "bar")
     self.failUnlessEqual(song.list("foo"), ["one more"])
     song.remove("foo", "one more")
     self.failIf("foo" in song)
 def test_remove(self):
     song = AudioFile()
     song.add("foo", "bar")
     song.add("foo", "another")
     song.add("foo", "one more")
     song.remove("foo", "another")
     self.failUnlessEqual(song.list("foo"), ["bar", "one more"])
     song.remove("foo", "bar")
     self.failUnlessEqual(song.list("foo"), ["one more"])
     song.remove("foo", "one more")
     self.failIf("foo" in song)
    def test_people_multi_value(self):
        q = AudioFile([
            ("arranger", "A\nX"),
            ("performer", "A\nY"),
            ("performer:foo", "A\nX"),
        ])

        self.failUnlessEqual(q.list("~people"), ["A", "Y", "X"])
        self.failUnlessEqual(
            q.list("~people:roles"),
            ["A (Arrangement, Foo)", "Y", "X (Arrangement, Foo)"])
    def test_people_multi_value(self):
        q = AudioFile([
            ("arranger", "A\nX"),
            ("performer", "A\nY"),
            ("performer:foo", "A\nX"),
        ])

        self.failUnlessEqual(q.list("~people"), ["A", "Y", "X"])
        self.failUnlessEqual(
            q.list("~people:roles"),
            ["A (Arrangement, Foo)", "Y", "X (Arrangement, Foo)"])
 def test_peoplesort(self):
     q = AudioFile([("performer:vocals", "The A"),
                    ("performersort:vocals", "A, The"),
                    ("performer:guitar", "The B"),
                    ("performersort:guitar", "B, The"),
                    ("performer", "The C"), ("performersort", "C, The"),
                    ("albumartist", "The B"),
                    ("albumartistsort", "B, The")])
     self.failUnlessEqual(q.list("~peoplesort"),
                          ["B, The", "C, The", "A, The"])
     self.failUnlessEqual(q.list("~peoplesort:roles"),
                          ["B, The (Guitar)", "C, The", "A, The (Vocals)"])
Example #13
0
    def test_list(self):
        for key in bar_1_1.realkeys():
            self.failUnlessEqual(bar_1_1.list(key), [bar_1_1(key)])

        af = AudioFile({"~filename": fsnative(u"foo")})
        self.failUnlessEqual(af.list("artist"), [])
        self.failUnlessEqual(af.list("title"), [af("title")])
        self.failUnlessEqual(af.list("not a key"), [])

        self.failUnlessEqual(len(bar_2_1.list("artist")), 2)
        self.failUnlessEqual(bar_2_1.list("artist"),
                             bar_2_1["artist"].split("\n"))
Example #14
0
    def test_list(self):
        for key in bar_1_1.realkeys():
            self.failUnlessEqual(bar_1_1.list(key), [bar_1_1(key)])

        af = AudioFile({"~filename": fsnative(u"foo")})
        self.failUnlessEqual(af.list("artist"), [])
        self.failUnlessEqual(af.list("title"), [af("title")])
        self.failUnlessEqual(af.list("not a key"), [])

        self.failUnlessEqual(len(bar_2_1.list("artist")), 2)
        self.failUnlessEqual(bar_2_1.list("artist"),
                             bar_2_1["artist"].split("\n"))
 def test_peoplesort(self):
     q = AudioFile([("performer:vocals", "The A"),
                    ("performersort:vocals", "A, The"),
                    ("performer:guitar", "The B"),
                    ("performersort:guitar", "B, The"),
                    ("performer", "The C"),
                    ("performersort", "C, The"),
                    ("albumartist", "The B"),
                    ("albumartistsort", "B, The")])
     self.failUnlessEqual(q.list("~peoplesort"),
                          ["B, The", "C, The", "A, The"])
     self.failUnlessEqual(q.list("~peoplesort:roles"),
                          ["B, The (Guitar)", "C, The", "A, The (Vocals)"])
Example #16
0
 def test_add(self):
     song = AudioFile()
     self.failIf("foo" in song)
     song.add("foo", "bar")
     self.failUnlessEqual(song["foo"], "bar")
     song.add("foo", "another")
     self.failUnlessEqual(song.list("foo"), ["bar", "another"])
 def test_add(self):
     song = AudioFile()
     self.failIf("foo" in song)
     song.add("foo", "bar")
     self.failUnlessEqual(song["foo"], "bar")
     song.add("foo", "another")
     self.failUnlessEqual(song.list("foo"), ["bar", "another"])
Example #18
0
    def test_performers_multi_value(self):
        q = AudioFile([
            ("performer:vocals", "X\nA\nY"),
            ("performer:guitar", "Y\nB\nA"),
            ("performer", "C\nB\nA"),
        ])

        self.failUnlessEqual(set(q.list("~performer")),
                             {"A", "B", "C", "X", "Y"})

        self.failUnlessEqual(
            set(q.list("~performer:roles")), {
                "A (Guitar, Vocals)",
                "C",
                "B (Guitar)",
                "X (Vocals)",
                "Y (Guitar, Vocals)",
            })
 def test_change(self):
     song = AudioFile()
     song.add("foo", "bar")
     song.add("foo", "another")
     song.change("foo", "bar", "one more")
     self.failUnlessEqual(song.list("foo"), ["one more", "another"])
     song.change("foo", "does not exist", "finally")
     self.failUnlessEqual(song["foo"], "finally")
     song.change("foo", "finally", "we're done")
     self.failUnlessEqual(song["foo"], "we're done")
Example #20
0
 def test_change(self):
     song = AudioFile()
     song.add("foo", "bar")
     song.add("foo", "another")
     song.change("foo", "bar", "one more")
     self.failUnlessEqual(song.list("foo"), ["one more", "another"])
     song.change("foo", "does not exist", "finally")
     self.failUnlessEqual(song["foo"], "finally")
     song.change("foo", "finally", "we're done")
     self.failUnlessEqual(song["foo"], "we're done")
Example #21
0
 def _score(cls, t: DidlMusicTrack, song: AudioFile) -> float:
     d = t.to_dict()
     try:
         person = song.list("~people")[0]
     except IndexError:
         person = None
     album = song("album")
     score = (int(
         remove_punctuation(t.title).lower() == remove_punctuation(
             song("title")).lower()) +
              int(bool(person) and person in d.values()) +
              int(bool(album) and album in d.get("album", "")))
     if cls.DEBUG:
         print_d("%.1f for %s (%s)" % (score, t.title, d))
     return score
Example #22
0
    def test_build_mbids(self):
        Release = brainz.mb.Release
        build_song_data = brainz.widgets.build_song_data
        apply_options = brainz.widgets.apply_options
        apply_to_song = brainz.widgets.apply_to_song

        release = Release(TEST_DATA)
        track = release.tracks[1]
        meta = build_song_data(release, track)
        apply_options(meta, True, False, False, True)
        dummy = AudioFile()
        apply_to_song(meta, dummy)

        self.assertEqual(dummy("musicbrainz_releasetrackid"), track.id)
        self.assertEqual(dummy("musicbrainz_albumid"), release.id)
        self.assertEqual(
            dummy.list("musicbrainz_artistid"),
            [u'410c9baf-5469-44f6-9852-826524b80c61',
             u'146c01d0-d3a2-44c3-acb5-9208bce75e14'])
Example #23
0
    def test_build_mbids_labelid(self):
        Release = brainz.mb.Release
        build_song_data = brainz.widgets.build_song_data
        apply_options = brainz.widgets.apply_options
        apply_to_song = brainz.widgets.apply_to_song

        release = Release(TEST_DATA)
        track = release.tracks[1]
        meta = build_song_data(release, track)
        apply_options(meta, True, False, False, True, True)
        dummy = AudioFile()
        apply_to_song(meta, dummy)

        self.assertEqual(dummy("musicbrainz_releasetrackid"), track.id)
        self.assertEqual(dummy("musicbrainz_albumid"), release.id)
        self.assertEqual(dummy.list("musicbrainz_artistid"), [
            u'410c9baf-5469-44f6-9852-826524b80c61',
            u'146c01d0-d3a2-44c3-acb5-9208bce75e14'
        ])
        self.assertEqual(dummy("labelid"), u"pgram002")
Example #24
0
 def test_blank_tag_handling_list(self):
     q = AudioFile([("artist", "A\n\nB\n"), ("performer", ""),
                    ("albumartist", "C")])
     self.failUnlessEqual(q.list("performer"), [])
     self.failUnlessEqual(q.list("~people"), ["A", "B", "C"])
 def test_remove_unknown(self):
     song = AudioFile()
     song.add("foo", "bar")
     song.remove("foo", "not in list")
     song.remove("nope")
     self.failUnlessEqual(song.list("foo"), ["bar"])
Example #26
0
 def test_performers(self):
     q = AudioFile([("performer:vocals", "A"), ("performer:guitar", "B"),
                    ("performer", "C")])
     self.failUnlessEqual(set(q.list("~performers")), {"A", "B", "C"})
     self.failUnlessEqual(set(q.list("~performers:roles")),
                          {"A (Vocals)", "B (Guitar)", "C"})
Example #27
0
 def test_remove_unknown(self):
     song = AudioFile()
     song.add("foo", "bar")
     song.remove("foo", "not in list")
     song.remove("nope")
     self.failUnlessEqual(song.list("foo"), ["bar"])
 def test_performers(self):
     q = AudioFile([("performer:vocals", "A"), ("performer:guitar", "B"),
                    ("performer", "C")])
     self.failUnlessEqual(set(q.list("~performers")), {"A", "B", "C"})
     self.failUnlessEqual(set(q.list("~performers:roles")),
                          {"A (Vocals)", "B (Guitar)", "C"})