Skip to content

chriskyfung/AutoFetcher-IG-Stories-to-GDrive

 
 

Repository files navigation

IG Stories to GDrive Fetcher

built with clasp code style: prettier license: AGPL-3.0 Health Status Last Tested Date

A no-code tool that lets you easily save the Instagram Stories of any user to 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.

Important

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 V10 or higher.

Tip

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 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.

    function moveSelected() {
      const IGSF = IGStoriesToGDriveDEV.getInstance();
      IGSF.moveSelected();
    }
    
    function onOpen() {
      const IGSF = IGStoriesToGDriveDEV.getInstance();
      IGSF.initUi();
    }

Note

Release On 2023-02-16
Thanks for the contributions from hidehiro98❤ We can now save downloaded files from different IG users to separate Google Drive folders 📁.

🗄️ Table of Contents

📡 Introduction

This project lets you use Google Sheets and Google Apps Script, a platform that allows you to create web apps with JavaScript, to make a cloud tool that saves the latest Instagram Stories of any user you choose to your Google Drive.

With this tool, you can:

  • Type the Instagram usernames and IDs of the people whose Stories you want to save in a Google Sheet.
  • Create a time-based trigger to run the script regularly at fixed intervals.
  • Modify the code to fit your needs and use it to connect and automate various Google services, such as Gmail, Calendar, Drive, and Sheets.

This project is free and open-source. You can find the source code, the Google Sheet template, and the step-by-step instructions on how to use the tool in this repository. For more information, please visit the project website.

🛹 Usage

Note

From build21110a onwards, the Apps Script has been redesigned to work with a Google Sheet file as a user interface.

To get started, click the button below to make a copy of our Google Sheet template to your Google Drive.

The spreadsheet consists of the following three sheets:

Sheet Name Description
Subscriptions A table where you can list the Instagram users and their IDs that you want to subscribe to.
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.

You can use the Google Sheet file and bind our script to it in the following ways:

  • Use our shared library: The easiest option that requires no coding

    Simply make a copy of our template to your Google Drive. The Google Sheet will come with the pre-built script, which contains the functions to import and use our library.

  • Inject our code into your project: Make a standalone project

    Open the Script editor from your Google Sheet file and edit the script that is bound to your Google Sheet file. Copy the code from the /dist/bundle.js file in our repository and paste it to a .gs file in your Script editor. Then, follow the example in the Advanced Configurations documentation page to get and call the functions from the IGSF object.

  • Deploy a new library: Reuse your code across multiple projects

    Create a new Apps Script project and paste the code from /dist/bundle.js to it. Then, deploy the project as a library for other scripts and reference it in your Google Sheet files.

📩 Set Up Subscriptions

To subscribe to the stories of your favorite Instagram users, you need to add their names and IDs to the table on the “Subscriptions” sheet.

The Instagram User ID is a unique number that identifies each Instagram user. You can find the ID of any user by using the ID finder powered by The Code of a Ninja.

Tip

For example, to subscribe to the stories from BBC News’s Instagram account, you can enter bbcnews as the name in the first column and 16278726 as the ID in the second column.

The script will fetch the photos and videos from Instagram and upload them to your Google Drive folder whenever you click on the ▶ Run button.

⚙️ Configuration Settings

The “Settings” sheet contains a tabular form where you can enter the values of options and parameters for running the script. Here is a brief explanation of each setting:

Google Drive

  • Folder ID : (Optional) The ID of a Google Drive folder where you want to save the media files. If you leave this blank, the files will be downloaded to the root folder of your Google Drive.

Tip

You can find the ID in the URL of the folder. For example, if the URL of the folder is https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j1k2l3m4n?resourcekey=0-XXXXXCt-XXXXX4WRe1aA, then the folder ID is 1a2b3c4d5e6f7g8h9i0j1k2l3m4n.

Instagram

Warning

Please note that this information may change over time and may not be accurate.

