Browse Source

Manage artist/album names containing path separators ('/' or '\')

master
Gwendal 6 years ago
parent
commit
416c1e5bb0
2 changed files with 10 additions and 5 deletions
  1. +3
    -5
      src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt
  2. +7
    -0
      src/main/kotlin/bandcampcollectiondownloader/Util.kt

+ 3
- 5
src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt View File

@ -84,11 +84,9 @@ fun downloadAll(cookiesFile: Path?, bandcampUser: String, downloadFormat: String
val url = digitalItem.downloads[downloadFormat]?.get("url").orEmpty() val url = digitalItem.downloads[downloadFormat]?.get("url").orEmpty()
val artid = digitalItem.art_id val artid = digitalItem.art_id
// If windows, replace colons in file names by a unicode char that looks like a colon
if (isWindows()) {
albumtitle = albumtitle.replace(':', '꞉')
artist = artist.replace(':', '꞉')
}
// Replace invalid chars by similar unicode chars
albumtitle = replaceInvalidCharsByUnicode(albumtitle)
artist = replaceInvalidCharsByUnicode(artist)
// Prepare artist and album folder // Prepare artist and album folder
val albumFolderName = "$releaseYear - $albumtitle" val albumFolderName = "$releaseYear - $albumtitle"


+ 7
- 0
src/main/kotlin/bandcampcollectiondownloader/Util.kt View File

@ -68,3 +68,10 @@ fun isWindows(): Boolean {
return os.indexOf("win") >= 0 return os.indexOf("win") >= 0
} }
fun replaceInvalidCharsByUnicode(s: String): String {
var result: String = s
result = result.replace(':', '꞉')
result = result.replace('/', '/')
result = result.replace('\\', '⧹')
return result
}

Loading…
Cancel
Save