Disqus is a popular service that provides commenting functionality. All you
need to do for your HTML page to have embedded discussion is to add a bit of
javascript.
They have awesome importers from various blog engines. This blog was originally
hosted on Blogspot, migration to static blog generated by Octopress required me
to search for alternative commenting facilities and I decided to use disqus (is
there anything else, really?) Now I switched to WordPress and I wanted my
comments back.
Disqus does provide the ability to export all the comments in a XML file. Quick
Google search told me that it was possible to get the comments quite easily
into WordPress by converting the disqus dump into WXR, but it is not really
that easy. WordPress will ignore the post if it is already there and will not
import comments. There’s a plugin that imports disqus comments, but I wanted
full support of nested comments and little to no PHP coding.
I dumped all the wordpress database locally and hacked up a script that reads
the comments.xml file and puts the necessary data into the database. The script
needs access to some sort of a database in order to figure out the post_id for
each post and generate the comment identifiers for correct nesting.
...ANONYMOUS_EMAIL='nobody@example.net'# Database configurationDATABASE={'host':'lab.lappyfamily.net','user':'rtg','name':'rtginua6_wp1',}# Admin informationADMIN_INFO={'comment_author':'Roman Yepishev','comment_author_email':'roman.yepishev@yandex.ua','user_id':1}# Names used in disqus that represent administratorADMIN_ALIASES=set(['rtg','Roman','rye'])...
And the script itself runs on an uncompressed disqus XML. The script will skip all pages that it could not find the URLs for:
$ python wp-import-disqus.py comments.xml
Skipping comment for http://rtg.in.ua/app/acer-exif-fixup/index.html
After script finished I dumped the comments table and uploaded it via the phpmyadmin interface.