Example #1
0
def nest_music_file(drive: Drive, file: dict, destination: Path):
    artist, album, title = (sanitize_name(file[name])
                            for name in ['artist', 'album', 'title'])

    filepath = (destination / artist / album / title).with_suffix(
        file['path'].suffix)
    output = sanitize_path(filepath)

    drive.rename(file['path'], output)
Example #2
0
def flat_music_file(drive: Drive, file: dict, destination: Path):
    artist, album, title = (sanitize_name(file[name]) for name in ['artist', 'album', 'title'])

    name = f'{artist} - {album} - {title}'
    suffix = file['path'].suffix
    filepath = destination / (name + suffix)
    output = sanitize_path(filepath)

    drive.rename(file['path'], output)
Example #3
0
def test_sanitize_path_when_input_is_file():
    assert sanitize_path(
        Path("/path/to/folder/file.ext")) == Path("/path/to/folder/file.ext")
Example #4
0
def test_sanitize_path_when_input_is_none():
    with pytest.raises(ValueError):
        sanitize_path(None)
Example #5
0
def test_sanitize_path_when_input_is_folder():
    assert sanitize_path(Path("/path/to/folder")) == Path("/path/to/folder")