27 Commits

Author SHA1 Message Date
330e48beaa refactor: full async, rate limit backoff, graceful shutdown, health endpoint
- Switch from requests to httpx.AsyncClient (full async HTTP)
- Add _request() with exponential backoff on 429/401
- Cache followees with 5-min TTL to reduce API calls
- Remove dead code (_get_all_stories, instagram_password, session_file)
- Graceful shutdown via asyncio.Event + SIGTERM/SIGINT handlers
- Add /health command with connection status
- Stream media downloads with httpx + aiofiles
- Track story expiring_at for smart cleanup
- Sanitize .env.example (remove real tokens)
2026-06-17 16:03:47 +07:00
da64550426 docs: add README with setup and usage instructions 2026-06-17 15:16:57 +07:00
57871a81d7 fix: fetch stories via web API with correct response parsing
- Replace broken reels_tray/reels_media (403 login_required) with per-user web API
- Fix response parsing: stories are in reel.items, not root items
- Use Chrome UA and web X-IG-App-ID for web API endpoint
v1.0.0
2026-06-17 15:10:42 +07:00
9eb7bdadfb fix: use web API for stories (mobile API blocked)
- Try www.instagram.com/api/v1/feed/user/{id}/story/
- Desktop Chrome user-agent for web endpoint
- Fallback from reels_media POST to web GET
2026-06-17 14:56:47 +07:00
e72c1ef8ee fix: add X-CSRFToken header for POST requests
Instagram requires CSRF token from cookies for POST endpoints like reels_media
2026-06-17 14:47:03 +07:00
2e53249f87 fix: retry login after 401 rate limit (wait 60s) 2026-06-17 13:09:42 +07:00
642f5756d8 debug: log reels_media raw response, fix Content-Type 2026-06-17 12:57:20 +07:00
7040334eec fix: use reels_media endpoint for stories (returns actual items)
- /feed/user/{id}/story/ only returns reel metadata, not items
- /feed/reels_media/ with POST returns actual story media
- Batch user IDs (20 per request) for efficiency
- Fallback: reels_tray -> reels_media batch
2026-06-17 12:55:43 +07:00
3e792659f2 feat: /debug @username command + verbose story logging
- /debug @username shows raw API response for stories endpoint
- Debug logging enabled for story fetch
- /status now shows SQLite stats (story/post counts)
2026-06-17 12:52:20 +07:00
5eec400f20 fix: SQLite check_same_thread=False for async usage 2026-06-17 12:45:32 +07:00
957eedb5ed feat: SQLite database + stories fallback
- Replace JSON state with SQLite (media.db)
- Schema: media_id, username, media_type, shortcode, file_path, downloaded_at
- Automatic cleanup of old records and files
- Fallback: per-user story fetch when reels_tray is empty
- Stats query for monitoring
2026-06-17 12:43:35 +07:00
bbae5fa363 debug: add raw reels_tray response logging
- Log response keys and body when tray is empty
- Add include_feed_video param
2026-06-17 12:39:52 +07:00
df2273a81c feat: use reels_tray for stories (single request for all users)
- /feed/reels_tray/ fetches all stories in one API call
- Stories sent before posts (they're more time-sensitive)
- Per-user story fetch kept as fallback
- Much faster: 1 request vs 85 individual requests
2026-06-17 12:37:44 +07:00
915298e158 feat: parallel stories and posts fetching per followee
- Stories and posts fetched simultaneously via asyncio.gather
- Semaphore limits concurrent followee checks (default 5)
- CONCURRENT_CHECKS env var to tune parallelism
- 5-10x faster first run on large followee lists
2026-06-17 12:29:34 +07:00
c786adc079 feat: skip posts older than 24h on first run
- Add MAX_POST_AGE_HOURS config (default 24)
- Filter posts by taken_at timestamp
- Stop fetching when hitting old posts (Instagram returns newest first)
- .env: MAX_POST_AGE_HOURS=24
2026-06-17 12:24:58 +07:00
179605e9b5 feat: add debug logging for stories endpoint
- Log when new stories are found per user
- Log HTTP status for non-200/404 responses
- Show count of new stories
2026-06-17 12:23:01 +07:00
37b895d84f fix: login via followees endpoint instead of /users/self/info/
- Login check uses /friendships/{ds_user_id}/following/ (works reliably)
- Store own_user_id from cookies to avoid extra API call
- Skip separate user info fetch
2026-06-17 12:07:27 +07:00
cb2461ace4 fix: correct Instagram private API endpoints
- /users/self/info/ for profile info (not /accounts/current_user/)
- /friendships/{user_id}/following/ for followees list
- Added own_user_id fetch before followees
- Better debug logging for response structure
2026-06-17 12:05:34 +07:00
1bd68c9a0e rewrite: switch from instaloader to Instagram Private API
instaloader blocked by Instagram GraphQL 403. Using mobile API instead:
- i.instagram.com/api/v1 endpoints (same as Android app)
- Direct cookie loading from cookies.txt
- Stories, posts, albums, videos
- Random delays between requests
- Removed instaloader dependency, using requests directly
2026-06-17 12:02:51 +07:00
bc1649d0ac fix: remove RateController that requires context arg 2026-06-17 12:00:06 +07:00
c119b28e4d fix: add mobile user-agent and random delays to bypass Instagram anti-bot
- iPhone Safari user-agent + X-IG-App-ID header
- 2-6s random delay between profile checks
- 1-3s delay between media downloads
- RateController for built-in throttling
- Try/except per followee to not stop on errors
2026-06-17 11:58:02 +07:00
0faebcd41b fix: verify session belongs to expected account before using
- Add _verify_session() to check profile exists after loading session
- Skip session files from wrong accounts
- Clear cookies before trying next auth method
2026-06-17 11:53:32 +07:00
ad7ab58eb1 feat: better diagnostics for profile and cookie verification
- Show which account cookies belong to (ds_user_id)
- Catch ProfileNotExistsException with clear error
- Log profile info on successful fetch
2026-06-17 11:51:43 +07:00
b566708746 fix: correct session and cookies file paths
- Session file: check /data/session-ig, /data/downloads/session-ig
- Cookies: check /data/cookies.txt and /data/downloads/cookies.txt
- Fix docker-compose SESSION_FILE path
2026-06-17 11:47:20 +07:00
78217432b6 fix: better diagnostics for cookie auth failures
- Detect missing sessionid cookie and log clear error
- Improved instructions for both auth methods
2026-06-17 11:40:27 +07:00
b1aa0eb6f5 fix: support cookie-based auth, direct login often blocked by Instagram
- Try instaloader session file first
- Then cookies.txt (Mozilla format from browser extension)
- Then cookies.json (from browser extensions)
- Direct login as last resort with clear instructions
2026-06-17 11:37:53 +07:00
6c51413d12 feat: Telegram bot for Instagram monitoring via instaloader
- aiogram 3 bot with commands /start /check /status /stop
- InstagramMonitor: periodic check of followees stories and posts
- Docker deployment with docker-compose
- State tracking to avoid duplicate sends
- Auto-cleanup of old media files
2026-06-17 11:30:13 +07:00