My girlfriend and I have been using Copy Me That for a few years now to store our recipes and plan meals. It’s been a great tool for us! But I’ve been hearing amazing things about a different app called Paprika. Since I’m always on the lookout for new and fun tools, and Paprika is currently running a 50% off Black Friday sale, I thought I’d give it a shot.
We currently have 1782 recipes saved in Copy Me That. It’s absolutely essential that we’re able to export our recipes into any new tool that we want to use. Luckily for us, Paprika supports importing from Copy Me That. Unluckily, their importer does not import collections (or tags, in Paprika terminology). This is kind of a dealbreaker. I was able to find someone on reddit talking about how Paprika uses a SQLite database to store everything, so I thought I’d give it a shot.
Once I bought and logged into the Paprika Windows app, I used Everything to search for the directory where the database might be. Found it! It’s in C:\Users\Andrew\AppData\Local\Paprika Recipe Manager 3\Database
.
I made a backup copy of the database, just in case. Then I opened the database file in DB Browser for SQLite to see what sort of structure I was working with, and it’s pretty straightforward. All I really care about are the recipes
, recipe_categories
, and recipes_to_categories
tables.
Rewind! Last night I requested a recipe export from Copy Me That. They have two options; I chose the full HTML export. The structure of the HTML is pretty straightforward. It’s just a single HTML file with a bunch of nodes that look like this:
I was glad to see how well-structured the HTML is, since that makes it easy to parse. I created a new .NET console project and added the HtmlAgilityPack package. My idea here is to read the HTML file, parse out the recipes, and then create a SQL script I can run to import the recipe categories into the Paprika database.
First, we load the HTML file into the doc
variable.
Then we loop through each recipe node, extract the data we care about, and add it to our recipes
list.
The SelectSinglNode
and SelectNodes
methods are from HTML Agility Pack. They use XPath to select the nodes we care about.
Now I use a StringBuilder and some logic to build the SQL script:
I had to do some string manipulation to clean up the data, since the HTML contains a lot of whitespace and line breaks.
I could have used Entity Framework to run the resulting SQL script, but I decided to just run it by hand in DB Browser for SQLite.
Finally, in order to actually get Paprika to recognize the new recipes_to_categories entries (and this took multiple hours of trial and error), I had to create a new _test
category and add every single recipe to it. This is done easily in the desktop app by hitting Ctrl+A
to select all recipes, then dragging them to the new category. Let your desktop app finish syncing, delete the _test
category, sync one more time, and then you’re done!