Sat, 01 Sep 2007
Recovering a Pyblosxom blog using liferea's RSS cache
My buddy who used to host lewk.org didn't pay his bills, so his server got taken down last week. What sucks is I that never backed up my Pyblosxom data. What doesn't suck is that thankfully Liferea, my RSS reader, did for me.
Grepping through ~/.liferea_1.2/cache/feeds, I was able to find my blog cached in some XML format. Then I wrote a little bit of code to re-create my Pyblosxom entry structure with the proper filenames and timestamps.
#!/usr/bin/python -tt
"""
Turns XML into pyblosxom blog entries.
It parses BLOG_XML pulling out blog entires in the form of:
<feed version="1.1">
<item>
<title></title>
<description></description>
<source>http://foo.com/blog/2007/08/20/bar.html</source>
<time>1187621268</time>
</item>
</feed>
The file '2007/08/20/bar.txt' will be created in pyblosxom format with
the appropriate timestamp. The #mdate is used by the pyblosxom.vim plugin.
title
#mdate Aug 20 10:47:48 2007
<p>description</p>
"""
import os
import time
try: from xml.etree import cElementTree
except ImportError: import cElementTree
iterparse = cElementTree.iterparse
entries = {} # { 'title' : <Element> }
BLOG_XML = 'blog.xml'
BLOG_ROOT = 'http://foo.com/blog/'
def getField(elem, field):
for child in elem:
if child.tag == field:
return child.text
## Pull out all feed items, removing older duplicates
for event, elem in iterparse(BLOG_XML):
if elem.tag == 'feed':
for child in elem:
if child.tag == 'item':
title = getField(child, 'title')
if entries.has_key(title):
if int(getField(child, 'time')) > \
int(getField(entries[title], 'time')):
entries[title] = child
else:
entries[title] = child
for title, entry in entries.items():
source = getField(entry, 'source').replace(BLOG_ROOT, '')
source = source.replace('.html', '.txt')
if not os.path.isdir(os.path.dirname(source)):
os.makedirs(os.path.dirname(source))
output = file(source, 'w')
output.write(title + '\n')
mtime = time.localtime(int(getField(entry, 'time')))
mdate = time.strftime("%b %e %H:%M:%S %Y", mtime)
output.write("#mdate %s\n" % mdate)
output.write("<p>%s</p>\n" % getField(entry, 'description'))
output.close()
timestamp = time.strftime("%y%m%d%H%M", mtime)
os.system("touch -t %s %s" % (timestamp, source))
It also adds an #mdate tag into each entry, which read by the spiffy pyblosxom mdate vim hack that Jordan Sissel wrote to restore each entries original timestamp after editing. His code only works on FreeBSD at the moment, so I started a pyblosxom.vim plugin that works on Linux (hopefully it will eventually support both, along with a bunch of other handy functions). You can find all of this code in my mercurial repo: hg.lewk.org/xml2pyblosxom
posted at: 12:44 | link | | 31 comments
Posted by heevepsycle at Mon Jul 14 07:10:23 2008
Please come my new blog
http://regidomain.com/
Let's talk about it
Posted by thantymoplaph at Wed Oct 29 16:50:47 2008
Very interesting blog. Be good to my ticklish crisis I have a nice fresh joke for you people) How many Microsoft employees does it take to screw in a lightbulb? None. We'll just declare darkness the new standard.
Posted by buzi at Fri Oct 31 06:27:53 2008
Hi! I found a nice online pharmacy! Viagra 10 pills x 25 mg
Posted by yuvutu at Sun Jan 4 08:06:53 2009
Heather wound her hand around each cock and began pumping them up and down gently <a href=" http://www.kaboodle.com/jessicasimps ">yuvutu mature</a> =) <a href=" http://www.kaboodle.com/lilly123 ">youtubeporno</a>
Posted by thehun at Sun Jan 4 17:40:43 2009
I agreed quickly as I simply wanted to see the cum squirt from one cock before they were spent <a href=" http://www.kaboodle.com/jasej ">www thehun net</a> ;)) <a href=" http://www.kaboodle.com/salmah ">www spankwire co</a>
Posted by redtub at Sun Jan 4 17:47:49 2009
I teased myself for as long as I could before my hand began to drift down my stomach until my fingers touched my dripping pussy lips <a href=" http://www.kaboodle.com/lizv ">redtub com</a> ;)) <a href=" http://www.kaboodle.com/pama125 ">m porntube com</a>
Posted by shufuni at Sun Jan 4 21:53:52 2009
They had each used me twice by the time I agreed. Tim said he thought I was lying so he fucked my tiny asshole while forcing me to eat Staci.
<a href=" http://www.kaboodle.com/silvias ">shufuni com</a> ;) <a href=" http://www.kaboodle.com/bellad ">and sextube</a>
Posted by pornhub at Mon Jan 5 05:15:11 2009
Her cunt felt warm and wet and I slowly eased my way fully into her, then held my finger there, lightly feeling her with the very finger tip <a href=" http://www.kaboodle.com/bigstan ">xxx pornhub</a> ;) <a href=" http://www.kaboodle.com/lolka124 ">pinkworld coom</a>
Posted by erotik at Mon Jan 5 15:51:35 2009
He puts his dick in my mouth. Its so big that it barely fits my mouth. I begin to suck him. <a href=" http://www.kaboodle.com/feliciass ">privat erotik</a> ))) <a href=" http://www.kaboodle.com/jessicafio ">efukt shake</a>
Posted by Daxickwm at Mon Jan 12 03:09:02 2009
Good crew it's cool :) <a href=" http://www.justin.tv/jessicasa/profile ">sites like porntube</a> %]]]
Posted by Fxnojabt at Mon Jan 12 03:56:05 2009
Excellent work, Nice Design <a href=" http://www.justin.tv/sofiana/profile ">lolitateens</a> tsjnet
Posted by Xottbcno at Mon Jan 12 21:34:26 2009
I love this site <a href=" http://www.justin.tv/mayana/profile ">tiny preteen lolitas and boys</a> 341
Posted by Czyzremm at Tue Jan 13 08:01:42 2009
very best job <a href=" http://www.justin.tv/amberina/profile ">little lolitas nude porn pics</a> 9204
Posted by Xvjaqeou at Tue Jan 13 14:44:41 2009
Punk not dead <a href=" http://www.justin.tv/nicolena/profile ">animal sex movies tube</a> :O
Posted by Cpfzkszi at Fri Jan 16 00:11:45 2009
It's serious <a href=" http://www.livevideo.com/Zoeana ">hardcoretube</a> 0077
Posted by Cpfzkszi at Fri Jan 16 00:11:59 2009
It's serious <a href=" http://www.livevideo.com/Zoeana ">hardcoretube</a> 0077
Posted by Atnkpfza at Sat Jan 17 07:54:05 2009
This site is crazy :) <a href=" http://www.livevideo.com/Vanessiana ">little lolitas nude</a> 75345
Posted by Vdbeqnwu at Sat Jan 17 14:57:10 2009
Best Site good looking <a href=" http://www.livevideo.com/Averia ">pagina de lolitas little kiss</a> lduhpq
Posted by Vdbeqnwu at Sat Jan 17 14:57:45 2009
Best Site good looking <a href=" http://www.livevideo.com/Averia ">pagina de lolitas little kiss</a> lduhpq
Posted by Rsezttfq at Sun Jan 18 02:18:28 2009
This site is crazy :) <a href=" http://www.livevideo.com/Alexandriana ">porn yuo tubeporn yutube
</a> kwhg
Posted by Lrloukwr at Sun Jan 18 11:02:39 2009
I'm happy very good site <a href=" http://www.livevideo.com/Destinya ">animal sex tube 365</a> yrdh
Posted by Hbgelyae at Fri Jan 23 03:41:54 2009
good post man thx <a href=" http://ololorialni.ifrance.com/lolita-teens.html ">lolita teens
</a> =-DDD
Posted by yifguhtf at Thu Jun 18 06:10:29 2009
tfhgvvg http://www.linkedin.com/in/rt56rt7ju tiava hardcore kujgbjvhg http://www.linkedin.com/in/jyuyt thumbzilla pics
Posted by NEX-5N at Wed Nov 16 16:55:56 2011
Аз всъщност планира да обсъди вашия блог пост е невероятно реалистично. Да изберат да чуят нещо съвсем ново с това за сметка на наистина предлагат идентични сайт в рамките на моята САЩ по време на този въпрос, така че тази конкретна помощ? И всички много. Аз бях в състояние добър поглед по темата, плюс забелязал голям брой блогове, но в контраст с това. Благодарим ви, че за разкриване на толкова много вътре във вашия уебсайт.







