summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2023-06-11 04:34:59 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2023-06-11 04:34:59 -0600
commit0ed2a2071fe5b7610d4e4122096129857359b651 (patch)
tree2b0100b9a4c843a0c5765d34965d659b3f72fa87
parent9afd8b6d116a127752e38dd4759c1978c4bba653 (diff)
update manga server entry
-rw-r--r--db/db_blog.psv2
-rw-r--r--live/blog/a/manga_server_with_komga.html85
-rw-r--r--live/blog/rss.xml84
-rw-r--r--live/blog/sitemap.xml2
-rw-r--r--src/blog/a/manga_server_with_komga.md91
5 files changed, 184 insertions, 80 deletions
diff --git a/db/db_blog.psv b/db/db_blog.psv
index 40dbc0a..97dfc07 100644
--- a/db/db_blog.psv
+++ b/db/db_blog.psv
@@ -22,4 +22,4 @@ a/updated_pyssg_pymdvar_and_website.md|1683376754.7018104|0.0|442ad5da7342439101
a/al_fin_tengo_fibra_opticona.md|1683622740.1853704|0.0|949b8fd2aca929d74d8217474c990515|rant,short,spanish,update
a/learned_go_and_lua_hard_way.md|1685763137.7581403|0.0|493f86ce317f7b182b62c3438e5f7a8a|english,rant,short,tools
a/updating_creating_entries_titles_to_setup.md|1685764004.1478639|0.0|2bcf247ed5c2aa9fd5f4b542043123fe|english,short,update
-a/manga_server_with_komga.md|1686425767.8936074|0.0|53c8a073947cd87aa719f30977f08118|code,english,server,tools,tutorial
+a/manga_server_with_komga.md|1686425767.8936074|1686479602.0948951|76a7476c4ab4d568e39c90f07377090b|code,english,server,tools,tutorial
diff --git a/live/blog/a/manga_server_with_komga.html b/live/blog/a/manga_server_with_komga.html
index e264374..182956d 100644
--- a/live/blog/a/manga_server_with_komga.html
+++ b/live/blog/a/manga_server_with_komga.html
@@ -159,7 +159,7 @@ sudo rm -r yay
</code></pre>
<p>This <code>komga</code> package creates a <code>komga</code> (service) user and group which is tied to the also included <code>komga.service</code>.</p>
<p>Configure it by editing <code>/etc/komga.conf</code>:</p>
-<pre><code class="language-conf">SERVER_PORT=8989
+<pre><code class="language-sh">SERVER_PORT=8989
SERVER_SERVLET_CONTEXT_PATH=/ # this depends a lot of how it's going to be served (domain, subdomain, ip, etc)
KOMGA_LIBRARIES_SCAN_CRON=&quot;0 0 * * * ?&quot;
@@ -176,14 +176,14 @@ KOMGA_DATABASE_BACKUP_SCHEDULE=&quot;0 0 */8 * * ?&quot;
<p>My changes (shown above):</p>
<ul>
<li>Port on <code>8989</code> because <code>8080</code> its too generic.</li>
-<li><code>cron</code> schedules<ul>
+<li><code>cron</code> schedules.<ul>
<li>It&rsquo;s not actually <code>cron</code> but rather a <code>cron</code>-like syntax used by <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html">Spring</a> as stated in the <a href="https://komga.org/installation/configuration.html#optional-configuration">Komga config</a>.</li>
</ul>
</li>
<li>Added the remember me key.</li>
<li>For more check out <a href="https://komga.org/installation/configuration.html">Komga: Configuration options</a>.</li>
</ul>
-<p>If you&rsquo;re going to run it locally (or LAN/VPN) you can start the <code>komga.service</code> and access it via IP at <code>http://&lt;your-server-ip&gt;:&lt;port&gt;(/base_url)</code> as stated at <a href="https://komga.org/installation/webui.html">Komga: Accessing the web interface</a>, else continue with the next steps for the reverse proxy and certificate.</p>
+<p>If you&rsquo;re going to run it locally (or LAN/VPN) you can start the <code>komga.service</code> and access it via IP at <code>http://&lt;your-server-ip&gt;:&lt;port&gt;(/base_url)</code> as stated at <a href="https://komga.org/installation/webui.html">Komga: Accessing the web interface</a>, then you can continue with the <a href="#mangal">mangal</a> section, else continue with the next steps for the reverse proxy and certificate.</p>
<h3 id="reverse-proxy">Reverse proxy<a class="headerlink" href="#reverse-proxy" title="Permanent link">&para;</a></h3>
<p>Create the reverse proxy configuration (this is for <code>nginx</code>). In my case I&rsquo;ll use a subdomain, so this is a new config called <code>komga.conf</code> at the usual <code>sites-available/enabled</code> path:</p>
<pre><code class="language-nginx">server {
@@ -203,7 +203,7 @@ KOMGA_DATABASE_BACKUP_SCHEDULE=&quot;0 0 */8 * * ?&quot;
}
}
</code></pre>
-<p>If it&rsquo;s going to be used as a subdir on another domain then just change the <code>location</code> (with <code>/subdir</code> instead of <code>/</code>) directive to the corresponding <code>.conf</code> file; be careful with the <code>proxy_pass</code> directive, it has to match what you configured at <code>/etc/komga.conf</code> for the <code>SERVER_SERVLET_CONTEXT_PATH</code> regardless of the <code>/subdir</code> you selected at <code>location</code>.</p>
+<p>If it&rsquo;s going to be used as a subdir on another domain then just change the <code>location</code> with <code>/subdir</code> instead of <code>/</code>; be careful with the <code>proxy_pass</code> directive, it has to match what you configured at <code>/etc/komga.conf</code> for the <code>SERVER_SERVLET_CONTEXT_PATH</code> regardless of the <code>/subdir</code> you selected at <code>location</code>.</p>
<h3 id="ssl-certificate">SSL certificate<a class="headerlink" href="#ssl-certificate" title="Permanent link">&para;</a></h3>
<p>If using a subdir then the same certificate for the subdomain/domain should work fine and no extra stuff is needed, else if following along me then we can create/extend the certificate by running:</p>
<pre><code class="language-sh">certbot --nginx
@@ -259,12 +259,12 @@ default:other::r-x
<p>So instad of installing with <code>yay</code> we&rsquo;ll build it from source. We need to have <code>go</code> installed:</p>
<pre><code class="language-sh">pacman -S go
</code></pre>
-<p>Then clone my fork of <code>mangal</code> and build/install it:</p>
+<p>Then clone my fork of <code>mangal</code> and <code>build</code>/<code>install</code> it:</p>
<pre><code class="language-sh">git clone https://github.com/luevano/mangal.git # not sure if you can use SSH to clone
cd mangal
make install # or just `make build` and then move the binary to somewhere in your $PATH
</code></pre>
-<p>This will use <code>go install</code> so it will install to a path specified by your environment variables, for more run <code>go help install</code>. It was installed to <code>$HOME/.local/bin/go/mangal</code> for me, then just make sure this is included in your PATH.</p>
+<p>This will use <code>go install</code> so it will install to a path specified by the <code>go</code> environment variables, for more run <code>go help install</code>. It was installed to <code>$HOME/.local/bin/go/mangal</code> for me because my env vars, then just make sure this is included in your <code>PATH</code>.</p>
<p>Check it was correctly installed by running <code>mangal version</code>, which should print something like:</p>
<pre><code>▇▇▇ mangal
@@ -292,11 +292,11 @@ mangal config set -k logs.write -v true # I like to get logs for what happens
<h3 id="usage_1">Usage<a class="headerlink" href="#usage_1" title="Permanent link">&para;</a></h3>
<p>Two main ways of using <code>mangal</code>: </p>
<ul>
-<li>TUI: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough.</li>
-<li>inline: for automation on manga that is still publishing and I need to check/download every once in a while.</li>
+<li><strong>TUI</strong>: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough.</li>
+<li><strong>inline</strong>: for automation on manga that is still publishing and I need to check/download every once in a while.</li>
</ul>
<h4 id="headless-browser">Headless browser<a class="headerlink" href="#headless-browser" title="Permanent link">&para;</a></h4>
-<p>Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the <em>headless</em> browser (actually just a wrapper of <a href="https://github.com/go-rod/rod">go-rod/rod</a>, and honestly it is not really a &ldquo;headless&rdquo; browser, <code>mangal</code> &ldquo;documentation&rdquo; is just wrong). For mor on my rant check out my last <a href="https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html">entry</a>.</p>
+<p>Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the <em>headless</em> browser (actually just a wrapper of <a href="https://github.com/go-rod/rod">go-rod/rod</a>, and honestly it is not really a &ldquo;headless&rdquo; browser, <code>mangal</code> &ldquo;documentation&rdquo; is just wrong). For more on my rant check out my last <a href="https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html">entry</a>.</p>
<p>There is no concrete documentation on the &ldquo;headless&rdquo; browser, only that it is automatically set up and ready to use&hellip; but it doesn&rsquo;t install any library/dependency needed. I discovered the following libraries that were missing on my Arch minimal install:</p>
<ul>
<li>library -&gt; arch package containing it</li>
@@ -322,18 +322,30 @@ mangal config set -k logs.write -v true # I like to get logs for what happens
<pre><code class="language-sh">mangal
</code></pre>
<p>Download manga using the TUI by selecting the source/scrapper, search the manga/comic you want and then you can select each chapter to download (use <code>tab</code> to select all). This is what I use when downloading manga that already finished publishing, or when I&rsquo;m just searching and testing out how it downloads the manga (directory name, and manga information).</p>
-<p>Note that some scrapters will contain duplicated chapters, as they have uploaded chapters from the community. This happens a lot with <a href="https://mangadex.org/">MangaDex</a>.</p>
+<p>Note that some scrapters will contain duplicated chapters, as they have multiple uploaded chapters from the community, usually for different <em>scanlation groups</em>. This happens a lot with <a href="https://mangadex.org/">MangaDex</a>.</p>
<h4 id="inline">Inline<a class="headerlink" href="#inline" title="Permanent link">&para;</a></h4>
<p>The inline mode is a single terminal command meant to be used to automate stuff or for more advanced options. You can peek a bit into the &ldquo;<a href="https://github.com/metafates/mangal/wiki/Inline-mode#command-examples">documentation</a>&rdquo; which honestly its ass because it doesn&rsquo;t explain much. The minimal command for inline according to the help is:</p>
<pre><code class="language-sh">mangal inline --manga &lt;option&gt; --query &lt;manga-title&gt;
</code></pre>
-<p>But this will not produce anything because it also needs <code>--source</code> (or set the default using the config key <code>downloader.default_sources</code>) and either <code>--json</code> (for the search result) or <code>--download</code> to actually download whatever was found but it could download something you don&rsquo;t want so do the <code>--json</code> first.</p>
+<p>But this will not produce anything because it also needs <code>--source</code> (or set the default using the config key <code>downloader.default_sources</code>) and either <code>--json</code> which basically just does the search and returns the result in <code>json</code> format or <code>--download</code> to actually download whatever is found; I recommend to do <code>--json</code> first to check that the correct manga will be downloaded then do <code>--download</code>.</p>
<p>Something not mentioned anywhere is the <code>--manga</code> flag options (found it at the source code), it has 3 available options:</p>
<ul>
<li><code>first</code>: first manga entry found for the search.</li>
<li><code>last</code>: last manga entry found for the search.</li>
<li><code>exact</code>: exact manga title match. This is the one I use.</li>
</ul>
+<p>Similar to <code>--chapters</code>, there are a few options not explained (that I found at the source code, too). I usually just use <code>all</code> but other options:</p>
+<ul>
+<li><code>all</code>: all chapters found in the chapter list.</li>
+<li><code>first</code>: first chapter found in the chapter list.</li>
+<li><code>last</code>: last chapter found in the chapter list</li>
+<li><code>[from]-[to]</code>: selector for the chapters found in the chapter list, index starts at 0.<ul>
+<li>If the selectors (<code>from</code> or <code>to</code>) exceed the amount of chapters in the chapterlist it just adjusts to he maximum available.</li>
+<li>I had to fix this at the source code because if you wanted <code>to</code> to be the last chapter, it did <code>to + 1</code> and it failed due to index out of range.</li>
+</ul>
+</li>
+<li><code>@[sub]@</code>: not sure how this works exactly, my understanding is that it&rsquo;s for &ldquo;named&rdquo; chapters.</li>
+</ul>
<p>That said, I&rsquo;ll do an example by using <a href="https://mangapill.com">Mangapill</a> as source, and will search for <a href="https://mangapill.com/manga/2285/kimetsu-no-yaiba">Demon Slayer: Kimetsu no Yaiba</a>:</p>
<ol>
<li>Search first and make sure my command will pull the manga I want:</li>
@@ -341,16 +353,16 @@ mangal config set -k logs.write -v true # I like to get logs for what happens
<pre><code class="language-sh">mangal inline --source &quot;Mangapill&quot; --manga &quot;exact&quot; --query &quot;Kimetsu no Yaiba&quot; --json | jq # I use jq to pretty format the output
</code></pre>
<ol start="2">
-<li>
-<p>I make sure the json output contains the correct manga information: name, url, etc..</p>
+<li>I make sure the json output contains the correct manga information: name, url, etc..</li>
+</ol>
<ul>
<li>You can also include the flag <code>--include-anilist-manga</code> to include anilist information (if any) so you can check that the correct anilist id is attached. If the correct one is not attached (and it exists) then you can run the command:</li>
</ul>
-<p><code>sh
-mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922</code></p>
-<p>Which means that all &ldquo;searches&rdquo; for that <code>--name</code> flag will be attached to that specific anilist ID.
-3. If I&rsquo;m okay with the outputs, then I change <code>--json</code> for <code>--download</code> to actually download:</p>
-</li>
+<pre><code class="language-sh">mangal inline anilist set --name &quot;Kimetsu no Yaiba&quot; --id 101922
+</code></pre>
+<p>Which means that all &ldquo;searches&rdquo; for that <code>--name</code> flag will be attached to that specific anilist ID.</p>
+<ol start="3">
+<li>If I&rsquo;m okay with the outputs, then I change <code>--json</code> for <code>--download</code> to actually download:</li>
</ol>
<pre><code class="language-sh">mangal inline --source &quot;Mangapill&quot; --manga &quot;exact&quot; --query &quot;Kimetsu no Yaiba&quot; --download
</code></pre>
@@ -358,26 +370,26 @@ mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922</code></p>
<li>Check if the manga is downloaded correctly. I do this by going to my download directory and checking the directory name (I&rsquo;m picky with this stuff), that all chapters where downloaded, that it includes a correct <code>series.json</code> file and it contains a <code>cover.&lt;img-ext&gt;</code>; this usually means it correctly pulled information from anilist and that it will contain metadata Komga will be able to use.</li>
</ol>
<h4 id="komga-library">Komga library<a class="headerlink" href="#komga-library" title="Permanent link">&para;</a></h4>
-<p>Now I just check that it is correctly added to Komga by clicking on the 3 dots to the right of the library name and click on &ldquo;Scan library files&rdquo; to refresh if the cron timer hasn&rsquo;t pass by yet.</p>
+<p>Now I just check that it is correctly added to Komga by clicking on the 3 dots to the right of the library name and click on &ldquo;Scan library files&rdquo; to refresh if the cron timer hasn&rsquo;t activated this yet.</p>
<p>Then I check that the metadata is correct (once the manga is fully indexed), such as title, summary, chapter count, language, tags, genre, etc., which honestly it never works fine as <code>mangal</code> creates the <code>series.json</code> with the <code>comicId</code> field with an upper case <code>I</code> and Komga expects it to be a lower case <code>i</code> (<code>comicid</code>) so it falls back to using the info from the first chapter. I&rsquo;ll probably will fix this on <code>mangal</code> side, and see how it goes.</p>
<p>So, what I do is manually edit the metadata for the manga, by changing whatever it&rsquo;s wrong or add what&rsquo;s missing (I like adding anilist and MyAnimeList links) and then leave it as is.</p>
<h4 id="automation">Automation<a class="headerlink" href="#automation" title="Permanent link">&para;</a></h4>
-<p>The straight forward approach for automation is just to bundle a bunch of <code>mangal inline</code> commands in a shell script and automate either via <a href="https://wiki.archlinux.org/title/cron">cron</a> or <a href="https://wiki.archlinux.org/title/systemd/Timers">systemd/Timers</a>. But, as always, I overcomplicated/overengineered my approach, which is the following:</p>
+<p>The straight forward approach for automation is just to bundle a bunch of <code>mangal inline</code> commands in a shell script and schedule it&rsquo;s execution either via <a href="https://wiki.archlinux.org/title/cron">cron</a> or <a href="https://wiki.archlinux.org/title/systemd/Timers">systemd/Timers</a>. But, as always, I overcomplicated/overengineered my approach, which is the following:</p>
<ol>
<li>Group manga names per source.</li>
+<li>Configure anything that should always be set before executing <code>mangal</code>, this includes anilist bindings.</li>
<li>Have a way to track the changes/updates on each run.</li>
<li>Use that tracker to know where to start downloading chapters from.<ul>
-<li>This is optional, as you can just do <code>--chapters "all"</code> and it will work. This is mostly to keep the logs/output cleaner/shorter.</li>
+<li>This is optional, as you can just do <code>--chapters "all"</code> and it will work but I do it mostly to keep the logs/output cleaner/shorter.</li>
</ul>
</li>
-<li>Do any configuration needed beforehand.</li>
<li>Download/update each manga using <code>mangal inline</code>.</li>
-<li>Wrap everything in a <code>systemd</code> service and timer.</li>
+<li>Wrap everything in a <code>systemd</code> <code>service</code> and <code>timer</code>.</li>
</ol>
<p>Manga list example:</p>
<pre><code class="language-sh">mangapill=&quot;Berserk|Chainsaw Man|Dandadan|Jujutsu Kaisen|etc...&quot;
</code></pre>
-<p>Bash function that handles the download per manga in the list:</p>
+<p>Function that handles the download per manga in the list:</p>
<pre><code class="language-sh">mangal_src_dl () {
source_name=$1
manga_list=$(echo &quot;$2&quot; | tr '|' '\n')
@@ -413,6 +425,22 @@ mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922</code></p>
}
</code></pre>
<p>Where <code>$TRACKER_FILE</code> is just a variable holding a path to some file where you can store the tracking and <code>$DOWNLOAD_FORMAT</code> the format for the mangas, for me it&rsquo;s <code>cbz</code>. Then the usage would be something like <code>mangal_src_dl "Mangapill" "$mangapill"</code>, meaning that it is a function call per source.</p>
+<p>A simpler function without &ldquo;tracking&rdquo; would be:</p>
+<pre><code class="language-sh">mangal_src_dl () {
+ source_name=$1
+ manga_list=$(echo &quot;$2&quot; | tr '|' '\n')
+
+ while IFS= read -r line; do
+ echo &quot;Downloading all chapters for $line from $source_name...&quot;
+ mangal inline -S &quot;$source_name&quot; -q &quot;$line&quot; -m &quot;exact&quot; -F &quot;$DOWNLOAD_FORMAT&quot; -c &quot;all&quot; -d
+ if [ $? -ne 0 ]; then
+ echo &quot;Failed to download chapters for $line.&quot;
+ continue
+ fi
+ echo &quot;Finished downloading chapters for $line.&quot;
+ done &lt;&lt;&lt; &quot;$manga_list&quot;
+}
+</code></pre>
<p>The tracker file would have a format like follows:</p>
<pre><code># Updated: 06/10/23 10:53:15 AM CST
Berserk|0392|392|Mangapill
@@ -420,8 +448,12 @@ Dandadan|0110|110|Mangapill
...
</code></pre>
<p>And note that if you already had manga downloaded and you run the script for the first time, then it will show as if it downloaded everything from the first chapter, but that&rsquo;s just how <code>mangal</code> works, it will actually just discover downloaded chapters and only download anything missing.</p>
-<p>Any configuration the downloader/updater might need needs to be done before the <code>mangal_src_dl</code> calls. I like to configure mangal for download path, format, etc.. To clear the <code>mangal</code> cache and <code>rod</code> browser (headless browser used in some custom sources) as well as set up any anilist bindings. An example of an anilist binding I had to do is for Mushoku Tensei, as it has both a light novel and manga version, both having different information, for me it was <code>mangal inline anilist set --name "Mushoku Tensei - Isekai Ittara Honki Dasu" --id 85564</code>.</p>
-<p>Finally is just a matter of using your prefered way of scheduling, I&rsquo;ll use <code>systemd/Timers</code> but anything is fine. You could make the downloader script more sophisticated and only running every week on which each manga gets released usually, but that&rsquo;s too much work, so I&rsquo;ll just run it once daily probably, or 2-3 times daily.</p>
+<p>Any configuration the downloader/updater might need needs to be done before the <code>mangal_src_dl</code> calls. I like to configure mangal for download path, format, etc.. I found that it is needed to clear the <code>mangal</code> and <code>rod</code> browser cache (headless browser used in some custom sources) from personal experience and from others: <a href="https://github.com/metafates/mangal/issues/170">mangal#170</a> and <a href="https://github.com/oae/kaizoku/issues/89">kaizoku#89</a>.</p>
+<p>Also you should set any anilist binding necessary for the downloading (as the cache was cleared). An example of an anilist binding I had to do is for Mushoku Tensei, as it has both a <a href="https://anilist.co/manga/85470/Mushoku-Tensei-Jobless-Reincarnation/">light novel</a> and <a href="https://anilist.co/manga/85564/Mushoku-Tensei-Jobless-Reincarnation/">manga</a> version, which for me it&rsquo;s the following binding:</p>
+<pre><code class="language-sh">mangal inline anilist set --name &quot;Mushoku Tensei - Isekai Ittara Honki Dasu&quot; --id 85564
+</code></pre>
+<p>Finally is just a matter of using your prefered way of scheduling, I&rsquo;ll use <code>systemd/Timers</code> but anything is fine. You could make the downloader script more sophisticated and only running every week on which each manga gets (usually) released but that&rsquo;s too much work; I&rsquo;ll just run it once daily probably.</p>
+<p>A feature I want to add and probably will is sending notifications (probably through email) on a summary for manga downloaded or failed to download so I&rsquo;m on top of the updates. For now this is good enough and it&rsquo;s been working so far.</p>
<h3 id="alternative-downloaders">Alternative downloaders<a class="headerlink" href="#alternative-downloaders" title="Permanent link">&para;</a></h3>
<p>Just for the record, here is a list of downloaders/scrapers I considered before starting to use <code>mangal</code>:</p>
<ul>
@@ -457,6 +489,7 @@ Dandadan|0110|110|Mangapill
<div class="article-info">
<p>By David Luévano</p>
<p>Created: Sat, Jun 10, 2023 @ 19:36 UTC</p>
+ <p>Modified: Sun, Jun 11, 2023 @ 10:33 UTC</p>
<div class="article-tags">
<p>Tags:
<a href="https://blog.luevano.xyz/tag/@code.html">code</a>, <a href="https://blog.luevano.xyz/tag/@english.html">english</a>, <a href="https://blog.luevano.xyz/tag/@server.html">server</a>, <a href="https://blog.luevano.xyz/tag/@tools.html">tools</a>, <a href="https://blog.luevano.xyz/tag/@tutorial.html">tutorial</a> </p>
diff --git a/live/blog/rss.xml b/live/blog/rss.xml
index 7997277..303b255 100644
--- a/live/blog/rss.xml
+++ b/live/blog/rss.xml
@@ -105,7 +105,7 @@ sudo rm -r yay
</code></pre>
<p>This <code>komga</code> package creates a <code>komga</code> (service) user and group which is tied to the also included <code>komga.service</code>.</p>
<p>Configure it by editing <code>/etc/komga.conf</code>:</p>
-<pre><code class="language-conf">SERVER_PORT=8989
+<pre><code class="language-sh">SERVER_PORT=8989
SERVER_SERVLET_CONTEXT_PATH=/ # this depends a lot of how it's going to be served (domain, subdomain, ip, etc)
KOMGA_LIBRARIES_SCAN_CRON=&quot;0 0 * * * ?&quot;
@@ -122,14 +122,14 @@ KOMGA_DATABASE_BACKUP_SCHEDULE=&quot;0 0 */8 * * ?&quot;
<p>My changes (shown above):</p>
<ul>
<li>Port on <code>8989</code> because <code>8080</code> its too generic.</li>
-<li><code>cron</code> schedules<ul>
+<li><code>cron</code> schedules.<ul>
<li>It&rsquo;s not actually <code>cron</code> but rather a <code>cron</code>-like syntax used by <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html">Spring</a> as stated in the <a href="https://komga.org/installation/configuration.html#optional-configuration">Komga config</a>.</li>
</ul>
</li>
<li>Added the remember me key.</li>
<li>For more check out <a href="https://komga.org/installation/configuration.html">Komga: Configuration options</a>.</li>
</ul>
-<p>If you&rsquo;re going to run it locally (or LAN/VPN) you can start the <code>komga.service</code> and access it via IP at <code>http://&lt;your-server-ip&gt;:&lt;port&gt;(/base_url)</code> as stated at <a href="https://komga.org/installation/webui.html">Komga: Accessing the web interface</a>, else continue with the next steps for the reverse proxy and certificate.</p>
+<p>If you&rsquo;re going to run it locally (or LAN/VPN) you can start the <code>komga.service</code> and access it via IP at <code>http://&lt;your-server-ip&gt;:&lt;port&gt;(/base_url)</code> as stated at <a href="https://komga.org/installation/webui.html">Komga: Accessing the web interface</a>, then you can continue with the <a href="#mangal">mangal</a> section, else continue with the next steps for the reverse proxy and certificate.</p>
<h3 id="reverse-proxy">Reverse proxy<a class="headerlink" href="#reverse-proxy" title="Permanent link">&para;</a></h3>
<p>Create the reverse proxy configuration (this is for <code>nginx</code>). In my case I&rsquo;ll use a subdomain, so this is a new config called <code>komga.conf</code> at the usual <code>sites-available/enabled</code> path:</p>
<pre><code class="language-nginx">server {
@@ -149,7 +149,7 @@ KOMGA_DATABASE_BACKUP_SCHEDULE=&quot;0 0 */8 * * ?&quot;
}
}
</code></pre>
-<p>If it&rsquo;s going to be used as a subdir on another domain then just change the <code>location</code> (with <code>/subdir</code> instead of <code>/</code>) directive to the corresponding <code>.conf</code> file; be careful with the <code>proxy_pass</code> directive, it has to match what you configured at <code>/etc/komga.conf</code> for the <code>SERVER_SERVLET_CONTEXT_PATH</code> regardless of the <code>/subdir</code> you selected at <code>location</code>.</p>
+<p>If it&rsquo;s going to be used as a subdir on another domain then just change the <code>location</code> with <code>/subdir</code> instead of <code>/</code>; be careful with the <code>proxy_pass</code> directive, it has to match what you configured at <code>/etc/komga.conf</code> for the <code>SERVER_SERVLET_CONTEXT_PATH</code> regardless of the <code>/subdir</code> you selected at <code>location</code>.</p>
<h3 id="ssl-certificate">SSL certificate<a class="headerlink" href="#ssl-certificate" title="Permanent link">&para;</a></h3>
<p>If using a subdir then the same certificate for the subdomain/domain should work fine and no extra stuff is needed, else if following along me then we can create/extend the certificate by running:</p>
<pre><code class="language-sh">certbot --nginx
@@ -205,12 +205,12 @@ default:other::r-x
<p>So instad of installing with <code>yay</code> we&rsquo;ll build it from source. We need to have <code>go</code> installed:</p>
<pre><code class="language-sh">pacman -S go
</code></pre>
-<p>Then clone my fork of <code>mangal</code> and build/install it:</p>
+<p>Then clone my fork of <code>mangal</code> and <code>build</code>/<code>install</code> it:</p>
<pre><code class="language-sh">git clone https://github.com/luevano/mangal.git # not sure if you can use SSH to clone
cd mangal
make install # or just `make build` and then move the binary to somewhere in your $PATH
</code></pre>
-<p>This will use <code>go install</code> so it will install to a path specified by your environment variables, for more run <code>go help install</code>. It was installed to <code>$HOME/.local/bin/go/mangal</code> for me, then just make sure this is included in your PATH.</p>
+<p>This will use <code>go install</code> so it will install to a path specified by the <code>go</code> environment variables, for more run <code>go help install</code>. It was installed to <code>$HOME/.local/bin/go/mangal</code> for me because my env vars, then just make sure this is included in your <code>PATH</code>.</p>
<p>Check it was correctly installed by running <code>mangal version</code>, which should print something like:</p>
<pre><code>▇▇▇ mangal
@@ -238,11 +238,11 @@ mangal config set -k logs.write -v true # I like to get logs for what happens
<h3 id="usage_1">Usage<a class="headerlink" href="#usage_1" title="Permanent link">&para;</a></h3>
<p>Two main ways of using <code>mangal</code>: </p>
<ul>
-<li>TUI: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough.</li>
-<li>inline: for automation on manga that is still publishing and I need to check/download every once in a while.</li>
+<li><strong>TUI</strong>: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough.</li>
+<li><strong>inline</strong>: for automation on manga that is still publishing and I need to check/download every once in a while.</li>
</ul>
<h4 id="headless-browser">Headless browser<a class="headerlink" href="#headless-browser" title="Permanent link">&para;</a></h4>
-<p>Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the <em>headless</em> browser (actually just a wrapper of <a href="https://github.com/go-rod/rod">go-rod/rod</a>, and honestly it is not really a &ldquo;headless&rdquo; browser, <code>mangal</code> &ldquo;documentation&rdquo; is just wrong). For mor on my rant check out my last <a href="https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html">entry</a>.</p>
+<p>Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the <em>headless</em> browser (actually just a wrapper of <a href="https://github.com/go-rod/rod">go-rod/rod</a>, and honestly it is not really a &ldquo;headless&rdquo; browser, <code>mangal</code> &ldquo;documentation&rdquo; is just wrong). For more on my rant check out my last <a href="https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html">entry</a>.</p>
<p>There is no concrete documentation on the &ldquo;headless&rdquo; browser, only that it is automatically set up and ready to use&hellip; but it doesn&rsquo;t install any library/dependency needed. I discovered the following libraries that were missing on my Arch minimal install:</p>
<ul>
<li>library -&gt; arch package containing it</li>
@@ -268,18 +268,30 @@ mangal config set -k logs.write -v true # I like to get logs for what happens
<pre><code class="language-sh">mangal
</code></pre>
<p>Download manga using the TUI by selecting the source/scrapper, search the manga/comic you want and then you can select each chapter to download (use <code>tab</code> to select all). This is what I use when downloading manga that already finished publishing, or when I&rsquo;m just searching and testing out how it downloads the manga (directory name, and manga information).</p>
-<p>Note that some scrapters will contain duplicated chapters, as they have uploaded chapters from the community. This happens a lot with <a href="https://mangadex.org/">MangaDex</a>.</p>
+<p>Note that some scrapters will contain duplicated chapters, as they have multiple uploaded chapters from the community, usually for different <em>scanlation groups</em>. This happens a lot with <a href="https://mangadex.org/">MangaDex</a>.</p>
<h4 id="inline">Inline<a class="headerlink" href="#inline" title="Permanent link">&para;</a></h4>
<p>The inline mode is a single terminal command meant to be used to automate stuff or for more advanced options. You can peek a bit into the &ldquo;<a href="https://github.com/metafates/mangal/wiki/Inline-mode#command-examples">documentation</a>&rdquo; which honestly its ass because it doesn&rsquo;t explain much. The minimal command for inline according to the help is:</p>
<pre><code class="language-sh">mangal inline --manga &lt;option&gt; --query &lt;manga-title&gt;
</code></pre>
-<p>But this will not produce anything because it also needs <code>--source</code> (or set the default using the config key <code>downloader.default_sources</code>) and either <code>--json</code> (for the search result) or <code>--download</code> to actually download whatever was found but it could download something you don&rsquo;t want so do the <code>--json</code> first.</p>
+<p>But this will not produce anything because it also needs <code>--source</code> (or set the default using the config key <code>downloader.default_sources</code>) and either <code>--json</code> which basically just does the search and returns the result in <code>json</code> format or <code>--download</code> to actually download whatever is found; I recommend to do <code>--json</code> first to check that the correct manga will be downloaded then do <code>--download</code>.</p>
<p>Something not mentioned anywhere is the <code>--manga</code> flag options (found it at the source code), it has 3 available options:</p>
<ul>
<li><code>first</code>: first manga entry found for the search.</li>
<li><code>last</code>: last manga entry found for the search.</li>
<li><code>exact</code>: exact manga title match. This is the one I use.</li>
</ul>
+<p>Similar to <code>--chapters</code>, there are a few options not explained (that I found at the source code, too). I usually just use <code>all</code> but other options:</p>
+<ul>
+<li><code>all</code>: all chapters found in the chapter list.</li>
+<li><code>first</code>: first chapter found in the chapter list.</li>
+<li><code>last</code>: last chapter found in the chapter list</li>
+<li><code>[from]-[to]</code>: selector for the chapters found in the chapter list, index starts at 0.<ul>
+<li>If the selectors (<code>from</code> or <code>to</code>) exceed the amount of chapters in the chapterlist it just adjusts to he maximum available.</li>
+<li>I had to fix this at the source code because if you wanted <code>to</code> to be the last chapter, it did <code>to + 1</code> and it failed due to index out of range.</li>
+</ul>
+</li>
+<li><code>@[sub]@</code>: not sure how this works exactly, my understanding is that it&rsquo;s for &ldquo;named&rdquo; chapters.</li>
+</ul>
<p>That said, I&rsquo;ll do an example by using <a href="https://mangapill.com">Mangapill</a> as source, and will search for <a href="https://mangapill.com/manga/2285/kimetsu-no-yaiba">Demon Slayer: Kimetsu no Yaiba</a>:</p>
<ol>
<li>Search first and make sure my command will pull the manga I want:</li>
@@ -287,16 +299,16 @@ mangal config set -k logs.write -v true # I like to get logs for what happens
<pre><code class="language-sh">mangal inline --source &quot;Mangapill&quot; --manga &quot;exact&quot; --query &quot;Kimetsu no Yaiba&quot; --json | jq # I use jq to pretty format the output
</code></pre>
<ol start="2">
-<li>
-<p>I make sure the json output contains the correct manga information: name, url, etc..</p>
+<li>I make sure the json output contains the correct manga information: name, url, etc..</li>
+</ol>
<ul>
<li>You can also include the flag <code>--include-anilist-manga</code> to include anilist information (if any) so you can check that the correct anilist id is attached. If the correct one is not attached (and it exists) then you can run the command:</li>
</ul>
-<p><code>sh
-mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922</code></p>
-<p>Which means that all &ldquo;searches&rdquo; for that <code>--name</code> flag will be attached to that specific anilist ID.
-3. If I&rsquo;m okay with the outputs, then I change <code>--json</code> for <code>--download</code> to actually download:</p>
-</li>
+<pre><code class="language-sh">mangal inline anilist set --name &quot;Kimetsu no Yaiba&quot; --id 101922
+</code></pre>
+<p>Which means that all &ldquo;searches&rdquo; for that <code>--name</code> flag will be attached to that specific anilist ID.</p>
+<ol start="3">
+<li>If I&rsquo;m okay with the outputs, then I change <code>--json</code> for <code>--download</code> to actually download:</li>
</ol>
<pre><code class="language-sh">mangal inline --source &quot;Mangapill&quot; --manga &quot;exact&quot; --query &quot;Kimetsu no Yaiba&quot; --download
</code></pre>
@@ -304,26 +316,26 @@ mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922</code></p>
<li>Check if the manga is downloaded correctly. I do this by going to my download directory and checking the directory name (I&rsquo;m picky with this stuff), that all chapters where downloaded, that it includes a correct <code>series.json</code> file and it contains a <code>cover.&lt;img-ext&gt;</code>; this usually means it correctly pulled information from anilist and that it will contain metadata Komga will be able to use.</li>
</ol>
<h4 id="komga-library">Komga library<a class="headerlink" href="#komga-library" title="Permanent link">&para;</a></h4>
-<p>Now I just check that it is correctly added to Komga by clicking on the 3 dots to the right of the library name and click on &ldquo;Scan library files&rdquo; to refresh if the cron timer hasn&rsquo;t pass by yet.</p>
+<p>Now I just check that it is correctly added to Komga by clicking on the 3 dots to the right of the library name and click on &ldquo;Scan library files&rdquo; to refresh if the cron timer hasn&rsquo;t activated this yet.</p>
<p>Then I check that the metadata is correct (once the manga is fully indexed), such as title, summary, chapter count, language, tags, genre, etc., which honestly it never works fine as <code>mangal</code> creates the <code>series.json</code> with the <code>comicId</code> field with an upper case <code>I</code> and Komga expects it to be a lower case <code>i</code> (<code>comicid</code>) so it falls back to using the info from the first chapter. I&rsquo;ll probably will fix this on <code>mangal</code> side, and see how it goes.</p>
<p>So, what I do is manually edit the metadata for the manga, by changing whatever it&rsquo;s wrong or add what&rsquo;s missing (I like adding anilist and MyAnimeList links) and then leave it as is.</p>
<h4 id="automation">Automation<a class="headerlink" href="#automation" title="Permanent link">&para;</a></h4>
-<p>The straight forward approach for automation is just to bundle a bunch of <code>mangal inline</code> commands in a shell script and automate either via <a href="https://wiki.archlinux.org/title/cron">cron</a> or <a href="https://wiki.archlinux.org/title/systemd/Timers">systemd/Timers</a>. But, as always, I overcomplicated/overengineered my approach, which is the following:</p>
+<p>The straight forward approach for automation is just to bundle a bunch of <code>mangal inline</code> commands in a shell script and schedule it&rsquo;s execution either via <a href="https://wiki.archlinux.org/title/cron">cron</a> or <a href="https://wiki.archlinux.org/title/systemd/Timers">systemd/Timers</a>. But, as always, I overcomplicated/overengineered my approach, which is the following:</p>
<ol>
<li>Group manga names per source.</li>
+<li>Configure anything that should always be set before executing <code>mangal</code>, this includes anilist bindings.</li>
<li>Have a way to track the changes/updates on each run.</li>
<li>Use that tracker to know where to start downloading chapters from.<ul>
-<li>This is optional, as you can just do <code>--chapters "all"</code> and it will work. This is mostly to keep the logs/output cleaner/shorter.</li>
+<li>This is optional, as you can just do <code>--chapters "all"</code> and it will work but I do it mostly to keep the logs/output cleaner/shorter.</li>
</ul>
</li>
-<li>Do any configuration needed beforehand.</li>
<li>Download/update each manga using <code>mangal inline</code>.</li>
-<li>Wrap everything in a <code>systemd</code> service and timer.</li>
+<li>Wrap everything in a <code>systemd</code> <code>service</code> and <code>timer</code>.</li>
</ol>
<p>Manga list example:</p>
<pre><code class="language-sh">mangapill=&quot;Berserk|Chainsaw Man|Dandadan|Jujutsu Kaisen|etc...&quot;
</code></pre>
-<p>Bash function that handles the download per manga in the list:</p>
+<p>Function that handles the download per manga in the list:</p>
<pre><code class="language-sh">mangal_src_dl () {
source_name=$1
manga_list=$(echo &quot;$2&quot; | tr '|' '\n')
@@ -359,6 +371,22 @@ mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922</code></p>
}
</code></pre>
<p>Where <code>$TRACKER_FILE</code> is just a variable holding a path to some file where you can store the tracking and <code>$DOWNLOAD_FORMAT</code> the format for the mangas, for me it&rsquo;s <code>cbz</code>. Then the usage would be something like <code>mangal_src_dl "Mangapill" "$mangapill"</code>, meaning that it is a function call per source.</p>
+<p>A simpler function without &ldquo;tracking&rdquo; would be:</p>
+<pre><code class="language-sh">mangal_src_dl () {
+ source_name=$1
+ manga_list=$(echo &quot;$2&quot; | tr '|' '\n')
+
+ while IFS= read -r line; do
+ echo &quot;Downloading all chapters for $line from $source_name...&quot;
+ mangal inline -S &quot;$source_name&quot; -q &quot;$line&quot; -m &quot;exact&quot; -F &quot;$DOWNLOAD_FORMAT&quot; -c &quot;all&quot; -d
+ if [ $? -ne 0 ]; then
+ echo &quot;Failed to download chapters for $line.&quot;
+ continue
+ fi
+ echo &quot;Finished downloading chapters for $line.&quot;
+ done &lt;&lt;&lt; &quot;$manga_list&quot;
+}
+</code></pre>
<p>The tracker file would have a format like follows:</p>
<pre><code># Updated: 06/10/23 10:53:15 AM CST
Berserk|0392|392|Mangapill
@@ -366,8 +394,12 @@ Dandadan|0110|110|Mangapill
...
</code></pre>
<p>And note that if you already had manga downloaded and you run the script for the first time, then it will show as if it downloaded everything from the first chapter, but that&rsquo;s just how <code>mangal</code> works, it will actually just discover downloaded chapters and only download anything missing.</p>
-<p>Any configuration the downloader/updater might need needs to be done before the <code>mangal_src_dl</code> calls. I like to configure mangal for download path, format, etc.. To clear the <code>mangal</code> cache and <code>rod</code> browser (headless browser used in some custom sources) as well as set up any anilist bindings. An example of an anilist binding I had to do is for Mushoku Tensei, as it has both a light novel and manga version, both having different information, for me it was <code>mangal inline anilist set --name "Mushoku Tensei - Isekai Ittara Honki Dasu" --id 85564</code>.</p>
-<p>Finally is just a matter of using your prefered way of scheduling, I&rsquo;ll use <code>systemd/Timers</code> but anything is fine. You could make the downloader script more sophisticated and only running every week on which each manga gets released usually, but that&rsquo;s too much work, so I&rsquo;ll just run it once daily probably, or 2-3 times daily.</p>
+<p>Any configuration the downloader/updater might need needs to be done before the <code>mangal_src_dl</code> calls. I like to configure mangal for download path, format, etc.. I found that it is needed to clear the <code>mangal</code> and <code>rod</code> browser cache (headless browser used in some custom sources) from personal experience and from others: <a href="https://github.com/metafates/mangal/issues/170">mangal#170</a> and <a href="https://github.com/oae/kaizoku/issues/89">kaizoku#89</a>.</p>
+<p>Also you should set any anilist binding necessary for the downloading (as the cache was cleared). An example of an anilist binding I had to do is for Mushoku Tensei, as it has both a <a href="https://anilist.co/manga/85470/Mushoku-Tensei-Jobless-Reincarnation/">light novel</a> and <a href="https://anilist.co/manga/85564/Mushoku-Tensei-Jobless-Reincarnation/">manga</a> version, which for me it&rsquo;s the following binding:</p>
+<pre><code class="language-sh">mangal inline anilist set --name &quot;Mushoku Tensei - Isekai Ittara Honki Dasu&quot; --id 85564
+</code></pre>
+<p>Finally is just a matter of using your prefered way of scheduling, I&rsquo;ll use <code>systemd/Timers</code> but anything is fine. You could make the downloader script more sophisticated and only running every week on which each manga gets (usually) released but that&rsquo;s too much work; I&rsquo;ll just run it once daily probably.</p>
+<p>A feature I want to add and probably will is sending notifications (probably through email) on a summary for manga downloaded or failed to download so I&rsquo;m on top of the updates. For now this is good enough and it&rsquo;s been working so far.</p>
<h3 id="alternative-downloaders">Alternative downloaders<a class="headerlink" href="#alternative-downloaders" title="Permanent link">&para;</a></h3>
<p>Just for the record, here is a list of downloaders/scrapers I considered before starting to use <code>mangal</code>:</p>
<ul>
diff --git a/live/blog/sitemap.xml b/live/blog/sitemap.xml
index 1904029..a30b52f 100644
--- a/live/blog/sitemap.xml
+++ b/live/blog/sitemap.xml
@@ -47,7 +47,7 @@
<url>
<loc>https://blog.luevano.xyz/a/manga_server_with_komga.html</loc>
- <lastmod>2023-06-10</lastmod>
+ <lastmod>2023-06-11</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
diff --git a/src/blog/a/manga_server_with_komga.md b/src/blog/a/manga_server_with_komga.md
index fb5feac..257e0d7 100644
--- a/src/blog/a/manga_server_with_komga.md
+++ b/src/blog/a/manga_server_with_komga.md
@@ -75,7 +75,7 @@ This `komga` package creates a `komga` (service) user and group which is tied to
Configure it by editing `/etc/komga.conf`:
-```conf
+```sh
SERVER_PORT=8989
SERVER_SERVLET_CONTEXT_PATH=/ # this depends a lot of how it's going to be served (domain, subdomain, ip, etc)
@@ -94,12 +94,12 @@ KOMGA_DATABASE_BACKUP_SCHEDULE="0 0 */8 * * ?"
My changes (shown above):
- Port on `8989` because `8080` its too generic.
-- `cron` schedules
+- `cron` schedules.
- It's not actually `cron` but rather a `cron`-like syntax used by [Spring](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html) as stated in the [Komga config](https://komga.org/installation/configuration.html#optional-configuration).
- Added the remember me key.
- For more check out [Komga: Configuration options](https://komga.org/installation/configuration.html).
-If you're going to run it locally (or LAN/VPN) you can start the `komga.service` and access it via IP at `http://<your-server-ip>:<port>(/base_url)` as stated at [Komga: Accessing the web interface](https://komga.org/installation/webui.html), else continue with the next steps for the reverse proxy and certificate.
+If you're going to run it locally (or LAN/VPN) you can start the `komga.service` and access it via IP at `http://<your-server-ip>:<port>(/base_url)` as stated at [Komga: Accessing the web interface](https://komga.org/installation/webui.html), then you can continue with the [mangal](#mangal) section, else continue with the next steps for the reverse proxy and certificate.
## Reverse proxy
@@ -124,7 +124,7 @@ server {
}
```
-If it's going to be used as a subdir on another domain then just change the `location` (with `/subdir` instead of `/`) directive to the corresponding `.conf` file; be careful with the `proxy_pass` directive, it has to match what you configured at `/etc/komga.conf` for the `SERVER_SERVLET_CONTEXT_PATH` regardless of the `/subdir` you selected at `location`.
+If it's going to be used as a subdir on another domain then just change the `location` with `/subdir` instead of `/`; be careful with the `proxy_pass` directive, it has to match what you configured at `/etc/komga.conf` for the `SERVER_SERVLET_CONTEXT_PATH` regardless of the `/subdir` you selected at `location`.
## SSL certificate
@@ -222,7 +222,7 @@ So instad of installing with `yay` we'll build it from source. We need to have `
pacman -S go
```
-Then clone my fork of `mangal` and build/install it:
+Then clone my fork of `mangal` and `build`/`install` it:
```sh
git clone https://github.com/luevano/mangal.git # not sure if you can use SSH to clone
@@ -230,7 +230,7 @@ cd mangal
make install # or just `make build` and then move the binary to somewhere in your $PATH
```
-This will use `go install` so it will install to a path specified by your environment variables, for more run `go help install`. It was installed to `$HOME/.local/bin/go/mangal` for me, then just make sure this is included in your PATH.
+This will use `go install` so it will install to a path specified by the `go` environment variables, for more run `go help install`. It was installed to `$HOME/.local/bin/go/mangal` for me because my env vars, then just make sure this is included in your `PATH`.
Check it was correctly installed by running `mangal version`, which should print something like:
@@ -275,12 +275,12 @@ And install whatever you want, it picks up the sources/scrapers from the configu
Two main ways of using `mangal`:
-- TUI: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough.
-- inline: for automation on manga that is still publishing and I need to check/download every once in a while.
+- **TUI**: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough.
+- **inline**: for automation on manga that is still publishing and I need to check/download every once in a while.
### Headless browser
-Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the *headless* browser (actually just a wrapper of [go-rod/rod](https://github.com/go-rod/rod), and honestly it is not really a "headless" browser, `mangal` "documentation" is just wrong). For mor on my rant check out my last [entry](https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html).
+Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the *headless* browser (actually just a wrapper of [go-rod/rod](https://github.com/go-rod/rod), and honestly it is not really a "headless" browser, `mangal` "documentation" is just wrong). For more on my rant check out my last [entry](https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html).
There is no concrete documentation on the "headless" browser, only that it is automatically set up and ready to use... but it doesn't install any library/dependency needed. I discovered the following libraries that were missing on my Arch minimal install:
@@ -317,7 +317,7 @@ mangal
Download manga using the TUI by selecting the source/scrapper, search the manga/comic you want and then you can select each chapter to download (use `tab` to select all). This is what I use when downloading manga that already finished publishing, or when I'm just searching and testing out how it downloads the manga (directory name, and manga information).
-Note that some scrapters will contain duplicated chapters, as they have uploaded chapters from the community. This happens a lot with [MangaDex](https://mangadex.org/).
+Note that some scrapters will contain duplicated chapters, as they have multiple uploaded chapters from the community, usually for different *scanlation groups*. This happens a lot with [MangaDex](https://mangadex.org/).
### Inline
@@ -327,7 +327,7 @@ The inline mode is a single terminal command meant to be used to automate stuff
mangal inline --manga <option> --query <manga-title>
```
-But this will not produce anything because it also needs `--source` (or set the default using the config key `downloader.default_sources`) and either `--json` (for the search result) or `--download` to actually download whatever was found but it could download something you don't want so do the `--json` first.
+But this will not produce anything because it also needs `--source` (or set the default using the config key `downloader.default_sources`) and either `--json` which basically just does the search and returns the result in `json` format or `--download` to actually download whatever is found; I recommend to do `--json` first to check that the correct manga will be downloaded then do `--download`.
Something not mentioned anywhere is the `--manga` flag options (found it at the source code), it has 3 available options:
@@ -335,6 +335,16 @@ Something not mentioned anywhere is the `--manga` flag options (found it at the
- `last`: last manga entry found for the search.
- `exact`: exact manga title match. This is the one I use.
+Similar to `--chapters`, there are a few options not explained (that I found at the source code, too). I usually just use `all` but other options:
+
+- `all`: all chapters found in the chapter list.
+- `first`: first chapter found in the chapter list.
+- `last`: last chapter found in the chapter list
+- `[from]-[to]`: selector for the chapters found in the chapter list, index starts at 0.
+ - If the selectors (`from` or `to`) exceed the amount of chapters in the chapterlist it just adjusts to he maximum available.
+ - I had to fix this at the source code because if you wanted `to` to be the last chapter, it did `to + 1` and it failed due to index out of range.
+- `@[sub]@`: not sure how this works exactly, my understanding is that it's for "named" chapters.
+
That said, I'll do an example by using [Mangapill](https://mangapill.com) as source, and will search for [Demon Slayer: Kimetsu no Yaiba](https://mangapill.com/manga/2285/kimetsu-no-yaiba):
1. Search first and make sure my command will pull the manga I want:
@@ -344,13 +354,15 @@ mangal inline --source "Mangapill" --manga "exact" --query "Kimetsu no Yaiba" --
```
2. I make sure the json output contains the correct manga information: name, url, etc..
- - You can also include the flag `--include-anilist-manga` to include anilist information (if any) so you can check that the correct anilist id is attached. If the correct one is not attached (and it exists) then you can run the command:
- ```sh
- mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922
- ```
+- You can also include the flag `--include-anilist-manga` to include anilist information (if any) so you can check that the correct anilist id is attached. If the correct one is not attached (and it exists) then you can run the command:
+
+```sh
+mangal inline anilist set --name "Kimetsu no Yaiba" --id 101922
+```
+
+Which means that all "searches" for that `--name` flag will be attached to that specific anilist ID.
- Which means that all "searches" for that `--name` flag will be attached to that specific anilist ID.
3. If I'm okay with the outputs, then I change `--json` for `--download` to actually download:
```sh
@@ -361,7 +373,7 @@ mangal inline --source "Mangapill" --manga "exact" --query "Kimetsu no Yaiba" --
### Komga library
-Now I just check that it is correctly added to Komga by clicking on the 3 dots to the right of the library name and click on "Scan library files" to refresh if the cron timer hasn't pass by yet.
+Now I just check that it is correctly added to Komga by clicking on the 3 dots to the right of the library name and click on "Scan library files" to refresh if the cron timer hasn't activated this yet.
Then I check that the metadata is correct (once the manga is fully indexed), such as title, summary, chapter count, language, tags, genre, etc., which honestly it never works fine as `mangal` creates the `series.json` with the `comicId` field with an upper case `I` and Komga expects it to be a lower case `i` (`comicid`) so it falls back to using the info from the first chapter. I'll probably will fix this on `mangal` side, and see how it goes.
@@ -369,15 +381,15 @@ So, what I do is manually edit the metadata for the manga, by changing whatever
### Automation
-The straight forward approach for automation is just to bundle a bunch of `mangal inline` commands in a shell script and automate either via [cron](https://wiki.archlinux.org/title/cron) or [systemd/Timers](https://wiki.archlinux.org/title/systemd/Timers). But, as always, I overcomplicated/overengineered my approach, which is the following:
+The straight forward approach for automation is just to bundle a bunch of `mangal inline` commands in a shell script and schedule it's execution either via [cron](https://wiki.archlinux.org/title/cron) or [systemd/Timers](https://wiki.archlinux.org/title/systemd/Timers). But, as always, I overcomplicated/overengineered my approach, which is the following:
1. Group manga names per source.
-2. Have a way to track the changes/updates on each run.
-3. Use that tracker to know where to start downloading chapters from.
- - This is optional, as you can just do `--chapters "all"` and it will work. This is mostly to keep the logs/output cleaner/shorter.
-4. Do any configuration needed beforehand.
+2. Configure anything that should always be set before executing `mangal`, this includes anilist bindings.
+3. Have a way to track the changes/updates on each run.
+4. Use that tracker to know where to start downloading chapters from.
+ - This is optional, as you can just do `--chapters "all"` and it will work but I do it mostly to keep the logs/output cleaner/shorter.
5. Download/update each manga using `mangal inline`.
-6. Wrap everything in a `systemd` service and timer.
+6. Wrap everything in a `systemd` `service` and `timer`.
Manga list example:
@@ -385,7 +397,7 @@ Manga list example:
mangapill="Berserk|Chainsaw Man|Dandadan|Jujutsu Kaisen|etc..."
```
-Bash function that handles the download per manga in the list:
+Function that handles the download per manga in the list:
```sh
mangal_src_dl () {
@@ -425,6 +437,25 @@ mangal_src_dl () {
Where `$TRACKER_FILE` is just a variable holding a path to some file where you can store the tracking and `$DOWNLOAD_FORMAT` the format for the mangas, for me it's `cbz`. Then the usage would be something like `mangal_src_dl "Mangapill" "$mangapill"`, meaning that it is a function call per source.
+A simpler function without "tracking" would be:
+
+```sh
+mangal_src_dl () {
+ source_name=$1
+ manga_list=$(echo "$2" | tr '|' '\n')
+
+ while IFS= read -r line; do
+ echo "Downloading all chapters for $line from $source_name..."
+ mangal inline -S "$source_name" -q "$line" -m "exact" -F "$DOWNLOAD_FORMAT" -c "all" -d
+ if [ $? -ne 0 ]; then
+ echo "Failed to download chapters for $line."
+ continue
+ fi
+ echo "Finished downloading chapters for $line."
+ done <<< "$manga_list"
+}
+```
+
The tracker file would have a format like follows:
```
@@ -436,9 +467,17 @@ Dandadan|0110|110|Mangapill
And note that if you already had manga downloaded and you run the script for the first time, then it will show as if it downloaded everything from the first chapter, but that's just how `mangal` works, it will actually just discover downloaded chapters and only download anything missing.
-Any configuration the downloader/updater might need needs to be done before the `mangal_src_dl` calls. I like to configure mangal for download path, format, etc.. To clear the `mangal` cache and `rod` browser (headless browser used in some custom sources) as well as set up any anilist bindings. An example of an anilist binding I had to do is for Mushoku Tensei, as it has both a light novel and manga version, both having different information, for me it was `mangal inline anilist set --name "Mushoku Tensei - Isekai Ittara Honki Dasu" --id 85564`.
+Any configuration the downloader/updater might need needs to be done before the `mangal_src_dl` calls. I like to configure mangal for download path, format, etc.. I found that it is needed to clear the `mangal` and `rod` browser cache (headless browser used in some custom sources) from personal experience and from others: [mangal#170](https://github.com/metafates/mangal/issues/170) and [kaizoku#89](https://github.com/oae/kaizoku/issues/89).
+
+Also you should set any anilist binding necessary for the downloading (as the cache was cleared). An example of an anilist binding I had to do is for Mushoku Tensei, as it has both a [light novel](https://anilist.co/manga/85470/Mushoku-Tensei-Jobless-Reincarnation/) and [manga](https://anilist.co/manga/85564/Mushoku-Tensei-Jobless-Reincarnation/) version, which for me it's the following binding:
+
+```sh
+mangal inline anilist set --name "Mushoku Tensei - Isekai Ittara Honki Dasu" --id 85564
+```
+
+Finally is just a matter of using your prefered way of scheduling, I'll use `systemd/Timers` but anything is fine. You could make the downloader script more sophisticated and only running every week on which each manga gets (usually) released but that's too much work; I'll just run it once daily probably.
-Finally is just a matter of using your prefered way of scheduling, I'll use `systemd/Timers` but anything is fine. You could make the downloader script more sophisticated and only running every week on which each manga gets released usually, but that's too much work, so I'll just run it once daily probably, or 2-3 times daily.
+A feature I want to add and probably will is sending notifications (probably through email) on a summary for manga downloaded or failed to download so I'm on top of the updates. For now this is good enough and it's been working so far.
## Alternative downloaders