Beispiel #1
0
    def test_flush_changes_album(self, album):
        path = album.path
        artist = u'Foo'
        controller.retag_album(album, {'artist': artist})
        controller.flush_changes(album)

        changed_album = controller.build_albums(path).next()
        assert changed_album.artist == artist
Beispiel #2
0
    def test_rename_and_reorganize_collection_with_album(self, collection):
        album_path = path.join(collection, 'album')
        album = next(controller.build_albums(album_path))

        reorganize.reorganize_and_rename_collection(
            collection, include_only=album)

        self._assert_exists(album, collection)
Beispiel #3
0
    def setup_album(self):
        tempdir = tempfile.mkdtemp()

        orig_path = 'test_songs/album'
        dest_path = path.join(tempdir, 'album')

        shutil.copytree(orig_path, dest_path)

        return controller.build_albums(dest_path, False).next()
Beispiel #4
0
    def addPath(self, path):
        if os.path.isfile(path):
            track = controller.build_track(path)
            containerAlbum = controller.album_from_tracks([track], u"Singles")
            self.albumView.model().addAlbum(containerAlbum)

        else:
            for album in controller.build_albums(path, recursive=True):
                self.albumView.model().addAlbum(album)
Beispiel #5
0
    def setup_album(self):
        """Setup: Creates a test album with 5 dummy songs on it"""
        tempdir = tempfile.mkdtemp()

        orig_path = 'test_songs/album'
        dest_path = os.path.join(tempdir, 'album')

        shutil.copytree(orig_path, dest_path)
        TestReadAlbum.path = dest_path

        album_iterator = build_albums(dest_path)
        return album_iterator.next()
Beispiel #6
0
def album(request):
    directory = 'mistagged'
    path = 'test_songs'
    temp_path = tempfile.mkdtemp()
    orig_path = os.path.join(path, directory)
    dest_path = os.path.join(temp_path, directory)

    shutil.copytree(orig_path, dest_path)

    def delete_tempfile():
        shutil.rmtree(temp_path)

    request.addfinalizer(delete_tempfile)
    albums = controller.build_albums(dest_path, False)
    return next(albums)
Beispiel #7
0
def reorganize_and_rename_collection(collection_root=COLLECTION_ROOT,
                                     organization_pattern=ORGANIZATION_PATTERN,
                                     album_pattern=ALBUM_PATTERN,
                                     track_pattern=TRACK_PATTERN,
                                     artist_pattern=ARTIST_PATTERN,
                                     include_only=None):

    if include_only:
        if isinstance(include_only, Album):
            collection = (include_only,)
        else:
            collection = include_only
    else:
        collection = controller.build_albums(collection_root, recursive=True)

    for album in collection:
        orig_path = album.path

        tempdir = tempfile.mkdtemp()
        dest_dir = os.path.join(tempdir, os.path.basename(album.path))
        shutil.copytree(album.path, dest_dir)
        controller.set_album_path(album, dest_dir)
        dest_path = tempdir

        for index, catagory in enumerate(organization_pattern.split('/')):
            print(catagory)
            if catagory == 'ARTIST':
                dest_path = _name_to_pattern(
                    album, dest_path, artist_pattern)
            elif catagory == 'ALBUM':
                dest_path = _name_to_pattern(
                    album, dest_path, album_pattern)
            elif catagory == 'TRACK':
                rename_tracks(album, track_pattern)
            else:
                raise Exception(
                    "{} is not a valid organization pattern token".format(
                        catagory))

            if index == 0:
                root_path = dest_path

        if not os.path.isdir(collection_root):
            os.mkdir(collection_root)
        shutil.move(root_path, collection_root)

        shutil.rmtree(tempdir)
        shutil.rmtree(orig_path)
Beispiel #8
0
 def test_rename_and_reorganize_collection(self, collection):
     albums = controller.build_albums(collection, True)
     reorganize.reorganize_and_rename_collection(collection)
     self._assert_exists(albums, collection)
Beispiel #9
0
 def test_missing_album(self):
     with pytest.raises(controller.NoFileFoundError):
         controller.build_albums('.').next()
Beispiel #10
0
 def test_recursive_albums(self, path, persist):
     for album in controller.build_albums(path, True):
         assert persist.match(album) == 1.0
Beispiel #11
0
 def test_single_album(self, path, persist):
     test_album = controller.build_albums(path).next()
     assert persist.match(test_album) == 1.0