Various scripting tasks

Hey scripting guys, I need some help. I just found out that I’m really no software developer. I have to solve some tasks:

[ul][li]inserting Business News that is available once per day[/li]
[li]inserting News about cars that is availabel twice a week[/li]
[li]inserting complete show that can be split up into 4 or 6 parts for 2 hours, insert jingles and fillers to fit 2x 1h[/li]
[li]inserting complete show that is available with one file per song, split them into 2 hours[/li][/ul]

Let’s start with the business news. My problem is, that they are not available during planning for the next week. So I have a playlist for each hour already, containing all the music and jingles.
Serge will probably notice something here…

I tried to modify this script here: http://forum.mairlist.com/index.php/topic,2724.0.html
This is my result:

[code]/ Original posted by Vincent Volmer
// New version by Cad Delworth

const
DIR = ‘M:\Mp3\Vorproduktionen\Aktuelle Wirtschaftsnews aus dem Radio mit Michael Weyland’;

var
ads: IContainerPlaylistItem;
adsPlaylist: IPlaylist;
adsContainerAsPlaylistItem, piNews: IPlaylistItem;
curHour: TDateTime;

procedure AddCurrentPlaylistItemFromFile(f: String; b: boolean);
begin
CurrentPlaylist.Add(Factory.CreatePlaylistItemFromFile(f, b));
end;

begin
SystemLog(‘Insert Wirtschaftsnews’);
// calculate current hour as Delphi TDateTime
// curHour := (trunc(now * 24)) / 24;

// create a new Container Item and put the ads. in it
ads := Factory.CreateContainerPlaylistItem;
adsPlaylist := ads.GetPlaylist;
adsPlaylist.AppendPlaylist(Factory.CreatePlaylistItemFromFile(
DIR + ‘News’+FormatDateTime(‘yyyymmdd’, now) + ‘_kvp.mp3’
));

// reference the entire Container as a PlaylistItem and title it
adsContainerAsPlaylistItem := IPlaylistItem(ads);
adsContainerAsPlaylistItem.SetTitle(
FormatDateTime(‘yyyy-mm-dd’, now)
+ ’ Wirthscaftsnews’);

// Add Container PlaylistItem to current Playlist
CurrentPlaylist.Add(adsContainerAsPlaylistItem);

end.[/code]
But I end up in a type mismatch.

Next problem I have, the next day, I want to have the News of the day before, as long as the new file is not available.
Could somebody help me?
Thanks
Malte

Regarding the news, it’s not necessary to use a script here - you can just create an event and use variable substitution.

The easiest way would however be to use a fixed filename (news.mp3 instead of news-.mp3), and overwrite the file each time you download a new version. If no file is available for a particular day, just delete the file and mAirList will skip it.

Hi Torben,
I forgot to mention, that the news are automaticly downloaded and the Name is already given. But never the less I like you approach. It should be possible, to copy the needed file to a name without date by a batch file that is called via ShellExecute once a day.
What about the length? They are not always the same, could that be a problem?
I think I’d still prefere to insert it by a script, so I don’t need to synchronize the database and the difference in length should be no problem as well, because the Minischeduler doesn’t need to care.

Best Regards
Malte

It’s no problem if the length changes from day to day, because the actual length is determined again as you open the file in the player (and it can even change during playback, if the file still grows) - just make sure that there aren’t any cue points set for the file, in particular no Fade Out or Cue Out, because they would interrupt the playback.

If you’re using the event mechanisms with a fixed filename, make sure that there is no MMD file or database entry for the file, so Auto Cue is performed based on the current file version everytime you load the file. Alternatively, create an MMD file and delete all Cue Points before saving it.

When using a fixed filename, you can also just add the file to the database and use it in the Mini Scheduler. You don’t need to synchronize all the time, only once. It’s not a problem if the actual duration is different from what is stored in the database. Same arguments as above apply.

I only read this right now…

