~q3cpma/mangadex-tools

c54e7c2ba46419e8ccdc3e07b6082f72736b3fbc — q3cpma 4 months ago 29101c3
Fix cover downloading
1 files changed, 9 insertions(+), 8 deletions(-)

M mdex_util.tcl
M mdex_util.tcl => mdex_util.tcl +9 -8
@@ 137,7 137,7 @@ proc cover_filename {cover_data lang {title ""}} {
		set title [get_rel_title [dict get $cover_data relationships] $lang]
	}
	set ret "$title - c000"
	set vol [dict get $cover_data data attributes volume]
	set vol [dict get $cover_data attributes volume]
	if {$vol ne "null"} {
		if {[string is entier -strict $vol]} {
			append ret " (v[format %02d $vol])"


@@ 147,7 147,7 @@ proc cover_filename {cover_data lang {title ""}} {
			append ret " (v$vol)"
		}
	}
	set ext [file extension [dict get $cover_data data attributes fileName]]
	set ext [file extension [dict get $cover_data attributes fileName]]
	append ret " - Cover$ext"
}



@@ 222,12 222,13 @@ proc dl_covers {mid lang {volumes ""}} {
	if {[catch {api_get cover $query_params} json]} {
		util::die "Failed to download cover list JSON!\n\n$json"
	}
	set covers [dict get [json::json2dict $json] results]
	foreach cov $covers {
		if {[dict get $cov result] eq "ok" &&
			($volumes eq "" || [dict get $cov data attributes volume] in $volumes)
		} {
			lappend urls $COVER_SERVER/covers/$mid/[dict get $cov data attributes fileName]
	set json [json::json2dict $json]
	if {[dict get $json result] ne "ok"} {
		error "Wrong result returned: [dict get $json errors]"
	}
	foreach cov [dict get $json data] {
		if {$volumes eq "" || [dict get $cov attributes volume] in $volumes} {
			lappend urls $COVER_SERVER/covers/$mid/[dict get $cov attributes fileName]
			lappend outnames [cover_filename $cov $lang]
		}
	}