DJB Radio Spider 3 User's Guide
×
Menu
Index

Macro Tutorial for FTP Sites

 
Many a user has struggled with the creation of an appropriate Macro.
It is one of the most complicated parts of the program, and yet the most powerful.
 
You could learn all of the {mt:Date:format} variables and create them by hand, but there is an easier way.
 
If you have the login and password correct for an FTP site and can browse the FTP,
by following the steps below you can make sure that is works every time.
 
 
EXAMPLE 1: DOWNLOAD A DAILY SHOW 5 DAYS A WEEK OVERWRITING A CUT NUMBER
For this example, lets assume the URL is FTP://ftp.show.com/
Let us further assume the show is called DailyShow-mm-dd-yyyy.mp3 (where the mm-dd-yyyy are replaced by the actual date of the show).
Next assumption is you are downloading it the day of the show in the wee hours of the morning.
Also in this example we are downloading the weekday show directly into the DJB Radio automation system and overwriting the previous show on cut number 1001.
The path and cut number go in the "Download To:" box.
 
Click Add Item on the Radio Spider interface and fill in your information.
I am using the example info above, but you would have the actual path, user name, and password from the provider.
I selected Mon-Fri in the download days box and 3AM for the time.  Replace File(s); Copy Files (No Conversion) for the Download Method
And the path to the JBMusic folder and the cut number to overwrite.
Putting the cut number is renaming the original file on download, but you select replace to overwrite the existing cut.
 
When you click Browse the FTP, you should see a list of the available files to download, assuming the address and your username and password are correct.
Since this example is for a weekday show, let us assume you select the show for Monday December 16th, 2019.  Now your window will look like the one below.
 
 
This is great and a perfectly valid entry, but it will only download the show for one specific day.  Now we need to click Add/Test Macro.
The image below shows just the top of the Macro window. 
Note that it shows the URL and the expanded result is identical because we haven't replaced anything yet with a Macro.
 
 
We need to replace the 12 with the correct month (MM) so it will still work in January. 
You also need to know whether the provider uses 01 or 1 for January's month; for this example I am assuming 2-digit months and days.  Now scroll down the list and find Month Number (2 Digit) and click it.
At the bottom you see the Macro {mt:Date:MM} and the Macro Result 12. 
Now click and drag to select just the 12 in the Input Entry box as I have done in the image below. 
 
Follow the logic, we need to replace the 12 with the current MM, which results in 12.  So far so good.
 
 
Click the Inset Macro Into Main Entry Above button. 
Now you will see the Macro inserted into the Input Entry and the result is still the correct date.
 
 
If you forgot to select the 12 and the cursor was in front of the 12, you would see DailyShow-{mt:Date:MM}12-16-2019.mp3 and the result would be DailyShow-1212-16-2019.mp3.  Too many 12s and the download would fail.  To fix this you could manually delete the 12 from the Input Entry.
 
The Expanded Result window is your friend.  It shows you exactly what the file is that Spider will try to grab and if it does not match, it will not work.
Please note that if there are spaces in the Input Entry, they will be replaced with dots in the Expanded Result for clarity.  If you have 2 spaces you will see 2 dots.
 
To continue the tutorial, you can then select the Day number (2 Digit), then click and drag on the 16 to select it and click the Inset Macro Into Main Entry Above.
Then find Year XXXX: Four digit year and click it, click and drag to select 2019 and  click the Inset Macro Into Main Entry Above.
 
The final Input Entry should read:        FTP://ftp.show.com/DailyShow-{mt:Date:MM}-{mt:Date:DD}-{mt:Date:YYYY}.mp3
 
And the Expanded Result should be:  FTP://ftp.show.com/DailyShow-12-11-2019.mp3
 
BUT WAIT!  That isn't right. 
Since DD returns today's date and I am writing this on the 11th, if I Force Start the item today it will download the show for the 11th, but if you schedule the item to run at 3AM every Monday-Friday, then it will download:
 
DailyShow-12-16-2019.mp3 on Monday
DailyShow-12-17-2019.mp3 on Tuesday
DailyShow-12-18-2019.mp3 on Wednesday
DailyShow-12-19-2019.mp3 on Thursday
DailyShow-12-20-2019.mp3 on Friday
 
One Item can download and overwrite the same cut number as often as you schedule it, in this case 5 days per week and it will use the correct month, day, and year forever with no further effort on your part.
 
 
EXAMPLE 2: DOWNLOAD NEXT SUNDAY'S SHOW ON WEDNESDAY OVERWRITING A CUT NUMBER
For this example, lets assume the URL is FTP://ftp.show.com/
Let us further assume the show is called SundayShow-mm-dd-yyyy.WAV (where the mm-dd-yyyy are replaced by the actual date of the show).
Next assumption is you are downloading it the Wednesday before the show .
Also in this example we are downloading the Sunday show directly into DJB automation and overwriting the previous show on cut number 2007.
Also new to this example, we need to convert the WAV file to an MP3.
 
Create a new item and put in the URL, username, password and the path and cut number as before.
Click Browse the FTP and select the imaginary entry SundayShow-12-15-2019.WAV
 
 
Click the Add/Test Macro button.
You already know how to do the replacement from the first example, but now you are downloading it on Wednesday the 11th, but you want the date to be Sunday the 15th. 
You could use the day offset to add 4 to the day, but what if Wednesday is the 31st? 
The DD would increment to 4, but the MM would stay the same and you'd download last month's show.
 
The answer to this conundrum is on the left hand side of the Macro editor: Select Day Offset.
Since you want the upcoming Sunday's dates, us the offset marked Next Sunday.
 
As before, scroll down the list and find Month Number (2 Digit) and click it.
At the bottom you see the Macro {mt:Date:mt:Sun:MM} and the Macro Result 12. 
Since the upcoming Sunday is still in December, the result is 12.  But this will produce the upcoming Sunday's correct month even if it crosses into another month or even next year.
Now click and drag to select just the 12 in the Input Entry box like we did before in Example 1.
Repeat for 2 Digit Day and 4 Digit Year.
 
Your final Input Entry is: FTP://ftp.show.com/SundayShow-{mt:Date:mtSun:MM}-{mt:Date:mtSun:DD}-{mt:Date:mtSun:YYYY}.WAV
And the expanded result is: FTP://ftp.show.com/SundayShow-12-15-2019.WAV
Even though it is checking the date on the 11th, it returns the 15th because on the extra mt:Sun: directive.
 
Now you would click OK to save and return to the item edit screen. 
Note in the picture below the URL is too long to fit in the URL box, but it is all there.
You can click on it and use the arrow keys on the keyboard to check.
 
NEW STEP:  Since we are going to convert this Wave file to an MP3, click the Audio Conversion button.
In the window below you can see I have selected MP3 for the format, 44100Hz for the frequency and 256 kBPS for the Encode Format.
I have also checked the Normalize box and left 0dB as the value.  If the Sunday shows are way too loud you can reduce the volume by normalizing to a negative value like -3. 
 
 
If you download a WAV and save it as an MP3 without this conversion step, it will not play. 
A wave file with an MP3 extension is still a wave file and may confuse your automation system.
 
The online help was created with Dr.Explain