Insert dynamic local news as a container

For a local radio station, I created a script that will insert a container every hour that contains multiple news items that can be randomly select from folders. This way you can have up to date news which sounds different every hour. You only need to import the news items in the right folders and the script will create a news container every hour.

Even if you generate your playlists in advance (for for example voice tracking). At playout this script will still insert the latest local news from the database as a container. The people doing the voice tracks will see a placeholder (dummy) in their playlist and know when the local news is being played.

By using a sub playlist, you are very flexbile in what should be in the container as we can use the hour templates that are already available in mAirlist.

I create a manual on how to configure and use this in mAirlist.You can find the step by step manual here:
https://1drv.ms/w/s!ApAW11tenPiUq8xafeUhRSifGhxz0A

This is the script:

//Local News insert script
//By Stefan van der Wiele
//
//This script will replace a dummy with a container that contains the content of a subplaylist for that hour


var
	ads: IContainerPlaylistItem;
	adsContainerAsPlaylistItem: IPlaylistItem;
	plSubPlaylist: IPlaylist;
	iInsertLocation, i: INTEGER;
	errorMessage: string;

const	
	
	//Only change these values	

	sDummyTitle = 'Regionieuws'; // Title of Dummy item to replace
	sContainerArtist = 'Regionieuws'; //Artist of the container that is created
	sContainerTitle = 'Regionieuws'; //Title of the container that is created
	iSubPlaylist = 1; // ID of SubPlaylist (can be found in configuration)
	sysLogName = 'Local News Script'; // 'Name used in systemlog
	removeDummy = false; // Set to true if dummy item needs to be removed after adding the container

procedure createContainer;
begin

	// Create a new Container Item
	ads := Factory.CreateContainerPlaylistItem;

	adsContainerAsPlaylistItem := IPlaylistItem(ads);
	adsContainerAsPlaylistItem.SetTitle(sContainerTitle);
	adsContainerAsPlaylistItem.SetArtist(sContainerArtist);
	adsContainerAsPlaylistItem.SetItemType(pitNews);
	
end;

procedure writeLog(sysLogData: string);
begin
	SystemLog(sysLogName + ': ' + sysLogData);
end;

function fillContainer: boolean;
var
	exitbool: boolean;
begin
	plSubPlaylist := Database(0).GetCurrentPlaylist(iSubPlaylist)

	if plSubPlaylist.GetDuration <> 0 then begin
		ads.GetPlaylist.Assign(plSubPlaylist);
		exitbool := true;
	end 
	else
	begin		
		exitbool := false;
	end;
	result := exitbool;
	
end;

function findDummy: integer;
begin

  for i := 0 to Playlist(0).GetCount -1 do
  begin

  if Playlist(0).GetItem(i).GetTitle = sDummyTitle then begin
	iInsertLocation := i+1;	
  end;
  break;
  end;

result := iInsertLocation;

end;

procedure insertContainer;
begin
	
	Playlist(0).Insert(iInsertLocation, adsContainerAsPlaylistItem);
end;




begin
	//Trying to find dummy, if not found generate error message
	if findDummy > 0 then begin

		//Create container and set values
		createContainer;

		//Check if container has content and insert container
		if fillContainer then begin
			insertContainer;

			//After inserting the container remove the dummy
			if removeDummy then begin 
				Playlist(0).Delete(i);
			end;
		end
		else
		begin
			writeLog(' SubPlaylist is empty, did you generate it?');
		end;
	end
	else
	begin
		writeLog(' Dummy not found, please check if it is in the current playlist and if the name is correct');		
	end;
	

end.
2 Likes

Hello there Wiele,
Nice topic, and thanks for the manual, i am getting creasy here try to use mairlist and creating a template for three recorded shows that i have to play, daily, witch i receive by email… my issue is that each show is divided in four separate files… Now i would like to try to use you idea, witch is great, and i am trying to add each of those shows like you instruct for the news, i think it will work well, just a thing, i don’t know how to create the .MLS file for the script, would you please send me the file already on the good format? In any case i thank you for the attention,
Regards,
Julio julioroth1@yahoo.com

Hi @julio ,

your problem could easyly be solved with variable filenames.

I made a quick step-by-step tutorial here for a time announcing element (in v6) but you just could use it for your daily shows by defining variables for your shows.

Then you just have to put this shows in the corresponding folders and mAirlist will pick the right show for the correct hour template of the specific date and time automatically and put it in the playlist.

Hello Stefan,

Many thanks for your replay, it looks clear enough,

I see now how can i do it, and I think that I could do it as I never worked before with the script, but it is a job for the weekend, I will set it up for a test,

Best regards,

Julio

1 Like