B
B
Bobur Bakhritdinov2016-04-01 08:42:31
PHP
Bobur Bakhritdinov, 2016-04-01 08:42:31

Form a path to a file from a torrent?

Hello everyone, I'll forgive you to help form the path to the file from the torrent.
Script:

$dict = bdec_file('public/downloads/torrents/'.$id.'.torrent', (1024 * 1024) );
print_r($dict);

Result:
Here
the Torrent file is created in Multiple File Mode.
Specification Multiple File Mode:
Info in Multiple File Mode
For the case of the multi-file mode, the info dictionary contains the following structure:
name: the name of the directory in which to store all the files. This is purely advisory. (string)
files: a list of dictionaries, one for each file. Each dictionary in this list contains the following keys:
length: length of the file in bytes (integer)
md5sum: (optional) a 32-character hexadecimal string corresponding to the MD5 sum of the file. This is not used by BitTorrent at all, but it is included by some programs for greater compatibility.
path: a list containing one or more string elements that together represent the path and filename. Each element in the list corresponds to either a directory name or (in the case of the final element) the filename. For example, a the file "dir1/dir2/file.ext" would consist of three string elements: "dir1", "dir2", and "file.ext". This is encoded as a bencoded list of strings such as l4:dir14:dir28:file.exte
Specification
Here
As written here, you need to form the path to the file.
I tried to create it myself, here is an example:
<?php
$dirname = $dict['value']['info']['value']['name']['value'];
echo $dirname;
?>

The result is a folder: test
Real path to the file /A_police_officer_with_the_ruble_in_2016_SATRip/test/
Forms only the previous folder.
How to generate full path?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bobur Bakhritdinov, 2016-04-01
@bakhritdinov_b

I decided everything on my own,
Reason: I
created inside the A_police_officer_with_the_ruble_in_2016_SATRip folder 2 more episode_1 episode_2 folders and everything worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question