Incorrect .torrent generation (webseed)
gildedgod - November 10, 2008 - 11:47
| Project: | BitTorrent |
| Version: | 5.x-2.0-beta3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
.torrents generated by module using web-seed mode are incorrect (tested by µTorrent 1.8, message "invalid torrent file").
To check this issue, i added into bt_torrent.module on line 346 this string:
<?php
die("DEBUG MODE: \n\n".print_r($torrent));
?>before this lines:
<?php
if (variable_get('bt_override_announce', 1) == 0) {
$torrent['announce'] = variable_get('bt_override_announce_url', $torrent['announce']);
}
?>Results:
First - from uploaded own .torrent file
Array
(
[announce] => http://[***].ru/announce.php?passkey=%EB%DC%2B%F3%8F%05%C5%88NQ%1Di%81%CEV%92H%27u%D2
[created by] => uTorrent/1810
[creation date] => 1225462823
[encoding] => UTF-8
[info] => Array
(
[files] => Array
(
[0] => Array
(
[length] => 94139126
[path] => Array
(
[0] => Kidou Senshi Gundam SEED MSV Astray 01 - Red Frame [18C040C8].mp4
)
)
[1] => Array
(
[length] => 86521716
[path] => Array
(
[0] => Kidou Senshi Gundam SEED MSV Astray 02 - Blue Frame [EB77EB28].mp4
)
)
)
[name] => Kidou Senshi Gundam SEED MSV Astray
[piece length] => 262144
[pieces] => [binary_data]
)
)Second - generated by server
Array
(
[announce] => http://[***].ru/announce.php
[creation date] => 1226314037
[httpseeds] => Array
(
[0] => http://[***].ru/seed.php
)
[url-list] => Array
(
[0] => http://[***].ru/
)
[info] => Array
(
[name] => 0/_season-2007-04/Arusu the Adventure/
[piece length] => 4194304
[pieces] => [binary data]
[files] => Array
(
[0] => Array
(
[length] => 193337616
[path] => Array
(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.03.[DVD.RAW][h264.Vorbis][229AAAFB].mkv
)
)
[1] => Array
(
[length] => 193862465
[path] => Array
(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.04.[DVD.RAW][h264.Vorbis][92F26F12].mkv
)
)
[2] => Array
(
[length] => 193173265
[path] => Array
(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.06.[DVD.RAW][h264.Vorbis][5C780BF8].mkv
)
)
[3] => Array
(
[length] => 193749763
[path] => Array
(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.02.[DVD.RAW][h264.Vorbis][D8BB4A57].mkv
)
)
[4] => Array
(
[length] => 192787981
[path] => Array
(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.01.[DVD.RAW][h264.Vorbis][D819FB9A].mkv
)
)
[5] => Array
(
[length] => 194007944
[path] => Array
(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.05.[DVD.RAW][h264.Vorbis][8B021B99].mkv
)
)
)
)
)From first array module produces correct .torrent, from second - invalid. Why?

#1
Omg!))) It's strange that i didn't notice this:
[path] => Array(
[3] => Arusu the Adventure
[4] =>
[5] => [mguu].Arusu.the.Adventure.05.[DVD.RAW][h264.Vorbis][8B021B99].mkv
)
bt_torrent.module, lines 258-291:
<?php
foreach ($files as $file) {
$handle = fopen($file, 'rb');
if ($last_piece_size != 0) {
$piece = fread($handle, $piece_size - $last_piece_size);
$pieces .= sha1($last_piece . $piece);
}
$last_piece_size = 0;
$last_piece = '';
// Create the hashes for the pieces
while ($piece = fread($handle, $piece_size)) {
if (strlen($piece) != $piece_size) {
$last_piece_size = strlen($piece);
$last_piece = $piece;
}
else {
$pieces .= sha1($piece, TRUE);
}
}
fclose($handle);
// TODO: Make this unset more dynamic
$path = explode('/', $file);
unset($path[0]);
unset($path[1]);
unset($path[2]);
$torrent_files[] = array(
'length' => filesize($file),
'path' => $path,
);
}
?>
Here it is:
<?php
// TODO: Make this unset more dynamic
$path = explode('/', $file);
unset($path[0]);
unset($path[1]);
unset($path[2]);
$torrent_files[] = array(
'length' => filesize($file),
'path' => $path,
);
?>
This code is wery interesting. It based on a fact that there is 3-level depth directory. But i've got even deeper folders =)
What about basename function?
<?php// DONE: absolutely dynamic )))
$path = array(basename($file));
$torrent_files[] = array(
'length' => filesize($file),
'path' => $path,
);
?>
#2