Example #1
0
def metadata(images=(), **meta):
    new_metadata = Metadata(**meta)

    for current_image in images:
        new_metadata.addImage(*current_image)

    return new_metadata
def test_overwrites_existing_attached_pictures(mp3):
    filename = mp3(APIC_FRONT=("image/jpeg", "", b"front-cover.jpg"))
    metadata = Metadata()

    container.save(filename, metadata)
    assert_that(container.load(filename).images, has_length(0), "removed images")

    metadata.addImage(mime="image/jpeg", data=b"salers.jpg", desc="Front")
    container.save(filename, metadata)

    assert_that(container.load(filename).images, has_length(1), "updated images")
def test_stores_several_pictures_sharing_the_same_description(mp3):
    filename = mp3()
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"salers.jpg", desc="Front Cover")
    metadata.addImage("image/jpeg", b"ragber.jpg", desc="Front Cover")

    container.save(filename, metadata)

    assert_that(container.load(filename).images, contains_inanyorder(
        Image("image/jpeg", b"salers.jpg", type_=Image.OTHER, desc="Front Cover"),
        Image("image/jpeg", b"ragber.jpg", type_=Image.OTHER, desc="Front Cover (2)"),
    ))
def test_stores_several_pictures(flac):
    filename = flac()
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"front-1.jpg", desc="Front Cover")
    metadata.addImage("image/jpeg", b"front-2.jpg", desc="Front Cover")

    container.save(filename, metadata)

    assert_that(container.load(filename).images, contains_inanyorder(
        Image("image/jpeg", b"front-1.jpg", type_=Image.OTHER, desc="Front Cover"),
        Image("image/jpeg", b"front-2.jpg", type_=Image.OTHER, desc="Front Cover (2)"),
    ))
def test_overwrites_existing_attached_pictures(mp3):
    filename = mp3(APIC_FRONT=("image/jpeg", "", b"front-cover.jpg"))
    metadata = Metadata()

    container.save(filename, metadata)
    assert_that(
        container.load(filename).images, has_length(0), "removed images")

    metadata.addImage(mime="image/jpeg", data=b"salers.jpg", desc="Front")
    container.save(filename, metadata)

    assert_that(
        container.load(filename).images, has_length(1), "updated images")
def test_round_trips_metadata_to_file(mp3):
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"salers.jpg", Image.FRONT_COVER)
    metadata["release_name"] = "Album"
    metadata["compilation"] = True
    metadata["lead_performer"] = "Lead Performer"
    metadata["lead_performer_region"] = ("CA", "MTL")
    metadata["isnis"] = {
        "Lead Performer": "0000123456789",
        "Lyricist": "0000123456789"
    }
    metadata["ipis"] = {"Lyricist": "0000123456789"}
    metadata["iswc"] = "T-345246800-1"
    metadata["guest_performers"] = [("Guitar", "Guitarist"),
                                    ("Guitar", "Bassist"),
                                    ("Piano", "Pianist")]
    metadata["label_name"] = "Label Name"
    metadata["production_company"] = "Production Company"
    metadata["production_company_region"] = ("CA", "MTL")
    metadata["catalog_number"] = "123 456-1"
    metadata["upc"] = "987654321111"
    metadata["recording_time"] = "2012-07-01"
    metadata["release_time"] = "2013-12-01"
    metadata["original_release_time"] = "1999-01-01"
    metadata["recording_studio"] = "Studio Name"
    metadata["recording_studio_region"] = ("CA", "MTL")
    metadata["recording_studio_address"] = "2020 des zinzins, Montreal"
    metadata["music_producer"] = "Music Producer"
    metadata["mixer"] = "Mixing Engineer"
    metadata["contributors"] = [("recording", "Recording Eng."),
                                ("mastering", "Mastering Eng."),
                                ("recording", "Assistant Recording Eng.")]
    metadata["comments"] = "Comments"
    metadata["primary_style"] = "Jazz"
    metadata["track_title"] = "Track Title"
    metadata["version_info"] = "Version Info"
    metadata["featured_guest"] = "Featured Guest"
    metadata["lyricist"] = ["Lyricist"]
    metadata["composer"] = ["Composer"]
    metadata["publisher"] = ["Publisher"]
    metadata["isrc"] = "ZZXX87654321"
    metadata["labels"] = "Tag1 Tag2 Tag3"
    metadata["lyrics"] = "Lyrics"
    metadata["language"] = "fra"
    metadata["tagger"] = "TGiT"
    metadata["tagger_version"] = "1.0"
    metadata["tagging_time"] = "2014-03-26 18:18:55"
    metadata["track_number"] = 3
    metadata["total_tracks"] = 5

    assert_can_be_saved_and_reloaded_with_same_state(mp3, metadata)
