Migrate uTorrent to Deluge

Suggestions and discussion of future versions
roisiano
New User
New User
Posts: 3
Joined: Sat Oct 21, 2017 9:03 am

Re: Migrate uTorrent to Deluge

Post by roisiano »

Cha0s wrote:I have uploaded the script to GitHub so it won't get 'lost' again :)
https://github.com/RLoaD/utorrent-to-deluge

I don't know if it still works or not though. I haven't used Deluge for ages (too slow UI for my amount of torrents)
Thanks.

It seems those files work in Windows... but for Windows I have no problem to import torrents from utorrent to Deluge with utorrent import plugin.

My real problem is that:
1) I can't migrate torrents from utorrent (Windows 7) to Deluge (Ubuntu 16.04)
2) I can't migrate torrents from Deluge (Windows 7) to Deluge (Ubuntu 16.04)

Migrating torrents from utorrent (Windows 7) to Deluge (Windows 7) is not a problem for me at all... but it's not what I need (except, perhaps, for a first step, but it's not the final objective).

So... the "real" problem is not with changing client (in Windows). The "real" problem is to use these torrent in Deluge in other Operating System (Ubuntu 16.04) with different paths (C:/ in Windows ; \media\roisiano\ in Ubuntu)... and I want to use Deluge in Ubuntu.
User avatar
Cha0s
Member
Member
Posts: 24
Joined: Sun Dec 28, 2008 10:48 am

Re: Migrate uTorrent to Deluge

Post by Cha0s »

The script is written in PHP, so you can run it pretty much on any OS that PHP supports.
If you are familiar with basic PHP you should be able to make the script work by editing it to fit your needs.
By default it only works on windows (it uses the wfio php module for windows). The original script (uploaded somewhere in the first posts on this thread) was for linux IIRC.

The script just reads the torrents added in uTorrent by parsing (BEdecode) resume.dat and loop through it.
For each iteration it simply runs deluge cli and tries to add the torrent to deluge by reading the torrent path from resume.dat
Pretty basic stuff.

But as I mentioned I don't use deluge anymore so I am not up to date with how it works or its limitations.
During times of universal deceit, telling the truth becomes a revolutionary act.
roisiano
New User
New User
Posts: 3
Joined: Sat Oct 21, 2017 9:03 am

Re: Migrate uTorrent to Deluge

Post by roisiano »

Cha0s wrote:The script is written in PHP, so you can run it pretty much on any OS that PHP supports.
If you are familiar with basic PHP you should be able to make the script work by editing it to fit your needs.
By default it only works on windows (it uses the wfio php module for windows). The original script (uploaded somewhere in the first posts on this thread) was for linux IIRC.

The script just reads the torrents added in uTorrent by parsing (BEdecode) resume.dat and loop through it.
For each iteration it simply runs deluge cli and tries to add the torrent to deluge by reading the torrent path from resume.dat
Pretty basic stuff.

But as I mentioned I don't use deluge anymore so I am not up to date with how it works or its limitations.
I think that's not the case :roll:

I can do "basic" actions like changing paths in the .php script... but not more than this:

Code: Select all

// Configuration Vars
$TORRENT_CLIENT = 'deluge'; //choose between 'deluge' and 'transmission'
$BITTORRENT_PATH = '/home/roisiano/Descargas'; // Path to resume.dat without the trailing slash (/)
$DELUGE = '/usr/bin/deluge'; // Path to deluge executable
$TRANSMISSION = '/usr/bin/transmission-remote'; // Path to transmission-remote executable
$TIME_TO_WAIT = 2; //time in seconds to wait between each torrent add.
// $WINDOWS_PATHS = array ('C:\\', 'V:\\');
// $LINUX_PATHS   = array ('/media/roisiano/W.7 H.P. x641/', '/media/roisiano/Datos/');

I copied resume.dat from Windows (Roaming/Utorrent) to /home/roisiano/Descargas in Ubuntu.
C:/ in Windows 7 --> /media/roisiano/W.7 H.P. x641 mounted in Ubuntu
V:/ in Windows 7 --> /media/roisiano/Datos mounted in Ubuntu


And executing the order in Ubuntu:
$ /usr/bin/php /home/roisiano/Descargas/resume_decode.php

The result:
PHP Warning: Illegal string offset 'path' in /home/roisiano/Descargas/resume_decode.php on line 54
PHP Warning: Illegal string offset 'path' in /home/roisiano/Descargas/resume_decode.php on line 61
Torrent File: /home/roisiano/Descargas/.fileguard
Save path:
[ERROR] !! NOT Adding to deluge! ...

(etc., etc., etc.)

until:
PHP Notice: Undefined variable: ERROR3 in /home/roisiano/Descargas/resume_decode.php on line 116

resume_decode.php used:

Code: Select all

