57 Commits
Author SHA1 Message Date
Ziad Arafat 827ae9db2c Say why media-preload refused a watch request
A 400 from the preload API used to fall into the download-status path, so a
season that is not in the library yet looked like "the command doesn't
work" (She-Ra season 3 on 2026-12-01). Problem responses now raise
PreloadRefusedError and the cog replies with the service's own reason
before adding download context.
2026-12-01 00:22:19 -07:00
Ziad Arafat e5386d9b28 Warm the VPS cache after new Discord media requests import 2026-11-28 18:23:34 -07:00
RustyRaptor 6efce31ee8 Allow explicit album searches for playlist matches 2026-11-27 20:34:46 -07:00
Ziad Arafat 335cdeea4b Spend less on MusicBrainz and bound the catalog fallback
A single catalog candidate already decides the album, so the importer no
longer waits a second on MusicBrainz for a tie-break it cannot change, and
the MBID fallback now stops after the three best-ranked release groups.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 17:08:25 -07:00
Ziad Arafat 15fe770536 Keep the MusicBrainz tests typing clean and formatted
The release-group branch landed with test-only type errors and
unformatted modules, so mise run check failed before the cog could ship.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 17:00:02 -07:00
Ziad Arafat 7b472625ad Merge branch 'main' into feat/musicbrainz-release-groups 2026-11-25 16:26:15 -07:00
Ziad Arafat d0975086b6 Fill album gaps with MusicBrainz instead of guessing
Lidarr's album lookup matches titles only: it cannot say whether an album
really holds the requested track, and it returns nothing when Spotify's album
title differs from MusicBrainz's. Both are gaps this closes.

watch/musicbrainz.py searches recordings and returns the release groups that
hold that recording: release-group MBID, primary and secondary types, first
release date, credited artist and the track titles on each release. It spaces
calls by the documented one per second, retries 429/503, and returns nothing
on failure, so an import never breaks because MusicBrainz is down. Music
trackers use the same User-Agent string as the rest of the bot.

watch/music.py: MusicImporter takes an optional musicbrainz collaborator
(absent in the existing tests, so their behaviour is unchanged). When it is
present, _album asks it for the groups holding the track, and:
- choose_album prefers a candidate whose MBID is known to hold the track over
  one that merely wins on release type,
- a dead end (no title match in the catalog) is resolved by looking up the
  release group MusicBrainz named, by MBID,
- credited-artist filtering keeps "Various Artists" compilations out,
- any MusicBrainz error falls back to exactly the previous answer.

Tests came first: 11 unit cases for parsing, credit filtering, containment,
retry, throttle spacing and degradation, and 5 integration cases against a
scripted Lidarr edge for containment preference, dead-end resolution, the
compilation guard and the outage path. They failed before the module existed;
the full suite is 376 passed and ruff is clean.

Live check against the live MusicBrainz API (Avicii "Wake Me Up")
returned five credited release groups, including the studio album "True"
holding the track and the single. It confirms the ranking shapes and the
containment lookup; it also shows the honest limit: when the requested album
title is the single, the single is still what gets chosen, because switching
to a different album is not this function's call.

Not deployed. Branch is for the Buffy agent to merge and deploy.
2026-11-25 16:26:06 -07:00
Ziad Arafat 0c90c82ee8 Enable yt-dlp's remote JS challenge solver
Without the solver, YouTube logs an n-challenge failure and leaves formats
missing even when a file is produced.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 16:20:36 -07:00
Ziad Arafat 9e2f14fff4 Match the deployed YouTube folder name
The quadlet cannot pass a path containing spaces, so the library folder is
now Music/YouTube.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 16:16:24 -07:00
Ziad Arafat c577a7f369 Prefer a studio album when a track resolves to several release groups
importplaylist monitors the release group that contains a requested track.
When Lidarr returned more than one match for the title, choose_album gave up
and the requester had to pick by hand; when a single was the only match, the
grab targeted an uncached single. Uncached singles are what stall against
TorBox on a plan-1 account, exceed the proxy timeout and make Lidarr retry
with yet another release — the Avicii singles were stuck in that loop.

Release groups now rank album > EP > single, with a plain edition ahead of a
compilation, live, remix, DJ-mix, mixtape, soundtrack or spoken-word edition.
The rank only breaks ties: a lone match is still selected, and two equally
ranked candidates stay ambiguous so the requester chooses.

