Commit Graph
23 Commits
Author SHA1 Message Date
Mak5erandClaude Fable 5 caffc343af refactor: apply full-project audit — bug fixes, performance, deduplication
Full-codebase audit (149 raw findings, 57 verified and applied).

Fixes:
- download resume: recompute Range header per retry attempt; never resume
  preallocated multipart .part files (silent media corruption)
- inline sends: canonical error tail (rate-limit/queue-busy/timeout/failure)
  for all platforms; YouTube inline no longer strands tokens in
  'processing' for 6h
- admin mailing: exclude banned users; fix Telegram error-text matching
- middlewares: instantiate once and share across message/callback/inline
  so antiflood/ban state no longer fragments
- event loop: move ZIP compression, JSON state persistence, admin FS
  walks, PIL/ffmpeg/ffprobe work off the loop
- download queue: prune idle per-user scopes; cancelled leader releases
  joined duplicate requests
- worker subprocess: disable log sinks (stderr error protocol and log
  rotation no longer race the parent)
- third-party loggers route through app handlers instead of lastResort
- tiktok: fix mojibake reaction emoji; per-user settings in doc callback;
  per-URL locks for short-URL expansion; parallel photo-set downloads
- ci: fix broken yt-dlp auto-bump workflow baseline
- db: drop redundant analytics_events indexes (migration 000010)

Refactoring:
- services/inline/send_flow.py: shared inline delivery flow for all five
  platforms (~640 duplicated lines removed)
- services/media/audio_flow.py: shared MP3 pipeline (was duplicated 6x
  across youtube/youtube_inline/soundcloud/spotify)
- CobaltMediaService base + shared Cobalt response parsing
- services/platforms/ytdlp_helpers.py: shared yt-dlp scaffolding
- register_inline_send_handlers: one chosen_inline_result/callback
  registration factory for 8 handlers
- merge pinterest/threads single-media and media-group flows
- logging decorator factory; remove ~11 dead repository methods

Tests: 470 -> 518 passing, coverage 77.3% -> 80.9% (CI gate 74%).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 16:25:59 +03:00
Mak5er 48115e06e7 test(db): update expected default user settings in test_add_user_and_settings 2026-07-22 20:10:56 +03:00
Mak5er 40662635b7 feat: add Spotify audio downloads and rich metadata
Add Spotify track resolution through YouTube audio sources with oEmbed fallback, caching, routing, analytics, and user-facing support. Normalize MP3 filenames, ID3 tags, JPEG cover art, Telegram thumbnails, and duplicate artist metadata across Spotify, YouTube Music, and SoundCloud. Extend regression coverage for provider parsing, delivery, metadata, covers, cache behavior, and link dispatch.
2026-07-10 12:22:17 +03:00
Mak5er be4016a8a3 perf: harden downloader and runtime lifecycle 2026-07-09 23:59:34 +03:00
Mak5er 0a0ab1466f perf: tune connection pool for Neon serverless (5+10, 300s recycle, FIFO) 2026-06-18 18:28:44 +03:00
Mak5er fc41bde6f9 fix(db): normalize alembic database URL handling
Resolve Alembic paths relative to the services directory, load DATABASE_URL from the project .env, and normalize async PostgreSQL URLs before migrations run.

