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

Ability for syndicated or prerecorded shows to send meta info on a schedule.

Started by DJ Sharky, May 23, 2024, 05:27:34 AM

DJ Sharky

This is a request that was made about 10 years ago by someone else and Marius said it would be a good idea that he would strongly consider. So I am rehashing the idea. I would love to see Radio DJ have the ability to read either a cue sheet or xls file or even a xml file for a pre-recorded or syndicated show so that the current meta info was send at the correct time (via the cue sheet).

Thanks!

stevewa

how does your streamer (icecast or shoutcast) get the Now Playing metadata?
from a GET / Post to it's URL, or from RadioDJ plugin sending it ?

do your syndicated or pre-recorded shows write cue files using UTF-8 any special characters?

if you have a example of a cue sheet you can post, upload or link to it.



DJ Sharky

OK here is an example of one of my .cue sheets for one of my prerecorded shows.

For my prerecorded shows I do the .cue sheets manually. But many of my syndicated shows have their own cue sheets. The info below is simply a .txt file saved as a .cue file.

PERFORMER "BGX Radio"
TITLE "Hard Rock and Metal Mondays"
FILE "BGX Radio - Hard Rock and Metal Mondays ep16.mp3" MP3
  BGX Intro
    TITLE "Intro"
    PERFORMER "BGX Radio"
    INDEX 01 00:00:00
  TRACK 01
    TITLE "Amaranthine"
    PERFORMER "Amaranthe"
    INDEX 01 00:01:06
  TRACK 02
    TITLE "Rock and Roll Machine"
    PERFORMER "Triumph"
    INDEX 01 00:04:25
  TRACK 03
    TITLE "Wallflowers"
    PERFORMER "Jinjer"
    INDEX 01 00:11:24
  TRACK 04
    TITLE "Rats"
    PERFORMER "Ghost"
    INDEX 01 00:15:35
  Advert
    TITLE "Marley in the Morning"
    PERFORMER "Dave Marley"
    INDEX 01 00:19:44
  Station ID 
    TITLE "Station ID"
    PERFORMER "BGX Radio"
    INDEX 01 00:20:39
  Radio Host
    TITLE "Host Ken B"
    PERFORMER "BGX Radio"
    INDEX 01 00:20:48
  TRACK 05
    TITLE "Hot Blooded"
    PERFORMER "Foriegner"
    INDEX 01 00:21:35
  TRACK 06
    TITLE "Mama, I'm Coming Home"
    PERFORMER "Ozzy Ozbourne"
    INDEX 01 00:25:44
  TRACK 07
    TITLE "Black Wedding"
    PERFORMER "In This Moment"
    INDEX 01 00:29:46
  TRACK 08
    TITLE "Radar Love"
    PERFORMER "Golden Earring"
    INDEX 01 00:33:22
  Advert
    TITLE "Niagara Live Sessions"
    PERFORMER "BGX Radio "
    INDEX 01 00:39:43
  Radio Host
    TITLE "Host Ken B"
    PERFORMER "BGX Radio"
    INDEX 01 00:39:57
  TRACK 09
    TITLE "Hot For Teacher"
    PERFORMER "Van Halen"
    INDEX 01 00:40:45
  TRACK 10
    TITLE "Neck Bone"
    PERFORMER "Powerman 5000"
    INDEX 01 00:45:24
  TRACK 11
    TITLE "Know Your Enemy"
    PERFORMER "Rage Against the Machine"
    INDEX 01 00:49:56
  Radio Host
    TITLE "Host Ken B"
    PERFORMER "BGX Radio"
    INDEX 01 00:54:12
  TRACK 12
    TITLE "Cleanse the Bloodlines"
    PERFORMER "Unleash the Archers"
    INDEX 01 00:55:10


stevewa

let me think about this over the holiday (memorial day) weekend.

the cue file needs a script to parse it into a file with leading timestamps,
then a 2nd script needs to run in the background, while the synd show is playing, usign a looop & sleep function to wake up every 5 seconds (or so), and check the time vs the track index timestamp, and if it has changed, then read that track metadata from the transformed cue sheet file, and write it to the NowPlaying.txt file.

can you answer the question on how radiodj sends your track metadata to your streaming server?
is it using the NowPlaying.txt file made by radiodj?

also, how do you get the synd show audio file?
is it an automated download, or do you do it manually?

also, how do you play the synd show?
is it triggered by a RadioDJ event?


DJ Sharky

I had to laugh at your response as I know where this is going. I have been doing research and I know this is how it can be done. I do web design and I'm pretty proficient with css and such but this script you mention can easily be done in python. Knowing this I am trying to learn python with a crash course on youtube lol. Then it dawned on me...I used chat GPT to come up with an appropriate script to make this happen. The issue is that I still don't know python but have Python code to make this happen but have no idea how to compile or implement it.

I think instead of using a .cue sheet that an .xml would be a better choice. That being said...

See the code below from chat GPT:

==================================================

