How to use the picard.track.Track function in picard

To help you get started, we’ve selected a few picard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metabrainz / picard / test / test_imagelist.py View on Github external
def test_remove_from_track_with_common_images(self):
        track = Track('00000000-0000-0000-0000-000000000000')
        track.linked_files = list(self.test_files[1:])
        update_metadata_images(track)
        track.linked_files.remove(self.test_files[1])
        remove_metadata_images(track, [self.test_files[1]])
        self.assertEqual(set(self.test_images[1:]), set(track.orig_metadata.images))
        self.assertTrue(track.orig_metadata.has_common_images)
github metabrainz / picard / test / test_mbjson.py View on Github external
def test_recording_instrument_credits(self):
        m = Metadata()
        t = Track('1')
        config.setting['standardize_instruments'] = False
        recording_to_metadata(self.json_doc, m, t)
        self.assertEqual(m['performer:vocals'], 'Ed Sheeran')
        self.assertEqual(m['performer:acoustic guitar'], 'Ed Sheeran')
github metabrainz / picard / test / test_imagelist.py View on Github external
def test_update_album_images(self):
        album = Album('00000000-0000-0000-0000-000000000000')
        track1 = Track('00000000-0000-0000-0000-000000000001')
        track1.linked_files.append(self.test_files[0])
        track2 = Track('00000000-0000-0000-0000-000000000002')
        track2.linked_files.append(self.test_files[1])
        album.tracks = [track1, track2]
        album.unmatched_files.files.append(self.test_files[2])
        update_metadata_images(album)
        self.assertEqual(set(self.test_images), set(album.orig_metadata.images))
        self.assertFalse(album.orig_metadata.has_common_images)

        album.tracks.remove(track2)
        update_metadata_images(album)
        self.assertEqual(set(self.test_images), set(album.orig_metadata.images))
        self.assertFalse(album.orig_metadata.has_common_images)

        # album.unmatched_files.files.remove(self.test_files[2])
        album.tracks.remove(track1)
github metabrainz / picard / test / test_mbjson.py View on Github external
def test_recording_standardize_artist_credits(self):
        m = Metadata()
        t = Track("1")
        config.setting["standardize_artists"] = True
        recording_to_metadata(self.json_doc, m, t)
        self.assertNotIn('performer:solo', m)
        self.assertEqual(m['performer:solo vocals'], 'Anni-Frid Lyngstad')
github metabrainz / picard / test / test_acoustid.py View on Github external
def test_recording(self):
        m = Metadata()
        t = Track("1")
        parsed_recording = parse_recording(self.json_doc)
        recording_to_metadata(parsed_recording, m, t)
        self.assertEqual(m, {})
github metabrainz / picard / picard / util / imagelist.py View on Github external
"""Remove the images in the metadata of `removed_sources` from the metadata of `obj`.

    Args:
        obj: A `Cluster`, `Album` or `Track` object with `metadata` property
        removed_sources: List of child objects (`Track` or `File`) which's metadata images should be removed from `obj`
    """
    from picard.track import Track

    state = _get_state(obj)
    (removed_new_images, removed_orig_images) = _get_metadata_images(state, removed_sources)

    if state.update_new_metadata:
        sources = [s.metadata for s in state.sources]
        _remove_images(obj.metadata, sources, removed_new_images)
    if state.update_orig_metadata:
        sources = [s.orig_metadata for s in state.sources if not isinstance(s, Track)]
        _remove_images(obj.orig_metadata, sources, removed_orig_images)
github metabrainz / picard / picard / album.py View on Github external
def _finalize_loading_track(self, track_node, metadata, artists, va, absolutetracknumber, discpregap):
        track = Track(track_node.recording[0].id, self)
        self._new_tracks.append(track)

        # Get track metadata
        tm = track.metadata
        tm.copy(metadata)
        track_to_metadata(track_node, track)
        track.metadata["~absolutetracknumber"] = absolutetracknumber
        track._customize_metadata()

        self._new_metadata.length += tm.length
        artists.add(tm["artist"])
        if va:
            tm["compilation"] = "1"
        if discpregap:
            tm["~discpregap"] = "1"
github fdemmer / Picard-Last.fm.ng-Plugin / lastfmng / plugin.py View on Github external
def _load_tracks(self, release_node, album):
        # this happens after the album metadata processor in picard
        self.tracks = []
        for medium_node in release_node['media']:
            mm = Metadata()
            mm.copy(album._new_metadata)  # noqa
            medium_to_metadata(medium_node, mm)
            for track_node in medium_node['tracks']:
                track = Track(track_node['recording']['id'], album)
                self.tracks.append(track)
                # Get track metadata
                tm = track.metadata
                tm.copy(mm)
                track_to_metadata(track_node, track)
                track._customize_metadata()  # noqa
github metabrainz / picard / picard / ui / scriptsmenu.py View on Github external
def _get_metadata_objects(self, objs):
        for obj in objs:
            if hasattr(obj, 'metadata'):
                yield obj
            if isinstance(obj, Cluster):
                yield from self._get_metadata_objects(obj.files)
            if isinstance(obj, ClusterList):
                yield from self._get_metadata_objects(obj)
            if isinstance(obj, Album):
                yield from self._get_metadata_objects(obj.tracks)
                yield from self._get_metadata_objects(obj.unmatched_files.iterfiles())
            if isinstance(obj, Track):
                yield from self._get_metadata_objects(obj.linked_files)
github metabrainz / picard-plugins / plugins / bpm / __init__.py View on Github external
def callback(self, objs):
        for obj in objs:
            if isinstance(obj, Track):
                for file_ in obj.linked_files:
                    self._add_file_to_queue(file_)
            elif isinstance(obj, File):
                self._add_file_to_queue(obj)