Tests came first (tests/test_music_release_preference.py, 8 cases): studio
album over single, EP between the two, plain over compilation and live,
plain single over a remix edition, ties still ambiguous, typeless lookups
keeping the old behaviour, a lone single still selected, and the artist
check not being outranked. watch/music.py was changed only after those
tests failed. Full suite: 362 passed; ruff clean.

Not deployed. Branch is for the Buffy agent to merge and deploy.
2026-11-25 16:14:34 -07:00
Ziad Arafat 85eab7bb16 Fetch MusicBrainz-missing songs from YouTube or skip them
Playlist reviews mixed "artist absent from MusicBrainz" with genuine album
ambiguity, so requesters had no path forward for artists the catalogue lacks.
Report that reason separately, keep album matching (including the manual
picker) to the Spotify artist so tribute/cover releases are never monitored,
and add `importplaylist youtube` (yt-dlp search or a pasted link, downloaded
into the Jellyfin music folder) plus `importplaylist ignore` for a permanent
skip. Failed downloads and ignored songs stop counting as review.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 16:10:55 -07:00
Ziad Arafat 1084a822e7 Finish the playlist review loop with retry and album matching
A failing catalogue lookup aborted the whole import, leaving every later
song unresolved with no review label until the seven-day stall. Isolate
per-track failures, retry them while the job waits, surface them after
three attempts, and clear stale labels once a song arrives. Requesters can
now retry reviewed songs or pick their Lidarr album directly.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 15:44:01 -07:00
Ziad Arafat 4d62c7928d Let an owner clear an uncertain playlist write before reimport
The import guard already required verification, but no command could clear
the pending mutation, so a flagged playlist stayed stuck.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-25 15:16:47 -07:00
Ziad Arafat 9f3d751432 Import public Spotify playlists and notify requesters on completion 2026-11-23 09:07:49 -07:00
Ziad Arafat c8a8e9d947 Tolerate slow catalogue lookups without retrying ARR mutations 2026-11-22 13:38:34 -07:00
Ziad Arafat 64c37b39ec Retain one TV season per user with shared claims and archive protection 2026-11-22 13:18:50 -07:00
Ziad Arafat 5e8acbf7d0 Report ARR download progress for watch and duplicate requests 2026-11-22 12:02:57 -07:00
Ziad Arafat 5aafc6a9ab Add owner-controlled movie and TV download requests to watch cog 2026-11-22 11:36:29 -07:00
Ziad ArafatandClaude Opus 5.5 b390b7d392 test-container: download through the home lab's VPS proxy
DOGEBOT_PROXY (default http://10.77.0.1:3128, empty disables) is passed to
uv and pip inside the Red image; the home network reaches PyPI at ~30 KB/s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:26:41 -07:00
Ziad ArafatandClaude Opus 5.5 95d3b87610 Test the watch cog over real HTTP; test-container installs like Red; TDD rules
- tests/test_watch_cog.py + watch_helpers.py: the watch cog against a fake
  media-preload on a real socket (spec-shaped JSON, bearer token), so the
  generated client, httpx, httpcore and anyio all run. 21 tests; checked
  against six mutations of watch.py, each caught.
- scripts/test-container.sh installs cog requirements the way Red's
  Downloader does (pip -t lib, image's PIP_CONSTRAINT, lib appended after
  the venv via DOGE_COGS_LIB). On the pre-constraint image 20 watch tests
  fail with the 2026-11-09 production error; on the current image all pass.
- test_alignment_isolation: discover every core module instead of a hand
  list that had missed guess, render, baseline, sampling and others.
- TESTING.md (the loop, good tests, layers) and CLAUDE.md for agents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:42:47 -07:00
Ziad Arafat bec3a0a8c2 try to fix error by upgrading packages 2026-11-09 11:46:05 -07:00
Ziad ArafatandClaude Opus 5.5 027f11c90f doge_alignment: server baseline, per-person time zones, profile hints
Guesses now see what's normal on the server: a weekly cached baseline from
24 random moments in the public channels (per-regular style numbers, message
shares, and a model-written culture summary from anonymised conversations),
and how the person compares with the regulars. `alignment baseline` rebuilds
and shows it; ALIGNMENT_BASELINE=off turns it off.

Each person's time zone comes from aikaterna's timezone cog (read from its
Config); Mountain Time otherwise. The dossier adds nickname, custom status
and roles, since bots can't read the About me bio.

scripts/experiments holds the harnesses and results: the baseline moved
Chaotic Neutral from 9/10 to 8/10; per-axis scores didn't repeat between
identical asks, so relative ranking of scores was dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-06 18:23:15 -07:00
Ziad ArafatandClaude Opus 5.5 db621d671a doge_alignment: guess times in Mountain Time instead of UTC
Activity hours, late nights, weekends and transcript headers use
ALIGNMENT_TIMEZONE (default America/Denver, so MST/MDT) until per-person
zones come from the timezone cog. tzdata is a requirement for hosts
without a system zone database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 16:01:07 -07:00
Ziad ArafatandClaude Opus 5.5 d15e76ebd7 doge_alignment: richer guesses from conversations, activity and avatar
- Context: around a couple of their messages on each sampled page, fetch
  the channel conversation. core/conversations.py merges quick consecutive
  messages into turns, splits conversations at 20-minute lulls (replies
  stay with what they answer), trims around the person and renders
  transcripts with others as A, B, ...; people who blocked guesses are
  hidden, bots left out.
- core/activity.py: posting rate between sampled pages over the years
  and its variation, busiest UTC hours and spread, nights and weekends,
  burstiness, run length, length and style shares.
- Avatar: ImageMagick palette with colour names, and a description from
  the model's vision (Qwen3.5 has it).
- core/guess.py: dossier packed to a token budget (default 32k,
  ALIGNMENT_CONTEXT_TOKENS) round-robin across the history; page count
  follows the budget. Discord markup is tidied first: raw text ran at
  1.6 chars/token, tidied 2.4, which cut one real prompt from 34k to 14k
  tokens. New candid, debiased system prompt; temperature 0.3.
- gather.py holds the Discord fetching; the cog shows progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 15:44:55 -07:00
Ziad ArafatandClaude Opus 5.5 43809412cd doge_alignment: guess from the whole message history, sampled at random
alignment guess used the last 35 messages in the 8 busiest channels. It
now uses Discord's guild message search (author filter, channels the
viewer can see) to reach the person's whole history: core/sampling.py
picks 8 random pages across all of it, walking past the 10,000-result
offset limit with max_id windows, keeps 5 random messages with text from
each, and picks 35. Search allows about one request per 5 seconds, so
that's ~40 s; 70 single random messages took over two minutes on a real
10,193-message history. Falls back to scanning channels without search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 14:52:28 -07:00
Ziad ArafatandClaude Opus 5.5 c61ef5b642 doge_alignment: ALIGNMENT_MODEL_REASONING (reasoning_effort) for thinking models
Ollama's reasoning models spend the whole token budget thinking unless
reasoning_effort is "none"; it's only sent when set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 14:30:16 -07:00
Ziad ArafatandClaude Opus 5.5 96822d5f8c doge_alignment: suggestions, custom charts, model guesses, emoji names
- alignment suggest/suggestions/accept/reject, with Accept/Reject buttons
  that survive restarts (DynamicItem); model guesses are suggestions too.
