# 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](#overview) - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Usage](#usage) - [Configuration](#configuration) - [Contributing](#contributing) - [License](#license) - [Acknowledgments](#acknowledgments) --- ## 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](https://docs.mealie.io/documentation/getting-started/api-usage/) 3. Generate a Instagram Session File (!thats the most tricky step). A [helper script](https://raw.githubusercontent.com/JoTec2002/InstagramToMealie/refs/heads/main/helpers/instaloader_login_helper.py) is provided in this repo! It's just copied from the [Instaloader Docs](https://instaloader.github.io/troubleshooting.html). 1. Download the script: [https://raw.githubusercontent.com/JoTec2002/InstagramToMealie/refs/heads/main/helpers/instaloader_login_helper.py](https://raw.githubusercontent.com/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: ```sh ❯ git clone https://github.com/JoTec2002/InstagramToMealie ``` 2. Navigate to the project directory: ```sh ❯ cd InstagramToMealie ``` 3. Install the project dependencies: ```sh ❯ pip install -r requirements.txt ``` 4. Start the server: ```sh ❯ python -u main.py ```
**Use the provided Docker image at [jotec2002/instagramtomealie](https://hub.docker.com/repository/docker/jotec2002/instagramtomealie/general)** Deploy it via Docker Compose alongside your Mealie installation Example `compose.yaml` file using a session file to authenticate: ```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: 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. ```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: 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`: ```diff 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=` 3. If you need an API which responds with the result of the import, use `POST http://instagramtomealie.my-server.com/api` sending the URL as either the request's body in JSON format (preferred, `{"url": ""}`) or as a query param (see previous bullet point). The API responds a JSON in the format: ```json { "recipe_slug": , "error": , "url": } ``` ### Configuration ```env 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 - **💬 [Join the Discussions](https://github.com/JoTec2002/InstagramToMealie/discussions)**: Share your insights, provide feedback, or ask questions. - **🐛 [Report Issues](https://github.com/JoTec2002/InstagramToMealie/issues)**: Submit bugs found or log feature requests for the `InstagramToMealie` project. - **💡 [Submit Pull Requests](https://github.com/JoTec2002/InstagramToMealie/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs.
Contributor Graph

--- ## License This project is protected under the MIT License. For more details, refer to the [LICENSE](https://choosealicense.com/licenses/) file. --- ## Acknowledgments - [Mealie](https://github.com/mealie-recipes/mealie/) - [Instadownloader](https://github.com/instaloader/instaloader) ---