Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

6
Become a Fan
5.5

Description:
xkcd (http://xkcd.com/) plugin for plasma comic.
Last changelog:

2.0

Thanks to Mike Vastola for his updates to make the comic work again.
To reduce the risk for issues in the future Mike changed the code to use XKCD's JSON API.


Ratings & Comments

18 Comments

raphis

8 8 great

mvastola

Thanks for this addon. It's worked for the longest time. I've been running into issues for a while now though, and I tried @TuxmAL's patch, but it didn't work (the regex still wasn't parsing correctly). I played with the code a bit (okay, a lot) and changed things to use XKCD's JSON API instead, which makes parsing much easier and hopefully also makes this more resilient to website changes. I'm not sure if this is still being maintained, but if so, feel free to incorporate my changes. I could fork, but it would be nicer to fix things for long-time users of this comic addin instead. See: https://gist.github.com/mvastola/6d937854f2202091afc2fbb2f7253ef6

raphis

Hi Mike, the patch from @TuxmAL actually worked for me today. Anyhow I like the idea of parsing the JSON, hope it is more robust so it gets used here on the main branch. Thanks to you both!

mfuchs

Thank you very much for your patch! I applied it and it works again now. Your solution seems way more robust than what I had there. :)

mfuchs

And sorry for the long delay.

TuxmAL

Some changes in xkcd.com site, has broken xkcd comics again. To restore the functionality please add this patch to the downloaded version: ``` 35c35 < var re = new RegExp("Permanent link to this comic: https://xkcd.com/(\\d )/"); --- > var re = new RegExp("https://xkcd.com/(\\d )/"); 86c86 < var re = new RegExp("Image URL \\(for hotlinking/embedding\\): (https://imgs\.xkcd\.com/comics/. )"); --- > var re = new RegExp('"(https://imgs\.xkcd\.com/comics/. )"'); ```

mfuchs

Thank you for the information. I am sorry that it took me so long to react.

TuxmAL

You're welcome!

z3ntu

Broken, please fix :)

TuxmAL

Hi, I've noted a change in xkcd.com site, gone full https now. Here are the fixes needed to patch the code: 33c33 < var re = new RegExp("Permanent link to this comic: http://xkcd.com/(\\d+)/"); --- > var re = new RegExp("Permanent link to this comic: https://xkcd.com/(\\d+)/"); 47c47 < comic.requestPage("http:" + match[1], comic.Image); --- > comic.requestPage("https:" + match[1], comic.Image); a couple of fix again makes ' and " in additionalText looks like quote and double quote: 56c56,57 < comic.additionalText = match[2]; --- > var additionalTxt = match[2]; > comic.additionalText = additionalTxt.replace(/&#quot;/g, "\"").replace(/'/g, "'"); thanks!

TuxmAL

ops! last patch is 56c56,57 < comic.additionalText = match[2]; --- > var additionalTxt = match[2]; > comic.additionalText = additionalTxt.replace(/&#quot;/g, "\"").replace(/&'/g, "'");

TuxmAL

ugh! Last replace contains / & # 3 9 ;/ (remove spaces between chars).

mfuchs

Thanks for your work! I updated the comic.

TuxmAL

You are welcome! Thanks for your work, it has been a good source to learn comics plugin!

cbxAmadyne

The original code does not handle empty "title" and "alt" tags to well. This patch fixes that as well:http://download.amadyne.net/xkcd-main-2015-04.patch Quote:

--- main.es 2009-02-01 03:40:16.000000000 +0100 +++ main_new.es 2015-04-02 08:26:04.215609602 +0200 @@ -41,10 +41,10 @@ } } if (id == comic.Page) { - var re = new RegExp("<img src=\"(http://imgs.xkcd.com/comics/[^\"]+)\""); + var re = new RegExp("<img src=\"(//imgs\.xkcd\.com/comics/[^\"]+)\""); var match = re.exec(data); if (match != null) { - comic.requestPage(match[1], comic.Image); + comic.requestPage("http:" + match[1], comic.Image); } else { comic.error(); return; @@ -49,12 +49,15 @@ comic.error(); return; } - //find the tooltip and the strip title of the comic - re = new RegExp("src=\"http://imgs.xkcd.com/comics/.+\" title=\"([^\"]+)\" alt=\"([^\"]+)\""); + re = new RegExp("<img src=\"(//imgs\.xkcd\.com/comics/[^\"]+)\" title=\"([^\"]+)\""); + match = re.exec(data); + if (match != null) { + comic.additionalText = match[2]; + } + re = new RegExp("<img src=\"(//imgs\.xkcd\.com/comics/[^\"]+)\".+alt=\"([^\"]+)\""); match = re.exec(data); if (match != null) { - comic.additionalText = match[1]; comic.title = match[2]; } }

mfuchs

Thanks for the patch. :) I updated xkcd using your changes.

cbxAmadyne

xkcd.com has updated the image link to no longer contain "http:" Quote:

--- main_new.es 2015-04-01 17:35:10.992105603 +0200 +++ main.es 2009-02-01 03:40:16.000000000 +0100 @@ -41,10 +41,10 @@ } } if (id == comic.Page) { - var re = new RegExp("<img src=\"(//imgs.xkcd.com/comics/[^\"]+)\""); + var re = new RegExp("<img src=\"(http://imgs.xkcd.com/comics/[^\"]+)\""); var match = re.exec(data); if (match != null) { - comic.requestPage("http:" + match[1], comic.Image); + comic.requestPage(match[1], comic.Image); } else { comic.error(); return;

quazgar

Please have a look at KDE bug #333063 https://bugs.kde.org/show_bug.cgi?id=333063 For some comics this great plugin crashes the Plasma Desktop.

Pling
0 Affiliates
Details
license
version 2.0
updated
added
downloads 24h 22
mediaviews 24h 0
pageviews 24h 2

More Plasma Comic Sources from mfuchs:

Dilbert
mfuchs
last update date: 4 years ago

Score 6.8

NICHTLUSTIG [ger]
mfuchs
last update date: 4 years ago

Score 6.1

Sarah's Scribbles [eng]
mfuchs
last update date: 5 years ago

Score 5.7

Penny Arcade [eng]
mfuchs
last update date: 5 years ago

Score 5.0

General Protection Fault [eng]
mfuchs
last update date: 5 years ago

Score 5.0

PhD [eng]
mfuchs
last update date: 5 years ago

Score 4.4

Other Plasma Comic Sources:

EL Mundo de Joe
hompis
last update date: 15 years ago

Score 5.0

el joven lovecraft
2cats
last update date: 16 years ago

Score 5.0

Everybody loves Eric Raymond
lordt
last update date: 15 years ago

Score 5.7

Gunnerkrigg Court
konny77
last update date: 14 years ago

Score 4.7

toothpaste for dinner
s2r2
last update date: 16 years ago

Score 5.0

Partially Clips (en)
TheBlackCat
last update date: 16 years ago

Score 5.0