Paprika Recipe Manager for iPad, importing data in yaml format

Not about virtual worlds this time… 🙂

I recently bought the Paprika Recipe Manager for my iPad to use in the kitchen. Before, I used a simple web-based database application that retrieved my recipes from a MySQL database. Now I wanted to import all my 1200 recipes into Paprika, including all the photos.

Paprika supports importing recipes in many formats, but as far as I could see, the only format that supports the inclusion of photos is yaml. Some basic instructions are given in the Paprika User Manual, but the description is very brief and lacks some details. Below are my findings from making a simple php program to convert my database into yaml format and import it into Paprika.

  • Photos should be JPG or PNG. Preferred dimensions are 280×280. Other dimensions are accepted, but the photos will be scaled.
  • I encoded the photos successfully in PHP in the following way:
$img = fread(fopen($filename, "r"), filesize($filename));
$base64 = base64_encode($img);
$lines = str_split($base64,76);
  • To improve the readability (and editability) of the file, I broke up the base64 string in multiple lines of 76 characters.
  • Avoid any characters with values above 127 (0x7f). I replaced all dangerous characters into their “nearest” regular ASCII ones by:
 $r = @iconv('UTF-8', 'ASCII//TRANSLIT', $r);
  • The ‘@’ before the “iconv” helps to prevent unwanted warning messages.
  • Don’t start a text line with ‘,’ (comma), ‘[‘ (square bracked) or ‘<‘. I didn’t research this in-depth, but I assume that this confuses the yaml parser.
  • Avoid empty lines in the list of ingredients or the preparation instructions.
  • It seems that Parika first checks the syntax of the full import file, before actually inserting recipes into its database. This saved me a lot of trouble: either all recipes were inserted or none. No half-way breaks that leave you wondering which recipes were inserted and which not. Thank you Paprika developers!
  • Line breaks in the preparation instructions cause paragraph breaks in Paprika, so a single paragraph should be formatted as one long text line.
  • Only very limited space is available for the source field (somewhere around 20 characters? I didn’t check). Long source descriptions are accepted, but only partly visible in Paprika.

Here is an example of accepted imput. Long lines are shortened here by “…”. File extension should be “.yml”. The file should be imported into your iPad by means of iTunes file sharing, then you can select it in Paprika under “Import”. 

- name: Caramel salmon
  servings: 4
  prep_time: 10 min
  cook_time: 10 min
  on_favorites: yes
  categories: [Hoofdgerecht]
  ingredients: |
    1 tbsp vegetable oil
    800 g salmon, with skin, cut into large cubes
    1 red onion, sliced
    3 cloves garlic, sliced
    3 tbsp dark soy sauce
    115 g brown sugar
    3 tbsp fish sauce
    1 tbsp lime juice
  directions: |
    1. Heat the oil in a large frying pan over a high  ...
    2. Reduce the heat to medium and add a little extr ...
    3. Return the salmon to the pan and cook for 1 mi ...
    4. Serve with steamed rice, with a little sauce dri ...
    Serve with steamed rice and cucumber salad
  photo: |
    /9j/4AAQSkZJRgABAQIAHAAcAAD/4QypaHR0cDovL25zLmFkb2Jl...
    YWNrZXQgYmVnaW49J++7vycgaWQ9J1c1TTBNcENlaGlIenJlU3pO...
    ZXRhIHhtbG5zOng9J2Fkb2JlOm5zOm1ldGEvJyB4OnhtcHRrPSdJ...
    (many more lines)
    cf8AVV/bRXloHL1+20s7obp/RQr3toh2EmNrluQhQ+jWABnGRXnA...
    if/Z

- name: Chocolate cheesecake
  servings: 12
  categories: [Gebak]
  (etc)

One response to “Paprika Recipe Manager for iPad, importing data in yaml format

  1. Thank you so much for this! *File extension should be “.yml”*. I was using .yaml instead of .yml and it was giving me unhelpful error messages

Leave a comment