To use a script to parse an XML file and send metadata to RadioDJ, you can utilize RadioDJ's HTTP API or an external plugin that supports metadata updates. Below, I'll guide you through creating a Python script to parse the XML file and send the metadata to RadioDJ.


1. **Prepare the XML File:**
   - Ensure your XML file is properly structured. Here's an example:
          <?xml version="1.0" encoding="UTF-8"?>
     <tracks>
         <track>
             <title>Song Title 1</title>
             <artist>Artist 1</artist>
             <start_time>2024-05-22T10:00:00</start_time>
         </track>
         <track>
             <title>Song Title 2</title>
             <artist>Artist 2</artist>
             <start_time>2024-05-22T10:05:00</start_time>
         </track>
         <!-- Add more tracks as needed -->
     </tracks>
 

2. **Install Necessary Python Libraries:**
   - Ensure you have `requests` and `xml.etree.ElementTree` libraries installed. You can install `requests` using pip
     
3. **Create the Python Script:**

### Python Script to Parse XML and Send Metadata to RadioDJ


import xml.etree.ElementTree as ET
import time
import requests
from datetime import datetime

# Parse the XML file
tree = ET.parse('songs_metadata.xml')
root = tree.getroot()

# Function to send metadata to RadioDJ
def send_metadata(title, artist):
    url = 'http://localhost:8000/metadata'  # Update this URL based on your RadioDJ API endpoint
    data = {'title': title, 'artist': artist}
    response = requests.post(url, data=data)
    return response.status_code

# Function to convert ISO time to epoch time
def iso_to_epoch(iso_time):
    dt = datetime.strptime(iso_time, '%Y-%m-%dT%H:%M:%S')
    return int(time.mktime(dt.timetuple()))

# Iterate through the XML and send metadata at the appropriate times
for track in root.findall('track'):
    title = track.find('title').text
    artist = track.find('artist').text
    start_time = track.find('start_time').text
   
    # Convert start_time to epoch time for delay calculation
    start_epoch = iso_to_epoch(start_time)
    current_time = int(time.time())
    delay = start_epoch - current_time
   
    if delay > 0:
        time.sleep(delay)
   
    # Send the metadata
    status = send_metadata(title, artist)
    if status == 200:
        print(f"Successfully sent metadata: {title} by {artist}")
    else:
        print(f"Failed to send metadata: {title} by {artist}, status code: {status}")
```

### How the Script Works

1. **Parsing the XML File:**
   - The script uses the `xml.etree.ElementTree` library to parse the XML file and extract metadata.

2. **Converting ISO Time to Epoch Time:**
   - The `iso_to_epoch` function converts the ISO 8601 formatted time string to epoch time for accurate timing calculations.

3. **Calculating the Delay:**
   - The script calculates the delay between the current time and the track's start time, then waits (sleeps) for the calculated duration.

4. **Sending Metadata to RadioDJ:**
   - The `send_metadata` function sends the track's title and artist to RadioDJ using an HTTP POST request. The URL should be updated to match your RadioDJ API endpoint.

5. **Handling Responses:**
   - The script prints a success or failure message based on the response status code.

### Configuring RadioDJ for Metadata Updates

1. **Enable HTTP API or Plugin:**
   - Ensure RadioDJ is configured to accept metadata updates via HTTP API or through an appropriate plugin.

2. **API Endpoint:**
   - Update the `url` variable in the script to match the correct API endpoint for RadioDJ.

3. **Testing:**
   - Test the script with a sample XML file to ensure it updates the metadata correctly in RadioDJ.

By following these steps, you can automate the process of sending song metadata to RadioDJ at the appropriate times using a Python script that parses an XML file.

=====================================================

What do you think?


DJ Sharky

To answer your questions:

how radiodj sends your track metadata to your streaming server? I use butt as my encoder.
is it using the NowPlaying.txt file made by radiodj? Yes
how do you get the synd show audio file? normally dropbox, google drive and some I have to manually download
how do you play the synd show? An event
is it triggered by a RadioDJ event? Yes

Quick note also...my weekly or daily syndicated or my pre-recorded shows are always named the same. So as an example: I have a morning show that runs monday - friday. The name of the file as an example MorningShowMonday.mp3 or MorningShowTuesday.mp3 and those would be the names every week... they would never change (for that show). This makes it so I don't have to change the file in the events each week when the new show is available.

stevewa

LOL too. I also had to laugh at your use of ChatGPT.  :hihi:

Come on, humans are smart enough, we don't need AI. It's not even AI, it's just echoing stuff humans already made.

I asked if any cue sheets used UTF-8 characters within, because this can be done with simple VBScript, so you don't need all the hassle of Python installation and learning. And since you said you know web design, you probably know enough javascript to get vbscript to work.

I suggested doing this because this feature is not likely to be added to RadioDJ, it was asked for so long ago, and not created yet, and Marius has been absent for a long time, so I tried to help by thinking up a solution.

At this point I'm not sure if you want me to continue to try to help, or if you are going to try to do it yourself. So I'll stop thinking about it for now. good luck.