# Browser Listener — Windows Server

Uses Playwright + Instagram WEB API (same as Firefox/Chrome login).
No instagrapi. No sessionid paste. Works on datacenter IP.

## Setup (once)

```powershell
cd C:\ins\instagram-listener
python -m pip install -r requirements.txt
install_playwright_browsers.bat
copy env.windows.txt .env
```

On **Windows Server 2012 R2**, `playwright install` may show a Node.js warning and fail.
Install **Mozilla Firefox** on the server — the listener uses system Firefox automatically.

## Step 1 — Login in browser

```powershell
login_browser.bat
```

- Browser opens
- Log in as @downista.bot
- Press ENTER in console when done

Profile saved: data\browser_profile

## Step 2 — Run listener 24/7

```powershell
run_browser.bat
```

## .env keys

```env
LISTENER_MODE=browser
BROWSER_CHANNEL=firefox
BROWSER_HEADLESS=0
BROWSER_PROFILE_DIR=./data/browser_profile
```

`BROWSER_HEADLESS=0` on Server 2012 — keep RDP session open while listener runs.

Use chrome: BROWSER_CHANNEL=chrome

## Test

1. /linkinstagram in Telegram bot
2. Share reel to @downista.bot in Instagram DM
3. Check logs\listener.log

## Old API mode (instagrapi)

```env
LISTENER_MODE=api
```

Only works on residential IP / proxy.

## Troubleshooting

| Problem | Fix |
|---------|-----|
| Browser not logged in | login_browser.bat again |
| Inbox HTTP 403 | Re-login login_browser.bat |
| Playwright install Node warning (Server 2012) | Install Firefox ESR; skip playwright install |
| Playwright missing | install_playwright_browsers.bat or install Firefox |
