Coder Social home page Coder Social logo

pytorrent's Introduction

PyTorrent - Python BitTorrent

PyTorrent is a CLI tool that downloads files from the BitTorrent network.

I wanted to make my own functional and straightforward program to learn how does BitTorrent protocol work and improve my python skills.

It is almost written from scratch, python 2.7 without twisted. Only the pubsub library was used to create events, when a new peer is connected, or when data is received from a peer.

This tool needs a lot of improvements, but it does its job, you can :

  • Read a torrent file
  • Scrape udp or http trackers
  • Connect to peers
  • Ask them for the blocks you want
  • Save a block in RAM, and when a piece is completed and checked, write the data into you hard drive
  • Deal with the one-file or multi-files torrents

But you can’t :

  • Download more than one torrent at a time
  • Upload data to the BitTorrent network
  • Benefit of a good algorithm to ask your peers for blocks (like the rarest piece algo)
  • Pause and resume download
  • Leech or Seed to other peers
  • And a lot of other things

Don't hesitate to ask me questions if you need help, or send me a pull request for new features or improvements.

Installation

You can run the following command to install the dependencies using pip

pip install -r requirements.txt

💥 Because it's using the "select" function, this code will not be able to run on Windows: python-select-on-windows

Running the program

If you want to specify a torrent file, you need to edit it manually in the run.py file:

self.torrent = Torrent.Torrent("path_to_your_torrent") 

Then simply run: python main.py

The files will be downloaded in the same path as your run.py script.

Sources :

I wouldn't go that far without the help of Lita, Kristen Widman's & the Bittorrent Unofficial Spec, so thank you.

pytorrent's People

Contributors

frozenfighter avatar gallexis avatar

Watchers

 avatar  avatar

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.