Пример #1
0
    def testAddRemoveLyrics(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        comment = "Why can't I be you?"
        for i, (c, d, l) in enumerate([(comment, "c0", None),
                                       (comment, "c1", None),
                                       (comment, "c2", 'eng'),
                                       ("¿Por qué no puedo ser tú ?", "c2",
                                        'esp'),
                                      ]):

            darg = ":{}".format(d) if d else ""
            larg = ":{}".format(l) if l else ""
            opts = ["--add-comment={c}{darg}{larg}".format(**locals()),
                    self.test_file]

            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)

            tag_comment = af.tag.comments.get(d or "",
                                              lang=utils.b(l if l else "eng"))
            assert (tag_comment.text == c)
            assert (tag_comment.description == d or "")
            assert (tag_comment.lang == utils.b(l if l else "eng"))

        for d, l in [("c0", None),
                     ("c1", None),
                     ("c2", "eng"),
                     ("c2", "esp"),
                    ]:

            larg = ":{}".format(l) if l else ""
            opts = ["--remove-comment={d}{larg}".format(**locals()),
                    self.test_file]
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            tag_comment = af.tag.comments.get(d,
                                              lang=utils.b(l if l else "eng"))
            assert tag_comment is None

        assert (len(af.tag.comments) == 0)
Пример #2
0
    def testAddRemoveLyrics(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        comment = "Why can't I be you?"
        for i, (c, d, l) in enumerate([(comment, "c0", None),
                                       (comment, "c1", None),
                                       (comment, "c2", 'eng'),
                                       ("¿Por qué no puedo ser tú ?", "c2",
                                        'esp'),
                                      ]):

            darg = ":{}".format(d) if d else ""
            larg = ":{}".format(l) if l else ""
            opts = ["--add-comment={c}{darg}{larg}".format(**locals()),
                    self.test_file]

            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)

            tag_comment = af.tag.comments.get(d or "",
                                              lang=utils.b(l if l else "eng"))
            assert (tag_comment.text == c)
            assert (tag_comment.description == d or "")
            assert (tag_comment.lang == utils.b(l if l else "eng"))

        for d, l in [("c0", None),
                     ("c1", None),
                     ("c2", "eng"),
                     ("c2", "esp"),
                    ]:

            larg = ":{}".format(l) if l else ""
            opts = ["--remove-comment={d}{larg}".format(**locals()),
                    self.test_file]
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            tag_comment = af.tag.comments.get(d,
                                              lang=utils.b(l if l else "eng"))
            assert tag_comment is None

        assert (len(af.tag.comments) == 0)