Didn’t Michael give you my downloader application. By using that one you have the possibility to either leave the old file, delete the old file or copy a substitute file to the target, should the download fail for whatever reason.

If you keep the filename the same, why not simply put it into the rotation lists of the scheduler for each day where required.

On the other hand, inserting it via event should be no problem. We do the same for the news headlines @ xx:30 in the morning

Let me know if you need any further help…

regards:
-Serge-

Don’t know much about your downloader application, but here’s another software that might be helpful: http://www.freedownloadmanager.org/

There exist tons of software like that.
The problem is that the name of the file to be fetched changes with the date.
So I’m not sure if any other software can handle that.

The downloader I wrote simply gets a file with the current datecode from any server via http Protocol.
If anybody has interrest in it, let me know…

regards:
-Serge-

[Off topic] BTW Torben, with the 934 snapshot I saw in config that REST is listed under disabled modules…

When did you download your license file? Try re-downloading it.

I just tried the first one I found and it works good so far.
http://juicereceiver.sourceforge.net/

The only problem I have is, indeed the changing filenames. I think we’ll go for the MMD file w/o Cue, because I found out that the Autocue that works good with music (we have changed default values) Sometimes cuts the end of the file. So If there are just no cue points we’re fine.

I think I’ll handle the rest by a small batch file and the copy or xcopy command. Batch is the only programming I’m familiar with, :wink: but still you can do a lot with it. I already use a batch to apply mp3gain to the downloaded files.

So I can simplify my scipt and just insert a specific file.

I’ll come back with the other “problems” soon.

Thanks so far
Malte

Malte,

Juice is not what you need. I also struggled with that (long time ago) for downloading podcasts with no success. I believe the project is dead in meantime…
We currently use The DJPro Podcast downloader which just works fine. But as we will kick the whole DJPro stuff, I’m currently writing a much more flexible Podcast downloader. Due to the Problems I encountered with the new setup of mAirList on the new Playout machine, I’m far behind schedule for finishing it.

May I suggest you to use my downloader program. It just works fine for Michaels (and other’s) Podcasts. It’s already in use by several other radio stations without problems.
What it does is save the current file with todays timestamp off the webserver and saves it locally to the path/filename you specify.

regards:
-Serge-

@Torben
You were right with the license file. I did not saved it together with the config, but always keep it apart. In a hassle, I copied an older one.

So as requested by some users, here’s the link to the downloader. Enjoy!

http://homepage.internet.lu/radiorom/Downloader/Downloader_News.rar

A few explanations to the .ini (it defaults to Michael’s business news [in German])


URL=http://www.was-audio.eu/aanews/W_Newsyyyymmdd_kvp.mp3
Destination=C:\Downloader_News\W_News.mp3
DateFormat=yyyymmdd
ShellExec=
Substitute=C:\Downloader_News\Silence_100ms.mp3
InhibitProcess=
MaxRetries=3

URL is self explaining. Just make sure the date code there is same as specified in DateFormat below. (I know, I could have made that in one step, but this was just easier)

ShellExec is executed after the download has completed. We (as an example) write the ID3 Tag and start mp3gain to level the file via a batch job.
(If somebody needs WriteID3.exe to write an ID3 Tag to a file, let me know

Substitite is the path to the substitute file, should the download break or fail for whatever reason.
Default is a 100ms Silence file. Other options are:

  • if left empty, the destination file does not get deleted.
  • if set to “Delete” (without quotes), the destination file is deleted on download failure

InhibitProcess will not start the downloader if a certain process is running.
A short explanation to this:
We use the downloader for downloading the News every hour. Our Playlist creation software scans (openes) every file inserted to the playlist to get the exact lentgh of the file. This would be in conflict with the downloader running at the same time.
So we simply inhibit the download if the scheduling software is running.

MaxRetries is the number of retries the program attempts to download the file, should something go wrong.
I know, that I should have added a “sleeptime” between the retries here. I’ll do so in a future release.
On the other hand, the program works so reliable that it is almost unnesessary :smiley:

regards:
-Serge-