Skip to content

Commit

Permalink
Merge pull request #2138 from fbdtemme/master
Browse files Browse the repository at this point in the history
Add option to create hybrid torrents
  • Loading branch information
Novik authored Jan 28, 2021
2 parents 1467430 + ae1427f commit 18c031f
Show file tree
Hide file tree
Showing 30 changed files with 110 additions and 29 deletions.
24 changes: 16 additions & 8 deletions plugins/create/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ static public function getTrackerDomain($announce)
if($useExternal=="mktorrent")
$piece_size = log($piece_size,2);
else

if(isset($_REQUEST['hybrid']))
$hybrid = TRUE;

if($useExternal===false)
$useExternal = "inner";
$task = new rTask( array
Expand All @@ -128,17 +132,21 @@ static public function getTrackerDomain($announce)
'source'=>$_REQUEST['source'],
'start_seeding'=>$_REQUEST['start_seeding'],
'piece_size'=>$_REQUEST['piece_size'],
'private'=>$_REQUEST['private']
'private'=>$_REQUEST['private'],
'hybrid'=>$_REQUEST['hybrid'],
) );
$commands = array();

$commands[] = escapeshellarg($rootPath.'/plugins/create/'.$useExternal.'.sh')." ".
$task->id." ".
escapeshellarg(getPHP())." ".
escapeshellarg($pathToCreatetorrent)." ".
escapeshellarg($path_edit)." ".
$piece_size." ".
escapeshellarg(getUser())." ".
escapeshellarg(rTask::formatPath($task->id));
$task->id." ".
escapeshellarg(getPHP())." ".
escapeshellarg($pathToCreatetorrent)." ".
escapeshellarg($path_edit)." ".
$piece_size." ".
escapeshellarg(getUser())." ".
escapeshellarg(rTask::formatPath($task->id))." ".
escapeshellarg($hybrid);

$commands[] = '{';
$commands[] = 'chmod a+r "${dir}"/result.torrent';
$commands[] = '}';
Expand Down
1 change: 1 addition & 0 deletions plugins/create/conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// "createtorrent" - use program createtorrent (see http://www.createtorrent.com)
// "mktorrent" - use program mktorrent (see http://mktorrent.sourceforge.net)
// "buildtorrent" - use program buildtorrent (see http://claudiusmaximus.goto10.org/cm/torrent.html)
// "torrenttools" - use program torrenttools (see http://github.com/fbdtemme/torrenttools)
$pathToCreatetorrent = ''; // Something like /bin/createtorrent, or /bin/transmissioncli. If empty, program will be found in PATH.