<?php
/*
 * IMPORT ìTorrent/BitTorrent data to Deluge/Transmission
 *
 * Copyright (C) 2009 Eyaggelos Koutroumpas (Cha0s) <cha0s@cha0s.gr>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 dated June, 1991.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

 /*
   Use with php-cli
   e.g.: /usr/bin/php /path/to/resume_decode.php
   You will get some info of the progress.
   In the end you will have the data from print_r() which shows which 
   torrents could not be added for some readon (eg: wrong path).
   You can use this results to add the failed torrents manualy.
 */

// Configuration Vars
$TORRENT_CLIENT = 'deluge'; //choose between 'deluge' and 'transmission'
$BITTORRENT_PATH = '/home/roisiano/Descargas'; // Path to resume.dat without the trailing slash (/)
$DELUGE = '/usr/bin/deluge'; // Path to deluge executable
$TRANSMISSION = '/usr/bin/transmission-remote'; // Path to transmission-remote executable
$TIME_TO_WAIT = 2; //time in seconds to wait between each torrent add.
// $WINDOWS_PATHS = array ('C:\\', 'V:\\');
// $LINUX_PATHS   = array ('/media/roisiano/W.7 H.P. x641/', '/media/roisiano/Datos/');


require('./BDecode.php');
$content = file_get_contents( $BITTORRENT_PATH . '/resume.dat');
$info = BDecode($content);
unset($content);

$i1 = 0;
$i2 = 0;
$i3 = 0;
foreach($info as $key => $value){
	$SAVE_PATH = FALSE;
	$TORRENT_PATH = FALSE;
	$SAVE_PATH_expl = FALSE;
	
	if ($info[$key]['path']){
		
		// Clean paths first
		$TORRENT_PATH = $BITTORRENT_PATH . "/" . $key;
		$TORRENT_PATH = str_replace ("\\", "/", $TORRENT_PATH);
		// $TORRENT_PATH = escapeshellcmd ($TORRENT_PATH);
		
		$SAVE_PATH = $info[$key]['path'];
		// $SAVE_PATH = str_replace ($WINDOWS_PATHS[0], $LINUX_PATHS[0], $SAVE_PATH);
		// $SAVE_PATH = str_replace ($WINDOWS_PATHS[1], $LINUX_PATHS[1], $SAVE_PATH);
		// $SAVE_PATH = str_replace ($WINDOWS_PATHS[2], $LINUX_PATHS[2], $SAVE_PATH);
		// $SAVE_PATH = str_replace ($WINDOWS_PATHS[3], $LINUX_PATHS[3], $SAVE_PATH);
		$SAVE_PATH = str_replace ("\\", "/", $SAVE_PATH);
		// $SAVE_PATH = escapeshellcmd ($SAVE_PATH);
		$SAVE_PATH = strrev ($SAVE_PATH);
		$SAVE_PATH_expl = explode ("/", $SAVE_PATH);
		$SAVE_PATH_expl[0] = FALSE;
		$SAVE_PATH = implode ("/", $SAVE_PATH_expl);
		$SAVE_PATH = strrev ($SAVE_PATH);
		
		echo "Torrent File: " .  $TORRENT_PATH . "\n";
		echo "Save path: " . $SAVE_PATH . "\n";
		
		if ( is_file($BITTORRENT_PATH . "/" . $key) && is_dir ($SAVE_PATH) ){
			
			if (is_dir ($SAVE_PATH . $info[$key]['caption'])){
				// $TORRENT_PATH = str_replace (" ", "\\ ", $TORRENT_PATH);
				// $SAVE_PATH = str_replace (" ", "\\ ", $SAVE_PATH);
				
                if ($TORRENT_CLIENT == 'deluge'){
                    echo "Adding to deluge! ... \n";
					echo $DELUGE ." \"add -p \"\"".$SAVE_PATH. "\"\"\n\"\"". $TORRENT_PATH. "\"\"\"\n\n";
				    exec ($DELUGE ." \"add -p \"\"".$SAVE_PATH. "\"\" \"\"". $TORRENT_PATH. "\"\"\"");
                }elseif ($TORRENT_CLIENT == 'transmission'){
				    echo "transmission-remote --add --download-dir ".$SAVE_PATH. " ". $TORRENT_PATH. " \n\n";
                    exec ("transmission-remote --add --download-dir ".$SAVE_PATH. " ". $TORRENT_PATH );
                }

				sleep ($TIME_TO_WAIT);
		
			}else{
			echo "[ERROR] !! WRONG PATH  !! NOT Adding to ".$TORRENT_CLIENT."! ... \n\n\n";
			$ERROR[$i1] = $TORRENT_PATH;
			$i1++;
			}
		
		}else{
		echo "[ERROR] !! NOT Adding to ".$TORRENT_CLIENT."! ... \n\n\n";
		$ERROR2[$i2] = $TORRENT_PATH;
		$i2++;
		}
	
	}else{
	echo "[MAJOR ERROR] !! NO PATH?! ... \n\n\n";
	$ERROR3[$i3] = $TORRENT_PATH;
	$i3++;
	}
	
}

print_r ($ERROR);
print_r ($ERROR2);
print_r ($ERROR3);
?>
Post Reply