Example #7
0
def test_round_trips_metadata_to_file(flac):
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"honeycomb.jpg", Image.FRONT_COVER)
    metadata["release_name"] = "St-Henri"
    metadata["lead_performer"] = "Joel Miller"
    metadata["lead_performer_region"] = ("CA", "MTL")
    metadata["isnis"] = {
        "Joel Miller": "0000000123456789",
        "Rebecca Ann Maloy": "9876543210000000"
    }
    metadata["ipis"] = {
        "Joel Miller": "0000000123456789",
        "Rebecca Ann Maloy": "9876543210000000"
    }
    metadata["label_name"] = "Effendi Records Inc."
    metadata["primary_style"] = "Modern Jazz"
    metadata["recording_time"] = "2007-11-02"
    metadata["track_title"] = "Salsa Coltrane"
    metadata["isrc"] = "CABL31201254"
    metadata["iswc"] = "T-345246800-1"
    metadata["tagger"] = "TGiT"
    metadata["tagger_version"] = "1.0"
    metadata["tagging_time"] = "2014-03-26 18:18:55"
    metadata["track_number"] = 3
    metadata["total_tracks"] = 5
    metadata["recording_studio"] = "Effendi Records Inc."
    metadata["recording_studio_region"] = ("CA", "MTL")
    metadata["recording_studio_address"] = "2020 des zinzins, Montreal"
    metadata["production_company"] = "Effendi Records Inc."
    metadata["production_company_region"] = ("CA", "MTL")
    metadata["music_producer"] = "Joel Miller & Paul Johnston"
    metadata["lyricist"] = ["Joel Miller"]
    metadata["catalog_number"] = "001-002-003"
    metadata["upc"] = "123456789999"
    metadata["mixer"] = "Mixing Engineer"
    metadata["comments"] = "Comments of any nature"
    metadata["publisher"] = ["Who publishes the disc the track came from"]
    metadata["composer"] = ["Composer of the work"]
    metadata["version_info"] = "Specifics about that version of the track"
    metadata["lyrics"] = "Lyrics of the track"
    metadata["language"] = "Language of the lyrics"
    metadata["compilation"] = False
    metadata["featured_guest"] = "A collaborating artist"
    metadata["labels"] = "tag1, tag2, tag3"
    metadata["release_time"] = "2008-03-01"
    metadata["guest_performers"] = [("Guitar", "Guitarist"),
                                    ("Guitar", "Bassist"),
                                    ("Piano", "Pianist")]

    _assert_can_be_saved_and_reloaded_with_same_state(flac, metadata)
def test_overwrites_existing_attached_pictures(flac):
    filename = flac(PICTURES=(
        ("image/jpeg", PictureType.FRONT_COVER, "Front", b"front.jpg"),
        ("image/jpeg", PictureType.BACK_COVER, "Back", b"back.jpg")))

    metadata = Metadata()

    container.save(filename, metadata)
    assert_that(container.load(filename).images, has_length(0), "removed images")

    metadata.addImage(mime="image/jpeg", data=b"front.jpg", desc="Front")
    container.save(filename, metadata)

    assert_that(container.load(filename).images, has_length(1), "updated images")
Example #9
0
def test_updates_tags_and_replaces_images_when_updated():
    metadata = Metadata()
    metadata["artist"] = "Pascal Obispo"
    metadata.addImage("img/jpeg", "missing")

    other = Metadata()
    other["album"] = "Un jour comme aujourd'hui"
    other.addImage("img/png", "cover.png")

    metadata.update(other)
    assert_that(
        metadata,
        has_entries(artist="Pascal Obispo", album="Un jour comme aujourd'hui"),
        "updated tags")
    assert_that(metadata.images, contains(has_property("data", "cover.png")),
                "updated images")
Example #10
0
def test_round_trips_metadata_to_file(mp3):
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"salers.jpg", Image.FRONT_COVER)
    metadata["release_name"] = "Album"
    metadata["compilation"] = True
    metadata["lead_performer"] = "Lead Performer"
    metadata["lead_performer_region"] = ("CA", "MTL")
    metadata["isnis"] = {"Lead Performer": "0000123456789",
                         "Lyricist": "0000123456789"}
    metadata["ipis"] = {"Lyricist": "0000123456789"}
    metadata["iswc"] = "T-345246800-1"
    metadata["guest_performers"] = [("Guitar", "Guitarist"), ("Guitar", "Bassist"), ("Piano", "Pianist")]
    metadata["label_name"] = "Label Name"
    metadata["production_company"] = "Production Company"
    metadata["production_company_region"] = ("CA", "MTL")
    metadata["catalog_number"] = "123 456-1"
    metadata["upc"] = "987654321111"
    metadata["recording_time"] = "2012-07-01"
    metadata["release_time"] = "2013-12-01"
    metadata["original_release_time"] = "1999-01-01"
    metadata["recording_studio"] = "Studio Name"
    metadata["recording_studio_region"] = ("CA", "MTL")
    metadata["recording_studio_address"] = "2020 des zinzins, Montreal"
    metadata["music_producer"] = "Music Producer"
    metadata["mixer"] = "Mixing Engineer"
    metadata["contributors"] = [("recording", "Recording Eng."),
                                ("mastering", "Mastering Eng."),
                                ("recording", "Assistant Recording Eng.")]
    metadata["comments"] = "Comments"
    metadata["primary_style"] = "Jazz"
    metadata["track_title"] = "Track Title"
    metadata["version_info"] = "Version Info"
    metadata["featured_guest"] = "Featured Guest"
    metadata["lyricist"] = ["Lyricist"]
    metadata["composer"] = ["Composer"]
    metadata["publisher"] = ["Publisher"]
    metadata["isrc"] = "ZZXX87654321"
    metadata["labels"] = "Tag1 Tag2 Tag3"
    metadata["lyrics"] = "Lyrics"
    metadata["language"] = "fra"
    metadata["tagger"] = "TGiT"
    metadata["tagger_version"] = "1.0"
    metadata["tagging_time"] = "2014-03-26 18:18:55"
    metadata["track_number"] = 3
    metadata["total_tracks"] = 5

    assert_can_be_saved_and_reloaded_with_same_state(mp3, metadata)
Example #11
0
def test_overwrites_existing_attached_pictures(flac):
    filename = flac(PICTURES=(("image/jpeg", PictureType.FRONT_COVER, "Front",
                               b"front.jpg"),
                              ("image/jpeg", PictureType.BACK_COVER, "Back",
                               b"back.jpg")))

    metadata = Metadata()

    container.save(filename, metadata)
    assert_that(
        container.load(filename).images, has_length(0), "removed images")

    metadata.addImage(mime="image/jpeg", data=b"front.jpg", desc="Front")
    container.save(filename, metadata)

    assert_that(
        container.load(filename).images, has_length(1), "updated images")
Example #12
0
def test_copies_a_selection_of_its_tags_with_images():
    metadata = Metadata(artist="Alain Souchon",
                        album="C'est déjà ça",
                        track="Foule sentimentale")
    metadata.addImage("img/jpeg", "front-cover.jpg")
    metadata.addImage("img/jpeg", "back-cover.jpg")

    selection = metadata.copy("artist", "album", "label")

    assert_that(selection, has_length(2))
    assert_that(
        selection,
        all_of(has_entries(artist="Alain Souchon", album="C'est déjà ça"),
               is_not(has_key("track")), is_not(has_key("label"))),
        "selected tags")
    assert_that(
        selection.images,
        contains(has_property("data", "front-cover.jpg"),
                 has_property("data", "back-cover.jpg")), "selected images")