$recentTrackersMaxCount = 15;
13 changes: 11 additions & 2 deletions plugins/create/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ theWebUI.checkCreate = function()
"comment" : $.trim($("#comment").val()),
"source" : $.trim($("#source").val()),
"private" : $('#private').prop('checked') ? 1 : 0,
"start_seeding" : $('#start_seeding').prop('checked') ? 1 : 0
"start_seeding" : $('#start_seeding').prop('checked') ? 1 : 0,
"hybrid" : $('#hybrid').prop('checked') ? 1 : 0,
},
{
noclose: true
Expand Down Expand Up @@ -116,6 +117,13 @@ plugin.onLangLoaded = function()
if(plugin.hidePieceSize)
pieceSize = "";

var hybridTorrent =
"<label for='hybrid' id='lbl_hybrid' class='nomargin'>"+
"<input type='checkbox' name='hybrid' id='hybrid'/>"+theUILang.HybridTorrent+"</label>";

if(plugin.hideHybrid)
hybridTorrent = "";

theDialogManager.make("tcreate",theUILang.CreateNewTorrent,
"<div class='cont fxcaret'>"+
"<fieldset>"+
Expand All @@ -136,7 +144,8 @@ plugin.onLangLoaded = function()
"<fieldset>"+
"<legend>"+theUILang.Other+"</legend>"+
"<label for='start_seeding' id='lbl_start_seeding' class='nomargin'><input type='checkbox' name='start_seeding' id='start_seeding'/>"+theUILang.StartSeeding+"</label>"+
"<label class='nomargin'><input type='checkbox' name='private' id='private'/>"+theUILang.PrivateTorrent+"</label><br/>"+
"<label class='nomargin'><input type='checkbox' name='private' id='private'/>"+theUILang.PrivateTorrent+"</label>"+
hybridTorrent+"<br/>"+
"</fieldset>"+
"</div>"+
"<div class='aright buttons-list'><input type='button' id='recentTrackers' value='"+theUILang.recentTrackers+"...' class='Button menuitem' onclick='theWebUI.showRecentTrackers()'/><input type='button' id='torrentCreate' value='"+theUILang.torrentCreate+"' class='OK Button' onclick='theWebUI.checkCreate()'/><input type='button' class='Cancel Button' value='"+theUILang.Cancel+"'/></div>",true);
Expand Down
4 changes: 4 additions & 0 deletions plugins/create/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
{
if(($useExternal === "transmissioncli") || ($useExternal === "transmissioncreate"))
$jResult.="plugin.hidePieceSize = true;";

if (($useExternal !== "torrenttools"))
$jResult.="plugin.hideHybrid = true;";

$theSettings->registerPlugin($plugin["name"],$pInfo["perms"]);
}
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/create/lang/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/da.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/el.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Η λειτουργία τερματίστηκε.";
theUILang.recentTrackers = "Πρόσφατοι trackers";
theUILang.source = "Πηγή";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "El proceso fue detenido.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Le processus a été interrompu.";
theUILang.recentTrackers = "Trackers récents";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Folyamat leállt.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
1 change: 1 addition & 0 deletions plugins/create/lang/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
theUILang.torrentKilled = "Il processo è stato arrestato.";
theUILang.recentTrackers = "Tracker recenti";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "중지";
theUILang.torrentKilled = "프로세스가 중지되었습니다.";
theUILang.recentTrackers = "최근 트래커";
theUILang.source = "원본";
theUILang.source = "원본";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/lv.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "proces is gestopt.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/no.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stopp";
theUILang.torrentKilled = "Prosessen ble stoppet.";
theUILang.recentTrackers = "Siste trackere";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Proces został zatrzymany.";
theUILang.recentTrackers = "Ostatnie trackery";
theUILang.source = "Źródło";
theUILang.source = "Źródło";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Остановить";
theUILang.torrentKilled = "Процесс остановлен.";
theUILang.recentTrackers = "Недавние трекеры";
theUILang.source = "Источник";
theUILang.source = "Источник";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/sr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stoppa";
theUILang.torrentKilled = "Processen stoppades.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/uk.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Зупинити";
theUILang.torrentKilled = "Процес зупинено.";
theUILang.recentTrackers = "Недавні трекери";
theUILang.source = "Джерело";
theUILang.source = "Джерело";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/vi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Dừng";
theUILang.torrentKilled = "Quá trình tạo torrent đã ngừng lại.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
3 changes: 2 additions & 1 deletion plugins/create/lang/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "停止";
theUILang.torrentKilled = "进程已停止.";
theUILang.recentTrackers = "最近的 trackers";
theUILang.source = "源";
theUILang.source = "源";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
5 changes: 3 additions & 2 deletions plugins/create/lang/zh-tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
theUILang.torrentKill = "Stop";
theUILang.torrentKilled = "Process was stopped.";
theUILang.recentTrackers = "Recent trackers";
theUILang.source = "Source";
theUILang.source = "Source";
theUILang.HybridTorrent = "Hybrid torrent";

thePlugins.get("create").langLoaded();
thePlugins.get("create").langLoaded();
34 changes: 34 additions & 0 deletions plugins/create/torrenttools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
#
# $1 - taskNo
# $2 - php
# $3 - torrenttools
# $4 - path
# $5 - piecesize
# $6 - user
# $7 - dir
# $8 - hybrid

if [ ${8} ] ; then
protocol="hybrid"
else
protocol="v1"
fi

"${3}" create -l ${5} -o "${7}/temp.torrent" --protocol "${protocol}" "${4}"

last=$?
chmod a+r "${7}/temp.torrent"

if [ $last -eq 0 ] ; then
echo 'Try to correct torrent file...'
cd "$(dirname $0)"
"${2}" ./correct.php ${1} "${6}"
last=$?
if [ $last -eq 0 ] ; then
echo 'Done.'
else
echo 'Error.'
fi
fi
exit $last

0 comments on commit 18c031f

Please sign in to comment.