Automation

Music Automation

Automation as it applies to albums, singles and artists

Music Automation lets RKHM build and maintain your music catalog for you. Instead of adding every artist, album and track by hand, RKHM can pull metadata from Spotify and MusicBrainz, and attach playable sources from YouTube or SoundCloud.

Check Spotify access before configuring automation
Spotify requires the owner of a Development Mode app to have an active Premium subscription. Development Mode is intended for learning and personal, non-commercial use; it is not a general production API entitlement. Spotify has also restricted endpoints and metadata available to newer apps. Review Spotify changes and Spotify’s quota modes before planning a public music catalogue.

There are three separate mechanisms behind the feature. They are configured on the same screen, but they are triggered in completely different ways and they do different things. Reading this table first will save you a lot of confusion later.

MechanismWhat triggers itWhat it doesCan it import brand-new items?
Full AutomationA visitor opens an artist or album page, or uses your searchTalks to Spotify live and merges fresh data into the page being rendered — an artist's albums, an album's tracks, the artists credited on them — and mixes Spotify search results into your search pageYes, and more than you might expect. See the warning below
On-demand source fetchA visitor presses play on a track that has no playable sourceSearches YouTube or SoundCloud for that one track and stores the result as a new track sourceNo — it only attaches a source to a track you already have
Music CronjobsA scheduled background process on your serverWalks a list of IDs, or a filtered set of your own database rows, and creates or updates artists, albums, tracks and playlistsYes — this is the deliberate, controllable bulk import mechanism

In short: Cronjobs grow your catalog deliberately and on a schedule you control, Full Automation grows it as a side effect of people browsing, and on-demand fetch is a safety net for a track someone tries to play that has no audio attached yet.

Before you start: credentials

All automation settings live on one page: Admin area → Content → Music → Automation. The same page is also linked from Settings → Cronjob → Music - Automation.

GroupWhat you enterNeeded for
SpotifyClient ID, Client Secret — from a developer app owned by a Spotify Premium accountEverything Spotify — Full Automation and Spotify cronjobs
YoutubeAPI Key(s), one per line, and an API region code (default US)Finding YouTube videos as track sources, both by cronjob and on demand
Youtube DownloadActiveDownloading a YouTube video and converting it to a local MP3. Requires working FFmpeg and youtube-dl, configured on Setting → General → External Tools. Read the disclaimer below before enabling
SoundcloudClient ID, Client Secret, Enable SoundCloud as Music SourceOn-demand SoundCloud source fetch
LyricsAutomated Lyrics Source, plus a Musixmatch API key or an AZLyrics proxyAutomated lyrics
MusicBrainzNothing — no credentials exist for itMusicBrainz is free and unauthenticated, so it works out of the box

Get Spotify credentials by creating an app at Spotify for Developers, using an account with an active Premium subscription. Get a YouTube key by enabling YouTube Data API v3 in Google Cloud. If you have installed the Spotify Multi Accounts tool, the Client ID and Secret fields on this page are replaced by a note — define your keys on that tool's own settings page instead.

About scrapper tools and youtube-dl
RKHM offers optional YouTube, SoundCloud and Spotify scraper tools, a Spotify Multi Accounts tool, and yt-dlp based downloading. Using scrapers and downloading is only legal for research purposes and personal use — don't rely on them for a public or commercial site. They are also affected by provider rate limits and changes on the provider's side. A Spotify Premium subscription alone does not grant Extended Quota Mode or permission for every commercial use.
A Spotify Premium subscription is active on the account owning your developer app
Spotify Client ID and Client Secret are both filled in — one without the other silently fails every Spotify call
At least one YouTube Data API v3 key entered, if you want YouTube sources
SoundCloud Client ID and Secret entered, if you want SoundCloud sources
An OS-level scheduler is calling RKHM's cron runner — see the warning further down

Mechanism 1 — Full Automation

Enable it with Full Automation in the Spotify group. When it is on, RKHM talks to Spotify live, while a visitor is browsing, and merges what it finds into the page it is about to render.

How it works
  • When a visitor searches your site, RKHM also searches Spotify and adds closely-matching artists and albums that you do not already have into the search results. Clicking one creates it on your site.
  • When a visitor opens an artist page, RKHM re-checks that artist on Spotify and pulls their albums — and creating those albums creates the tracks and the artists credited on them.
  • When a visitor opens an album page, the same thing happens one level down: the album's tracks are pulled, and every artist credited on them is created if missing.
  • Any artist RKHM encounters in a Spotify response gets a row in your database — lead artists, featured artists, and, if a scrapper tool is installed, related artists too.
  • It is deliberately disabled during background cron runs — it is a live, per-page-view mechanism only.
