Execute auto upload after complete

Suggest, post, or discuss plugins for Deluge
ludothegreat
Member
Member
Posts: 12
Joined: Tue Oct 26, 2010 7:08 am

Re: Execute auto upload after complete

Post by ludothegreat »

Cas wrote:You could create a simple python script using ftplib. Read the wiki and ftplib example for some help.
Heading off to work, I'll check out the links there. Thanks!
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute auto upload after complete

Post by Cas »

Depending on your python experience you might find using a bash script easier.

http://www.linuxconfig.org/example-of-s ... ipt-client
ludothegreat
Member
Member
Posts: 12
Joined: Tue Oct 26, 2010 7:08 am

Re: Execute auto upload after complete

Post by ludothegreat »

Bash I am more comfortable with. Thanks for both the links!
ludothegreat
Member
Member
Posts: 12
Joined: Tue Oct 26, 2010 7:08 am

Re: Execute auto upload after complete

Post by ludothegreat »

That bash script is exactly what I need.

My only question is if $1 will only upload the files/folders that just finished per the torrent or if it will dump everything in my "completed" dir?

Code: Select all

#!/bin/bash

ftp_site=myhostname
username=myusername
passwd=mypass

PS3='Select a destination directory: ' 

# bash select
select path in "." "public_html/" "public_html/myblog/" "backup/images/" 
do
ftp -in <<EOF
open $ftp_site
user $username $passwd
cd ]$path
put $1
close 
bye
EOF
echo $1 uploaded to $path ! 

# Break, otherwise endless loop
  break  
done
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute auto upload after complete

Post by Cas »

it will be on a per torrent basis but i think you need $2 to get the file name.

it would be easier for you to code if you use variables set to those args at the top of your script

Code: Select all

torrentid=$1
torrentname=$2
torrentpath=$3
ludothegreat
Member
Member
Posts: 12
Joined: Tue Oct 26, 2010 7:08 am

Re: Execute auto upload after complete

Post by ludothegreat »

so something like this:

Code: Select all

#!/bin/bash

ftp_site=myhostname
username=myusername
passwd=mypass
torrentpath=$1

PS3='Select a destination directory: ' 

# bash select
select path in "." "public_html/" "public_html/myblog/" "backup/images/" 
do
ftp -in <<EOF
open $ftp_site
user $username $passwd
cd $path
put $1
close 
bye
EOF
echo $1 uploaded to $path ! 

# Break, otherwise endless loop
  break  
done
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute auto upload after complete

Post by Cas »

those 3 args $1, $2, $3 are fixed arguments passed to the script every time. you need to use $2 which is the torrent name not torrentid.

I have done a quick edit of the code but i have not tested it

Code: Select all

#!/bin/bash

ftp_site=myhostname
username=myusername
passwd=mypass

torrentid=$1
torrentname=$2
torrentpath=$3

ftp -in <<EOF
open $ftp_site
user $username $passwd
cd $torrentpath
put $torrentname
close 
bye
EOF
echo $torrentname uploaded to $path ! 

ludothegreat
Member
Member
Posts: 12
Joined: Tue Oct 26, 2010 7:08 am

Re: Execute auto upload after complete

Post by ludothegreat »

I'll give it a shot, thank you a ton for the help!

I've also been looking at other protocols to use. SCP seems to look pretty handy, but what syntax to use in order to get the right files is where I'm getting confused. Is this what I want to do in order to transfer the files/folders via SCP?

Code: Select all

scp -r $torrentid user:pass@mediabox.com ~/
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute auto upload after complete

Post by Cas »

ssh will not allow passwords from scripts, for obvious security reasons, so the only way is to create a ssh key and put it on the seed box and host an ssh daemon on your windows box with cygwin.

scp <source> <destination>

e.g.

scp $torrentname user@192.168.0.1:/home/user/destdir

($torrentid is not the filename)
ludothegreat
Member
Member
Posts: 12
Joined: Tue Oct 26, 2010 7:08 am

Re: Execute auto upload after complete

Post by ludothegreat »

Cas wrote:ssh will not allow passwords from scripts, for obvious security reasons, so the only way is to create a ssh key and put it on the seed box and host an ssh daemon on your windows box with cygwin.

scp <source> <destination>

e.g.

scp $torrentname user@192.168.0.1:/home/user/destdir

($torrentid is not the filename)
Awesome, this is all doable as well. Looks like I have some options to play with here. Now to just get off work and test everything out.
Post Reply