Browse Source

Rename main file + remove old attemps

master
Gwendal 7 years ago
parent
commit
8b99aa6159
4 changed files with 272 additions and 368 deletions
  1. +0
    -0
      src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt
  2. +0
    -54
      src/main/kotlin/bandcampdownloader/DownloadPageSelenium.kt
  3. +0
    -42
      src/main/kotlin/bandcampdownloader/LoginSelenium.kt

src/main/kotlin/bandcampdownloader/CollectionPageJSoup.kt → src/main/kotlin/bandcampcollectiondownloader/BandcampCollectionDownloader.kt View File


+ 0
- 54
src/main/kotlin/bandcampdownloader/DownloadPageSelenium.kt View File

@ -1,54 +0,0 @@
package bandcampdownloader
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.support.ui.ExpectedCondition
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
import java.io.FileOutputStream
import java.net.URL
import java.nio.channels.Channels
import java.nio.channels.ReadableByteChannel
fun main(args: Array<String>) {
System.setProperty("webdriver.gecko.driver", "/home/zerwan/Applications/geckodriver-v0.21.0-linux64/geckodriver");
val driver = FirefoxDriver()
val wait = WebDriverWait(driver, 10)
try {
driver.get("https://bandcamp.com/download?from=collection&payment_id=1994465229&sig=d36377b10094ec86c1bd41a5700bc7cd&sitem_id=17410034")
// Find and click on format list toggle
val formatListToggle = driver.findElement(By.cssSelector(".item-format"))
formatListToggle.click()
// Find and click and the Ogg format
val oggLocator = By.cssSelector(".formats-container ul li:nth-of-type(5)")
val ogg = driver.findElement(oggLocator)
wait.until(ExpectedConditions.elementToBeClickable(oggLocator))
ogg.click()
// Find the download link and retrieve URL
val locator = By.cssSelector("a.item-button")
wait.until(ExpectedConditions.elementToBeClickable(locator))
val download = driver.findElement(locator)
val url = download.getAttribute("href")
// Quit driver
driver.quit()
// Download
val website = URL(url)
val rbc = Channels.newChannel(website.openStream())
val fos = FileOutputStream("/home/zerwan/tmp/album.zip")
fos.channel.transferFrom(rbc, 0, java.lang.Long.MAX_VALUE)
println(url)
} finally {
//Close the browser
driver.quit()
}
}

+ 0
- 42
src/main/kotlin/bandcampdownloader/LoginSelenium.kt View File

@ -1,42 +0,0 @@
package bandcampdownloader
import org.openqa.selenium.By
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
fun main(args: Array<String>) {
System.setProperty("webdriver.gecko.driver", "/home/zerwan/Applications/geckodriver-v0.21.0-linux64/geckodriver");
val driver = FirefoxDriver()
val wait = WebDriverWait(driver, 600)
try {
driver.get("https://bandcamp.com/login")
// Find and fill username field
val usernameField = driver.findElement(By.id("username-field"))
usernameField.sendKeys("oWbf1axApJRg8gRKlrE7U7ZDiooJJaXYHa5ZefM_bandcamp@bousse.fr")
// Find and fill password field
val passwordField = driver.findElement(By.id("password-field"))
passwordField.sendKeys("y1Dh2kttnLZYeT5RuNkylmptY")
// Find and press submit button
val button = driver.findElement(By.tagName("button"))
button.click()
// Wait until login is done
wait.until(ExpectedConditions.titleContains("collection"))
// Get resulting cookies
val cookies = driver.manage().cookies
println(cookies)
// Quit driver
driver.quit()
} finally {
// Quit driver
driver.quit()
}
}

Loading…
Cancel
Save