~q3cpma/mangadex-tools

fcb0da11c013e2efaff98c8e5455cc59c064fc34 — q3cpma 2 months ago 16ff8ac
Improve monitor documentation
2 files changed, 67 insertions(+), 30 deletions(-)

M README
M mdex_monitor.tcl
M README => README +48 -19
@@ 34,18 34,22 @@ Some useful tools to interface with MangaDex via its JSON API:

+----------------------------------------------------------------------------------+
| NAME                                                                             |
|     mdex_monitor.tcl - monitor MangaDex mangas                                   |
|     mdex_monitor.tcl - monitor MangaDex manga updates                            |
|                                                                                  |
| SYNOPSIS                                                                         |
|     mdex_monitor.tcl [OPTION]... CATALOG                                         |
|                                                                                  |
| DESCRIPTION                                                                      |
|     Read mangas to monitor from CATALOG, a file containing a Tcl list using the  |
|     following syntax:                                                            |
|           {MANGA_ID ?OPTION VALUE? ...} ...                                      |
|           # Comment                                                              |
|     Read mangas to monitor from CATALOG, a file using the following syntax:      |
|           CATALOG = ITEM ITEM...                                                 |
|           ITEM = MANGA_ID | "{" MANGA_ID OPTION VALUE OPTION VALUE... "}"        |
|                                                                                  |
|     with the following OPTIONs available:                                        |
|     Comments are everything from a "#" to a newline or end of file.              |
|     Since this is actually a literal Tcl list, all the spaces used in these      |
|     syntax rules are runs of one or more whitespace characters ([[:space:]]+ in  |
|     POSIX EREs).                                                                 |
|                                                                                  |
|     The following item OPTIONs are available:                                    |
|           autodl                                                                 |
|               If VALUE is 1, new chapters for this manga are downloaded to the   |
|               directory specified via the -autodl-dir option. If the -autodl     |


@@ 58,11 62,17 @@ Some useful tools to interface with MangaDex via its JSON API:
|           title                                                                  |
|               Use VALUE as title instead of the MangaDex provided one.           |
|                                                                                  |
|     For each manga, an Atom feed is created next to the given CATALOG file and   |
|     updated for each new chapter.                                                |
|     For each list item:                                                          |
|           If this is the first run since it was added to the CATALOG, nothing is |
|           done except for the creation of its (empty) Atom feed in the same      |
|           directory as the CATALOG.                                              |
|                                                                                  |
|           Else, MangaDex is queried to find if there are new chapters since the  |
|           last run. If this is the case, its Atom feed is updated with and those |
|           chapters are downloaded if autodl is currently enabled.                |
|                                                                                  |
|     A database holding the last timestamp for each catalog entry is also created |
|     at the same place.                                                           |
|     A database holding the last chapter timestamp for each item is also          |
|     maintained in that same directory.                                           |
|                                                                                  |
| OPTIONS                                                                          |
|     -proxy PROXY_URL                                                             |


@@ 126,23 136,42 @@ Download the covers for volume 1, 2 and 3:
    $ mdex_dl.tcl https://mangadex.org/title/ea3122bb-0c28-4669-8686-d6df1274512f covers 1 2 3

Monitoring example:
    $ ls
    $ ls manga_dir/
    catalog.tcllist
    $ cat catalog.tcllist
    {ea3122bb-0c28-4669-8686-d6df1274512f autodl 1 title "Baki the Grappler" group "TheSpinyBackTeam"}
    $ cat manga_dir/catalog.tcllist
    5e9a2a3e-f992-4af4-a887-cd130460c9e5  # Baki Dou (2018)
    $ mdex_monitor.tcl -autodl -autodl-dir ~/Mangos/autodl catalog.tcllist
    ...
    $ ls
    {ea3122bb-0c28-4669-8686-d6df1274512f
        autodl 1
        title "Baki the Grappler"
        group "TheSpinyBackTeam"
    }
    {f1c716b5-e82f-4625-a646-280cfa66abad title "City Hunter"}
    $ mdex_monitor.tcl -autodl manga_dir/catalog.tcllist
    [1/3] Processing manga 5e9a2a3e-f992-4af4-a887-cd130460c9e5...
    Downloading manga feed JSON...
    No new chapters
    [2/3] Processing manga ea3122bb-0c28-4669-8686-d6df1274512f...
    Downloading manga feed JSON...
    No new chapters
    [3/3] Processing manga f1c716b5-e82f-4625-a646-280cfa66abad...
    Downloading manga feed JSON...
    [1/1] Downloading City Hunter - c185 (v34) [ACF Team]...
    Downloading @Home server URL JSON...
    <...curl output...>
    $ ls -1F manga_dir/
    City Hunter - c185 (v34) [ACF Team]/
    Baki Dou (2018)_ea3122bb-0c28-4669-8686-d6df1274512f.xml
    Baki the Grappler_5e9a2a3e-f992-4af4-a887-cd130460c9e5.xml
    City Hunter_ea3122bb-0c28-4669-8686-d6df1274512f.xml
    catalog.tcllist
    timestamps.tcldict