Full Automation can grow your catalog far beyond what you intended
This is the part people underestimate. Content pulls in more content through relations: one artist page pulls their albums, those albums pull their tracks, those tracks pull every featured artist, and with a scrapper tool installed, related artists as well — each of whom is a new artist row that will do the same thing the next time somebody opens their page. A handful of visitors browsing casually can add thousands of rows you never asked for. If you are building a curated or niche site, do not treat Full Automation as a harmless freshness feature. Use Music Cronjobs instead, where you decide exactly what enters the catalog.
When Full Automation is the wrong choice
  1. Curation: you lose control of what is in your catalog. Anything a visitor searches for, and everything related to anything they open, can end up on your site permanently.
  2. Database growth: the expansion described above is unbounded. Plan for it, or avoid it.
  3. High traffic: thousands of visitors a day means thousands of live Spotify calls, and you can reach Spotify's limits.
  4. Speed: RKHM has to wait for Spotify's servers before answering the visitor. Pre-collecting with cronjobs is always faster.
  5. Missing sources: items created this way still need an audio or video source attached, which takes extra time at exactly the wrong moment.

Mechanism 2 — On-demand source fetch

This is the quietest of the three, and the one most often misunderstood. It is controlled by two toggles: Enable YouTube as Music Source (Youtube group) and Enable SoundCloud as Music Source (Soundcloud group).

When a visitor presses play on a track that has no working source, RKHM searches YouTube or SoundCloud for that single track, and — if it finds a good match — stores it as a new source on that track so playback can start. No admin action, no cronjob, resolved inside that one request. If Youtube Download → Active is also on, RKHM can instead download the video and convert it to a local MP3.

This is not bulk automation
These two toggles are not part of Full Automation and they are not schedulable as a cronjob. They fix exactly one track, at the moment someone tries to play it, and only for tracks that entered your catalog from Spotify and currently have no playable stream. Tracks from a manual upload or from MusicBrainz-only enrichment are never touched by this path.

Two related toggles sit in the same Youtube group. Enable Replacement of Broken YouTube Videos lets the player report unavailable videos back to your server, so they can be found and replaced. Enforce 30-Day YouTube ID Storage Limit makes RKHM delete stored YouTube IDs after 30 days, to comply with YouTube's API policies.

Reporting is throttled so it cannot be abused. The limits live on Settings → Player → Report Limits, and they apply to every kind of reportable source, not only YouTube videos: Max Reports per User per Item (default 1), Max Reports per IP per Item (default 1), and Max Reports per IP per Day (default 10, counted as unique items).

Mechanism 3 — Music Cronjobs

Think of music cronjobs as diligent carriers working behind the scenes. Each one travels to Spotify, MusicBrainz or YouTube, collects what you told it to collect, and brings it back to your server without you doing anything. You control what they collect, how often, and how much per trip — which is exactly what Full Automation does not give you.

You manage them at Admin area → Content → Music → Cronjobs (also linked from Settings → Cronjob → Music - Cronjobs). Create as many as you like, each with its own purpose and its own schedule. More jobs means more API requests and more database work, so build them deliberately rather than all at once.

Anatomy of a music cronjob

FieldWhat it means
Name / CommentYour own label and notes. Visible to admins only
API NameSpotify, MusicBrainz or YouTube
Object typeArtist, Album, Track or Playlist. Which ones are available depends on the API you picked
Dynamic IDSOff = you paste the API IDs yourself. On = RKHM picks items out of your own database using filters you define
Static IDsOne API ID per line. Only shown when Dynamic IDS is off. The Browse Spotify button helps you find them
Execution intervalMinutes between runs of this job. 1 = once a minute, 60 = once an hour
Update intervalDays before an ID this job already checked becomes eligible to be checked again
Item limitHow many items to process in a single run. Higher means longer runs and more API usage
ActiveThe on/off switch for this job. Inactive jobs are never registered with the cron engine

Static IDs vs Dynamic IDs

Static means you hand the job a fixed list of API IDs, one per line. This is how you seed a catalog: pick ten artists you care about and let the job fetch them and everything attached to them. Use the Browse Spotify button next to the field — type a keyword, click a result, and its ID is added to the list for you.

Dynamic means the job looks into your own database instead, and you narrow it down with Dynamic Filter fields — the same filters you use when browsing artists, albums or tracks in the admin area. This is how you keep an existing catalog fresh, and how you enrich items you already have.

Two things are worth knowing about dynamic jobs. A dynamic Spotify job only picks up items that already carry a Spotify ID — it refreshes what you have, it does not discover new items. A dynamic MusicBrainz artist job with Get related artists enabled can create new artist entries as it discovers relations, which means its scope can keep expanding run after run. Watch that one.

What each API can do

APIObject typesQuery typeExtra options
SpotifyArtist, Album, Track, PlaylistStatic or DynamicGet albums, Sync genres, and for playlists Create playlists plus an owner user. Get related artists and Get top tracks only appear if the Spotify Scrapper tool is installed, because affected Development Mode apps cannot use the former official endpoints
MusicBrainzArtist, Album, TrackDynamic — it works against rows already in your databaseArtist: Get related artists, Get genres, Get tags. Album and Track: Get genres, Get tags
YouTubeTrack onlyDynamic only — both are enforced, the form will refuse to save otherwiseDownload videos — also download the video and convert it to a local audio file. Make sure youtube-dl and FFmpeg work first, and read the disclaimer above

A YouTube job skips any track that already has a YouTube source, and with Download videos on it also skips tracks that already have a local audio source — so it never re-does work it has already done.

Creating a cronjob, step by step

Fill in the credentials for the API you are about to use, on the Music Automation page
Go to Content → Music → Cronjobs and click create
Give the job a name that says what it is for — 'Seed', 'Famous Checker', 'YouTube sources'
Pick the API Name and Object type
Choose Static or Dynamic, then fill in the IDs or the dynamic filters on the Query tab
Set Execution interval, Update interval and Item limit
Tick the extra options you want for that API
Save, then use the Activate button on the list screen to switch the job on
Cronjobs need a scheduler on your server
RKHM ships the cron runner but it cannot start itself. An OS-level scheduler — a cron entry on Linux, Task Scheduler on Windows — must call it periodically, for example once a minute. Until that is set up, no cronjob will ever run, music or otherwise, no matter how you configure it. Your host's control panel usually has a Cron Jobs section for this.

You can also restrict which days of the week a job is allowed to run, on Settings → Cronjob → Setting. This works for music jobs exactly as it does for RKHM's built-in ones.

Tuning: the three intervals

Execution Interval: how frequently the job runs, in minutes. 60 means up to 24 runs a day. By default jobs are executed one after another, so consider how many other jobs you have running. With Parallel execution turned on under Setting → Cronjob → Setting (added in v2.1.04), each due job starts as its own background process, up to the limit you set. If you are not sure, 10 minutes is a good baseline.

Update Interval: how current the data stays, in days. 1 means every ID is re-synced daily; 365 means annually. Frequent updates only make sense for dynamic content, like popular artists who release often. Most albums and tracks barely change, so a high number there is both more suitable and much cheaper on your API quota.

Item Limit: how many items are processed per run. Lower means fewer API requests per run. Note that one item is not one API request — a playlist can cost hundreds of requests if it contains hundreds of entries, and an artist with Get albums enabled costs far more than a bare artist lookup.

Create several cronjobs for different purposes. Set Item limit to 1 and Execution interval to 10 for all of them, then give each one a different Update interval based on how often that kind of content actually changes on the source.
General advice
Reading the stats box

The cronjob list screen shows a live Stats box for every job. Use it to judge whether a job's settings can actually keep up with the set of items you pointed it at.

  • Execution interval and Update interval — repeated back to you for quick comparison
  • Max up-to-date items — an estimate of how many items this job can realistically keep current, based on your intervals, your item limit, and how expensive that object type is to fetch
  • Query type — Static or Dynamic
  • Query item count — how many items the job's query covers in total
  • Checked item count — how many of them have been checked recently enough to still count as up to date
  • Queued for check count — how many are waiting their turn

If Queued for check count never goes down, the job is not keeping up: raise the item limit, lower the execution interval, or raise the update interval so items stay valid longer.

Worked examples

Example 1 — seeding a hip-hop catalog. Create a job called Seed. API Name: Spotify. Object type: Artist. Dynamic IDS: off. Update interval: 1. Enable Get albums and Sync genres. Use Browse Spotify to add the IDs of ten artists you care about. Each run collects those artists along with their albums and tracks.

Then add a Famous Checker: same API and object type, but Dynamic IDS on, update interval 7, with a dynamic filter that narrows the selection to the artists you most want kept current. Add a Mid Checker alongside it with an update interval of 60 and a looser filter, so your less-critical artists are still refreshed, just far less often.

