Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
    def testRemoveAllComments(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

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

            darg = u":{}".format(d) if d else ""
            larg = u":{}".format(l) if l else ""
            opts = [
                u"--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_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)

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

        opts = [u"--remove-all-comments", self.test_file]
        self._addVersionOpt(version, opts)

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

        af = eyed3.load(self.test_file)
        assert_equal(len(af.tag.comments), 0)
Ejemplo n.º 4
0
def testReadEmptyMp3():
    with RedirectStdStreams() as out:
        args, _, config = main.parseCommandLine(
            [os.path.join(DATA_D, "test.mp3")])
        retval = main.main(args, config)
        assert_equal(retval, 0)
    assert_not_equal(out.stderr.read().find("No ID3 v1.x/v2.x tag found"), -1)
Ejemplo n.º 5
0
def testLameInfoPlugin():
    test_file = Path(DATA_D) / "mp3_samples/mpeg2.5 12.000kHz __vbr__ simple.mp3"
    with RedirectStdStreams() as plugin_out:
        args, _, config = main.parseCommandLine(["-P", "lameinfo", str(test_file)])
        retval = main.main(args, config)
        assert retval == 0

    stdout = plugin_out.stdout.read()
    assert stdout[stdout.index("Encoder Version"):].strip() == \
"""
Encoder Version     : LAME3.99r
LAME Tag Revision   : 0
VBR Method          : Variable Bitrate method2 (mtrh)
Lowpass Filter      : 6000
Radio Replay Gain   : 12.2 dB (Set automatically)
Encoding Flags      : --nspsytune --nssafejoint
ATH Type            : 5
Bitrate (Minimum)   : 8
Encoder Delay       : 576 samples
Encoder Padding     : 960 samples
Noise Shaping       : 1
Stereo Mode         : Stereo
Unwise Settings     : False
Sample Frequency    : 44.1 kHz
MP3 Gain            : 0 (+0.0 dB)
Preset              : V0
Surround Info       : None
Music Length        : 67.88 KB
Music CRC-16        : 8707
LAME Tag CRC-16     : 0000
""".strip()
Ejemplo n.º 6
0
def testReadEmptyMp3():
    with RedirectStdStreams() as out:
        args, _, config = main.parseCommandLine([os.path.join(DATA_D,
                                                              "test.mp3")])
        retval = main.main(args, config)
        assert retval == 0
    assert out.stderr.read().find("No ID3 v1.x/v2.x tag found") != -1
Ejemplo n.º 7
0
 def func(audiofile, args, expected_retval=0, reload_version=None):
     try:
         args, _, config = main.parseCommandLine(args + [audiofile.path])
         retval = main.main(args, config)
     except SystemExit as sys_exit:
         retval = sys_exit.code
     assert retval == expected_retval
     return eyed3.load(audiofile.path, tag_version=reload_version)
Ejemplo n.º 8
0
def _eyeD3(audiofile, args, expected_retval=0):
    try:
        args, _, config = main.parseCommandLine(args + [audiofile.path])
        retval = main.main(args, config)
    except SystemExit as exit:
        retval = exit.code
    assert retval == expected_retval
    return eyed3.load(audiofile.path)
Ejemplo n.º 9
0
 def func(audiofile, args, expected_retval=0, reload_version=None):
     try:
         args, _, config = main.parseCommandLine(args + [audiofile.path])
         retval = main.main(args, config)
     except SystemExit as exit:
         retval = exit.code
     assert retval == expected_retval
     return eyed3.load(audiofile.path, tag_version=reload_version)
Ejemplo n.º 10
0
    def testUniqueFileId_N(self):
        # Add 3
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                       "--unique-file-id=Engine:Kid",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 3
        assert af.tag.unique_file_ids.get("Travis").uniq_id == b"Me"
        assert af.tag.unique_file_ids.get("Engine").uniq_id == b"Kid"
        assert af.tag.unique_file_ids.get(b"Owner").uniq_id == b"Kid"

        # Remove 2
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       "--unique-file-id=Engine:",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1

        # Remove not found ID
        with RedirectStdStreams() as out:
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        sout = out.stdout.read()
        assert "Unique file ID 'Travis' not found" in sout

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
Ejemplo n.º 11
0
    def testUniqueFileId_N(self):
        # Add 3
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                       "--unique-file-id=Engine:Kid",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 3
        assert af.tag.unique_file_ids.get("Travis").uniq_id == b"Me"
        assert af.tag.unique_file_ids.get("Engine").uniq_id == b"Kid"
        assert af.tag.unique_file_ids.get(b"Owner").uniq_id == b"Kid"

        # Remove 2
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       "--unique-file-id=Engine:",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1

        # Remove not found ID
        with RedirectStdStreams() as out:
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        sout = out.stdout.read()
        assert "Unique file ID 'Travis' not found" in sout

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
Ejemplo n.º 12
0
def _runPlugin(afile, plugin) -> str:
    with RedirectStdStreams() as plugin_out:
        args, _, config = main.parseCommandLine(
            ["-P", plugin, str(afile.path)])
        assert main.main(args, config) == 0

    stdout = plugin_out.stdout.read().strip()
    print(stdout)
    return stdout
Ejemplo n.º 13
0
def testLameInfoPlugin_None():
    test_file = Path(DATA_D) / "test.mp3"
    with RedirectStdStreams() as plugin_out:
        args, _, config = main.parseCommandLine(["-P", "lameinfo", str(test_file)])
        retval = main.main(args, config)
        assert retval == 0

    stdout = plugin_out.stdout.read()
    assert stdout[stdout.index("--\n") + 3:].strip() == "No LAME Tag"
Ejemplo n.º 14
0
    def testUniqueFileId_1(self):
        with RedirectStdStreams() as out:
            assert out
            args, _, config = main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                                     self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
        assert af.tag.unique_file_ids.get(b"Travis").uniq_id == b"Me"
Ejemplo n.º 15
0
    def testUniqueFileId_1(self):
        with RedirectStdStreams() as out:
            assert out
            args, _, config = main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                                     self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
        assert af.tag.unique_file_ids.get(b"Travis").uniq_id == b"Me"
Ejemplo n.º 16
0
    def testNewTagComposer(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--composer=H.R.", 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
            assert af.tag.composer == "H.R."
Ejemplo n.º 17
0
    def testNewTagNonStdGenre(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in (("-G", "108", "--non-std-genre", self.test_file),
                     ("--genre=108", "--non-std-genre", 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.tag.non_std_genre.name == "108"
            assert af.tag.non_std_genre.id is None
Ejemplo n.º 18
0
    def testNewTagComposer(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--composer=H.R.", 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
            assert af.tag.composer == "H.R."
Ejemplo n.º 19
0
    def testNewTagOrigRelease(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["--orig-release-date=1981", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.original_release_date.year, 1981)
Ejemplo n.º 20
0
    def testNewTagOrigRelease(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--orig-release-date=1981", 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)
            assert (af.tag.original_release_date.year == 1981)
Ejemplo n.º 21
0
    def testNewTagAlbum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-A", "Psychedelic Jungle", self.test_file],
                      ["--album=Psychedelic Jungle", 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)
            assert (af.tag.album == "Psychedelic Jungle")
Ejemplo n.º 22
0
    def testNewTagArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-a", "The Cramps", self.test_file],
                     ["--artist=The Cramps", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.artist, u"The Cramps")
Ejemplo n.º 23
0
    def testNewTagTrackNum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-n", "14", self.test_file],
                      ["--track=14", 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)
            assert (af.tag.track_num[0] == 14)
Ejemplo n.º 24
0
    def testNewTagTitle(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-t", "Green Door", self.test_file],
                     ["--title=Green Door", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.title, u"Green Door")
Ejemplo n.º 25
0
    def testNewTagAlbumArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-b", "Various Artists", self.test_file],
                      ["--album-artist=Various Artists", 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
            assert af.tag.album_artist == "Various Artists"
    def testNewTagAlbumArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-b", "Various Artists", self.test_file],
                      ["--album-artist=Various Artists", 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
            assert af.tag.album_artist == u"Various Artists"
Ejemplo n.º 27
0
    def testNewTagArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-a", "The Cramps", self.test_file],
                      ["--artist=The Cramps", 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
            assert af.tag.artist == "The Cramps"
Ejemplo n.º 28
0
    def testNewTagTrackNum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-n", "14", self.test_file],
                     ["--track=14", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.track_num[0], 14)
Ejemplo n.º 29
0
    def testNewTagTitle(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-t", "Green Door", self.test_file],
                      ["--title=Green Door", 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)
            assert (af.tag.title == "Green Door")
Ejemplo n.º 30
0
    def testNewTagAlbum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-A", "Psychedelic Jungle", self.test_file],
                     ["--album=Psychedelic Jungle", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.album, u"Psychedelic Jungle")
Ejemplo n.º 31
0
    def testNewTagPublisher(self):
        for expected, opts in [
            ("SST", ["--publisher", "SST", self.test_file]),
            ("Dischord", ["--publisher=Dischord", self.test_file]),
        ]:

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.publisher, expected)
Ejemplo n.º 32
0
    def testNewTagGenre(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-G", "Rock", self.test_file],
                     ["--genre=Rock", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.genre.name, "Rock")
            assert_equal(af.tag.genre.id, 17)
Ejemplo n.º 33
0
    def testNewTagRecordingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["--recording-date=1993-10-30", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.recording_date.year, 1993)
            assert_equal(af.tag.recording_date.month, 10)
            assert_equal(af.tag.recording_date.day, 30)
Ejemplo n.º 34
0
    def testNewTagRecordingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--recording-date=1993-10-30", 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)
            assert (af.tag.recording_date.year == 1993)
            assert (af.tag.recording_date.month == 10)
            assert (af.tag.recording_date.day == 30)
Ejemplo n.º 35
0
    def testNewTagPublisher(self):
        for expected, opts in [
                ("SST", ["--publisher", "SST", self.test_file]),
                ("Dischord", ["--publisher=Dischord", self.test_file]),
               ]:

            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)
            assert (af.tag.publisher == expected)
Ejemplo n.º 36
0
    def testNewTagGenre(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-G", "Rock", self.test_file],
                      ["--genre=Rock", 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)
            assert (af.tag.genre.name == "Rock")
            assert (af.tag.genre.id == 17)
Ejemplo n.º 37
0
    def testNewTagReleaseDate(self, version=id3.ID3_DEFAULT_VERSION):
        for date in ["1981", "1981-03-06", "1981-03"]:
            orig_date = core.Date.parse(date)

            for opts in [["--release-date=%s" % str(date), self.test_file]]:
                self._addVersionOpt(version, opts)

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

                af = eyed3.load(self.test_file)
                assert_is_not_none(af)
                assert_is_not_none(af.tag)
                assert_equal(af.tag.release_date, orig_date)
Ejemplo n.º 38
0
    def testNewTagReleaseDate(self, version=id3.ID3_DEFAULT_VERSION):
        for date in ["1981", "1981-03-06", "1981-03"]:
            orig_date = core.Date.parse(date)

            for opts in [ ["--release-date=%s" % str(date), 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)
                assert (af.tag.release_date == orig_date)
Ejemplo n.º 39
0
    def testNewTagBpm(self):
        for expected, opts in [ (1, ["--bpm=1", self.test_file]),
                                (180, ["--bpm=180", self.test_file]),
                                (117, ["--bpm", "116.7", self.test_file]),
                                (116, ["--bpm", "116.4", self.test_file]),
                              ]:

            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)
            assert (af.tag.bpm == expected)
Ejemplo n.º 40
0
    def testNewTagBpm(self):
        for expected, opts in [ (1, ["--bpm=1", self.test_file]),
                                (180, ["--bpm=180", self.test_file]),
                                (117, ["--bpm", "116.7", self.test_file]),
                                (116, ["--bpm", "116.4", self.test_file]),
                              ]:

            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)
            assert (af.tag.bpm == expected)
Ejemplo n.º 41
0
    def testNewTagYear(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-Y", "1981", self.test_file],
                      ["--release-year=1981", 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)
            if version == id3.ID3_V2_3:
                assert (af.tag.original_release_date.year == 1981)
            else:
                assert (af.tag.release_date.year == 1981)
Ejemplo n.º 42
0
    def testNewTagEncodingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--encoding-date=2012-10-23T20:22", 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)
            assert (af.tag.encoding_date.year == 2012)
            assert (af.tag.encoding_date.month == 10)
            assert (af.tag.encoding_date.day == 23)
            assert (af.tag.encoding_date.hour == 20)
            assert (af.tag.encoding_date.minute == 22)
Ejemplo n.º 43
0
    def testNewTagPlayCount(self):
        for expected, opts in [ (0, ["--play-count=0", self.test_file]),
                                (1, ["--play-count=+1", self.test_file]),
                                (6, ["--play-count=+5", self.test_file]),
                                (7, ["--play-count=7", self.test_file]),
                                (10000, ["--play-count=10000", self.test_file]),
                              ]:

            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)
            assert (af.tag.play_count == expected)
Ejemplo n.º 44
0
    def testNewTagTaggingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--tagging-date=2012-10-23T20:22", 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)
            assert (af.tag.tagging_date.year == 2012)
            assert (af.tag.tagging_date.month == 10)
            assert (af.tag.tagging_date.day == 23)
            assert (af.tag.tagging_date.hour == 20)
            assert (af.tag.tagging_date.minute == 22)
Ejemplo n.º 45
0
    def testNewTagTaggingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["--tagging-date=2012-10-23T20:22", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.tagging_date.year, 2012)
            assert_equal(af.tag.tagging_date.month, 10)
            assert_equal(af.tag.tagging_date.day, 23)
            assert_equal(af.tag.tagging_date.hour, 20)
            assert_equal(af.tag.tagging_date.minute, 22)
Ejemplo n.º 46
0
    def testNewTagPlayCount(self):
        for expected, opts in [ (0, ["--play-count=0", self.test_file]),
                                (1, ["--play-count=+1", self.test_file]),
                                (6, ["--play-count=+5", self.test_file]),
                                (7, ["--play-count=7", self.test_file]),
                                (10000, ["--play-count=10000", self.test_file]),
                              ]:

            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)
            assert (af.tag.play_count == expected)
Ejemplo n.º 47
0
    def testNewTagTrackTotal(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        for opts in [ ["-N", "14", self.test_file],
                      ["--track-total=14", 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)
            assert (af.tag.track_num[1] == 14)
Ejemplo n.º 48
0
    def testNewTagTrackTotal(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        for opts in [["-N", "14", self.test_file],
                     ["--track-total=14", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.track_num[1], 14)
Ejemplo n.º 49
0
    def testNewTagSimpleComment(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        for opts in [["-c", "Starlette", self.test_file],
                     ["--comment=Starlette", self.test_file]]:
            self._addVersionOpt(version, opts)

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

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.comments[0].text, "Starlette")
            assert_equal(af.tag.comments[0].description, "")
Ejemplo n.º 50
0
    def testNewTagSimpleComment(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        for opts in [ ["-c", "Starlette", self.test_file],
                      ["--comment=Starlette", 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)
            assert (af.tag.comments[0].text == "Starlette")
            assert (af.tag.comments[0].description == "")