Idem using a single feed:
    $ mdex_monitor.tcl -single-feed -autodl-dir ~/Mangos/autodl catalog.tcllist
    ...
    $ ls
    $ mdex_monitor.tcl -single-feed -auto-dl manga_dir/catalog.tcllist
    ...
    $ ls -1F manga_dir/
    City Hunter - c185 (v34) [ACF Team]/
    catalog.tcllist
    mangadex.xml
    timestamps.tcldict


@@ 153,5 182,5 @@ Idem using a single feed:

* Tcl 8.6
* tcllib (json module)
* curl
* curl >= 7.67.0
* tdom (mdex_monitor.tcl only)

M mdex_monitor.tcl => mdex_monitor.tcl +19 -11
@@ 8,7 8,7 @@ source [file join $scriptdir atom.tcl]
util::exec_require curl


proc remove_comments str {regsub -all {#[^\n]*\n?} $str {}}
# proc remove_comments str {regsub -all {#[^\n]*\n?} $str {}}

proc tstamp_compare {c1 c2} {- [get_chapter_tstamp $c1] [get_chapter_tstamp $c2]}



@@ 24,15 24,18 @@ set optres [util::autocli \
		single-feed {flag               {Use a single feed instead of one per manga.}}
	} \
	[file tail [info script]] \
	{monitor MangaDex mangas} \
	{monitor MangaDex manga updates} \
	CATALOG \
	{
		{Read mangas to monitor from CATALOG, a file containing a Tcl list using the following
		 syntax:}
		{    {MANGA_ID ?OPTION VALUE? ...} ...}
		{    # Comment}
		{Read mangas to monitor from __CATALOG__, a file using the following syntax:}
		{    CATALOG = ITEM ITEM...}
		{    ITEM = MANGA_ID | "{" MANGA_ID OPTION VALUE OPTION VALUE... "}"}
		{}
		{with the following OPTIONs available:}
		{Comments are everything from a "#" to a newline or end of file.}
		{Since this is actually a literal Tcl list, all the spaces used in these syntax rules are
		 runs of one or more whitespace characters ([[:space:]]+ in POSIX EREs).}
		{}
		{The following item OPTIONs are available:}
		{    autodl}
		{        If VALUE is 1, new chapters for this manga are downloaded to the directory
			     specified via the -autodl-dir option. If the -autodl option is set, using a value


@@ 44,11 47,16 @@ set optres [util::autocli \
		{    title}
		{        Use VALUE as title instead of the MangaDex provided one.}
		{}
		{For each manga, an Atom feed is created next to the given CATALOG file and updated for each
		 new chapter.}
		{For each list item:}
		{    If this is the first run since it was added to the __CATALOG__, nothing is done except
			 for the creation of its (empty) Atom feed in the same directory as the __CATALOG__.}
		{}
		{    Else, MangaDex is queried to find if there are new chapters since the last run. If this
			 is the case, its Atom feed is updated with and those chapters are downloaded if autodl
			 is currently enabled.}
		{}
		{A database holding the last timestamp for each catalog entry is also created at the same
		 place.}
		{A database holding the last chapter timestamp for each item is also maintained in that same
		 directory.}
	}]

if {![util::shift catalog_path] || $argc != 0} {