Table of Contents
[ ] Create a new table by clicking the “+” icon right next to your “EpisodeParts” tab and call the new table “Podcasts”. Set it up to have the following column headers.
RECORD_ID()[ ] Create a new table called “Episodes”. Set it up to have the following column headers.
RECORD_ID()[ ] Edit the columns in your EpisodeParts table to include the following new columns:
[ ] In the Podcasts table you made, add a new row. You can use this information if it’s handy, or you can find the RSS feed for any podcast at Chartable.com and enter it.
| Name | RSS |
|---|---|
| The Prof G Pod with Scott Galloway | https://feeds.megaphone.fm/WWO6655869236 |
[ ] Choose to “Add a trigger” and pick the “At scheduled time” option. Set the “Interval type” to “Days” and the “Timing” to every 1 day at a time of your choice.
[ ] Choose to “Add action” and pick “Run a script”. Then select to “Edit code” and paste in the script below
let inputconfig = input.config()
let table = base.getTable("Podcasts");
let queryResult = await table.selectRecordsAsync({
fields: ["RSS", "RecordId"],
sorts: [ ],
view: [ ]
});
let RSSapiurl = "<https://api.rssapi.net/v1/header/get>";
for (let record of queryResult.records) {
let PodcastRecord = record.getCellValueAsString("RecordId");
let RSSrecord = record.getCellValueAsString("RSS");
let body = {
"url": RSSrecord,
"limit": 1,
}
console.log(body)
let response = await fetch(RSSapiurl, {
method: 'POST',
body: new URLSearchParams(body),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-API-KEY': 'aad994ecd46a63c4c925a9ade3ce41e2',
},
});
console.log(response)
let data = await response.json();
console.log(data)
let table2 = base.getTable("Episodes");
let recordId = await table2.createRecordAsync({
});
let title = data.result.entries[0].title;
let link = data.result.entries[0].link;
if (link) {
await table2.updateRecordAsync(recordId, {
"Name": title,
"Link": link,
"Podcasts": [{id: PodcastRecord}],
})
}
}
[ ] Name the automation “Find Episodes” and flip the switch to turn it “On”
[ ] Choose to “Add a trigger” and pick the “When record created” option. Set the “Table” in the configuration to be the “Episodes” table
[ ] Click “Use suggested record”
[ ] Choose to “Add action” and pick “Run a script”. Then select to “Edit code” and paste in the script below
const data = input.config();
const updated_record_id = data.updated_record_id.toString();
const EpisodeParts = base.getTable("EpisodeParts");
let i = 0;
let count = 0;
const oneMinuteInSeconds = 60;
const records = [];
while (count <= 250) {
records.push({
fields: {
Episode: [{
id: updated_record_id
}],
Start: i.toString(),
End: (i + oneMinuteInSeconds).toString()
}
})
i += oneMinuteInSeconds;
count += 1;
}
let limit = 50;
let start = 0;
for (let i = 0; i < Math.ceil(records.length / 50); i += 1) {
await EpisodeParts.createRecordsAsync(records.slice(start, limit));
start = limit;
limit += 50;
}
[ ] On the left side of the “Edit code” interface, click “Add input variable” and type in “update_record_id”. Then click the plus sign in the input field and scroll down to find the option called “Airtable record id”.
[ ] Repeat this process and “Add input variable” called “Audio” with “Link” as the selected input
[ ] Click “Test” to confirm that everything runs smoothly. Then click “Finish editing”
[ ] Name the automation “Split Audio by Minutes” and flip the switch to turn it to “On”