# Jamendo music-bed workflow for AutoShorts

Session learning from replacing rejected generated/self-made music with licensed stock music.

## Trigger

Use this when producing or revising AutoShorts / Everyday Red Flags review videos and the user wants a real licensed background music bed instead of generated/self-made music.

## Credentials

- Jamendo credentials live at `~/.hermes/secrets/jamendo_api` with mode `0600`.
- Parse `.env` style lines:
  - `JAMENDO_CLIENT_ID=...`
  - `JAMENDO_CLIENT_SECRET=...`
- The public Tracks API needs the client ID; do not print either value.

## Default search posture

Use Jamendo's official endpoint only:

- `https://api.jamendo.com/v3.0/tracks/`

For platform-facing drafts, prefer a conservative license filter:

- `audiodownload_allowed=true`
- `vocalinstrumental=instrumental`
- `ccnc=false`
- `ccnd=false`
- `ccsa=false` where enough results exist
- Prefer CC BY over NC/ND/SA tracks to simplify YouTube/TikTok use and attribution.

Good query families for scam-self-defense shorts:

- `tense cinematic ambient`
- `dark suspense background`
- `cyber ambient minimal`
- `quiet technology tension`

## Download and metadata pattern

Store downloaded music under:

```text
AutoShortsBot/data/audio_beds/jamendo/
```

For every MP3, write a sibling `.license.json` containing at least:

- source: `Jamendo`
- track ID/title/artist/duration
- Jamendo track URL
- license URL
- attribution string
- downloaded file path
- whether it passed the default license safety filter

Example attribution shape:

```text
Hyper Threading by Zeropage — http://creativecommons.org/licenses/by/3.0/ — https://www.jamendo.com/track/23560
```

## Mixing pattern

- Mix music quietly under the existing voice, not as a dramatic foreground layer.
- Use FFmpeg sidechain compression/ducking keyed from the voice track.
- Typical starting volume: `0.10` to `0.13`.
- Preserve the video stream with `-c:v copy` when only replacing/mixing audio.
- Re-probe the final MP4 and recompute SHA256 after mixing; the approval command must bind to the music-mixed artifact, not the pre-music review file.

## Review package update pattern

After adding a Jamendo bed to an already rendered review video:

1. Create the music-mixed MP4 with a filename that includes the track/source, e.g. `_jamendo_hyper_threading_1080x1920_review.mp4`.
2. Recompute `video_sha256`.
3. Add a `music_bed` block to the private-upload package:
   - source
   - track
   - artist
   - license
   - license_url
   - track_url
   - license_metadata_path
   - mix notes
4. Recompute `posting_pack_sha256` from the package *before* inserting the new approval command.
5. Generate a new `APPROVED_FOR_PRIVATE_YOUTUBE_UPLOAD ...` command with the new video hash and package hash.
6. Copy the mixed MP4 to the Hermes media cache before delivery.

## Pitfalls

- Do not use a YouTube grabber on arbitrary “no copyright” videos unless the license is explicit and documented; Content ID can still claim or mute the upload.
- Do not treat Jamendo search hits as safe solely because the API returned them. Filter and store the license metadata locally.
- Do not leave the upload package pointing at the pre-music video after mixing music; that creates a hash-bound approval mismatch.
- Do not use NC/ND/SA tracks by default for platform-facing content when CC BY alternatives are available.
