-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTorrentDownload_MoveFile_SFTP.py
More file actions
69 lines (53 loc) · 2.14 KB
/
TorrentDownload_MoveFile_SFTP.py
File metadata and controls
69 lines (53 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from qbittorrent import Client
import shutil
import paramiko
qb = Client('http://127.0.0.1:8080/')
qb.login('','')
def sftp_function():
#Host IP
host = '192.168.50.248'
#Host Port
port = 22
#Host Username
username = ''
#Host Password
password = ''
#Paramiko library connects via ssh to host parameters
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,port,username,password)
sftp = ssh.open_sftp()
print('Time for SFTP process')
localpath = full_destination
print(f'Pulling file from {full_destination}\n')
sftp_path = '/media/ntfs/'+ filename
print(f'File will be moved to directory of {sftp_path}\nPlease wait as the upload process completes...\n')
sftp.put(localpath,sftp_path)
print(f'File has been uploaded to {sftp_path}\nVerify the results')
sftp.close()
ssh.close()
torrent_path = input('Enter the torrent path:\n')
torrent_file = open(f'{torrent_path}', 'rb')
qb.download_from_file(torrent_file)
print('Time to move the files over.\nVerify the torrent progress is at 100%.\n')
status_progress= input('Is progress at 100%?\nEnter Y when ready:\n')
if status_progress == 'Y':
#Takes user input for the full source path
source = input('Enter the full source directory:\n')
#Takes user input for the full destination path
destination = '/home/gcotto/Downloads/temp/'
filename = input(f'\nFile will be moved to directory of {destination}\nEnter the new file name:\n')
full_destination = destination + filename
new_path = shutil.move(source,full_destination)
print(f'File has been moved to {full_destination}\n')
begin_sftp = input('Ready to begin the SFTP process?\nEnter "Y" to continue:\n')
if begin_sftp == 'Y':
sftp_function()
delete_input = input('Do you want to delete the torrent directory?\nEnter Y or N:\n')
if delete_input == 'Y':
file_path = input('Enter the directory to delete:\n')
try:
shutil.rmtree(file_path)
except OSError as e:
print("Error: %s : %s" % (file_path, e.strerror))
print('Process has completed\nExiting the program...')