~q3cpma/mangadex-tools

337e9eed6248015129a038958836c6ee8ef7d60d — q3cpma a month ago 6bd039a
Import util only once and fix mdex_dl with the new URLs
4 files changed, 17 insertions(+), 11 deletions(-)

M mdex_dl.tcl
M mdex_monitor.tcl
M mdex_util.tcl
M util.tcl
M mdex_dl.tcl => mdex_dl.tcl +5 -3
@@ 2,7 2,9 @@
# TODO: group filtering ?
set scriptdir [file dirname [file dirname \
								 [file normalize [file join [info script] dummy]]]]
source [file join $scriptdir util.tcl]
if {![namespace exists util]} {
	source [file join $scriptdir util.tcl]
}
source [file join $scriptdir mdex_util.tcl]
util::exec_require curl



@@ 31,7 33,7 @@ if {$proxy ne ""} {
	set ::env(https_proxy) $proxy
}

if {[regexp "^$URL_BASE_RE/title/($UUID_RE)\$" [lindex $argv 0] -> mid]} {
if {[regexp "^$URL_BASE_RE/title/($UUID_RE)(?:/\[a-z-\]+)?\$" [lindex $argv 0] -> mid]} {
	if {$argc > 1 && [lindex $argv 1] eq "covers"} {
		dl_covers $mid $lang [lrange $argv 2 end]
		exit


@@ 48,7 50,7 @@ if {[regexp "^$URL_BASE_RE/title/($UUID_RE)\$" [lindex $argv 0] -> mid]} {
} else {
	set cids [lmap url $argv {
		if {![regexp "^$URL_BASE_RE/chapter/($UUID_RE)\$" $url -> cid]} {
			util::die "$url: not a chapter URL"
			util::die "$url: not a chapter or manga URL"
		}
		set cid
	}]

M mdex_monitor.tcl => mdex_monitor.tcl +3 -1
@@ 2,7 2,9 @@
# TODO: check when chapter is last (how?) and put it in Atom
set scriptdir [file dirname [file dirname \
								 [file normalize [file join [info script] dummy]]]]
source [file join $scriptdir util.tcl]
if {![namespace exists util]} {
	source [file join $scriptdir util.tcl]
}
source [file join $scriptdir mdex_util.tcl]
source [file join $scriptdir atom.tcl]
util::exec_require curl

M mdex_util.tcl => mdex_util.tcl +3 -1
@@ 1,7 1,9 @@
package require json
set scriptdir [file dirname [file dirname \
							 [file normalize [file join [info script] dummy]]]]
source [file join $scriptdir util.tcl]
if {![namespace exists util]} {
	source [file join $scriptdir util.tcl]
}

set URL_BASE       https://mangadex.org
set URL_BASE_RE    https://mangadex\.org

M util.tcl => util.tcl +6 -6
@@ 694,11 694,11 @@ namespace eval util {

	# Traditional FP foldl/reduce
	# Examples:
	#     % lreduce {1 2 3 4} 0  {acc elem} {+ $acc $elem}
	#     % lreduce {1 2 3 4} 0  {acc elem}  {+ $acc $elem}
	#     10
	#     % lreduce {1 2 3 4} 0 {acc e1 e2} {+ $acc [* $e1 $e2]}
	#     % lreduce {1 2 3 4} 0  {acc e1 e2} {+ $acc [* $e1 $e2]}
	#     14
	#     % lreduce {1 2 3 4} "" {acc elem} {string cat $acc $elem}
	#     % lreduce {1 2 3 4} "" {acc elem}  {string cat $acc $elem}
	#     1234
	proc lreduce {list init argvars script} {
		set elem_vars [lassign $argvars acc_var]


@@ 715,11 715,11 @@ namespace eval util {

	# Traditional FP foldl/reduce (inplace)
	# Examples:
	#     % lreduceip {1 2 3 4} 0  {acc elem} {incr acc $elem}
	#     % lreduceip {1 2 3 4} 0  {acc elem}  {incr acc $elem}
	#     10
	#     % lreduce {1 2 3 4} 0 {acc e1 e2} {incr acc [* $e1 $e2]}
	#     % lreduceip {1 2 3 4} 0  {acc e1 e2} {incr acc [* $e1 $e2]}
	#     14
	#     % lreduceip {1 2 3 4} "" {acc elem} {append acc $elem}
	#     % lreduceip {1 2 3 4} "" {acc elem}  {append acc $elem}
	#     1234
	proc lreduceip {list init argvars script} {
		set elem_vars [lassign $argvars acc_var]