Skip to content

Queue Mode, Bass Boost, Position Saving, and Cache Split#138

Open
nunotfc wants to merge 12 commits into
gumerov-amir:masterfrom
nunotfc:master
Open

Queue Mode, Bass Boost, Position Saving, and Cache Split#138
nunotfc wants to merge 12 commits into
gumerov-amir:masterfrom
nunotfc:master

Conversation

@nunotfc
Copy link
Copy Markdown

@nunotfc nunotfc commented Jan 18, 2026

Overview
This PR introduces queue-based playback, optional resume positions, a new bass boost control, cache storage split into multiple files, and several new commands/settings. It also includes fixes for YouTube search compatibility and improved status metadata handling, and chained commands.

Key Features

  • Queue playback mode (m q) that plays items in FIFO order, integrated into player logic (next/end-file behavior).
  • Queue management command (q) for listing, adding current track, removing by index, and clearing.
  • Play/search behavior updated to enqueue in queue mode (p/u) without interrupting current playback.
  • Optional position saving (ep) for seekable tracks; recents resume from saved position on r N.
  • Bass boost command (bb) with 0–100 level scale, saved to config and applied at startup.
  • User channel move command (go) allowing users to bring the bot into their channel (guarded by back_to_root_channel).
  • Mute toggle command (mu) using mpv mute property.
  • Time command (t) for elapsed/total playback duration and remaining time via tr.

Commands Added/Changed
User commands:

  • t: show elapsed/total time for current playback.
  • tr: show remaining time for current playback.
  • ep: toggle position saving (enable_positions in config).
  • bb [LEVEL]: set bass boost 0–100, bb shows current level.
  • mu: toggle mute.
  • q: queue management (q list, q + add current, q -N remove, q c clear).
  • p: when in queue mode, search first result and enqueue; starts playback if idle.
  • u: when in queue mode, enqueue URL/stream/file; starts playback if idle.
  • m: adds queue mode (q) alongside st/rt/tl/rtl/rnd.
  • go: move bot to user’s channel (respects back_to_root_channel setting).

Admin commands:

  • sm: toggle metadata display in status messages.
  • br: toggle allowing users to move bot to their channels.
  • q removed for quit; admin quit now qq/quit.
  • cc: now supports q (queue) and p (saved positions).

Playback/Player Changes

  • Mode.Queue added to player enums and queue-specific logic in next/previous/end-file.
  • Queue playback consumes items and continues automatically until empty.
  • Position saving on pause/stop and before switching tracks if enabled.
  • Resume positions stored on Track objects and applied on recents playback via delayed seek.
  • Bass boost now uses mpv audio filter property (af) with a 0–100 scale mapped to gain -30..30.

Config and Migrations

  • config version bumped to v3.
  • General config additions:
    • back_to_root_channel
    • showmeta
    • enable_positions (default false)
  • Player config addition:
    • bass_boost_level
  • Config migrator adds missing fields for existing configs.

Cache Storage Changes

  • Cache format version bumped to v4.
  • Cache split into multiple files under a cache directory:
    • recents.dat
    • favorites.dat
    • queue.dat
    • meta.json
  • Legacy single-file cache is still readable; split is written on save.
  • Cache locking removed in favor of simpler IO and separate files.

Status/Metadata

  • Status text now respects showmeta setting:
    • When enabled, shows track name/URL.
    • When disabled, uses generic “Active audio playback” / “Paused audio playback.”
  • Auto return to root channel when alone and back_to_root_channel is enabled.

Service Updates

  • YouTube service patches:
    • Ignore deprecated httpx “proxies” kwarg on httpx>=0.28.
    • Avoid TypeError when channel id is None in youtubesearchpython.
  • Search now guards against errors when building Track objects.

Tools

  • TeamTalk SDK downloader improved to select a stable 5.15 version when available, with better logging and fallback to latest version.

Files Added

  • bot/services/patches.py (YouTube compatibility patches)

Notes/Behavioral Changes

  • Queue mode auto-starts at startup if configured and queue has items.
  • Admin quit command is now qq/quit to free q for queue management.

Chained Commands
It is now possible to chain multiple commands using the | separator in a single message.
Example: "t | v 30" shows the playback time and sets the volume to 30.
The processing splits the message by |, executes each command sequentially, and sends the responses.

Testing

  • No automated tests added. Manual validation recommended for:
    • Queue playback flow (p/u in queue mode, q management, m q).
    • Position saving and resuming with r N.
    • Bass boost level set/clear behavior.
    • Status text with showmeta on/off.

nunotfc and others added 12 commits January 18, 2026 11:49
•
It is now possible to chain multiple commands using the | separator in a single message.
•
Example: "t | v 30" shows the playback time and sets the volume to 30.
•
The processing splits the message by |, executes each command sequentially, and sends the responses.
•
Tip added to the help: Tip: use "|" to chain commands (e.g., "t | v 30").
•
Improved error handling: when a command fails before its name is identified, an “unknown command” message is shown instead of a generic error.
Fixes
•
Logger: added force=True to logging.basicConfig() to ensure the logging configuration is applied even if it was previously initialized. This fixes the issue where logs were not being written to the file even with log: true in the config.
- New command: pi (pitch) - Adjust playback pitch from -12 to +12 semitones
- Refactored audio filters to combine bass boost and pitch in single af string
- MoveUsersCommand (go): now allows users outside bot's channel to move users
- MoveUsersCommand: fixed Python version check from <= (3,10,10) to < (3,11)
- Docker: added curl, unzip; installed Deno runtime; fixed apt cache path
- Docker: copy tviplayer.py custom extractor to yt-dlp (python3.11 path)
- Updated requirements: httpx, deno, yt-dlp-ejs, yt-dlp>=2024.0.dev0
New command /update (or /upd):
- Check for package updates from requirements.txt via pip
- Show updated packages with versions (e.g., yt-dlp 2024.1.1 -> 2024.2.1)
- Automatically restart bot if updates are available
- Communication via private message

Performance optimizations:
- CPU: loop_timeout 0.01s -> 0.1s (~90% reduction)
- RAM: YouTube search 300 -> 50 results (~83% reduction)
- RAM: Fixed memory leak in get_raw()
- RAM: Queue limited to 1000 items (FIFO)
- RAM: Track_list limited to 1000 items
- RAM: Fixed maxlen bug in recents
- CPU: YoutubeDL reused (single instance)

MPV buffer:
- Adjusted to 5 seconds (cache_secs=5) for all streams
- No back buffer (demuxer_max_back_bytes=0)
- Fixes live streams falling behind issue

Initialization fixes (TeamTalk):
- Fixed race condition on startup
- Bot now waits for channel join before processing commands
- 30 second timeout for joining channel
- Improved connection debug logs
- Better error handling for login/join channel

Modified files: bot/app_vars.py, bot/cache.py, bot/commands/__init__.py,
bot/commands/admin_commands.py, bot/commands/user_commands.py, bot/player/__init__.py,
bot/player/track.py, bot/services/yt.py, bot/__init__.py, bot/TeamTalk/__init__.py,
bot/TeamTalk/thread.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants