• Welcome to RadioDJ - Free Radio Automation Software Forum. Please log in or sign up.

RadioDJ Sweepers UNLOCKED!

Started by RadioDJ Dude, March 29, 2025, 07:09:43 PM

RadioDJ Dude

Years spent trying to crack this code has finally paid off! 🎉
 
The lack of flexibility with RadioDJ's Sweeper functionality has always been frustrating. I use it to run my voice tracks and it's a banger! (Previous vid on that system)

BUT, we've been limited to using one sweeper category at a time. Until now!

This hack AMPS creative possibilities on your radio station.

Say you have multiple sweeper categories...maybe one is for generic/evergreen content and another is for topical content (weather, local events, station promos)...now, you can run them ALL in the same hour!

In the video, I crack into the how and why this is a breakthrough. Enjoy!
XXX80s.com-XXXtreme 80s fun!
YouTube Channel: RadioDJ Dude

Kiwi

Out of curiosity...

Can you use an Event with the "Set Sweeper Category" and change the sweeper category this way? e.g. use the command to change your sweeper category every 15 minutes within the hour. Not sure how this would affect the tracks already loaded within the playlist.

RadioDJ Dude

Yes, you can. I used to use this method. HOWEVER, since RDJ loads content based on how many slots you select for your playlist, you need to factor that "math" into when you trigger a Sweeper Cat Change event. For example, if you have 5 slots and the current Sweeper Cat is A:

Song 1 (with Sweeper A)
Song 2
Song 3
Song 4
Song 5

The earliest you could program a sweeper from Cat B would be Song 7 (I could be off by a song, but you get the point).

Here's how that would look:

Song 1 (with Sweeper A)
Event-Change SWP Cat
Song 2
Song 3
Song 4
Song 5
Song 6
Song 7 (with Sweeper B)

Hopefully, that made sense! Looking at it, I'm even a tad confused. 🤣
XXX80s.com-XXXtreme 80s fun!
YouTube Channel: RadioDJ Dude

RadioDJ Dude

In case anyone starts having issues with my previous SQL query, use this one:

DELETE FROM playlists_list WHERE pID = 122;

INSERT INTO playlists_list (pID, sID, cstart, cnext, cend, fin, fout, swID, swplay, vtID, vtplay, swfirst, ord)
SELECT
    CAST(pID AS UNSIGNED),
    sID,
    -- Use the cue_times column selected *by* the subquery (no 's.' prefix here)
    ROUND(COALESCE(NULLIF(SUBSTRING_INDEX(SUBSTRING_INDEX(cue_times, '&sta=', -1), '&', 1), ''), 0.0), 5) AS cstart,
    ROUND(COALESCE(NULLIF(SUBSTRING_INDEX(SUBSTRING_INDEX(cue_times, '&xta=', -1), '&', 1), ''), 0.0), 5) AS cnext,
    ROUND(COALESCE(NULLIF(SUBSTRING_INDEX(SUBSTRING_INDEX(cue_times, '&end=', -1), '&', 1), ''), 0.0), 5) AS cend,
    fin,
    fout,
    swID,
    swplay,
    vtID,
    vtplay,
    swfirst,
    ord
FROM (
    -- This is the subquery aliased as data_prepared
    SELECT
        song1.id AS sID,
        '122' AS pID,
        s.cue_times, -- *** Select s.cue_times HERE ***
        0.00001 AS fin,
        1.00000 AS fout,
        swSelection.id AS swID,
        -10.00000 AS swplay,
        0 AS vtID,
        -100.00000 AS vtplay,
        'False' AS swfirst,
        -- Ensure ROW_NUMBER() is deterministic if date_played can be identical
        -- Using song1.id as a tie-breaker if ordering is the same
        ROW_NUMBER() OVER (ORDER BY song1.ordering, song1.id) - 1 AS ord
    FROM (
        -- Selecting song1 (Song selection)
        SELECT DISTINCT s.id, s.title, s.artist, 0 AS ordering
        FROM songs AS s
        LEFT JOIN queuelist AS q ON s.artist = q.artist
        WHERE s.enabled = 1
        AND s.song_type = 0
        AND s.id_genre IN ('143')
        AND s.gender = 'Mixt'
        AND s.id_subcat = 2
        AND TIMESTAMPDIFF(MINUTE, s.date_played, NOW()) > 50
        AND TIMESTAMPDIFF(MINUTE, s.artist_played, NOW()) > 50
        AND q.artist IS NULL
        ORDER BY s.date_played ASC
        LIMIT 1
    ) AS song1

    -- JOIN swID selection
    JOIN (
        -- Selecting swID (Sweeper selection)
        SELECT DISTINCT s.id
        FROM songs AS s
        LEFT JOIN queuelist AS q ON s.artist = q.artist
        WHERE s.enabled = 1
        AND s.song_type = 2
        AND s.id_subcat = 34
        AND q.artist IS NULL
        ORDER BY s.date_played ASC
        LIMIT 1
    ) AS swSelection ON 1 = 1  -- Ensures only one row joins (CROSS JOIN effectively since LIMIT 1 in both)

    -- Join back to songs AS s to get cue_times for the selected song1.id
    -- The alias 's' is valid within THIS scope
    JOIN songs AS s ON song1.id = s.id

) AS data_prepared; -- The columns selected above are available outside using this alias
*Of course, change pID and all song/sweeper data to match yours.

The issue with the previous version (I think), if a song didn't have cue points for start, next, end, it would error out. This code bypasses that. Have fun!
XXX80s.com-XXXtreme 80s fun!
YouTube Channel: RadioDJ Dude