rutorrent, пакетный экспорт .torrent файлов по меткам

1406
Hayden Thring

Желая перейти с rutorrent / rtorrent на deluge, но сохранить все мои метки торрентов, я разработал этот способ, изменив некоторые из php-файлов rutorrents и используя некоторый пользовательский javascript.

-1

1 ответ на вопрос

-1
Hayden Thring

This solution uses the 'source' plugin packaged with rutorrent.

First i changed the default behavior of rutorrent to save a .torrent to a specified directory instead of offer it up for download in the browser: (replace "/media/sdf1/home/torrents/" with thte absolute path to a directory you have created to put the .torrent files in)

/rutorrent/php/Torrent.php

public function send( $filename = null ) { if(is_null( $filename )) $filename = $this->info['name'].'.torrent'; if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'],'MSIE')) $filename = rawurlencode($filename); //header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); //cachedEcho( $this->__toString(), 'application/x-bittorrent', true ); $fp = fopen("/media/sdf1/home/torrents/".$filename, 'w'); fwrite($fp, $this->__toString()); fclose($fp); } 

Then this bit is optional, just prevents an error being thrown when send send function doesnt return anything, though it works still.

/rutorrent/plugins/source/action.php

if(isset($_REQUEST['hash'])) { $torrent = rTorrent::getSource($_REQUEST['hash']); if($torrent) $torrent->send(); } //header("HTTP/1.0 302 Moved Temporarily"); //header("Location: ".$_SERVER['PHP_SELF'].'?result=0'); 

Now the actual script, in javascript, it iterates over the visible list of torrents in rutorrent, so click the label you want, than run this code, either in a js file or as i did via the firebug js console. Note it can only do the torrents visible 'above the fold' and you must scroll down and re-run it for all the torrents 'pages' that are not visible in one screen height, though if you maximise your screen size and pane dimensions youll get as many as possible. (dont worry if there is double up, it does not affect things)

//can only do visible torrents, so have to scroll and execute again var torrents = new Array(); $("#List .stable-body tr").each(function(i){ torrents[i] = $( this ).attr("id"); }) var count = torrents.length; var i = 0; console.log( torrents ); function request(torrent){ if(i == count){ console.log( i+'/'+count ); console.log( "DONE" ); return; } $.get( "plugins/source/action.php", { hash: torrent}, function( data ) { i++; request(torrents[i]); }); console.log( i+'/'+count ); } request(torrents[0]); 

Now the .torrent files for that view will be in the specified folder. Move them, add them, label them, then repeat for other views/labels.