diff --git a/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt b/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt index f68f32b..52141dd 100644 --- a/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt +++ b/src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt @@ -138,13 +138,14 @@ fun downloadAll(cookiesFile: Path, bandcampUser: String, downloadFormat: String, } } println("""Found collection page: "${doc.title()}"""") - if (!doc.toString().contains("buy-now")) { - println("Provided cookies appear to be working!") - } // Get download pages val collection = doc.select("span.redownload-item a") + if (collection.isEmpty()) { + throw BandCampDownloaderError("No download links could by found in the collection page. This can be caused by an outdated or invalid cookies file.") + } + // For each download page for (item in collection) { val downloadPageURL = item.attr("href") diff --git a/src/test/kotlin/bandcampcollectiodownloader/test/BandcampCollectionDownloaderTests.kt b/src/test/kotlin/bandcampcollectiodownloader/test/BandcampCollectionDownloaderTests.kt index bb6c6ac..135413c 100644 --- a/src/test/kotlin/bandcampcollectiodownloader/test/BandcampCollectionDownloaderTests.kt +++ b/src/test/kotlin/bandcampcollectiodownloader/test/BandcampCollectionDownloaderTests.kt @@ -46,4 +46,11 @@ class BandcampCollectionDownloaderTests { downloadAll(Paths.get("./test-data/wellformedcookies.json"), "zerz1e3687dfs3df7", "bli", Paths.get("bli")) } } + + @Test + fun testErrorCookiesUselessForBandcampUser() { + assertThrows { + downloadAll(Paths.get("./test-data/wellformedcookies.json"), "bli", "bli", Paths.get("bli")) + } + } } \ No newline at end of file