Aivean / royalroad-downloader

https://royalroad.com book downloader
MIT License
57 stars 4 forks source link

[Feature Request] "Volume" download #25

Open ZeeWanderer opened 2 years ago

ZeeWanderer commented 2 years ago

With Royal Road allowing to organize chapters into Volumes it would be useful to download a specific Volume. image

On a sidenote: in pair with --from-chapter a --to-chapter equivalent would be useful. Also using RR chapter id (https://www.royalroad.com/fiction/49717/the-rise-of-the-winter-wolf/chapter/812891/b1-prologue -> 812891) to specify chapter range would make more sense than counting chapters. Yes, that would require looping over the entire chapter URL list once before the download but it is simpler for user-side. An universal option would be something like --chapter-range that allows standard range expressions e.g. "812891-812991,812993,812995" with addition of something like a wildcard symbol to denote an open range.

I digress, the feature request is only about the Volume download.

Aivean commented 2 years ago

This seems reasonable, I'll take a closer look next week.

ZeeWanderer commented 2 years ago

As far as i understand you parse a tags with href that starts from /fiction and contains /chapter https://github.com/Aivean/royalroad-downloader/blob/8e7f4fdcb0d2b1dcb3a51333445123016126eec3/src/main/scala/com/aivean/royalroad/Main.scala#L36 But instead if you parse tr tags

<tr style="cursor: pointer" data-url="/fiction/46638/steamforged-sorcery-a-steampunk-litrpg/chapter/803289/chapter-68-arrival" data-volume-id="531" class="chapter-row">
    <td>
        <a href="/fiction/46638/steamforged-sorcery-a-steampunk-litrpg/chapter/803289/chapter-68-arrival">
            Chapter 68: Arrival
        </a>
    </td>
    <td data-content="67" class="text-right">
        <a href="/fiction/46638/steamforged-sorcery-a-steampunk-litrpg/chapter/803289/chapter-68-arrival" data-content="67">
            <time unixtime="1639068708" title="12/9/2021 4:51:48 PM &#x2B;00:00" format="agoshort">3 months </time> ago
        </a>
    </td>
</tr>

and find tr you actually need by filtering data-url for /fiction and /chapter you also get data-volume-id attribute which contains either volume id or null. Then you can additionally search for volume name by searching tags for id="volume-N-label" where N is the data-volume-id.

<h6 id="volume-531-label">Volume 1</h6>

Then you can enumerate volumes by their id's order of appearance which should be reliable and then allow a user to specify a volume number via arguments. If there are no volumes, issue a warning and ignore the argument or an error depending on your preferences.

Raisoshi commented 1 year ago

Is "--from-chapter" a command? Where do I see how to use it and other available commands? Sorry if this is obvious, I can't see anything about it in the Code page or the readme

Aivean commented 1 year ago

@Raisoshi

Is "--from-chapter" a command? Where do I see how to use it and other available commands? Sorry if this is obvious, I can't see anything about it in the Code page or the readme

It's an an argument.

You can run the program with:

java -jar royalroad-downloader-assembly-VERSION.jar --help

to see the usage.

In short,

java -jar royalroad-downloader-assembly-VERSION.jar --from-chapter 123 https://link-to-the-book

should be the syntax.

God-damnit-all commented 1 year ago

Honestly, I'd just be happy with being able to save every chapter as a separate file.

A --to-chapter argument would be nice too.

Aivean commented 1 year ago

Honestly, I'd just be happy with being able to save every chapter as a separate file.

What's the use case for that?

A --to-chapter argument would be nice too.

Huh, I thought it already exists. Ok, I'll add it when I finally find some time :)

nozwock commented 11 months ago

I wrote a simple implementation of this for myself, sharing here in case someone finds it useful.

https://gist.github.com/nozwock/c692697b28fda884826a96593967a21c?permalink_comment_id=4723605#gistcomment-4723605