tardypad/sailfishos-daily-comics

Adding erzaehlmirnix comic

Closed this issue · 2 comments

Olf0 commented

Because I recently started to read the erzaehlmirnix comic strips, I really would like to be able to do so in DailyComics (which I am using daily for years).

Hence started some research:

First I wanted to see, if the strips proper (i.e. in some bitmap format) can be easily extracted from Twitter (I originally had doubts) and ended up with this piece of shell code for experimenting:

URL="https://mobile.twitter.com/erzaehlmirnix/media/grid"
URL="https://mobile.twitter.com/erzaehlmirnix/media/grid?idx=0"
SRC="$(curl -sS "$URL" | sed -n '/div class="card-photo"/,/\/div/p' | fgrep img | grep -o 'src="https.*"' | cut -f 2 -d '"' | cut -f 1-2 -d ":")"
SIZE=large
SIZE=medium
SIZE=small
curl -sSo "${SIZE}-$(echo "$SRC" | rev | cut -f 1 -d "/" | rev)" "$SRC:$SIZE"
ls -l *.png
  • The two URLs are equivalent, i.e. result in exactly the same page to be downloaded.
  • Older strips can be accessed be increasing the idx= numeric value of the second URL.
  • The three SIZEes (there may be more) are equivalent, i.e. result in exactly the same image file to be downloaded.
  • I discovered later, that the :$SIZE appendix can be omitted, still resulting in exactly the same image file to be downloaded.
  • Note that erzaehlmirnix strips are only available in PNG format.

So I consulted the detailed Addition of new comic info page:

  • Identifier name: erzaehlmirnix
  • info.json
{
"name": "erzaehlmirnix",
"color": "c1c3c2",
"language": "de",
"authors": [
"Nadja Hermann"
],
"homepage": "https://mobile.twitter.com/erzaehlmirnix/",
"stripSource": "https://mobile.twitter.com/erzaehlmirnix/media/grid"
}

(As a white "comic specific colour" (= background colour) is reasonably forbidden, choosing a light gray for this black & white comic strip.)

  • extract.js
function(page) {
var regex = /<img[^>]*id="[^"]*"[^>]*src="(https:[^":]*)[":]/;
var match = regex.exec(page);
return match[1];
}

While I seem to have the technical basics done and may now start to create an erzaehlmirnix logo from either logo-qpCYyk3_400x400
(source) or the last panel of a recent, typical strip (e.g., small-ERKZsSZXkAIqe09
(and use that strip as example file, too)) finally exported in JPEG format, I wonder if it really makes sense to continue working on this, due to the denoted requirement for the daily strip proper being in JPEG format: It is only available as PNG.

Can anyone clarify if that statement is still an unconditional requirement, or if DailyComics can also handle PNGs?

Olf0 commented

That was easier than expected, see PR #95:

  • The URL of the strip proper pointing to a file in PNG format works fine.
    It seems that the explicit statement only addresses local files (cover.jpg, example.jpg etc.).
  • While I was unable to find the refresher scripts mentioned, they did not seem to be necessary:
    After creating a new directory in /usr/share/harbour-dailycomics/plugins/, putting the correct files in there and freshly starting DailyComics, everything was working as expected.

P.S.: Still I wonder, why the local files ought to be in JPEG format, especially as this requires the color value from the info.json to be manually set for the background of the cover*.jpg and creates visible compression artifacts around edges with harsh contrasts (e.g., text!).
Allowing local files in PNG format would alleviate this due to its transparency support (hence the background color can be automatically set according to the color value from info.json) and lossless compression (still often resulting in similar file sizes as an JPEG).

Olf0 commented

Done, see PR #95 (first try, from Twitter) and the current PR #105 (now from Facebook).