Skip to content

YouTube: post pushed videos without waiting for the feed, log late notices once; random music uses all its services - #344

Merged
liamt8d merged 3 commits into
mainfrom
fix/yt-late-log
Oct 27, 2026
Merged

liamt8d merged 3 commits into
mainfrom
fix/yt-late-log

Conversation

@liamt8d

@liamt8d liamt8d commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

1. The late-notice log line (a bug of #343). YouTube: "…" reached the notice N min after it was published (…) was written while a channel was being looked at, for every recent video it had, on every look, so after a restart it flooded #general-logs. Now the engine writes it when a notice is really sent, once for each video (however many servers follow the channel), and only when it goes out more than 8 minutes after publication.

2. A video YouTube pushes is posted without waiting for the feed of the channel. A channel that Carlbot announced one minute after upload was not announced by Petto for over 15 minutes: its row in youtube_websub showed no push after the upload (the last one was 3 hours earlier, for an old video whose data changed), and the feed of the channel can take minutes to show a new video. The push body already carries the new entry (id, title, link, date), so:

  • the entries of a signed push are kept for 30 minutes and added to what the feed shows each time the channel is looked at, so the video is posted as soon as the channel is looked at after the push, with no wait for the feed;
  • a channel that pushes is looked at every 3 minutes when up to 300 channels are followed (10 up to 1500, 30 beyond): the feed of a channel costs no quota;
  • the log says each push that arrives (up to 300 channels) and, once a minute at most, a push that was ignored because the channel is not followed or the signature did not match, which is what was missing to tell a push that never came from one that was thrown away.

3. Random music always picked Deezer at a 5-minute pace. The service of a slot was chosen with slot * 2654435761; at a 5-minute pace the slot is about 6 million, the product is past what a JavaScript number keeps exactly and its last bit is always 0, so with two services (no Spotify keys) the same one was chosen every time (checked: 8 slots in a row, all Deezer; Apple answers when asked). The hash now uses Math.imul (exact in 32 bits) and the service is chosen with its high bits, so Deezer, Apple Music and Spotify (with keys) alternate.

How it was checked

npm run check passes with the test database and with an empty environment like the CI (feeds, i18n, types, the whole suite). New assertions: a poll writes no late line, a late video gives one line (once for two servers), a pushed video is posted although the feed does not show it, the intervals for 300 / 1500 / more channels, and both and all services are chosen over 40 consecutive 5-minute slots.

Not tested against the real YouTube hub or a real Discord server. Why the push for that video never arrived is not known yet: the new log lines will show whether it comes to the bot and is ignored, or does not come.

@liamt8d liamt8d changed the title YouTube: log the late-notice line only when a notice is really sent YouTube: post pushed videos without waiting for the feed, log late notices once; random music uses all its services Oct 27, 2026
@liamt8d
liamt8d merged commit acd83c3 into main Oct 27, 2026
4 checks passed
@liamt8d
liamt8d deleted the fix/yt-late-log branch October 27, 2026 18:00
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.

1 participant