So, you build a sleek, lightweight self-hosted media downloader like ReClip to grab videos without ads or trackers. You feed it a link, it works. Beautiful.

And then you try to download a Reel from Instagram.

Could not fetch video
ERROR: [Instagram] DZwi-O7Aeym: Instagram sent an empty media response.

Ah, yes. The modern web’s favorite message: “You look like a robot. No cookies for you.” 🤖🚫

Instagram doesn’t like anonymous guests. If you aren’t logged in, they won’t even show you the plate, let alone let you download from it.

The Solution: Feeding yt-dlp Some Cookies

The standard way to bypass this with yt-dlp is to export cookies from your logged-in browser session using an extension (like Get cookies.txt LOCALLY) and pass them using the --cookies flag.

But who wants to manually merge cookie files when you have multiple sites? I had a pile of files:

  • www.instagram.com_cookies.txt
  • www.youtube.com_cookies.txt
  • www.tiktok.com_cookies.txt

If we pass just one, we break the others.

Let’s Make It Automatic ⚡

Instead of forcing users (okay, me) to open a terminal and concatenate text files like it’s 1999, we updated ReClip’s Python backend to do the heavy lifting:

  1. Drop-in Cookies: Just export your cookies from Chrome, name them whatever you want ending in cookies.txt (like instagram_cookies.txt), and drop them into the project folder.
  2. Auto-Merging: Every time you fetch or download a video, ReClip scans the directory, merges all of those *cookies.txt files into a single, master cookies.txt under the hood, and hands it off to yt-dlp.

Here’s the snippet we added to app.py:

def merge_cookies():
    root_dir = os.path.dirname(__file__)
    merged_path = os.path.join(root_dir, "cookies.txt")
    cookie_files = glob.glob(os.path.join(root_dir, "*cookies.txt"))
    cookie_files = [f for f in cookie_files if os.path.basename(f) != "cookies.txt"]
    
    if not cookie_files:
        return
        
    merged_lines = ["# Netscape HTTP Cookie File\n"]
    for f in cookie_files:
        try:
            with open(f, "r", encoding="utf-8", errors="ignore") as fh:
                for line in fh:
                    if line.startswith("#") or not line.strip():
                        continue
                    merged_lines.append(line)
        except Exception:
            pass
            
    with open(merged_path, "w", encoding="utf-8") as fh:
        fh.writelines(merged_lines)

Housekeeping: Cleaning Up the Mess 🧹

While we were under the hood, we also realized that keeping every single downloaded video forever is a great way to wake up to a “Disk Full” alert at 3 AM.

So, we added a background daemon thread that wakes up every 5 minutes to sweep the floors, deleting any downloaded files and in-memory job records older than 1 hour.

Now, ReClip runs cleanly, eats cookies for breakfast, and sweeps its own floors.

Happy downloading! 🎥🍿