Skip to content

fuck this shitty codebase#657

Open
p1nkhamster wants to merge 1 commit into
monochrome-music:mainfrom
p1nkhamster:fix/aac-download-transcoding
Open

fuck this shitty codebase#657
p1nkhamster wants to merge 1 commit into
monochrome-music:mainfrom
p1nkhamster:fix/aac-download-transcoding

Conversation

@p1nkhamster
Copy link
Copy Markdown
Collaborator

@p1nkhamster p1nkhamster commented May 16, 2026

Description

this shit it not tested cause localhost is blocked by CORS. test this shit!!!!!!!!

Type of Change

  • Bug fix
  • New feature
  • Style/UI update
  • Docs only

Checklist

  • I have read the Contributing Guidelines.
  • I understand every line of code I am submitting.
  • I have tested these changes locally, and they work as expected.
  • Is this Pull request Using AI/Is Vibecoded?

By submitting this PR, I agree to follow the guidelines. I understand that the final decision to merge rests with the maintainers and that not all contributions can be accepted.

Summary by CodeRabbit

  • New Features
    • Simplified download quality options in Settings → Downloads; removed AAC-based options leaving only Hi-Res Lossless and Lossless choices available.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

This PR removes AAC-based download quality options from the UI and refactors the download pipeline to fetch HIGH/LOW requests as LOSSLESS sources, then transcode client-side using new custom AAC format presets instead of server-side transcoding.

Changes

AAC Quality Rerouting to Client-Side Transcoding

Layer / File(s) Summary
Custom AAC Format Presets
js/ffmpegFormats.ts
Adds FFMPEG_AAC_320 (320kbps) and FFMPEG_AAC_96 (96kbps) as new CustomFormat presets, each with specific ffmpegArgs and m4a output metadata for client-side transcoding.
API Source Quality Routing
js/api.js
Introduces qualityNeedsLosslessSource() helper to identify when HIGH/LOW and custom formats require LOSSLESS source fetching; updates enrichTrack and downloadTrack to route these quality requests to LOSSLESS source selection.
Download Postprocessing Refactoring
js/download-utils.ts
Remaps legacy HIGH/LOW to FFMPEG_AAC_320/FFMPEG_AAC_96 early in applyAudioPostProcessing; adds early return for custom lossy formats when source extension matches target (skipping redundant re-encoding); removes prior lossless-to-lossy AAC conversion logic.
UI and Settings Updates
index.html, js/settings.js
Removes HIGH ("AAC 320kbps") and LOW ("AAC 96kbps") options from the Download Quality dropdown; updates staticCategories to remove HIGH/LOW category mappings, leaving only HI_RES_LOSSLESS and LOSSLESS as Lossless options.
Test Coverage for New Transcoding Behavior
js/api.test.ts
Updates test matrix so HIGH and LOW cases now expect 1 ffmpeg call (client-side transcode) instead of 0; adjusts AAC bitrate expectations (96 and 239) to reflect observed encoded values; adds comments documenting silent-audio bitrate variance.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • monochrome-music/monochrome#631: Directly overlaps at applyAudioPostProcessing—this PR removes the sourceIsLossless && !statedLossless && !isCustomFormat(quality) branch that PR #631 added.
  • monochrome-music/monochrome#298: Aligns on consolidating download transcoding around ffmpegFormats custom-format handling and corresponding API quality-routing logic for HIGH/LOW rerouting.
  • monochrome-music/monochrome#417: Both modify LosslessAPI.enrichTrack and downloadTrack logic; this PR changes HIGH/LOW quality handling via lossless/AAC remapping.

Suggested reviewers

  • JulienMaille

Poem

🐰 A rabbit bounces through transcoding streams,
AAC presets now transcode by client dreams,
No server toils, just LOSSLESS at the start,
Then ffmpeg's brush paints custom audio art,
The dropdown springs clean—two options remain,
Pure lossless glory, transcoded with flair and main!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fuck this shitty codebase' is vague, profane, and entirely unrelated to the actual changes (removing AAC options and implementing lossless transcoding logic). Replace with a clear, professional title that describes the main change, such as 'Remove AAC download options and implement lossless transcoding for HIGH/LOW quality.'
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning Pull request description lacks professional detail, contains offensive language, and fails to provide substantive explanation of changes or testing status. Rewrite the description professionally, explaining what AAC download transcoding changes were made and why. Address testing concerns constructively (e.g., specify which environments need testing, describe manual test steps, or explain CORS workaround needed). Check guidelines and code understanding checkboxes if applicable.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@p1nkhamster
Copy link
Copy Markdown
Collaborator Author

