Giter Site home page Giter Site logo

ih2torrent's Introduction

ih2torrent

ih2torrent creates a trackerless torrent file from an infohash or a magnet URI. It uses BitTorrent DHT and the metadata protocol to find peers for the torrent and obtain its metadata.

In order to get the dependencies inside a virtualenv, run make. You need Python 3.5 or higher to run ih2torrent.

You can use pip to install ih2torrent: pip3 install ih2torrent

ih2torrent's People

Contributors

drxzcl avatar elektito 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ih2torrent's Issues

raise NotImplementedError

This command:
python ih2torrent.py --file test.torrent "magnet:?xt=urn:btih:6d1e38aa6d10e62c827102cb5e21f2d5b3f2e090"

Return this:

[2021-11-16 20:32:29,787][INFO] Using node ID: 4927ed92175a89cb0aa5841ae5e3de76c5d6bbf6
[2021-11-16 20:32:29,800][INFO] Using router.bittorrent.com as the bootstrapping node.
[2021-11-16 20:32:29,800][INFO] Resolving: router.bittorrent.com
Exception ignored from cffi callback <function _sock_state_cb at 0x000001D717F92040>:
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\ih2torrent\venv\lib\site-packages\pycares\__init__.py", line 99, in _sock_state_cb
    sock_state_cb(socket_fd, readable, writable)
  File "C:\Users\Administrator\Desktop\ih2torrent\venv\lib\site-packages\aiodns\__init__.py", line 111, in _sock_state_cb
    self.loop.add_reader(fd, self._handle_event, fd, READ)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 504, in add_reader
    raise NotImplementedError
NotImplementedError:

Windows 10
Python 3.9.5
aiodns==3.0.0
bencodepy==0.9.5
cffi==1.15.0
pycares==4.1.2
pycparser==2.21

Create a tracker based torrent file when a magnet URI with trackers is provided.

When we accept a magnet URI in place of the infohash, as issue #1 describes, we can create a traditional tracker based torrent file instead of a trackerless torrent. Add an option to the command-line so the user can choose the kind of torrent file created.

Update the README and project description to reflect the fact we no longer just create trackerless torrent files.

Invalid arguments are not handled gracefully.

Invalid infohashes or invalid filenames are not handled gracefully. The expected behavior is to show a clean message to the user saying what is wrong. Currently a Python stack trace is printed.

Deprecation warnings Python 3.8

I get the following warnings since Python 3.8:

/home/ih2torrent.py:378: DeprecationWarning: "@coroutine" decorator is depcated since Python 3.8, use "async def" instead
def ping(loop, host, port):
/home/ih2torrent.py:450: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
def dns_resolve(loop, name):
/home/ih2torrent.py:460: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
def get_metadata(loop, host, port, infohash):
/home/ih2torrent.py:565: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
def get_metadata_with_retries(loop, host, port, infohash):
/home/ih2torrent.py:604: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
def ih2torrent(loop, infohash, filename, bootstrap):
/home/ih2torrent.py:773: DeprecationWarning: Task.all_tasks() is deprecated, use asyncio.all_tasks() instead
pending = asyncio.Task.all_tasks()

I also get this error a few times:

Traceback (most recent call last):
File "/home/ih2torrent.py", line 784, in
main()
File "/home/ih2torrent.py", line 777, in main
loop.run_until_complete(asyncio.gather(*pending))
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
asyncio.exceptions.CancelledError`

The code still works, but it's spitting out above's warnings/errors.

Better retry mechanism for communication with peers.

Currently we only have retries for DHT queries. We can get better performance by adding retries to peer communications:

  • When we failed to connect to a peer, we can try it once or twice again, either immediately or better yet after a short delay. The peer might be only temporarily available.
  • When a connection to a peer is disrupted, it might very well pay to try again, either immediately or after a while.

Deprecation Warnings

I'm getting deprecation warnings:

/home/h2torrent.py:476: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
  done, pending = await asyncio.wait(
/home/ih2torrent.py:490: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
  done, pending = await asyncio.wait(
/home/ih2torrent.py:523: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
  done, pending = await asyncio.wait(

Pressing Ctrl-C does not always close the program gracefully.

Sometimes when Ctrl-C is pressed in the middle of execution a Python traceback is printed:

Traceback (most recent call last):
  File "./ih2torrent.py", line 620, in <module>
    loop.run_until_complete(asyncio.gather(*pending))
  File "/usr/local/lib/python3.5/asyncio/base_events.py", line 340, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.

This is obviously not expected behavior. Fix it.

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.