Convert Instagram cooking reels into structured recipes using AI
Project description
CRTR - Convert Reel To Recipe
Convert Instagram cooking reels into structured, nutritionally-analyzed recipes using AI.
Features
- 📥 Download Instagram reels directly from URLs or shortcodes
- 🎵 Extract audio from video files
- 🎤 Transcribe audio using OpenAI's Whisper model
- 🤖 Generate structured recipes with Google's Gemini AI
- 🇩🇰 Outputs recipes in Danish with metric measurements
- 📊 Includes nutritional analysis
- 💾 Saves recipes as formatted JSON files
Installation
Prerequisites
- Python 3.8 or higher
- FFmpeg (required for video/audio processing)
Installing FFmpeg
Windows:
# Using Chocolatey
choco install ffmpeg
# Or download from https://ffmpeg.org/download.html
macOS:
brew install ffmpeg
Linux:
sudo apt-get install ffmpeg # Debian/Ubuntu
sudo yum install ffmpeg # CentOS/RHEL
Install CRTR
From Source (Development)
# Clone the repository
git clone https://github.com/yourusername/crtr.git
cd crtr
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
From PyPI (once published)
pip install crtr
Quick Start
Basic Usage
from crtr import ConvertReelToRecipe, GeminiModel
# Initialize the converter
converter = ConvertReelToRecipe()
# Convert a reel to a recipe
recipe = converter.convert_to_recipe_from_reel_url(
reel_url="https://www.instagram.com/reel/ABC123xyz/",
ai_model=GeminiModel.GEMINI_2_0_FLASH.value,
api_key="your-google-ai-api-key"
)
print(recipe) # Outputs JSON-formatted recipe
Step-by-Step Usage
from crtr import ConvertReelToRecipe, TranscribeAudio, ModelSize
converter = ConvertReelToRecipe()
# 1. Download the reel
shortcode = converter.extract_shortcode("https://www.instagram.com/reel/ABC123xyz/")
video_path = converter.download_reel_from_shortcode(shortcode)
# 2. Extract audio
audio_path = converter.convert_video_to_audio(video_path)
# 3. Transcribe audio
transcript = converter.transcribe_audio(audio_path)
# 4. Build the AI prompt
prompt = converter.build_prompt(
description=converter.description,
transcript=transcript
)
# 5. Generate recipe
recipe = converter.generate_recipe(
ai_model="gemini-2.0-flash",
api_key="your-api-key"
)
Configuration
API Keys
You'll need a Google AI API key to use the recipe generation feature:
- Visit Google AI Studio
- Create a new API key
- Use it in your code or set as environment variable:
export GOOGLE_AI_API_KEY="your-key-here"
Model Selection
CRTR supports multiple AI models:
from crtr import GeminiModel
# Available models
GeminiModel.GEMINI_2_0_FLASH.value # Fast, recommended
GeminiModel.GEMINI_2_5_FLASH_LITE.value # Lightweight
For transcription, choose from different Whisper model sizes:
from crtr import ModelSize
# Available sizes (larger = more accurate but slower)
ModelSize.TINY.value
ModelSize.BASE.value
ModelSize.SMALL.value
ModelSize.MEDIUM.value # Default
ModelSize.LARGE_V3.value
Output Format
Recipes are generated as JSON with the following structure:
{
"title": "Recipe Name",
"meal_type": "Aftensmad",
"portions": 4,
"ingredients": [
{
"name": "Ingredient name",
"quantity": 100,
"unit": "g",
"danish_alternative": "Alternative if needed"
}
],
"equipment": ["Pan", "Knife"],
"instructions": ["Step 1", "Step 2"],
"serving_suggestions": ["Serve with..."],
"nutritional_summary": {
"total_recipe": {
"Energi_kcal": 1200,
"Protein_g": 45,
"Fedt_g": 30,
"Heraf_Mættet_Fedt_g": 10,
"Kulhydrater_g": 150,
"Heraf_Sukkerarter_g": 20,
"Salt_g": 2
},
"per_portion": { ... }
}
}
Project Structure
CRTR-refactor/
├── src/
│ └── crtr/
│ ├── __init__.py
│ ├── converter.py # Main converter class
│ ├── convert_video_to_audio.py # Audio extraction
│ ├── transcribe_audio.py # Whisper transcription
│ ├── generate_recipe_with_ai.py # Gemini AI integration
│ └── prompt.py # Recipe generation prompt
├── tests/
│ └── test_converter.py
├── pyproject.toml
├── README.md
├── LICENSE
└── .gitignore
Development
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=crtr --cov-report=html
Code Formatting
# Format code with black
black src/
# Check with flake8
flake8 src/
Requirements
instaloader>=4.10.0- Instagram content downloadingrequests>=2.31.0- HTTP requestsmoviepy>=1.0.3- Video processingfaster-whisper>=1.0.0- Audio transcriptiontorch>=2.0.0- Machine learning backendgoogle-genai>=0.2.0- Google AI integration
Limitations
- Instagram may rate-limit or block requests if used excessively
- Video downloads require the reel to be public
- Transcription quality depends on audio clarity
- AI-generated nutritional values are estimates
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- OpenAI Whisper for audio transcription
- Google Gemini for recipe generation
- Instaloader for Instagram integration
Disclaimer
This tool is for educational and personal use only. Please respect Instagram's Terms of Service and content creators' rights when downloading content.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crtr-0.1.1.tar.gz.
File metadata
- Download URL: crtr-0.1.1.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b8382d1e7d3c3c9763301bb18d8a8a78e156c9cfd1f786c988579b8b619be53
|
|
| MD5 |
f7cdeac58cfd5e86cb830032f113c0e8
|
|
| BLAKE2b-256 |
a4f18574817a8a7b4fc8c5839d9d6c79c5fa3ea7ee223a188fe9bab756ff8b52
|
File details
Details for the file crtr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: crtr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca66c4156f8390e699e21875b7bf347bc5b3f3ebe1f1e517f17de34afb3073a9
|
|
| MD5 |
69658cc7476804f3952a63b65047c722
|
|
| BLAKE2b-256 |
97034941bc9b52bf8de1c600fe1137af6aeb17ad054d9cd1e0fe1a6831a19700
|