Example 2 — enriching what you already have. For a Development Mode app affected by Spotify’s endpoint and metadata restrictions, use MusicBrainz to enrich existing artists with genres, tags, and related artists. Create a job with API Name: MusicBrainz, Object type: Artist, Dynamic IDS on, update interval 14, and enable Get genres and Get tags. It will walk your existing artists and fill in the metadata Spotify used to provide. Add Get related artists only if you are comfortable with the job creating new artist entries as it discovers relations.

Example 3 — attaching playable sources. Create a job with API Name: YouTube, Object type: Track, Dynamic IDS on (both are required). Give it a high update interval — an already-attached source does not need re-collecting. Use the dynamic filters to narrow it to the tracks you actually want playable, especially if you enable Download videos, so you are not downloading and converting your entire catalog.

Collecting sources

Metadata alone is not enough — an item also needs something with sound. RKHM supports three ways to get there.

  1. YouTube video: found either in the background by a YouTube cronjob, or on demand at the moment a visitor presses play.
  2. SoundCloud audio: fetched per visitor request only. There is no scheduled SoundCloud import — see the limits section below.
  3. YouTube video converted to MP3 (youtube-dl): available both on demand and via a cronjob. Because downloading and converting takes real time, cronjobs are strongly preferred so nobody waits — and use dynamic filters so you do not convert your entire catalog. Note the disclaimer near the top of this article before you enable it.

For YouTube and SoundCloud either approach is fine — once the ID is found it is stored, and no further API requests are made for that item. For youtube-dl, use cronjobs. And always give source-collecting cronjobs a large update interval: there is no reason to re-collect a source you already have.

Housekeeping jobs

Two settings register their own background jobs automatically — you do not create these on the Cronjobs screen, you just switch the setting on.

  • Enforce 30-Day YouTube ID Storage Limit adds a daily job that deletes stored YouTube sources older than 30 days.
  • Delete singles after EP release adds a daily job that looks for albums with the same title and artist, and where it finds exactly one studio album plus one or more singles, removes the duplicate singles.

If your music is already on your own disk rather than on a third-party service, none of the above applies — you want the Bulk Importer tool instead. Its Music Bulk Import job scans an upload folder, reads each audio file's ID3 tags (title, album, album artist, featured artists, embedded cover art) and creates the matching artists, albums and tracks for you. It is a one-directional import of files you already have, not a sync with an external API. See Bulk Importer for the details.

Monitoring

  • Settings → Cronjob → Run logs is the main screen. Each row shows the status, start and end time, and a detail message — either the job's own summary such as 'Checked 12 item(s)', or the error that stopped it.
  • Every active music cronjob has a Logs button on the list screen that opens the run logs already filtered to that job.
  • Finer per-step progress lines are recorded during each run, which is where you see individual lookups and failures.
  • The admin dashboard shows a Music Cronjobs card with the total number of jobs configured.
  • Error logs in the admin area will show you whether you have hit an API limit.
On-demand fetch failures do not appear in the run logs
The on-demand source fetch is not a cronjob, so it writes nothing to the run logs. If a visitor's play attempt fails to find a YouTube or SoundCloud match, there is no admin screen showing it — the only visible symptom is that the track stays unplayable. If you rely on that mechanism, spot-check playback yourself rather than waiting for a log entry.

Limits and constraints

SourceWhat to watch for
SpotifyDevelopment Mode requires the app owner to have Premium. Extended Quota Mode has separate access rules. Both Client ID and Client Secret are required; with only one filled in, every call fails and your jobs log a generic no-record error rather than a clear 'missing credentials' message. Endpoint availability depends on your app's quota mode — see Spotify changes
MusicBrainzFree and needs no key, but it is deliberately throttled to one request per second and backs off when asked to. It is the slowest of the three by design. A high item limit on a MusicBrainz job makes for very long runs
YouTubeThe quota is strict. You can request a higher one from Google or enter several API keys, one per line — RKHM picks one at random per request. Note that RKHM does not detect an exhausted key and skip it
SoundCloudOn-demand only. SoundCloud cannot be selected as the API for a music cronjob, so there is no scheduled or bulk SoundCloud import — only per-play fetching and manual uploads
Long-running jobsIf a run hangs — usually on a slow external API — its lock is held for up to six hours before the cron engine frees it, and that job will not run again in the meantime. Keep item limits modest on slow sources

Check the current Spotify, YouTube, and SoundCloud terms, including permissions for API access, scraping, downloads, and attribution, before using these integrations in a public app. Access credentials and source links do not by themselves grant rights to redistribute content.