Git Product home page Git Product logo

z1nc0r3 / twitter-video-downloader Goto Github PK

View Code? Open in Web Editor NEW
29.0 1.0 8.0 30 KB

This is a Python script that allows you to download videos from Twitter. It takes a Twitter video URL as input, extracts the video ID, and downloads the video using the URL with the highest bitrate.

Python 100.00%
python twitter twitter-bot video video-downloader terminal-app twitter-video twitter-video-downloader python-script python3

twitter-video-downloader's Introduction

Twitter Video Downloader 2.0

forthebadge made-with-python

Buy Me A Coffee

Hits


This is a Python script that allows you to download videos from X aka Twitter using the terminal. It takes a Twitter post URL as an input, extracts the highest-quality video URL, and downloads the video.

Prerequisites

  • Python 3.x
  • requests library (install requirements using pip install requests)
  • bs4 library (install using pip install beautifulsoup4)
  • tqdm library (install using pip install tqdm)

Usage

  1. Clone the repository:

    git clone https://github.com/z1nc0r3/twitter-video-downloader
    
  2. Navigate to the project directory:

    cd twitter-video-downloader
    
  3. Install the required packages

    pip install -r requirements.txt
    
  4. Run the script with the video URL as the argument

    python twitter_downloader.py {video url}
    
    eg :- python twitter_downloader.py https://x.com/realmadriden/status/1743790569866821949?s=20
    

Note

  • This script relies on the external website twitsave.com to retrieve the video URL for downloading. It uses the API provided by twitsave.com to fetch the video details.
  • Please ensure you have a stable internet connection and access to twitsave.com for the script to work properly.
  • Me and this project are not affiliated with twitsave.com. Please review and comply with the terms and conditions of twitsave.com/terms when using their services through this script.

twitter-video-downloader's People

Contributors

h4ppy-04 avatar z1nc0r3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

twitter-video-downloader's Issues

URL verification with urlparse

def extract_video_id(url):
pattern = r"status/(\d+)"
match = re.search(pattern, url)

An extra way to validate a URL that I've found helpful in my projects is to use the urlparse() function from the urllib library.

The URL is split up into sections so that components of a URL can be checked individually. For example, a Twitter URL is split up by urlparse as follows:

>>> urlparse("https://twitter.com/user/status/id")
ParseResult(scheme='https', netloc='twitter.com', path='/user/status/id', params='', query='', fragment='')

A few unit tests might look something like this:

tests/test_url_format.py

# Assuming all url arguments are standard twitter media url's.

def assert_domain_valid(url: str):
    """ Assert the site is equal to twitter.com """

    parsed_url = urlparse(url)
    
    assert parsed_url.hostname == 'twitter.com'

def assert_id_valid(url: str):
    """ Assert that the id is made up of exclusively digits """
    parsed_url = urlparse(url)
    url_id = parsed_url.path.split('/')[scheme.path.count('/')]
    assert url_id.isnumeric() == True

readme small error

I've noticed a small error in the usage example provided in the repository. The clone command includes "your-username" instead of the actual username. Great project btw!

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.