diff --git a/build.sbt b/build.sbt index cc5ab13..619f929 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "royalroadl-downloader" -version := "1.2.5" +version := "1.3.0" scalaVersion := "2.11.11" diff --git a/src/main/scala/com/aivean/royalroad/Args.scala b/src/main/scala/com/aivean/royalroad/Args.scala index 796fec9..a5696d0 100644 --- a/src/main/scala/com/aivean/royalroad/Args.scala +++ b/src/main/scala/com/aivean/royalroad/Args.scala @@ -2,11 +2,6 @@ package com.aivean.royalroad import org.rogach.scallop._; -/** - * - * @author Ivan Zaytsev - * 2016-06-19 - */ class Args(args: Seq[String]) extends ScallopConf(args) { banner( @@ -19,6 +14,12 @@ class Args(args: Seq[String]) extends ScallopConf(args) { |Options: | """.stripMargin) + val fromChapter = opt[Int]( + descr = "Start download from chapter #", + default = Some(0), + validate = _ >= 1 + ) + val titleQuery = opt[String]( descr = "CSS selector for chapter title (text of the found element is used)", default = Some("title") diff --git a/src/main/scala/com/aivean/royalroad/Main.scala b/src/main/scala/com/aivean/royalroad/Main.scala index 7dfa469..ce721e8 100644 --- a/src/main/scala/com/aivean/royalroad/Main.scala +++ b/src/main/scala/com/aivean/royalroad/Main.scala @@ -49,7 +49,7 @@ object Main extends App { val chapUrls = { val urls = threads.collect { - case x if x.startsWith("/") => "http://royalroadl.com" + x + case x if x.startsWith("/") => "https://www.royalroadl.com" + x case x => x }.par @@ -63,7 +63,7 @@ object Main extends App { else throw e } - val chaps = chapUrls.map { u => + val chaps = chapUrls.drop(cliArgs.fromChapter() - 1).map { u => val uDecoded = URLDecoder.decode(u, "utf-8") println(s"downloading: $uDecoded") uDecoded -> retry(browser.get(uDecoded))