Package: jncep
jncepCommand-line tool to generate EPUB files forJ-Novel Clubpre-pub novelsInstallThe tool requires Python 3.6+.To install, launch :pip install jncepThe command above will install thejncepPython library and its dependencies. The library includes a command-line script, also namedjncep, whose functionality is described below.Limitations & disclaimerThis tool only works with J-Novel Clubnovels, not manga.jncepis completely unaffiliated with J-Novel Club (it simply uses their API).IssuesReport issues athttps://github.com/gvellut/jncep/issuesUsageThejnceptool must be launched on the command-line. It has 4 commands:epub: To simply generate an EPUB filetrack: To tell the tool that a series is of interestupdate: To generate EPUB files for newly updated series of interestconfig: To manage an optional configuration fileJ-Novel Club account credentialsAll the commands need some user credentials (email and password) in order to communicate with the J-Novel Club API. They are the same values as the ones used to log in to the J-Novel Club website with a browser (unlessSign in with GoogleorSign in with Facebookis used: In that case, see the section just below).Those credentials can be passed directly on the command line using the--emailand--passwordarguments to thecommand(or subcommand fortrack), not thejnceptool directly. For example, using theepubcommand:jncep epub --email user@example.com --password "foo%bar666!" https://j-novel.club/series/tearmoon-empirePassing the credentials indirectlyIt is also possible to pass the credentials indirectly in one of 2 ways:configuration fileenvironment variablesThen it is possible to omit the--emailand--passwordoptions.In order to make them more readable, all the examples in the rest of this documentation will assume that the credentials have been passed through one of the two methods above.Configuration fileIt is possible to set the login and password using the configuration file:jncep config set EMAIL "user@example.com"jncep config set PASSWORD "foo%bar666!"Then, the same command as above can be simply launched as follows:jncep epub https://j-novel.club/series/tearmoon-empireSee thegeneral documentation on managing the configuration.Environment variablesOptionally, theJNCEP_EMAILandJNCEP_PASSWORDenv vars can be set instead of passing the--emailand--passwordarguments when launching the commands. For example, if they are set in the .bashrc in the following way:export JNCEP_EMAIL=user@example.comexport JNCEP_PASSWORD="foo%bar666!"Then, the same command as above can be simply launched as follows:jncep epub https://j-novel.club/series/tearmoon-empireSee thegeneral documentation on environment variables.Credentials when signing in at J-Novel Club with Google or FacebookIt is not possible to directly use Google credentials (ifSign in with Googleis used on the J-Novel Club website) or Facebook credentials (withSign in with Facebook). Instead, a password specific to J-Novel Club must first be created: It is the same process as the one needed to be performed in order to log in to the official J-Novel Club mobile app, in case Google or Facebook was originally used to sign up.Here is what needs to be done:Log in to the J-Novel Club website with Facebook or GoogleGo to theAccountpage from the link at the top.Click on thePasswordsection on the left hand side.Set a password on that screen.Then the login email of the Facebook or Google account, together with that new password, can be used as credentials for thejnceptool, either directly or using one of the indirect methods.Debugging modeA--debug(or-d) option can be passed to thejnceptool, before the specific command. It will print out more information about what is happening, using the standard Pythonloggingpackage.For example:jncep --debug updateIn case of an issue withjncep, it is recommended to launch with the--debugoption and to include the output in the issue report (either inline or as a file attachment, if too long).epubTheepubcommand is used for simple EPUB generation, based on a URL link to a part or volume or series on the J-Novel Club website.OptionsTo get some help about the arguments to theepubcommand, just launch with the--helpoption:~$ jncep epub --helpUsage: jncep epub [OPTIONS] JNOVEL_CLUB_URLGenerate EPUB files for J-Novel Club pre-pub novelsOptions:-l, --email TEXT        Login email for J-Novel Club account  [required]-p, --password TEXT     Login password for J-Novel Club account  [required]-o, --output DIRECTORY  Existing folder to write the output [default: Thecurrent directory]-s, --parts TEXT        Specification of a range of parts to download in theform of <vol>[.part]:<vol>[.part] [default: All thecontent linked by the JNOVEL_CLUB_URL argument,either a single part, a whole volume or the wholeseries]-v, --byvolume          Flag to indicate that the parts of different volumesshould be output in separate EPUBs-i, --images            Flag to indicate that the images of the novel shouldbe extracted into the output folder-c, --content           Flag to indicate that the raw content of the partsshould be extracted into the output folder-n, --no-replace        Flag to indicate that some unicode charactersunlikely to be in an EPUB reader font should NOT bereplaced and instead kept as is-t, --css FILE          Path to custom CSS file for the EPUBs [default: TheCSS provided by JNCEP]--help                  Show this message and exit.ExamplesBasic usageThe following command will create a single EPUB file of part 1 of Volume 1 of the 'Tearmoon Empire' novel in the specified.../jncbooksdirectory:jncep epub -o /Users/guilhem/Documents/jncbooks https://j-novel.club/read/tearmoon-empire-volume-1-part-1Account credentials must be passed (in this case, by using the env vars, as explained above), as well as a URL link to a part or volume or series on the J-Novel Club website. Whatever the URL links to is downloaded (single part or whole volume or whole series).The tool will then communicate with the J-Novel Club API using the specified credentials and download the necessary parts (texts and images), as well as a book cover. The EPUB file will be created inside the specified (optional) output directory,/Users/guilhem/Documents/jncbooks. The directory will be created if it doesn't exist.If the--outputor-oswitch is not present, the EPUB is output in the current directory. TheJNCEP_OUTPUTenv var can also be used instead of the switch to indicate a download directory.URLTo get the URL to pass as argument, you should first go to the series page on the the J-Novel Club website. Then copy the URL found in the browser URL bar:For series: Simply use the URL of the series page on J-Novel Club. It will have a shape likehttps://j-novel.club/series/redefining-the-meta-at-vrmmo-academy.For volumes: Click on the volume you are interested in. The URL in the browser will change to something likehttps://j-novel.club/series/redefining-the-meta-at-vrmmo-academy#volume-2.For parts: Click on one of the available parts below a specific volume. The web reader will then open and the URL will be something likehttps://j-novel.club/read/redefining-the-meta-at-vrmmo-academy-volume-1-part-1.It is also possible to pass the index of the series shown using thetrack listcommand:jncep epub 5It is equivalent to passing the URL of the corresponding series.Range of partsThe following command will create a single EPUB file with Parts 5 to 10 of Volume 1 of the 'Tearmoon Empire' novel (as long as the pre-pubs have not expired) in the current directory:jncep epub --parts 1.5:1.10 https://j-novel.club/read/tearmoon-empire-volume-1-part-1Compared to the previous example, a range of parts / volumes has been specified, in which case the URL is simply used to indicate the series (even if it is a link to just a part or volume of a series).The specified range is in the shape of<volume>[.<part>]:<volume>[.<part>]where<volume>and<part>are numbers (e.g.1.5:3). The specific part numbers are optional (as indicated by[and], which should not be present in the actual argument value) and are relative to the volume. If the part number is not specified, it is equivalent to<volume>.1if on the left and, if on the right, until the last part of the volume. Both sides of the range are inclusive.Any of the 2 sides of the:range separator is optional, like<volume>[.<part>]:, which means 'every part starting with the specified part until the last in the series', or even:, which means 'every part in the series'.Moreover, the:itself is also optional: It is possible to specify just<volume>[.<part>], in which case it is not interpreted as a range. If only the volume is specified (e.g.2), then all the parts of the volume will be downloaded and if there is also a part (e.g.2.1), only that part will be downloaded.Here are examples of valid values for the argument:1.5:2.8=> Part 5 of volume 1 to part 8 of volume 21:2.8=> Part 1 of volume 1 to part 8 of volume 21:3=> Part 1 of volume 1 to the last part of volume 32.7:=> Part 7 of volume 2 until the last part in the series:3.5=> From the first part in the series until part 5 of volume 3-1=> The last volume-1.3:=> From the third part of the last volume until the last part in the series:=> The whole series2=> All the parts of volume 2A note about volume numbersThe volume number used in the--partsoption is the one used by J-Novel Club internally, for its website and API. For most series, it is identical to the volume number as written in the volume sections on the series pages of the J-Novel Club website:Volume 7means7can be passed to the--partsoption.However, for some series, the volume numbering scheme is different. For example:The volumes ofAscendance of a Bookwormare written asPart x Volume y. However, internally, J-Novel Club still uses a single number to describe a volume for this series.Min-Maxing My TRPG BuildhasVolume 4 Canto IandVolume 4 Canto II. Internally, J-Novel Club describes the first as volume4and the second as volume5.There are also some series with a side-stories volume that has been inserted in the normal series but which doesn't follow the volume numbering scheme: This volume will shift the internal numbering for the volumes that come after.In order to get the volume number to use for the--partsoption for those series, you should go to the series page on J-Nobel Club, then click on the volume you want. Then the URL in the brower will change with#volume-xxadded at the end. This numberxxcan be used forjncep. For example, forAscendance of a Bookworm Part 4 Volume 8, the URL in the browser will change tohttps://j-novel.club/series/ascendance-of-a-bookworm#volume-20. It means you should use20as the volume number for the command.Alternatively, a negative volume counts from the last volume:-1is the last volume,-2the penultimate, etc ... So it might be easier to use that for series with many volumes and with an internal numbering that doesn't correspond to the external one.Rare Unicode charactersOriginally, the tool copied into the EPUB the text obtained from J-Novel Club as is. Depending on the font used by the ePub reader, some rare Unicode characters did not display. I noticed it in a series where the string used as the scene separator is♱(East Syriac Cross): My Kobo eBook reader would not show it with any of the fonts present on the device. UsingCrimson Text, the font used by J-Novel Club for its web reader, gave the same result. It turns out it was only rendered in the web reader by a fallback font, which on my Mac is Menlo (a monospace font by Apple). This issue also happened with the Calibre EPUB reader. However, the iBooks reader app on macOS displayed the character.To solve this issue (without having to mess with fonts), by default, this specific character is now replaced with "**". This behaviour can be overridden with the-nswitch. Both the characters to replace and the replacement string are hardcoded. If another character is unable to display properly,an issue can be filedand it will be processed by the tool in a later version.CSSThe default CSS used by the tool and embedded in the generated EPUB files can be foundin the repository. It is possible to download it and customize it. Then you can tell theepubcommand to use your own version by passing the-t/--cssoption with the path to your custom CSS as value.Configuration fileJust like the login and password, other options can be set in a configuration file. Here are the options that are used by theepubsubcommand (and also byupdate):EMAILPASSWORDOUTPUTCSSBYVOLUMEIMAGESCONTENTNOREPLACETo set an option, use thejncep config setcommand. For example:jncep config set OUTPUT "/user/gvellut/documents/jncepubs"This will add a value for the OUTPUT configuration option. When thejncep epubcommand is run, the value of the--outputoption will be taken from the configuration file, unless the--outputoption is actually present on the command-line, in which case it will take priority.Note: ForOUTPUTorCSS, the values of which should be file paths, thejncep config setcommand doesn't process the~(user HOME directory, usually expanded by the shell) nor resolves a relative path to an absolute one. The output of the command will show what exact value will be used later by theepubandupdatecommands: No additional transformation will be performed.See the paragraph about managing the configurationfurther in this page.FlagsThe options that set flags (BYVOLUME and below in the list above) should have one of the following values:1,true,t,yes,yoron. The value can be in upper case.For unsetting, the simplest is to useconfig unsetto remove the configuration option (the default value for all those flags isFalse). If a value is set, it should be one of the following:0,false,f,no,noroff.Environment variablesThe options can also be set using environment variables. They are the same as the configuration options, but with aJNCEP_prefix:For example:JNCEP_PASSWORDJNCEP_OUTPUTJNCEP_CSSand so on ...The specifig way of setting them will depend on your shell. For example, with Bash:export JNCEP_BYVOLUME=1The names of the environment variables arecase-sensitive.Priority order for option valuesThe priority order for option values is as follows:If a value is passed on the command-line, it has the highest priorityIf no value is passed, the value is taken from an environment variable if presentAfter that, the value is taken from the configuration fileSome options have a default value defined in the code: If no value has been explicitly passed using one of the 3 methods above, that default value will be used. Some options have no default values and are instead required: If no value is passed using one of the 3 methods just described, an error will be raised.trackThis command is used to manage series to track. It has 4 subcommands:add: Add a new series for tracking. After a series has been added, it can be updated using theupdatecommand.rm: Remove a series from trackinglist: List tracked seriesync:  Update the list of series to track based on series followed on the J-Novel Club website (or the opposite using the--reverseflag)In the cases ofaddandrm, a URL link to a part or volume or series on the J-Novel Club website must be passed and is used to specify the series. Credentials are also needed for them (but not forlist, which doesn't communicate with the J-Novel Club API).Tracking configurationThe tracking is performed by updating a local config file calledtracked.jsonand located inside the configuration folder. The location of the folder will vary depending on the OS. See thesection dedicated to the configurationfor more details.The configuration folder, as well thetracked.jsonfile will be created by the tool if they don't exist.Thetracked.jsonfile can be updated manually with a text editor if really needed but should generally be left alone (orjncepcould malfunction).OptionsTo get some help about the arguments to thetrackcommand, just launch with the--helpoption:~$ jncep track --helpUsage: jncep track [OPTIONS] COMMAND [ARGS]...Track updates to a seriesOptions:--help  Show this message and exit.Commands:add   Add a new series for trackinglist  List tracked seriesrm    Remove a series from trackingsync  Sync list of series to track based on series followed on J-Novel...In turn, theadd,rm,listandsyncsubcommands can be called with--helpto get details about their arguments.ExamplesTrackingTheaddsubcommand sets up tracking for a series by passing a URL to either the series, a volume or a part:jncep track add https://j-novel.club/series/tearmoon-empireAn entry with keyhttps://j-novel.club/series/tearmoon-empirewill be added to thetracked.jsonfile. Note that no Epub is generated by this command: Use theepubcommand to generate a file for the parts released until now.UntrackingThermsubcommand disables tracking for a specific series by passing a URL, for example for "Tearmoon Empire" that was added above:jncep track rm https://j-novel.club/read/tearmoon-empire-volume-1-part-14Note that the URL is different from before: It doesn't matter since it actually resolves to the same series.It is also possible to pass the index of the series shown using thelistsubcommand (see below):jncep track rm 5List tracked seriesThelistsubcommand lists the tracked series:jncep track list --detailsThis will display something like:16 series are tracked:[1] A Late-Start Tamer’s Laid-Back Life https://j-novel.club/series/a-late-start-tamer-s-laid-back-life 2.5 [Nov 04, 2021][2] Ascendance of a Bookworm https://j-novel.club/series/ascendance-of-a-bookworm 16.6 [Nov 08, 2021]...That subcommand doesn't need a login or password (it only reads the localtracked.jsonfile).Withouth the--detailsoption, only the index and the series titles are shown.The index inside the[..]can be used in thermsubcommand instead of the URL, as well as theepubcommand.SyncUsing thesyncsubcommand,trackwill update the list of series tracked byjncepbased on series followed on the J-Novel Club website:jncep track syncThe--reverseflag can be used for the opposite: The list of series followed on the J-Novel Club website will be updated to add series that are tracked locally by thejnceptool.By default, thesyncsubcommand doesn't do any deletion, it just adds missing entries. To make the list of tracked series and followed series identical, the--deleteflag can be passed.updateThis command is used to generate EPUB files for newly updated series that were previously added using thetrackcommand. Optionally, a URL link to a part or volume or series on the J-Novel Club website can be passed, in order to only update that series.This command uses the launch date of the parts to find out if the series has been updated.OptionsTo get some help about the arguments to theupdatecommand, just launch with the--helpoption:~$ jncep update --helpUsage: jncep update [OPTIONS] (JNOVEL_CLUB_URL?)Generate EPUB files for new parts of all tracked series (or specific seriesif a URL argument is passed)Options:-l, --email TEXT        Login email for J-Novel Club account  [required]-p, --password TEXT     Login password for J-Novel Club account  [required]-o, --output DIRECTORY  Existing folder to write the output [default: Thecurrent directory]-v, --byvolume          Flag to indicate that the parts of different volumesshould be output in separate EPUBs-i, --images            Flag to indicate that the images of the novel shouldbe extracted into the output folder-c, --content           Flag to indicate that the raw content of the partsshould be extracted into the output folder-n, --no-replace        Flag to indicate that some unicode charactersunlikely to be in an EPUB reader font should NOT bereplaced and instead kept as is-t, --css FILE          Path to custom CSS file for the EPUBs [default: TheCSS provided by JNCEP]-s, --sync              Flag to sync tracked series based on series followedon J-Novel Club and update the new ones from thebeginning of the series-j, --jnc-managed       Flag to indicate whether to use the series followedon the J-Novel Club website as the trackingreference for updating (equivalent to running 'tracksync --delete --beginning' followed by 'update')-w, --whole             Flag to indicate whether the whole volume should beregenerated when a new part is detected during theupdate-f, --whole-final       Flag to indicate whether an EPUB with a completevolume should also be generated when the final partof the volume is included in the update-e, --use-events        Flag to use the events feed to check for updates--help                  Show this message and exit.Most of the arguments to theepubcommand are also found here.ExampleThe following command will update all the series:jncep updateDepending on which series were configured, something like the following should be displayed on the last line:2 series sucessfully updated!Or if no tracked series has seen any updates:All series are already up to date!SyncThe--syncflag can be passed (together with the other options), in which case the list of tracked series is first updated based on the list of followed series on the J-Novel Club website (equivalent ofjncep track sync), then, only for the newly added series, an EPUB is created with the parts from the beginning.It can be useful for when a new series starts publishing: It can be set as Followed on the website then thisjncep update --synccommand can be launched to subscribe to the series and get all the newly released parts in one go, and without having to copy/paste a URL.Events feedIf you have a lot of followed series and update often, the flag--use-eventscan be used. In that case, theupdatecommand will first check the events feed provided by J-Novel Club: It includes all the part releases and can be used to know which series will need to be downloaded. With this flag, the tool saves time by not checking all the series individually.Configuration & environment variablesCompared to theepubcommand, theupdatecommand understands the additional configuration options:USE_EVENTSWHOLEWHOLE_FINALJNC_MANAGEDSince they are flags, they should have a value like1,true,t,yes,yoron(case insensitive) if set.They are also available as environment variables:JNCEP_USE_EVENTSJNCEP_WHOLEJNCEP_WHOLE_FINALJNCEP_JNC_MANAGEDAutomationTheupdatecommand can be called in the background from launchd (on macOS) or a scheduled task (on Windows) or cron (on Linux) in order to regularly download new content if available and create EPUBs (for example, once a day).There is no notification built in thejncep updatecommand but the text output can be combined with other tools to make something suitable. If there are updates, thejncep updatecommand outputs something like2 series sucessfully updated!, which can be processed by another tool do create a notification.configThis command is used to manage configuration options, as an alternative to passing values on the command line or through environment variables.It has 6 subcommands:show: Show some general info about the configuration (folder, actual configuration files, configuration values)list: Show available options that can be setset: Set the value of an optionunset: Unset an optioninit: Create an emptyconfig.inifile (for manual editing)migrate: Migrate configuration files to the post-v41 configuration folderThe configuration options are stored inside aconfig.inifile in the configuration folder. The file essentially uses the.inifile format for properties, except it doesn't support the[...]headers. When using thesetcommand, the file will be created if needed.OptionsTo get some help about theconfigcommand, just launch with the--helpoption:~$ jncep config --helpUsage: jncep config [OPTIONS] COMMAND [ARGS]...Manage configurationOptions:--help  Show this message and exit.Commands:init     Create configuration filelist     List configuration optionsmigrate  Migrate to standard configuration folder...set      Set configuration optionshow     List configuration detailsunset    Delete configuration optionIn turn, the subcommands can be called with--helpto get details about their arguments.Configuration folderThe configuation files are located inside the configuration folder that is either:/Users/<user>/Library/Application Support/jncepon macOSC:\Users\<user>\AppData\Roaming\jncepon Windows/home/<user>/.config/jncepon LinuxNote: Onjncep v41and before, the configuration folder was created at<HOME>/.jncep(where<HOME>is either/Users/<user>on macOS,C:\Users\<user>on Windows or/home/<user>on Linux). If the folder was created at that location because such a version was previously used, it will stay there andjncepshould keep working even if you update to a later version. The commandconfig migratecan be used for migrating to the new location. The commandconfig showcan be used to make sure of the location of the configuration folder.The folder contains both thetracked.jsonfile used by thetrackandupdatecommands, as well as theconfig.inifile that contains general configuration values used by all commands.showTheshowsubcommand shows some general info about the configuration:jncep config showThis will display something like:Configuration folder: C:\Users\gvellut\AppData\Roaming\jncepFound config file: config.iniOption: OUTPUT => output_test2Option: BYVOLUME => YFound tracking file: tracked.json13 series trackedlistThelistsubcommand shows available options that can be set:jncep config listThis will display something like:BYVOLUME       Flag to indicate that the parts ofdifferent volumes should be output inseparate EPUBsCONTENT        Flag to indicate that the raw content ofthe parts should be extracted into theoutput folderCSS            Path to custom CSS file for the EPUBsEMAIL          Login email for J-Novel Club account...The same options can be set using environment variables (except there is aJNCEP_prefix).setThesetsubcommand can be used to set the value for a configuration option:jncep config set EMAIL "jnclogin@aol.com"The option names are case-insensitive so it could also be written as:jncep config set email "jnclogin@aol.com"This will display something like:Option 'EMAIL' set to 'jnclogin@aol.com'Theconfig.inifile will be created if needed and will contain the following line:EMAIL = jnclogin@aol.comWarning: When using that command from the command-line, the shell may need some characters to be escaped. The rules vary depending on what shell is used. Also, forOUTPUTorCSS, the command doesn't process the~(user HOME directory, usually expanded by the shell) nor resolves a relative path to an absolute one. Please review the output to check if the option was set as intended.An alternative to using this command (as well asunset) is to edit theconfig.inifile with a text editor. The file must be saved in theUTF-8 encoding.unsetTheunsetsubcommand can be used to remove a configuration option:jncep config unset OUTPUTIt will display something like:Option 'OUTPUT' unsetThis will delete theOUTPUToption from the configuration file.initTheinitsubcommand creates an emptyconfig.inifile:jncep config initThis will display something like:New empty config file created: C:\Users\gvellut\AppData\Roaming\jncep\config.iniThen the file can be edited manually (or using thesetandunsetcommands). After editing, the file must be saved using theUTF-8 encoding.migrateThemigratesubcommand can be used to migrate configuration files to the post-v41 standard configuration folder:jncep config migrateThis will display something like:The configuration is now in: C:\Users\gvellut\AppData\Roaming\jncepYou may delete: C:\Users\gvellut\.jncepIt creates the new folder and performs a simple copy of the files present in the old directory.Note:jncepwill keep functioning with the<HOME>/.jncepfolder so it is not actually necessary to run this command.TODO (maybe)self-contained executable for macOS and Windows with PyInstallersimple GUI