This source code with GAScript add few movies from cinemagia website:
The commant the lines from the last post tutorial and use this source code.
This will add movies into separated sheet by date, see the source code:
// try {
// const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// const currentDate = new Date();
// extractedData.forEach((movie, rowIndex) => {
// if (movie.title !== "N/A" && movie.image !== "N/A") {
// const imageFormula = `=IMAGE("${movie.image}")`;
// const rowIndexAdjusted = sheet.getLastRow() + 1;
// sheet.appendRow([currentDate, movie.title, imageFormula, movie.channel, movie.time]);
// sheet.setRowHeight(rowIndexAdjusted, 76); // Set row height to 330px
// }
// });
// Logger.log("Processed movies count: ", extractedData.length);
// } catch (error) {
// Logger.log("Error adding data to spreadsheet: ", error.message);
// }
try {
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const currentDate = new Date();
// Formatăm data curentă pentru numele sheet-ului
const formattedDate = Utilities.formatDate(currentDate, SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone(), "yyyy-MM-dd");
const sheetName = `Data-${formattedDate}`;
// Verificăm dacă sheet-ul cu acest nume există deja
let sheet = spreadsheet.getSheetByName(sheetName);
if (!sheet) {
// Creăm un nou sheet dacă nu există
sheet = spreadsheet.insertSheet(sheetName);
}
extractedData.forEach((movie) => {
if (movie.title !== "N/A" && movie.image !== "N/A") {
const imageFormula = `=IMAGE("${movie.image}")`;
const rowIndexAdjusted = sheet.getLastRow() + 1;
sheet.appendRow([currentDate, movie.title, imageFormula, movie.channel, movie.time]);
// Păstrăm formatarea originală pentru înălțimea rândurilor
sheet.setRowHeight(rowIndexAdjusted, 76);
}
});
} catch (error) {
console.error("A apărut o eroare:", error.message);
}