Wordpress to Octopress: Videoer

Wordpress to Octopress

A couple of months back I’ve started to try to migrate from Wordpress to Octopress. As mentioned earlier the code formatting in Wordpress is and was driving me crazy. Long lines aren’t broken in a reasonable manner, intends are unreasonable and the visual editor seems to occasionally add and remove tags, which results in almost unreadable posts.

Since this blog already has a couple of hundred posts which I don’t want to loose, a migration should be well prepared. So I’m basically maintaining two blogs recently. This one on Wordpress and on Octopress.

Today I came another step closer to finish the migration.

Almost every Wednesday or so I include some music videos in the post about music. Wordpress uses a specific syntax for that:

[youtube=http://www.youtube.com/watch?v=JaNH56Vpg-A]

This isn’t used by Octopress to embed a video. As far as I figured out per default you need to know where the MP4-file is in order to include a video Octopress. However: Using the photo-tag from Devin Weaver I modified that script to replace tags for you-tube with the corresponding code. Now the following code will be replaced with an embedded video:

{% youtube <videoid> %}

Now I just had to replace the code in the posts with the new syntax. First I’ve made a test-run:

$ sed -n 's/\[youtube\=http\:\/\/.*=\(.*\)\]/\{\% youtube \1 \%\}/p' *.markdown

That helped me figure out where the replacement wouldn’t go smooth and manual intervention was required. I fixed just about five posts that way. The actual run later went flawless:

$ sed -i 's/\[youtube\=http\:\/\/.*=\(.*\)\]/\{\% youtube \1 \%\}/g' *.markdown

You can download the rb-file here

Later I found out that this has been done a month ago using the same syntax and the same result. Anyway, that way I’ve learned something new which I wouldn’t if I haven’t started thinking myself.


A later update

On my way to replace Wordpress with Octopress I’ve needed to setup a solution for including FLV-videos in some posts. That was a minority of posts, but still needed to be fixed.

After I’ve initially tried to convert the flv movies back to MP4 files and use the built-in solution for showing these, I’ve switched my strategy to include the originally FLV files again.

The original syntax:

[flv=<videourl> <width> <height>]

I’ve replaced with

{% flv <videourl> <width> <height> %}

I’ve basically used the photo-tag plugin from Devin Weaver again and have re-written it for implementing FLV video files. Somehow it works.

Since there were just a couple of videos embedded, I did it manually and didn’t use _sed_ to help me out.

You need to modify the script a bit to make it working:

  • Download the JWPlayer and decompress it.

  • Upload the file player.swf to your Webserver.

  • Replace www.myurl.com with the correct URL to the player.swf.

  • Put the file flv_tag.rb in the plugin folder of Octopress.