tardypad/sailfishos-daily-comics

C. Cassandra needs to be updated

Opened this issue · 4 comments

The current comic got from Tumblr often now shows only a preview of the comic and leaves the punchline out. Full comics can be found at https://tapas.io/series/CassandraComics.

I have a solution for cassandra comics but due to bug in Qt it will freeze application until comics download.
I can't take this decision myself. @tardypad What do you think about it?
Solution:

function(page) {
    var regex = /<a\sclass="ga-tracking\sjs-episode\s+"(.|\s)+?href="([^"]+)"/
    var match = regex.exec(page);
    var url = "https://tapas.io" + match[2]
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url , false);
    xhr.send(null);
    if(xhr.status === 200)
    {
        var newPage = xhr.responseText;
        var regex2 = /<img\s*src="([^"]*)"\sclass="content__img"/
        var match2 = regex2.exec(newPage);
        return match2[1];
    }
}

@Maledictus The javascript plugin is only supposed to extract the strip URL from a page. There shouldn't be any other logic like further requests.

AFAIR There would need to be more changes around the fetching/parsing logic in the C++ code to handle this properly.

I think C Cassandra should be removed for now. Last time I've checked (a long time ago) it wasn't possible to use comics from tapas.io in the app.

@tardypad I can do it on C++ side but I don't want to hardcode something comics-related in c++.

Yes there shouldn't be such comic specific code in there.

What I mean is that if there is more logic in the Javascript than just parsing, there needs to be some more general changes in the C++ side:

  • the function is no more just a simple "extractStripImageUrl"
  • we should properly handle and reports network and other type of errors from the Javascript code
  • maybe other stuff I don't remember

I wouldn't introduce those complex changes just to fix a single comic. If there are more requests for comics that would require such a feature, then maybe it'd be justified.
And if the app freezes when doing such downloads in the Javascript, I think it's another good reason not to do it for now.