uwaaa fuck you coderabbit!!!!!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
js/api.test.ts (1)

119-293: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Tests must pass before merge.

The pipeline shows multiple test failures, and the PR description explicitly states the changes are "not tested." This is unacceptable for merge:

Failures directly related to AAC transcoding changes:

  • Line 301: ffmpeg call count mismatch for 'HD Lossless (FLAC)' (expected 1, got 0)
  • Line 363: File type mismatch for 'HD Lossless (Unchanged)' (expected Mp4File, got FlacFile)

Failures that appear unrelated but need investigation:

  • Lines 452, 460, 468: OGG bitrate mismatches (expected vs actual: 314→330, 253→265, 130→137)
  • Line 1: RangeError in 'Lossless, but not really' test

Actions required before merge:

  1. Run the tests in a proper environment (resolve CORS/proxy issues)
  2. Fix all failing test cases or update expectations with documented justification
  3. Verify the OGG bitrate mismatches aren't regressions from your changes
  4. Ensure the 'HD Lossless' test cases work correctly with the new transcoding pipeline

The PR checklist indicates you haven't confirmed local tests pass. Please test thoroughly before requesting review.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/api.test.ts` around lines 119 - 293, Tests fail after AAC transcoding
changes: reproduce locally and run the test suite, then fix the transcoding
selection and container/bitrate logic so tests expecting ffmpeg calls and file
types pass. Inspect Detection (enum), transcodeTrack / chooseTranscode /
detectFormat, and the ffmpeg wrapper (where ffmpeg is invoked and ffmpeg call
counts are recorded) to ensure preferDolbyAtmos handling still returns
TRACK_ATMOS paths, that HD Lossless (FLAC) triggers an ffmpeg call when
Detection.FlacHD is detected, and that Mp4File vs FlacFile is produced correctly
by the code path that handles Detection.Mp4Flac; also verify OGG encoder bitrate
parameters (OGG_320/256/128) in the encoder config are unchanged and adjust them
back to prior values if your changes altered the bitrate calculations, and fix
the RangeError in the branch for Detection.AacReallyLow by adding proper
guards/validation in the code that maps detections to output quality. Ensure all
fixes are covered by running the failing tests and update expectations only with
documented justification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@js/api.test.ts`:
- Around line 408-410: The current AacHigh test asserts a 239 kbps result on
SILENCE_TRACK which may be misleading; add a parallel test that encodes
TRACK_ATMOS (or any non-silent track) with the same AAC settings (e.g., the
existing AacHigh test setup that calls ffmpeg with "-c:a aac -b:a 320k") and
assert the resulting mp4.audioProperties().bitrate is close to the target (e.g.,
within a reasonable tolerance of 320 kbps) to confirm the 239 kbps result is
specific to SILENCE_TRACK rather than a systemic encoder issue; reference the
AacHigh test, SILENCE_TRACK, TRACK_ATMOS, and mp4.audioProperties().bitrate when
locating and adding the new test.

---

Outside diff comments:
In `@js/api.test.ts`:
- Around line 119-293: Tests fail after AAC transcoding changes: reproduce
locally and run the test suite, then fix the transcoding selection and
container/bitrate logic so tests expecting ffmpeg calls and file types pass.
Inspect Detection (enum), transcodeTrack / chooseTranscode / detectFormat, and
the ffmpeg wrapper (where ffmpeg is invoked and ffmpeg call counts are recorded)
to ensure preferDolbyAtmos handling still returns TRACK_ATMOS paths, that HD
Lossless (FLAC) triggers an ffmpeg call when Detection.FlacHD is detected, and
that Mp4File vs FlacFile is produced correctly by the code path that handles
Detection.Mp4Flac; also verify OGG encoder bitrate parameters (OGG_320/256/128)
in the encoder config are unchanged and adjust them back to prior values if your
changes altered the bitrate calculations, and fix the RangeError in the branch
for Detection.AacReallyLow by adding proper guards/validation in the code that
maps detections to output quality. Ensure all fixes are covered by running the
failing tests and update expectations only with documented justification.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71bc9061-a608-4873-b77d-aa3b40ca4315

📥 Commits

Reviewing files that changed from the base of the PR and between d6fb57f and 2e806d9.

📒 Files selected for processing (6)
  • index.html
  • js/api.js
  • js/api.test.ts
  • js/download-utils.ts
  • js/ffmpegFormats.ts
  • js/settings.js
💤 Files with no reviewable changes (2)
  • js/settings.js
  • index.html

Comment thread js/api.test.ts
Comment on lines +408 to +410
// SILENCE_TRACK transcoded with -b:a 320k: ffmpeg's AAC encoder
// drops the actual bitrate well below the target on silent audio.
expect(mp4.audioProperties().bitrate).toBe(239);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check FFmpeg AAC encoder configuration

echo "=== FFMPEG_AAC_320 encoder arguments ==="
rg -nP -A5 "FFMPEG_AAC_320" js/ffmpegFormats.ts

echo -e "\n=== FFmpeg invocation in applyAudioPostProcessing ==="
rg -nP -A10 "ffmpeg.*-b:a|ffmpeg.*aac" js/download-utils.ts

Repository: monochrome-music/monochrome

Length of output: 422


🏁 Script executed:

# Check the test context around lines 408-410
cat -n js/api.test.ts | sed -n '390,420p'

Repository: monochrome-music/monochrome

Length of output: 1916


🏁 Script executed:

# Find SILENCE_TRACK definition
rg -n "SILENCE_TRACK|trackId.*46022548" js/

Repository: monochrome-music/monochrome

Length of output: 1105


🏁 Script executed:

# Look for other AAC bitrate test expectations
rg -n "AacHigh|AacLow|bitrate.*toBe" js/api.test.ts | head -20

Repository: monochrome-music/monochrome

Length of output: 1055


🏁 Script executed:

# Check git history for the 239 bitrate expectation
git log -p --all -S "toBe(239)" -- js/api.test.ts | head -100

Repository: monochrome-music/monochrome

Length of output: 53


🏁 Script executed:

# Search for any discussion or issues about AAC bitrate
rg -i "aac|bitrate|silent" js/ --type-list | head -5 && rg -i "aachigh|codec" js/api.test.ts | head -20

Repository: monochrome-music/monochrome

Length of output: 1353


🏁 Script executed:

# Check if there are any comments explaining the SILENCE_TRACK choice
cat -n js/api.test.ts | sed -n '90,110p'

Repository: monochrome-music/monochrome

Length of output: 944


🏁 Script executed:

# Compare the pattern: check what bitrate targets are used for each format
rg -n "b:a.*k|bitrate" js/ffmpegFormats.ts | grep -i "aac\|mp3\|vorbis"

Repository: monochrome-music/monochrome

Length of output: 616


Investigate AAC 320k bitrate deviation and add validation with non-silent audio.

The AacHigh bitrate expectation of 239 kbps significantly underperforms the 320k target (75% of target). While the comment notes this is due to SILENCE_TRACK, the pattern is concerning:

  • AAC 320k: 239 kbps (75% of target) ← outlier
  • AAC 256k: 263 kbps (103% of target)
  • AAC 96k: 96 kbps (100% of target)
  • MP3 320k: 322 kbps (101% of target)
  • Ogg 320k: 314 kbps (98% of target)

Only AAC at 320k deviates significantly. The FFmpeg arguments (-c:a aac -b:a 320k) are correct, but this pattern suggests either AAC encoder behavior at 320k specifically differs from other bitrates/codecs, or there's an underlying configuration issue.

Add a test case for AacHigh using TRACK_ATMOS (or another non-silent track) to verify the encoder approaches the target bitrate under normal conditions and confirm the 239 kbps result is specific to silent audio rather than a systemic encoder problem.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/api.test.ts` around lines 408 - 410, The current AacHigh test asserts a
239 kbps result on SILENCE_TRACK which may be misleading; add a parallel test
that encodes TRACK_ATMOS (or any non-silent track) with the same AAC settings
(e.g., the existing AacHigh test setup that calls ffmpeg with "-c:a aac -b:a
320k") and assert the resulting mp4.audioProperties().bitrate is close to the
target (e.g., within a reasonable tolerance of 320 kbps) to confirm the 239 kbps
result is specific to SILENCE_TRACK rather than a systemic encoder issue;
reference the AacHigh test, SILENCE_TRACK, TRACK_ATMOS, and
mp4.audioProperties().bitrate when locating and adding the new test.

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