Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
fix #7 encoding issues with chapters
add -f (--from-chapter) option to start downloading from specific chapter
  • Loading branch information
Aivean committed Jul 23, 2018
1 parent 7f3bb54 commit ed04324
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "royalroadl-downloader"

version := "1.2.5"
version := "1.3.0"

scalaVersion := "2.11.11"

Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/com/aivean/royalroad/Args.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ package com.aivean.royalroad

import org.rogach.scallop._;

/**
*
* @author <a href="mailto:[email protected]">Ivan Zaytsev</a>
* 2016-06-19
*/
class Args(args: Seq[String]) extends ScallopConf(args) {

banner(
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/aivean/royalroad/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand Down

0 comments on commit ed04324

Please sign in to comment.