- Custom charts (core/spec.py): title, column and row names, per-cell
  labels and colours; entries keep their classic position. Used in
  pictures, text, parsing, autocomplete and YAML export/import.
- alignment guess: up to 35 recent messages to an OpenAI-compatible local
  model, answer constrained by a JSON schema to the chart's labels;
  alignment guessing to opt out.
- Text through ImageMagick's Pango coder when present, so emoji and other
  scripts fall back to fonts that have them. Names are escaped for Pango
  and for ImageMagick's %[fx:], %w, \n and @file escapes, which Pango text
  otherwise expands (tested).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 13:05:20 -07:00
Ziad ArafatandClaude Opus 5.5 b33c060587 Add mise run test-container; pin Wand to the bot's 0.7.2
test-container runs the suite inside dogebot's Red image on yveltal, with
its ImageMagick 6, fonts and the cogs' info.json requirements, and is part
of mise run check. It fails on the copy_alpha bug that reached the bot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 12:21:16 -07:00
Ziad ArafatandClaude Opus 5.5 2120bc6b34 doge_alignment: work on ImageMagick 6 too (copy_opacity)
Debian 12's ImageMagick 6 has no copy_alpha operator; pick whichever the
installed ImageMagick provides. Checked by rendering in dogebot's container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 11:56:10 -07:00
Ziad ArafatandClaude Opus 5.5 b575ab6f75 doge_alignment: chart pictures, one command group, Discord-free core
Draw the chart with ImageMagick: one 3x3 picture, or nine tiles sent as a
Components V2 media gallery (3x3), with avatars cut into circles. Names and
avatars are looked up live; people who left are greyed out.

