O
O
Oleg2014-12-07 18:48:11
bittorrent
Oleg, 2014-12-07 18:48:11

How to make Torrent streaming?

I have a wonderful proxy project on Android here .
The task is simple - to embed torrent into it :) .
The bottom line is that I have a certain file somewhere on the Internet on the server.
The server can send SHA1 of this file for searching on torrent trackers (of this file).
Those. I get sha1, I look for trackers. I find. I get a list of peers. I start sequential download of the file from these peers.
Then the download is interrupted (for example) and the download of the same file starts, only from the middle.
Those. full streaming for video\audio player.
Question four:
How to get the sha1 file on the computer so that it is the same as on the torrent tracker. For some reason they are different for me.
Do I understand the process of downloading a torrent file correctly?
How can I connect to the torrent tracker manually, for debugging and visual understanding of the process of receiving files. Can through telnet what...
How to implement programmatically?
Programmatically, I need to get an InputStream with the ability to restart downloading from a specific byte.
Moreover, InputStream from the downloaded file will not work. Since it is not clear what information it contains exactly.
I can be wrong. Fix it.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
Oleg, 2014-12-09
@Master255

Attention correct answer!
Torrent files contain hashes of pieces of files and the .torrent file itself, but not the file that will be downloaded. Therefore, the hash of the downloaded file does not appear anywhere. And even more so, this hash cannot be searched. The principle of operation of torrents does not include a mechanism for searching a file by hash, but includes searching for a part of a file by its hash. Moreover, if the file is divided by at least one byte differently than on the torrent tracker, then the hash of its pieces will be completely different. All this makes it impossible to search for files on torrent trackers using their hashes.
Therefore, it is necessary to abandon the torrent technology in favor of another.
According to the article lurkmore.to/P2P. It becomes clear that there is only one other similar technology that you can rely on - this is Direct Connect (NMDC, DC ++, ADC).
It works in text mode and can search the TTH hash of a file, which can even be used to restore the file!
In this connection, I have a new question . Is it possible to connect to p2p via telnet?

3
386DX, 2014-12-07
@386DX

No way. Windows programs have been developing since 2009 and still a glitch on a glitch. Vryat you will be able to make a normal stream on android.

E
Eugene, 2014-12-07
@Nc_Soft

The hash can be generated like this https://github.com/adriengibrat/torrent-rw generates quite adequately, you can dig inside and see how it does it

<?php 
$torrent = new Torrent('file.mp4');
echo $torrent->hash_info();

You can also generate a torrent with the mktorrent console utility.
You can even use rtorrent or transmission, but it's somehow expensive to generate a hash.
Only I do not really understand how you want to distribute this torrent with only a hash.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question