def test_round_trips_metadata_to_file(flac):
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"honeycomb.jpg", Image.FRONT_COVER)
    metadata["release_name"] = "St-Henri"
    metadata["lead_performer"] = "Joel Miller"
    metadata["lead_performer_region"] = ("CA", "MTL")
    metadata["isnis"] = {"Joel Miller": "0000000123456789", "Rebecca Ann Maloy": "9876543210000000"}
    metadata["ipis"] = {"Joel Miller": "0000000123456789", "Rebecca Ann Maloy": "9876543210000000"}
    metadata["label_name"] = "Effendi Records Inc."
    metadata["primary_style"] = "Modern Jazz"
    metadata["recording_time"] = "2007-11-02"
    metadata["track_title"] = "Salsa Coltrane"
    metadata["isrc"] = "CABL31201254"
    metadata["iswc"] = "T-345246800-1"
    metadata["tagger"] = "TGiT"
    metadata["tagger_version"] = "1.0"
    metadata["tagging_time"] = "2014-03-26 18:18:55"
    metadata["track_number"] = 3
    metadata["total_tracks"] = 5
    metadata["recording_studio"] = "Effendi Records Inc."
    metadata["recording_studio_region"] = ("CA", "MTL")
    metadata["recording_studio_address"] = "2020 des zinzins, Montreal"
    metadata["production_company"] = "Effendi Records Inc."
    metadata["production_company_region"] = ("CA", "MTL")
    metadata["music_producer"] = "Joel Miller & Paul Johnston"
    metadata["lyricist"] = ["Joel Miller"]
    metadata["catalog_number"] = "001-002-003"
    metadata["upc"] = "123456789999"
    metadata["mixer"] = "Mixing Engineer"
    metadata["comments"] = "Comments of any nature"
    metadata["publisher"] = ["Who publishes the disc the track came from"]
    metadata["composer"] = ["Composer of the work"]
    metadata["version_info"] = "Specifics about that version of the track"
    metadata["lyrics"] = "Lyrics of the track"
    metadata["language"] = "Language of the lyrics"
    metadata["compilation"] = False
    metadata["featured_guest"] = "A collaborating artist"
    metadata["labels"] = "tag1, tag2, tag3"
    metadata["release_time"] = "2008-03-01"
    metadata["guest_performers"] = [("Guitar", "Guitarist"), ("Guitar", "Bassist"), ("Piano", "Pianist")]

    _assert_can_be_saved_and_reloaded_with_same_state(flac, metadata)
Example #14
0
def test_stores_several_pictures_sharing_the_same_description(mp3):
    filename = mp3()
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"salers.jpg", desc="Front Cover")
    metadata.addImage("image/jpeg", b"ragber.jpg", desc="Front Cover")

    container.save(filename, metadata)

    assert_that(
        container.load(filename).images,
        contains_inanyorder(
            Image("image/jpeg",
                  b"salers.jpg",
                  type_=Image.OTHER,
                  desc="Front Cover"),
            Image("image/jpeg",
                  b"ragber.jpg",
                  type_=Image.OTHER,
                  desc="Front Cover (2)"),
        ))
Example #15
0
def test_stores_several_pictures(flac):
    filename = flac()
    metadata = Metadata()
    metadata.addImage("image/jpeg", b"front-1.jpg", desc="Front Cover")
    metadata.addImage("image/jpeg", b"front-2.jpg", desc="Front Cover")

    container.save(filename, metadata)

    assert_that(
        container.load(filename).images,
        contains_inanyorder(
            Image("image/jpeg",
                  b"front-1.jpg",
                  type_=Image.OTHER,
                  desc="Front Cover"),
            Image("image/jpeg",
                  b"front-2.jpg",
                  type_=Image.OTHER,
                  desc="Front Cover (2)"),
        ))
Example #16
0
def test_looks_up_images_by_type():
    metadata = Metadata()
    metadata.addImage("img/jpeg", "front-cover.jpg", Image.FRONT_COVER)
    metadata.addImage("img/png", "front-cover.png", Image.FRONT_COVER)
    metadata.addImage("img/jpeg", "back-cover.jpg", Image.BACK_COVER)

    assert_that(
        metadata.imagesOfType(Image.FRONT_COVER),
        contains_inanyorder(has_property("data", "front-cover.jpg"),
                            has_property("data", "front-cover.png")),
        "front cover images")
Example #17
0
def test_is_not_empty_when_containing_images():
    metadata = Metadata()
    metadata.addImage("img/jpeg", "...")
    assert_that(metadata.empty(), is_(False), "emptiness")
Example #18
0
def test_is_empty_when_cleared():
    metadata = Metadata()
    metadata["artist"] = "John Doe"
    metadata.addImage("img/jpeg", "...")
    metadata.clear()
    assert_that(metadata.empty(), is_(True), "emptiness")
Example #19
0
def test_is_not_empty_when_holding_tags():
    metadata = Metadata()
    metadata["artist"] = "John Doe"
    metadata.addImage("img/jpeg", "...")
    assert_that(metadata.empty(), is_(False), "emptiness")