Comics + kross

Petri Damstén petri.damsten at gmail.com
Thu Sep 25 13:46:11 CEST 2008


hi,

This patch enables making comic providers with scripts (supported by kross).

Things to do:
- Get providers from dataengine (and fix script icon paths)
- Make plasma package and add GHNS for comics
- it would be nice to have a 'scale to content size' option

Dilbert with python would look like this:

#!/bin/env python
# -*- coding: utf-8 -*-

import comic
import re

def init():
    comic.comicAuthor = 'Scott Adams'
    comic.firstStripDate = '1994-01-01'
    url = 'http://dilbert.com/fast/%s/' % comic.requestedDate()

    infos = {
        'User-Agent': 'Mozilla/5.0 (compatible; Konqueror/3.5; Linux) 
KHTML/3.5.6 (like Gecko)',
        'Accept': 'text/html, image/jpeg, image/png, text/*, image/*, */*',
        'Accept-Encoding': 'deflate',
        'Accept-Charset': 'iso-8859-15, utf-8;q=0.5, *;q=0.5',
        'Accept-Language': 'en',
        'Host': 'dilbert.com',
        'Connection': 'Keep-Alive'
    }
    comic.requestPage(url, comic.Page, infos)

def identifierType():
    return comic.DateIdentifier

def identifier():
    return 'dilbert_x:%s' % comic.requestedDate()

def websiteUrl():
    return 'http://dilbert.com/strips/comic/%s/' % comic.requestedDate()

def pageRetrieved(id, data):
    if id == comic.Page:
        a = re.findall('<img 
src="(/dyn/str_strip/[0-9/]+/[0-9]+\.strip\.print\.gif)"', data);
        if len(a) > 0:
            url = 'http://dilbert.com/%s' % a[0]
        else:
            url = 'http://dilbert.com/img/v1/404.gif'
        comic.requestPage(url, comic.Image)

Should I continue on this road?

Petri

-------------- next part --------------
A non-text attachment was scrubbed...
Name: comic_kross.diff
Type: text/x-patch
Size: 18590 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20080925/e9a21447/attachment.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20080925/e9a21447/attachment.sig 


More information about the Plasma-devel mailing list