Beispiel #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)
Beispiel #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)
Beispiel #3
0
def test_sanitize_name():
    assert sanitize_name("My/File") == "MyFile"
Beispiel #4
0
def test_sanitize_name_when_input_is_completely_illegal():
    assert sanitize_name("***") == "BLANK"
Beispiel #5
0
def test_sanitize_name_when_input_is_emtpy():
    assert sanitize_name("") == "BLANK"
Beispiel #6
0
def test_sanitize_name_when_input_is_none():
    assert sanitize_name(None) == "BLANK"