Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import shutil
- import requests
- # set variables for connecting to uTorrent web UI
- port = 8080
- username = 'admin'
- password = 'Bza98990'
- # set action urls
- list_url = 'http://http://127.0.0.1:8080/gui/'
- # open IRL to get data
- r = requests.get(list_url, auth=(username, password))
- # set Source and destination folder
- SRC_DIR = 'D:\\Source\\'
- DES_DIR = 'D:\\Destination\\'
- # set what lind of files not to copy
- DENY_EXT = ('.txt', '.pdf', '.torrent','.exe', '.zip', '.docx','.iso', '.pptx',
- '.jpg', '.png', '.xlsx')
- # function to decide if folder or file already exists in destination folder
- def get_move_list():
- result = list()
- src_list = os.listdir(SRC_DIR)
- des_list = os.listdir(DES_DIR)
- for file in src_list:
- if not file.endswith(DENY_EXT):
- if file not in des_list:
- result.append(file)
- return result
- # check if file or folder is fully downloaded
- def completed_download(move_list):
- contol_list = []
- for torrent in move_list:
- if finished_torrent = str(torrent).find('100.0 %'):
- return torrent
- else:
- continue
- # copies the folders and files
- def move_file(controled_move_list):
- for file controled_move_list:
- try:
- shutil.copytree(SRC_DIR + file, DES_DIR + file, symlinks=False,
- ignore=None, ignore_dangling_symlinks=False)
- except OSError:
- shutil.copy(SRC_DIR + file, DES_DIR + file)
- print('Copy of ' + file + ' completed.')
- if __name__ == '__main__':
- move_list = get_move_list()
- controled_move_list = completed_download()
- move_file(move_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement