diff --git a/CHANGELOG.md b/CHANGELOG.md index ffc27e9..09d24aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,14 +7,66 @@ For more details on specific issues and pull requests, you can refer to the corresponding GitHub links provided. If you require further specific details about a particular build or feature, feel free to reach out. -## Work-in-progress (WIP) for Library V10 +## Library V10 (build240315a) / 2024-03-15 ### Bug Fixes -- Standardized the log date and time format to be consistent with the local time - zone and locale settings[#80]. +- Standardized log datetime format ([#80]) + + - Enhanced the `insertNewLog` function in `logger.js` to receive a JavaScript + Date object for the `datetime` parameter instead of a string. + - Retrieve the time zone from the spreadsheet's locate setting. + - Transformed the `datetime` parameter to a datetime string in the format of + `"yyyy-MM-dd HH:mm:ss"` using the `Utilities.formatDate()` method. + - Adjusted the `fetcher.js` file to pass the date and time as a `Date` object + when calling the `insertNewLog` function. + +- Resolved the "No item with the given ID could be found" error ([#112]) + + - Enclosed the `DriveApp.getFileById` method call in a `try-catch` block in + `logger.js`. + - Included error logging in the `catch` block if an exception is thrown. [#80]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/issues/80 +[#112]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/issues/112 + +### Dependencies + +- **Updated:** + - jekyll (3.9.0 → 3.9.5) + - nokogiri (1.16.0 → 1.16.2) in `/docs` ([#96]) + - apps-script-oauth2 (72d4dbc → 6ae908a) ([#101]) + - eslint-plugin-googleappsscript (1.0.4 → 1.0.5) ([#106]) + - @babel/preset-env (7.23.7 → 7.24.0) ([#107]) + - @rollup/plugin-multi-entry (6.0.0 → 6.0.1) ([#108]) + - eslint (8.34.0 → 8.57.0) ([#109]) + - rollup (3.15.0 → 4.12.0) ([#110]) + +[#96]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/96 +[#101]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/101 +[#106]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/106 +[#107]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/107 +[#108]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/108 +[#109]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/109 +[#110]: https://github.com/chriskyfung/AutoFetcher-IG-Stories-to-GDrive/pull/110 + +### Documentation + +- Corrected the permalink URLs of "Release Notes" and "Advanced Configurations" + pages. +- Updated API endpoint URLs for status badges. +- Enhanced formatting of H2 headers in release notes: + + - Eliminated build numbers from H2 headers. + - Enclosed release dates with parentheses. + +- Refined and styled the changelog. + +### CI/CD Integration + +- Implemented automated version updates via Dependabot. +- Upgraded github/codeql-action (1 → 3) and actions/checkout (2 → 4) in + `codeql-analysis.yml` * * * diff --git a/README.md b/README.md index 044f229..2618fc1 100644 --- a/README.md +++ b/README.md @@ -14,26 +14,20 @@ your Google Drive. You don’t need to install anything on your computer or phone, just use Google Sheets and Google Apps Script as a cloud tool to fetch the Stories you want. -> [!NOTE] -> **Release On 2023-02-16** -> Thanks for the contributions from [hidehiro98](https://github.com/hidehiro98)❤ -> We can now save downloaded files from different IG users to separate Google -> Drive folders 📁. - > [!IMPORTANT] -> **Release On 2024-02-05** +> **Release On 2024-03-15** > To use the latest features and bug fixes, please update the Library Version of > your Google Script to the latest one or create a new copy of the Google Sheet -> template with the name V9 or higher. +> template with the name V10 or higher. > [!TIP] -> **Manual upgrade from V8 to V9** +> **Manual upgrade from V8 to V9 or higher** > If you prefer to keep your existing Google Sheet file, you can manually update > the Apps Script by following these steps: > > 1. Open the Apps Script editor from your Google Sheet file. > 2. In the left panel, click on the **IGStoriesToGDrive** library under the **Libraries** section. -> 3. From the **Version** dropdown, select **9** and click **Save**. +> 3. From the **Version** dropdown, select **10** and click **Save**. > 4. Delete the `ui.gs` file from the project files. > 5. Open the `code.gs` file and add the following code to enable the new features. > @@ -49,6 +43,12 @@ the Stories you want. > } > ``` +> [!NOTE] +> **Release On 2023-02-16** +> Thanks for the contributions from [hidehiro98](https://github.com/hidehiro98)❤ +> We can now save downloaded files from different IG users to separate Google +> Drive folders 📁. + ## 🗄️ Table of Contents - [Introduction](#-introduction) @@ -106,6 +106,13 @@ The spreadsheet consists of the following three sheets: | Logs | A log sheet that records the file download activities. | | Settings | A tabular form where you can fill in the values of options and parameters for running the script. | +> [!NOTE] +> With Library V10, the script now leverages the time zone setting configured in Google Sheets, ensuring accurate + timestamps irrespective of your geographical location. To modify the time zone for a specific spreadsheet, please + refer to this [Google Support page]. By aligning the script with your spreadsheet's time zone, you can seamlessly manage tasks and track time entries with utmost precision. + +[Google Support page]: https://support.google.com/docs/answer/58515 + You can use the Google Sheet file and bind our script to it in the following ways: diff --git a/dist/bundle.js b/dist/bundle.js index 7eefe46..3a1a59c 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -8,7 +8,7 @@ * * Homepage: https://chriskyfung.github.io/AutoFetcher-IG-Stories-to-GDrive/ * - * Build at: Wed, 13 Mar 2024 05:45:49 GMT + * Build at: Fri, 15 Mar 2024 06:01:06 GMT */ const IGSF = Object.create(null); @@ -150,6 +150,7 @@ function loadSettings() { * Last modified : 2021-11-02 */ + /** * Create badges, namely "last-tested-date.svg" and a "last-tested-status.svg", * in the destination folder of your Google Drive using DriveApp service. @@ -242,6 +243,7 @@ function setHealthStatusBadge(healthy) { * Last updated at : 2023-02-21 */ + const numOfColumns = 5; const column = { filename: 5, @@ -251,27 +253,37 @@ const column = { let previousLogs; /** - * Insert and record the date time, username, media URL and file type to be - * downloaded to a new row at the start of the Google Sheet file that the - * Apps Script is bounded to. - * @param {String} datetime A date time in string format. - * @param {String} username An Instagram username - * @param {String} url A media URL - * @param {String} filetype The extension of the downloaded file - * @param {String} filename The filename of the downloaded file + * This function inserts a new log entry into the "Logs" sheet in a Google + * Sheets document. The log entry includes the datetime, username, URL, + * filetype, and filename. It formats the datetime, inserts a new row below the + * header, writes the log data to the new row, and inserts checkboxes into the + * respective column. + * @param {Date} datetime - The date and time of the log entry + * @param {string} username - TheInstagram username + * @param {string} url - The media URL + * @param {string} filetype - The extension of the downloaded file + * @param {string} filename - The filename of the downloaded file */ function insertNewLog(datetime, username, url, filetype, filename) { - // TODO: fix #84 logging blank file name - // Get the sheet to store the log data. - const logsSheet = SpreadsheetApp.getActive().getSheetByName( - sheetNames['logs'] + const spreadsheet = SpreadsheetApp.getActive(); + const logsSheet = spreadsheet.getSheetByName(sheetNames['logs']); + + // Use spreadsheet methods to get the desired date format and time zone + const formattedDateTime = Utilities.formatDate( + datetime, + spreadsheet.getSpreadsheetTimeZone(), + 'yyyy-MM-dd HH:mm:ss' ); - // Insert a blank row in a sheet below the header. + + // Insert a new row below the header logsSheet.insertRows(2); - // Write the log data to the new row. + + // Write the log data to the new row logsSheet .getRange(2, 1, 1, numOfColumns) - .setValues([[datetime, username, url, filetype, filename]]); + .setValues([[formattedDateTime, username, url, filetype, filename]]); + + // Insert checkboxes into the respective column (column.selected) logsSheet.getRange(2, column.selected).insertCheckboxes(); } @@ -553,6 +565,7 @@ const getFileDetails = (url) => { * @author Chris K.Y. Fung */ + /** * Compose the URL and the query string to the Instagram's API endpoint. * @param {String} igUserID The ID of the target Instagram user to fetch. @@ -734,11 +747,11 @@ function fetch(target) { return; } insertNewLog( - currentDatatime.toLocaleString(), // Datatime string + currentDatatime, // Date object target.name, // IG username url, // Full URL fileExtension, // File extension - fileLink, // Linked file name + fileLink, // Linked file name ); }); return msg; @@ -761,32 +774,6 @@ function createViewFileFormula(filename, folderId) { } } -/** - * ui.js - * Copyright (c) 2024 - * - * This file contains the Google Apps Script to create a custom menu in the - * Google Sheets when the spreadsheet opens. - * - * @author Chris K.Y. Fung - */ - -function initUi(e) { - try { - let ui = SpreadsheetApp.getUi(); - ui.createMenu('igFetcher') - .addItem('Fetch stories', 'run') - .addSubMenu(ui.createMenu('Logs') - .addItem('Move seleted files', 'moveSelected') - .addItem('Delete seleted logs', 'deleteSelected') - ) - .addToUi(); - } catch (err) { - // TODO (Developer) - Handle exception - Logger.log('Failed with error: %s', err.error); - } -} - /** * subscriber.js * Copyright (c) 2021 @@ -800,6 +787,7 @@ function initUi(e) { * Last modified : 2021-11-02 */ + /** * Get the listing from the Google Sheet that the Apps Script is bounded to, * and then fetch Instagram Stories for each item. @@ -833,6 +821,7 @@ function batchFetch() { * Last modified : 2022-11-22 */ + /** * Global variables */ @@ -921,6 +910,7 @@ function try_get() { * Last modified : 2022-11-22 */ + const igUserSampleSet = [ { name: 'bbcnews', id: '16278726' }, { name: 'cnn', id: '217723373' }, @@ -962,6 +952,32 @@ function test_pipeline() { return healthy; } +/** + * ui.js + * Copyright (c) 2024 + * + * This file contains the Google Apps Script to create a custom menu in the + * Google Sheets when the spreadsheet opens. + * + * @author Chris K.Y. Fung + */ + +function initUi(e) { + try { + let ui = SpreadsheetApp.getUi(); + ui.createMenu('igFetcher') + .addItem('Fetch stories', 'run') + .addSubMenu(ui.createMenu('Logs') + .addItem('Move seleted files', 'moveSelected') + .addItem('Delete seleted logs', 'deleteSelected') + ) + .addToUi(); + } catch (err) { + // TODO (Developer) - Handle exception + Logger.log('Failed with error: %s', err.error); + } +} + exports.badgeFileIds = badgeFileIds; exports.batchFetch = batchFetch; exports.createBadages = createBadages; diff --git a/docs/release-notes.md b/docs/release-notes.md index a3fee05..5e9c6c8 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -19,6 +19,28 @@ image: hide: true --- +{:.note.tip} +> ## Library V10 (2024-03-15) + +**Improved Reliability and Accuracy** + +* Standardized log date and time format for enhanced clarity and consistency. +* Resolved an error related to file retrieval, ensuring seamless operation. + +**Updated Dependencies for Enhanced Security and Functionality** + +* Boosted security and functionality with the latest versions of jekyll, nokogiri, and other dependencies. + +**Enhanced Documentation** + +* Corrected website links for better navigation. +* Updated API endpoint URLs for accurate information. +* Refined formatting for clearer and easier-to-read documentation. + +**Automated Versioning and Security Scans** + +* Automated version updates through Dependabot, ensuring timely updates for enhanced security. +* Upgraded GitHub actions for improved code quality and vulnerability detection. {:.note.tip} > ## Library V9 (2024-02-05) @@ -50,7 +72,7 @@ the Apps Script by following these steps: } ``` -✨ Features +✨ New Features - Add custom menu and menu items to Google Sheets @@ -78,7 +100,7 @@ the Apps Script by following these steps: {:.note.tip} > ## Library V8 (2023-02-16) -✨ Feature +✨ New Feature - Save downloaded files to seperate folders based on their IG username. 📁 @@ -118,7 +140,7 @@ the Apps Script by following these steps: {:.note.tip} > ## Library V2 (2021-12-06) -✨ Features +✨ New Features - Save the filename of downloaded files in Column E in the "Logs" sheet. - Show the thumbnail preview and open the file on Drive by hovering and clicking on a hyperlinked filename. diff --git a/package.json b/package.json index fd2454e..641cb4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "autofetcher-ig-stories-to-gdrive", - "version": "4.3.0", + "version": "4.3.1", "description": "A no-code tool that lets you easily save the Instagram Stories of any user to your Google Drive", "license": "AGPL-3.0", "author": "Chris K.Y. Fung (https://github.com/chriskyfung)",