Problem importing videos

I’m working on an export from a local Tumblr export (HTML + media files) to Ghost. Some code for this does already exist but has not been updated since Tumblr changed its export format.

The backbone is fairly straightforward: iterate over the children of the body, identify the structure and create a list of items to be imported. Then, in a second step, create the HTML for each part if necessary: text can usually be copied 1:1, images take a bit more work but are fairly straightforward and can rely on you copying the original files into Ghost and setting the src to something like __GHOST_URL__/content/media/image01.jpg. The HTML is then serialised in the JSON.

But I’ve a hit a roadblock when it comes to videos as it seems that the lexicalpart of the post containing the image source, width and height is required. This is easy enough to create but seems a little unnecessary. Has anyone come up with a workaround.

Hm, after playing a bit with the migrate tool I’ve figured a workaround: enclose the HTML with the following HTML comments <!--kg-card-begin: html--> and <!--kg-card-end: html-->.

In general, the advice seems to be to try and create mobiledoc, though as this seems to be largely the original HTML with some minor structural metadata, I’m not convinced. This might be helpful if the HTML can be simplified and paired back to the bare minimum and thus avoid the need to convert whatever the source is to Ghost HTML, but otherwise it’s an unnecessary complication.