|
(async function downloadMeetingRecordings() { |
|
const rows = document.querySelectorAll('#tablewithdata tbody tr'); |
|
|
|
for (let i = 0; i < rows.length; i++) { |
|
const row = rows[i]; |
|
|
|
// 1. Extract data from columns |
|
// Column 0: Date, Column 1: Meeting Name, Column 6: Meeting ID |
|
const rawDate = row.cells[0].innerText.trim(); |
|
const meetingName = row.cells[1].innerText.trim(); |
|
const meetingId = row.cells[6].innerText.trim(); |
|
|
|
// 2. Find the download link (the second <a> tag in the mp4 column) |
|
const downloadLink = row.cells[5].querySelector('a[download]'); |
|
|
|
if (!downloadLink) { |
|
console.warn(`No download link found for row ${i + 1}. Skipping.`); |
|
continue; |
|
} |
|
|
|
// 3. Sanitize filename (Remove / \ : * ? " < > | to prevent OS errors) |
|
const safeDate = rawDate.replace(/[/\\?%*:|"<>]/g, '-'); |
|
const safeName = meetingName.replace(/[/\\?%*:|"<>]/g, '-'); |
|
const fileName = `${safeDate} - ${safeName} - ${meetingId}.m4v`; |
|
|
|
// 4. Highlight the current row so you know which one is being processed |
|
row.style.backgroundColor = '#fff3cd'; // Light yellow highlight |
|
row.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
|
|
|
// 5. Trigger the download |
|
// We temporarily set the 'download' attribute to our custom filename |
|
const originalDownloadAttr = downloadLink.getAttribute('download'); |
|
downloadLink.setAttribute('download', fileName); |
|
downloadLink.click(); |
|
|
|
// 6. Prompt user to proceed |
|
// This "awaits" your manual confirmation before the loop continues |
|
const proceed = confirm( |
|
`Row ${i + 1} of ${rows.length}\n\n` + |
|
`File: ${fileName}\n\n` + |
|
`The download has been triggered. Click OK when you are ready to download the next one, or Cancel to stop.` |
|
); |
|
|
|
// Reset row color |
|
row.style.backgroundColor = ''; |
|
|
|
if (!proceed) { |
|
console.log('Batch download cancelled by user.'); |
|
break; |
|
} |
|
} |
|
|
|
console.log('Process complete.'); |
|
})(); |