Задать вопрос
@bakhritdinov_b

Сформировать данный с торрент файла?

Здравствуйте, помогите решить задачу!
Есть php код:
require 'system/functions/functions.benc.php';

$dict = bdec_file('public/test.torrent', (1024 * 1024) );

$v = $dict['value']['info']['value']['name']['value'];

print_r($v);

Код сформировал имя первого файла внутри торрента
Если сделать так:

require 'system/functions/functions.benc.php';

$dict = bdec_file('public/test.torrent', (1024 * 1024) );

print_r($dict);


print_r покажет все содержимый данный торрента в виде массива.
Результат:
Array ( [type] => dictionary [value] => Array ( [announce] => Array ( [type] => string [value] => http://alltor.me/bt/announce.php?uk=0zTRESOuis [strlen] => 49 [string] => 46:http://alltor.me/bt/announce.php?uk=0zTRESOuis ) [announce-list] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => http://alltor.me/bt/announce.php?uk=0zTRESOuis [strlen] => 49 [string] => 46:http://alltor.me/bt/announce.php?uk=0zTRESOuis ) ) [strlen] => 51 [string] => l46:http://alltor.me/bt/announce.php?uk=0zTRESOuise ) [1] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => http://alltor.me:2710/announce [strlen] => 33 [string] => 30:http://alltor.me:2710/announce ) ) [strlen] => 35 [string] => l30:http://alltor.me:2710/announcee ) [2] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => http://retracker.local/announce [strlen] => 34 [string] => 31:http://retracker.local/announce ) ) [strlen] => 36 [string] => l31:http://retracker.local/announcee ) ) [strlen] => 124 [string] => ll46:http://alltor.me/bt/announce.php?uk=0zTRESOuisel30:http://alltor.me:2710/announceel31:http://retracker.local/announceee ) [azureus_properties] => Array ( [type] => dictionary [value] => Array ( [dht_backup_enable] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) ) [strlen] => 25 [string] => d17:dht_backup_enablei0ee ) [comment] => Array ( [type] => string [value] => http://alltor.me/viewtopic.php?p=785241 [strlen] => 42 [string] => 39:http://alltor.me/viewtopic.php?p=785241 ) [created by] => Array ( [type] => string [value] => uTorrent/3130 [strlen] => 16 [string] => 13:uTorrent/3130 ) [creation date] => Array ( [type] => integer [value] => 1451070427 [strlen] => 12 [string] => i1451070427e ) [encoding] => Array ( [type] => string [value] => UTF-8 [strlen] => 7 [string] => 5:UTF-8 ) [info] => Array ( [type] => dictionary [value] => Array ( [file-duration] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => integer [value] => 9202 [strlen] => 6 [string] => i9202e ) [1] => Array ( [type] => integer [value] => 9135 [strlen] => 6 [string] => i9135e ) [2] => Array ( [type] => integer [value] => 8030 [strlen] => 6 [string] => i8030e ) [3] => Array ( [type] => integer [value] => 7849 [strlen] => 6 [string] => i7849e ) [4] => Array ( [type] => integer [value] => 7666 [strlen] => 6 [string] => i7666e ) [5] => Array ( [type] => integer [value] => 7374 [strlen] => 6 [string] => i7374e ) [6] => Array ( [type] => integer [value] => 7135 [strlen] => 6 [string] => i7135e ) ) [strlen] => 44 [string] => li9202ei9135ei8030ei7849ei7666ei7374ei7135ee ) [file-media] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) [1] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) [2] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) [3] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) [4] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) [5] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) [6] => Array ( [type] => integer [value] => 0 [strlen] => 3 [string] => i0e ) ) [strlen] => 23 [string] => li0ei0ei0ei0ei0ei0ei0ee ) [files] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1839396864 [strlen] => 12 [string] => i1839396864e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e02.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e02.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e02.avie ) ) [strlen] => 65 [string] => d6:lengthi1839396864e4:pathl32:Muhtesem Yuzyil.Kosem.s01e02.aviee ) [1] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1825562624 [strlen] => 12 [string] => i1825562624e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e01.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e01.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e01.avie ) ) [strlen] => 65 [string] => d6:lengthi1825562624e4:pathl32:Muhtesem Yuzyil.Kosem.s01e01.aviee ) [2] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1606918144 [strlen] => 12 [string] => i1606918144e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e03.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e03.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e03.avie ) ) [strlen] => 65 [string] => d6:lengthi1606918144e4:pathl32:Muhtesem Yuzyil.Kosem.s01e03.aviee ) [3] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1571627008 [strlen] => 12 [string] => i1571627008e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e06.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e06.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e06.avie ) ) [strlen] => 65 [string] => d6:lengthi1571627008e4:pathl32:Muhtesem Yuzyil.Kosem.s01e06.aviee ) [4] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1534844928 [strlen] => 12 [string] => i1534844928e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e05.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e05.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e05.avie ) ) [strlen] => 65 [string] => d6:lengthi1534844928e4:pathl32:Muhtesem Yuzyil.Kosem.s01e05.aviee ) [5] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1473341440 [strlen] => 12 [string] => i1473341440e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e07.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e07.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e07.avie ) ) [strlen] => 65 [string] => d6:lengthi1473341440e4:pathl32:Muhtesem Yuzyil.Kosem.s01e07.aviee ) [6] => Array ( [type] => dictionary [value] => Array ( [length] => Array ( [type] => integer [value] => 1427220480 [strlen] => 12 [string] => i1427220480e ) [path] => Array ( [type] => list [value] => Array ( [0] => Array ( [type] => string [value] => Muhtesem Yuzyil.Kosem.s01e04.avi [strlen] => 35 [string] => 32:Muhtesem Yuzyil.Kosem.s01e04.avi ) ) [strlen] => 37 [string] => l32:Muhtesem Yuzyil.Kosem.s01e04.avie ) ) [strlen] => 65 [string] => d6:lengthi1427220480e4:pathl32:Muhtesem Yuzyil.Kosem.s01e04.aviee ) ) [strlen] => 457 [string] => ld6:lengthi1839396864e4:pathl32:Muhtesem Yuzyil.Kosem.s01e02.avieed6:lengthi1825562624e4:pathl32:Muhtesem Yuzyil.Kosem.s01e01.avieed6:lengthi1606918144e4:pathl32:Muhtesem Yuzyil.Kosem.s01e03.avieed6:lengthi1571627008e4:pathl32:Muhtesem Yuzyil.Kosem.s01e06.avieed6:lengthi1534844928e4:pathl32:Muhtesem Yuzyil.Kosem.s01e05.avieed6:lengthi1473341440e4:pathl32:Muhtesem Yuzyil.Kosem.s01e07.avieed6:lengthi1427220480e4:pathl32:Muhtesem Yuzyil.Kosem.s01e04.avieee ) [name] => Array ( [type] => string [value] => Muhtesem.Yuzyil.Kosem.S01 [strlen] => 28 [string] => 25:Muhtesem.Yuzyil.Kosem.S01 ) [piece length] => Array ( [type] => integer [value] => 8388608 [strlen] => 9 [string] => i8388608e ) [pieces] => Array ( [type] => string [value] =>


Скриншот результатов:
541a6b3fcae342ac8d9ef406197f8e95.png
Хочу сформировать название папка и все файлы внутри папки (аналог модуля torrentpier 2 (список файлов)

684d1264d26c4543be86acdbfc20682d.jpg

Заранее спасибо!
  • Вопрос задан
  • 414 просмотров
Подписаться 1 Оценить Комментировать
Решения вопроса 1
wielski
@wielski
✔ Совет: Вам помогли? Отметьте ответы решением.
Первое что пришло в голову -

foreach($dict['path'] as $path){
    if($path['type'] == 'list'){
       foreach($path['value'] as $list){
           if($path['type'] == 'string'){
               // $path['value'] ваше значение имени файла
           }
       }
    }
}


В данной области не разбираюсь, но думаю принцип вы поняли.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы