tardypad / sailfishos-daily-comics

Daily comic strips reader for SailfishOS
MIT License
12 stars 17 forks source link

C. Cassandra needs to be updated #89

Open Ingvix opened 5 years ago

Ingvix commented 5 years ago

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.

Maledictus commented 4 years ago

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];
    }
}
tardypad commented 4 years ago

@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.

Maledictus commented 4 years ago

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

tardypad commented 4 years ago

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:

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.