Move all logic into doge_alignment/core, which imports neither discord.py
nor Red: immutable Chart dataclasses with pure operations, Config/YAML
storage, a view model, pure layout geometry, a Wand painter and an avatar
fetcher. The cog and a new CLI (python -m doge_alignment) are front ends.

Commands are now one hybrid `alignment` group (text and slash): show, set,
remove, prune, clear, style, export, import, admin add/remove/list. Red's
admin/mod roles, Administrators and the server owner count as admins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 11:34:36 -07:00
ziadarafatandClaude Opus 5.5 ee17b3c3e5 Bring doge_alignment up to the watch cog's standards
Fixes:
- setting or removing an alignment dropped the server's admin list
- charts were YAML files inside the cog folder, which Downloader replaces
  on every update; they now live in Red's Config
- the cog imported Wand (ImageMagick) at load time and couldn't load
  where ImageMagick is missing, such as dogebot's container
- info.json pip-installed this whole repo, red-discordbot and discord
  included, into Red's lib folder
- /alignment_remove_admin let the bot owner past one check and then
  refused them at the next

Structure: the cog folder is self-contained like watch. chart.py holds
the rules as pure functions; render.py keeps the image helpers (grid
layout fixed, debug viewers removed) and is imported only when used. The
repo is now a uv virtual project (no package build), with Red pinned to
dogebot's 3.5.24.

Standards: ruff with the lptn settings, ty and annotations, and pytest
(chart rules, Config storage and red_delete_data_for_user on Red's test
backend, image helpers) now cover both cogs; 52 tests. Missing features
are listed in doge_alignment/TODO.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 09:49:10 -07:00
ziadarafatandClaude Opus 5.5 aaa287d753 Add the watch cog: preload media through media-preload
`[p]watch <title>` asks the home lab's media-preload service to cache a
movie, a season, some episodes or the next N unwatched episodes, and
keeps a progress message (with a Cancel button) updated until done.
`link`/`unlink` store a Jellyfin user name for "next"; `status` and
`cancel` work on request ids.

The API client in clients/media-preload-client is generated from the
service's OpenAPI spec with openapi-python-client (`mise run
generate-client`); the cog installs it from this repo via info.json.

Also: ruff target py311 (Red 3.5's Python), a dev group with the client,
pytest, ruff and ty, and mise tasks. Lint and type checks cover the new
cog; doge_alignment is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-05 09:37:45 -07:00
RustyRaptor 8992f02d87 Fix requirements format in info.json 2025-11-02 12:57:36 -07:00
Ziad Arafat 0cb4882244 update function names to latest changes 2025-08-22 06:12:30 -06:00
Ziad Arafat 8476b25786 Implement major commands and functions for processing alignments 2025-08-22 06:11:54 -06:00
Ziad Arafat 3fcd46f3ef Added wand library to uv project for image processing 2025-08-22 06:10:39 -06:00
Ziad Arafat 598fb3362e Readme updated 2025-08-22 06:08:50 -06:00
Ziad Arafat 48ba748b5f fixed structure for created yaml files to ensure its always compliant. Updated test suite 2025-08-11 09:02:53 -06:00
Ziad Arafat 19e94917f0 added admin system commands and check for bot owner 2025-08-11 08:40:50 -06:00
Ziad Arafat 34c5352530 add new commands 2025-08-11 08:27:54 -06:00
Ziad Arafat 089b280b81 update data model to allow admin and allow setting other users 2025-08-11 08:17:03 -06:00
Ziad Arafat 1ad2018da4 fixed requirements item 2025-08-11 08:03:21 -06:00
Ziad Arafat 757b66d5d6 fixed imports 2025-08-11 08:00:27 -06:00
Ziad Arafat e7718c435c moved modules to the main package 2025-08-11 07:58:35 -06:00
Ziad Arafat 642feb023f added new requirement and fixed import to use playground 2025-08-11 07:24:00 -06:00
Ziad Arafat fc6abd1023 added init file for playground 2025-08-11 07:21:51 -06:00
Ziad Arafat 546ec8c85c sigh this is so annoying 2025-08-11 07:12:23 -06:00
Ziad Arafat ec881ca298 trying to fix the requirement 2025-08-11 07:09:19 -06:00
Ziad Arafat 588e794760 fix requirement 2025-08-11 07:07:09 -06:00
Ziad Arafat dccdd9e091 Added info.json with requirements test 2025-08-11 07:03:19 -06:00