Also extract shared database URL helpers and cover the behavior with database tests.
2026-04-20 12:02:07 +03:00
Mak5er 77c4cda0b8 Refactor logging paths and stabilize db tests 2026-04-10 00:42:21 +03:00
Mak5er 57012b387e perf: harden update backpressure and antiflood 2026-04-09 01:31:47 +03:00
Mak5er 0a42cba701 refactor: split storage database responsibilities 2026-04-09 00:20:30 +03:00
Mak5er 8d873067ca perf: index analytics event stats queries 2026-04-08 23:49:38 +03:00
Mak5er 88c01b9091 fix: harden settings integrity and validation 2026-04-08 23:40:55 +03:00
Mak5er a05c2aae34 refactor: switch database init to alembic migrations 2026-04-07 00:11:38 +03:00
Mak5er aee52dee6b refactor: remove unused database migration stubs
- delete the dead run_alembic_migration helper and the unused FastAPI-style get_session generator
- simplify DB tests accordingly
- drop the completed dead-code finding from the review backlog
2026-04-06 23:48:37 +03:00
Mak5er 3d58d5685c perf: add eviction for transient request caches
- add TTL and max-size pruning for pending requests, inline video requests, album links, and DB caches
- keep fail-soft settings fallback while preventing unbounded in-memory growth
- update code_review backlog to drop the completed eviction finding
2026-04-06 23:35:25 +03:00
Mak5er 784aee9747 fix: harden inline delivery and bot runtime safeguards
- secure admin callbacks and inline token ownership checks
- stabilize private chat handoff and fail-soft user settings reads
- improve inline album previews with captions, photo file_ids, and API-safe payloads
- fix download manager dedup, resume validation, and size-limit propagation
- add regression coverage for admin, db, runtime, inline, and download flows
2026-04-06 23:07:26 +03:00
Mak5er 566c85d93b Enhance statistics handling and chart rendering
- Introduced caching for statistics snapshots and charts to improve performance.
- Refactored the statistics fetching logic to aggregate data by service and date.
- Updated the chart rendering function to return PNG bytes directly without filesystem writes.
- Added new inline keyboard for statistics with options to toggle between total and split views.
- Improved test coverage for statistics-related functionalities, including fetching and rendering.
2026-03-22 23:05:08 +02:00
Mak5er b427dd5f2f Improve media caching and inline delivery 2026-03-22 02:38:33 +02:00
mak5er 1aa4858059 feat: expand cobalt integrations and polish inline album UX
- add Pinterest handler via Cobalt with inline support and tests

- extract reusable Cobalt media helpers and inline album deeplink storage

- add public reusable album deep-links handled from /start without default welcome

- unify inline photo/album copy in user messages and ensure Powered by MaxLoad captions

- add single-photo inline behavior with info keyboard across Instagram/TikTok/Pinterest

- include related stats/service wiring updates and regression tests
2026-02-17 00:57:08 +02:00
mak5er 3d3f090425 feat: add soundcloud + youtube music inline and stats mapping 2026-02-17 00:06:11 +02:00
mak5er c7fed30df2 Improve download UX: status, timeouts, caption truncation
- Add status messages (edit_text) + timeouts for YouTube/TikTok downloads\n- Fix TikTok slowness: short-url expansion timeout/cache, less global locking\n- Truncate captions to Telegram limits and escape HTML\n- Tune downloader concurrency and HTTP session connector\n- Update/add tests; pytest: 56 passed, 6 skipped
2026-02-11 01:08:16 +02:00
mak5er 5287841b83 Enhance stats functionality by adding service breakdown and updating keyboard for period selection 2025-12-22 13:18:46 +02:00
mak5er 449db311f2 Refactor user stats command to include error handling and logging
- Added try-except block in the stats command to handle exceptions and log errors.
- Updated logging to capture exceptions when generating stats.

Refactor YouTube download handler for improved error handling and type safety

- Introduced safe_int function to handle integer conversions safely.
- Updated download_video and inline_youtube_query functions to use safe_int for view and like counts.
- Removed custom OAuth verifier function and related code.

Simplify video info keyboard function

- Removed unused full_quality_callback parameter from return_video_info_keyboard function.

Update requirements for PostgreSQL support

- Added psycopg2-binary and asyncpg to requirements.txt for PostgreSQL database support.
- Added pytest-asyncio for async testing.

Update Alembic configuration for environment-based database URL

- Changed sqlalchemy.url in alembic.ini to use environment variable DATABASE_URL.

Refactor database connection to support PostgreSQL

- Updated db.py to use BigInteger for primary keys and adapt to PostgreSQL.
- Implemented asyncpg for asynchronous database operations.
- Added sequence adjustments for PostgreSQL after migrations.

Add migration script from SQLite to PostgreSQL

- Created migrate_sqlite_to_postgres.py to facilitate data migration from SQLite to PostgreSQL.

Implement a resilient downloader service

- Added download_manager.py with a ResilientDownloader class for robust file downloading.
- Supports multipart downloads, retries, and resuming interrupted downloads.

Refactor tests to accommodate new database and downloader structure

- Updated test_db.py to use DATABASE_URL for database connection in tests.
- Refactored Instagram handler tests to use the new InstagramService for downloading videos.
2025-12-15 23:58:44 +02:00
Mak5er dda200cc0c Add full quality option to video info keyboard and include full_quality router 2025-12-15 23:58:07 +02:00