Back in April WordPress.com announced a new REST style API. That got me thinking about writing a filesystem layer to expose that data, along similar lines to the pressfs code I’d written last year.
It is still rough, and only supports read-only public data, but in the spirit of release early (and often) I’m sharing the code for wpcomfs at https://github.com/josephscott/wpcomfs.
Assuming you have FUSE with Python bindings already working on your system you can download this and start trying it out in three easy steps:
python wpcomfs.py /tmp/wpcomfs/
After those steps you’ll have read-only data for en.blog.wordpress.com available at
The mount point
/tmp/wpcomfs and the site en.blog.wordpress.com are just examples. You mount wpcomfs where ever you’d like and you can expose public data for any public site hosted on WordPress.com. Since there are millions of sites hosted at WordPress.com wpcomfs will only load data for sites that you
This also works for WordPress.com sites that are using mapped domain names. For instance
mkdir /tmp/wpcomfs/sites/gigaom.com will provide you with a filesystem layer for GigaOM.com.
mkdir a site you get site data, recent posts, and recent comments. In order to keep interactions with the filesystem responsive this data is only loaded once, when
mkdir is run. Running
rmdir /tmp/wpcomfs/sites/en.blog.wordpress.com will remove the site data.
The top level directory for a site looks like:
$ ls -la /tmp/wpcomfs/sites/en.blog.wordpress.com/
-r-------- 1 root root 7 Jun 6 14:09 ID.txt
-r-------- 1 root root 28 Jun 6 14:09 URL.txt
dr-------- 2 root root 4096 Jun 6 14:09 comments
-r-------- 1 root root 61 Jun 6 14:09 description.txt
dr-------- 2 root root 4096 Jun 6 14:09 meta
-r-------- 1 root root 18 Jun 6 14:09 name.txt
dr-------- 2 root root 4096 Jun 6 14:09 posts
The contents of each file are available in read-only mode:
$ more /tmp/wpcomfs/sites/en.blog.wordpress.com/URL.txt
All of the dates exposed for files and directories in wpcomfs are based on when the site data was loaded. Basically when
mkdir was run for the site.
mkdir as many sites as you want. I haven’t tested an upper limit, but I imagine if you load enough of them your system will run out of memory and die.
I have noticed a few bugs. Specifically, in some cases post content runs into some encoding issues and doesn’t get exposed properly at the filesystem level. Another one that I’ve seen is that the comment count number doesn’t show up correctly. Both of these are issues in the Python code that I need to take the time to work out.
While not really a bug, there are also some patterns in this code that I’m not entirely happy with. I’m hoping with a bit more Python experience I’ll be able to simplify those.
Kick The Tires
The code is available at https://github.com/josephscott/wpcomfs, please give a try and let me know what you think.