Esempio n. 1
0
def metadata(images=(), **meta):
    new_metadata = Metadata(**meta)

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

    return new_metadata
Esempio n. 2
0
def test_removes_frame_when_tag_not_in_metadata(mp3):
    filename = mp3(TALB="Album",
                   TMCL=[["Guitar", "Guitarist"]],
                   TIPL=[["mix", "Mixing Engineer"]],
                   USLT=("", "fra"))

    container.save(filename, Metadata())
    assert_contains_metadata(filename, Metadata())
Esempio n. 3
0
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")
Esempio n. 4
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)"),
    ))
Esempio n. 5
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)"),
    ))
Esempio n. 6
0
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")
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
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")
Esempio n. 10
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")
Esempio n. 11
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")
Esempio n. 12
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)
Esempio n. 13
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")
def test_handles_flac_files_using_flac_container(flac):
    audio = flac()
    metadata = Metadata(lead_performer="Joel Miller")
    embedded_containers.save_metadata(audio, metadata)

    metadata = embedded_containers.load_metadata(audio)
    assert_that(metadata, has_entry('lead_performer', "Joel Miller"),
                'embedded metadata')
Esempio n. 15
0
def test_is_a_mutable_container():
    metadata = Metadata(artist="James Blunt")
    assert_that(metadata["artist"], equal_to("James Blunt"), "accessed item")
    metadata["artist"] = "Adele"
    assert_that(metadata["artist"], equal_to("Adele"), "assigned item")
    metadata["album"] = "Adele 21"
    assert_that(metadata, has_length(2), "length")
    assert_that("artist", is_in(metadata), "member")
    del metadata["artist"]
    assert_that("title", is_not(is_in(metadata)), "member")
Esempio n. 16
0
def test_removes_old_ipi_frames(mp3):
    filename = mp3(TXXX_IPI_Joel_Miller="00000123456789",
                   TXXX_IPI_Rebecca_Ann_Maloy="98765432100000")
    container.save(filename, Metadata(ipis={"Joel Miller": "00000123456789"}))

    tags = MP3(filename)
    assert_that(
        tags,
        all_of(has_key("TXXX:IPI:Joel Miller"),
               not_(has_key("TXXX:IPI:Rebecca Ann Maloy"))), "tags in file")
Esempio n. 17
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)
Esempio n. 18
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)"),
        ))
Esempio n. 19
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)"),
        ))
Esempio n. 20
0
    def load(self, filename):
        flac_file = mutagen.flac.FLAC(filename)

        metadata = Metadata()
        metadata["duration"] = flac_file.info.length
        metadata["bitrate"] = flac_file.info.sample_rate * flac_file.info.bits_per_sample

        for field in self.fields:
            field.read(flac_file, metadata)

        return metadata
Esempio n. 21
0
def test_removes_deprecated_frames_on_save(mp3):
    filename = mp3(TXXX_Tagger="TGiT v1.1",
                   TXXX_TAGGING_TIME="2014-03-26 14:18:55 EDT-0400",
                   TXXX_UPC="987654321111")
    container.save(filename, Metadata())

    tags = MP3(filename)
    assert_that(
        tags,
        all_of(not_(has_key("TXXX:Tagger")),
               not_(has_key("TXXX:TAGGING_TIME")), not_(has_key("TXXX:UPC"))),
        "tags in file")
Esempio n. 22
0
    def load(self, filename):
        audio_file = mp3.MP3(filename)

        frames = audio_file.tags or {}

        metadata = Metadata()
        metadata["duration"] = audio_file.info.length
        metadata["bitrate"] = audio_file.info.bitrate

        for processor in self._all_processors:
            processor.process_frames(metadata, frames)

        return metadata
Esempio n. 23
0
    def create_project(type_, name, location, reference_track_file=None):
        reference_track = from_catalog.load_track(
            reference_track_file) if reference_track_file else None
        metadata = reference_track.metadata.copy(
        ) if reference_track else Metadata()
        metadata['release_name'] = name
        album = Album(of_type=type_,
                      metadata=metadata,
                      filename=os.path.join(location, name,
                                            "{0}.tgit".format(name)))
        if reference_track:
            album.add_track(reference_track)

        to_catalog.save_project(album)
        studio.project_created(album)
        return album
Esempio n. 24
0
def load_project(filename):
    album_folder = dirname(filename)
    tracks_folder = join(album_folder, TRACKS_FOLDER_NAME)
    artwork_folder = join(album_folder, ARTWORK_FOLDER_NAME)

    data = yaml.read_data(filename)
    if Version(data["version"]) < "1.10.0":
        data = _from_1_9_to_1_11(data)
    album = Album(Metadata(data), of_type=data["type"], filename=filename)

    for image in data["images"]:
        mime, filename, type_, desc = image
        album.add_image(mime, fs.read(join(artwork_folder, filename)), type_,
                        desc)

    for track in data["tracks"]:
        album.add_track(_load_track(data["version"], tracks_folder, track))

    return album
Esempio n. 25
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")
Esempio n. 26
0
def test_accesses_entries_as_attr0ibutes():
    metadata = Metadata(artist="James Blunt")
    assert_that(metadata.artist, equal_to("James Blunt"), "accessed item")
Esempio n. 27
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")
Esempio n. 28
0
 def __init__(self, metadata=None, of_type=Type.FLAC, filename=None):
     self.metadata = metadata.copy(
         *Album.tags()) if metadata is not None else Metadata()
     self.tracks = []
     self.type = of_type
     self.filename = filename
Esempio n. 29
0
def test_missing_tag_is_considered_none():
    metadata = Metadata()
    assert_that(metadata["missing"], none(), "missing value")
Esempio n. 30
0
def test_is_not_empty_when_containing_images():
    metadata = Metadata()
    metadata.addImage("img/jpeg", "...")
    assert_that(metadata.empty(), is_(False), "emptiness")
Esempio n. 31
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")
Esempio n. 32
0
def test_takes_none_as_absence_of_tag(mp3):
    filename = mp3()
    container.save(filename, Metadata(compilation=None))
    assert_contains_metadata(filename, Metadata())
Esempio n. 33
0
 def __init__(self, filename, metadata=None, chain_of_title=None):
     self.filename = filename
     self.metadata = metadata or Metadata()
     self.chain_of_title = chain_of_title or ChainOfTitle.from_track(self)
Esempio n. 34
0
def test_round_trips_empty_metadata_to_file(mp3):
    assert_can_be_saved_and_reloaded_with_same_state(mp3, Metadata())
Esempio n. 35
0
def test_is_initially_empty():
    metadata = Metadata()
    assert_that(metadata, empty(), "tags")
    assert_that(list(metadata.images), empty(), "images")
    assert_that(metadata.empty(), is_(True), "emptiness")
Esempio n. 36
0
def test_handles_unicode_metadata(mp3):
    metadata = Metadata()
    metadata["release_name"] = "Titre en Français"
    assert_can_be_saved_and_reloaded_with_same_state(mp3, metadata)