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.
1 Like