To access the Instagram API, the script needs to send some request header fields that mimic the behavior of a logged-in user on instagram.com. These fields are:

  • x-asbd-id : A unique identifier for the user’s session. It is generated by Instagram’s servers and is used to track the user’s activity on the site.

  • x-csrftoken : A security token that is used to prevent cross-site request forgery (CSRF) attacks. It is generated by Instagram’s servers and is sent with every request to verify that the request is valid.

  • x-ig-app-id : A unique identifier for the Instagram application that the user is using. It is generated by Instagram’s servers and is used to track the user’s activity on the site.

  • x-ig-www-claim : A security token that is used to prevent cross-site scripting (XSS) attacks. It is generated by Instagram’s servers and is sent with every request to verify that the request is valid.

  • x-instagram-ajax : A header that is sent with every request to Instagram’s servers. It is used to indicate that the request was made using AJAX (Asynchronous JavaScript and XML) and to provide additional information about the request.

Caution

The x-instagram-ajax field has been deprecated from build230214a (Library v7).

  • cookie : A small piece of data that is sent from Instagram’s servers to the user’s browser. It is used to track the user’s activity on the site and to personalize the user’s experience.

🛠️ Advanced Configurations

In addition to the basic configurations outlined above, you can also enable the following advanced configurations:

  • Set Up Health Monitoring : (Optional) You can establish health checks to monitor Instagram’s API and user login status, update status badges, and send error report.

    To do this, you need to fill in these fields in the “Settings” sheet:

    Badge File IDs

    • Tested Date : (Optional) The file ID of the last-tested-date.svg badge.

    • Health Status : (Optional) The file ID of the last-tested-status.svg badge.

    Error Report

    • Email To : (Optional) The email address that will receive an error message when the health check function returns a “failed” status.
  • Enable Auto-Run : (Optional) You can set up a time-driven trigger for your Apps Script, enabling automated function execution at specific time intervals.

  • Deploy As a Web API : (Optional) You can deploy your Apps Script as a web API to make it accessible to users via a web browser.

For more information, please refer to the Advanced Configurations documentation page.

🛡️ Privacy and Security

We respect your privacy and data security. Here are some important points to note:

  • No sensitive data, such as your Instagram username, password, cookies, credentials, and tokens, will be shared with our developers or any third parties. They will only be stored in your Google Sheet file and used by the Apps Script to access the Instagram API.

  • The Apps Script, which is bound to a Google Sheet file that is stored in your Google Drive, will only run and be able to access your data with your Google Account. Unless you share the file with other users or place it in a shared folder, no one else can access or modify your data.

Tip

If you want better protection of your data, you can self-host the code as a standalone project. This way, you can have full control over the code and the data, and you can customize the script according to your needs.

Caution

If you have any worries about any potential security issues with our script or shared library, please do not use them. We are not responsible for any data loss or damage that may occur from using our tool.

❓ FAQ

If you have any questions or problems with using our tool, please refer to our FAQ section on the project webpage. We have answered some of the most common questions, such as:

  1. How to get the required Instagram headers and cookie for the tool?

  2. What to do if you receive an error message Exception: Request failed for https://i.instagram.com returned code 400.?

  3. What to do if you receive an error message Exception: Unexpected error while getting the method or property getFolderById on object DriveApp.?

If you cannot find the answer to your question in the FAQ section, please feel free to contact us via GitHub issues or discussions. We will try our best to help you. 😊


📋 Changelog

To see the full list of changes made in each release, please refer to the CHANGELOG.md file.

💕 Like my stuff?

If you enjoy using this tool and want to support me in the development, you can buy me a coffee. I would really appreciate it if you could show your appreciation and generosity.

Buy Me A Coffee

⚖️ License

This project is distributed under the AGPL-3.0 license. This means that you are free to use, modify, and share this project, as long as you follow these rules:

  • You must keep the original license and authorship information in the source code and any copies or derivatives of the project.
  • You must disclose the source code and any modifications you make to the project when you distribute it to others.
  • You must use the same license as the original project when you distribute it to others.

You can find the full text of the license in the LICENSE file.