Aivean / royalroad-downloader

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

Created a Simple Batch File for Simple Use #12

Closed ghost closed 6 years ago

ghost commented 6 years ago

I don't know if it's supposed to be like this, but I can't use URLs formatted in https://www.royalroadl.com/fiction/XXXX/title So I created a batch that should work with all URLs. (P.S There's another batch under this one, but it's a pathetic version of the first batch) These are both majorly flawed, but they should work for most books, and the first one should work for all books, including pasting in chapter URLs, and chapter URLs with the "d%C3%A9j%C3%A0-vu".


@setlocal enableextensions enabledelayedexpansion @echo off rem "Edit Information Here"

set programVersion="1.2.5" set allocateMemorySize="1024"

rem "For Memory Size, 1024 is 1G, 2048 is 2G, etc." rem "Above 1G will not work on all computers"

rem "Don't Edit Beyond This" set /p bookURL="Enter RoyalRoadL Book URL: " call:extractLeadingNumbers %bookURL% bookURLnumber set bookURLparsed="https://www.royalroadl.com/fiction/%bookURLnumber%"

java -Xmx%allocateMemorySize%m -Xms%allocateMemorySize%m -jar royalroadl-downloader-assembly-%programVersion%.jar %bookURLparsed%

pause

:extractLeadingNumbers inputString returnVar setlocal enableextensions disabledelayedexpansion set "string=%~1" for /f "tokens=1-2 delims=0123456789 " %%a in ("%string:^"=%") do set "delimiters=%%a%%b" for /f "delims=%delimiters% " %%a in ("%string:^"=%") do set "numbers=%%a" endlocal & set "%~2=%numbers%" goto :eof

endlocal


aaaaaaand one that works with books with four digit book titles


@setlocal enableextensions enabledelayedexpansion @echo off

rem "Edit Information Here"

set programVersion="1.2.5" set allocateMemorySize="1024"

rem "For Memory Size, 1024 is 1G, 2048 is 2G, etc." rem "Above 1G will not work on all computers"

rem "Don't Edit Beyond This" set /p bookURL="Enter RoyalRoadL Book URL: "

if not x%bookURL:https:=%==x%bookURL% if not x%bookURL:www.=%==x%bookURL% call:httpsWWW if not x%bookURL:https:=%==x%bookURL% if x%bookURL:www.=%==x%bookURL% call:httpsnoWWW

if not x%bookURL:http:=%==x%bookURL% if not x%bookURL:www.=%==x%bookURL% call:httpWWW if not x%bookURL:http:=%==x%bookURL% if x%bookURL:www.=%==x%bookURL% call:httpnoWWW

java -Xmx%allocateMemorySize%m -Xms%allocateMemorySize%m -jar royalroadl-downloader-assembly-%programVersion%.jar %bookURLparsed%

pause

:httpsWWW set bookURLparsed=%bookURL:~0,39% goto:eof

:httpsnoWWW set bookURLparsed=%bookURL:~0,36% goto:eof

:httpWWW set bookURLparsed=%bookURL:~0,38% goto:eof

:httpnoWWW set bookURLparsed=%bookURL:~0,35% goto:eof

endlocal


Aivean commented 6 years ago

Thank you for you effort! I'm sure Windows users will appreciate your script.

I promise to find some time in the near future to add support for all URL formats.

ghost commented 6 years ago

An easy way to do that is just to grab the fiction number, i.e. https://royalroadl.com/fiction/XXX/whatever, using logic that finds the first number and grabs all the numbers after that and ending where it is no longer a number and not reading the rest at all. After that, adding the number to a predefined URL of: https://royalroadl.com/fiction/number This way, you wouldn't have to change your code at all, only the way you interpret the URL.

Aivean commented 6 years ago

@dprohd , please check the latest release, is should support long urls.