Code Monkey home page Code Monkey logo

gabrielkheisa / instagram-downloader Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 16 KB

This micro web server allows you to download Instagram Reels videos by providing their query parameters. It utilizes Selenium to control a Chromium browser instance and navigate to the Instagram webpage. Once the video is loaded, it extracts the CDN link and redirects you to it.

Home Page: https://ig.gabrielkheisa.xyz/<query_params_from_instagram.com>

Python 85.84% Dockerfile 14.16%
instagram python selenium

instagram-downloader's Introduction

Instagram Video Downloader

This micro web server allows you to download Instagram Reels videos by providing their query parameters. It utilizes Selenium to control a Chromium browser instance and navigate to the Instagram webpage. Once the video is loaded, it extracts the CDN link and redirects you to it.

Usage:

https://ig.gabrielkheisa.xyz/<query_params_from_instagram.com>

Example:

Source

https://www.instagram.com/reel/Cz3dNmDMVC9/?igshid=MzRlODBiNWFlZA==

Replace

https://ig.gabrielkheisa.xyz/reel/Cz3dNmDMVC9/?igshid=MzRlODBiNWFlZA==

Returns redirect:

https://scontent.cdninstagram.com/v/t66.30100-16/316926421_1723935788092224_3596729375098306652_n.mp4?_nc_ht=scontent.cdninstagram.com&_nc_cat=100&_nc_ohc=6lyBPVcj...............

Notes: This redirect URL (https://scontent.cdninstagram.com/...) has expiration, in which you need to re-run the query to get a new URL signature

DISCLAIMER:

This micro web server does not directly download the Instagram Reels video. It simply locates the Instagram CDN link for the video and redirects you to it. Therefore, it is not technically a "downloader" but rather a CDN link extractor and redirector.

Tech stack

  • Python 3.6: Programming language
  • Selenium: Web automation framework
  • Chromium browser: Web browser, run in headless mode
  • Flask: Micro web server

Requirements

  • Python 3.6+
  • Selenium
  • Chromium browser
  • Flask

Installation

  1. Install Python 3.6 or newer.

  2. Install Selenium:

    pip install selenium
    
  3. Install Chromium browser:

    sudo apt install chromium-browser
    
  4. Install Flask:

    pip install Flask
    
  5. Clone this repository:

    git clone https://github.com/gabrielkheisa/instagram-downloader.git
    

With Dockerfile

  1. Build the Dockerfile

    sudo docker build -t instagram-downloader .
    
  2. Run the container

    sudo docker run -d -p 8080:8080 instagram-downloader
    

With existing Docker Image

  1. Pull the Docker image

    sudo docker pull ghcr.io/gabrielkheisa/instagram-downloader/gabrielkheisa/instagram-downloader:latest
    
  2. Run the container

    sudo docker run -d -p 8080:8080 ghcr.io/gabrielkheisa/instagram-downloader/gabrielkheisa/instagram-downloader
    

Usage

  1. Start the Flask app, skip this part if you use Docker:

    python run.py
    
  2. Open a web browser and navigate to http://localhost:8080/.

  3. Add the query parameters of your Instagram Reels endpoint, for example for the original Instagram URL:

https://www.instagram.com/reel/Cz3dNmDMVC9/?igshid=MzRlODBiNWFlZA==

To be filled with:

http://localhost:8080/reel/Cz3dNmDMVC9/?igshid=MzRlODBiNWFlZA==
  1. After you have something like https://scontent.cdninstagram.com/v/t66.30..., simply download the video
  2. If the Instagram Reels video exists or no exception or error occurs, you will be redirected to the Instagram CDN endpoint link where you can download the video directly, else it will redirect to instagram.com

Limitations

  • It takes 3 to 5 seconds for the Xpath in the remote URL (instagram.com) to be loaded properly, so delay is implicitly inserted in the webdriver, making the request relatively longer for each invocation.
  • It's possible that Instagram will change their Xpath website structure in the future, so you need to find the new Xpath location. Current Xpath and property:
/html/body/div[2]/div/div/div[2]/div/div/div[1]/section/main/div[1]/div/article/div/div[1]/div/div/div/div/div/div/div/video
src

instagram-downloader's People

Contributors

gabrielkheisa avatar

Stargazers

 avatar Yuke Brilliant H. avatar Assami Muzaki avatar  avatar Maz avatar

Watchers

 avatar

instagram-downloader's Issues

URL signature expired

in README

https://scontent.cdninstagram.com/v/t66.30100-16/316926421_1723935788092224_3596729375098306652_n.mp4?_nc_ht=scontent.cdninstagram.com&_nc_cat=100&_nc_ohc=6lyBPVcjJkYAX8kLe3I&edm=APs17CUBAAAA&ccb=7-5&oh=00_AfBNGf7HzFPnd-mhfvhZZZRk_-PlN3qx3hqbsINaUGA4aA&oe=6576D61D&_nc_sid=10d13b

and other output links

Has some kind of "URL signature", making the caching mechanism ineffective

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.