Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. import os
  2. import shutil
  3. import requests
  4.  
  5. # set variables for connecting to uTorrent web UI
  6. port = 8080
  7. username = 'admin'
  8. password = 'Bza98990'
  9.  
  10. # set action urls
  11. list_url = 'http://http://127.0.0.1:8080/gui/'
  12.  
  13. # open IRL to get data
  14. r = requests.get(list_url, auth=(username, password))
  15.  
  16. # set Source and destination folder
  17. SRC_DIR = 'D:\\Source\\'
  18. DES_DIR = 'D:\\Destination\\'
  19.  
  20. # set what lind of files not to copy
  21. DENY_EXT = ('.txt', '.pdf', '.torrent','.exe', '.zip', '.docx','.iso', '.pptx',
  22.             '.jpg', '.png', '.xlsx')
  23.  
  24. # function to decide if folder or file already exists in destination folder
  25. def get_move_list():
  26.     result      = list()
  27.     src_list    = os.listdir(SRC_DIR)
  28.     des_list    = os.listdir(DES_DIR)
  29.  
  30.     for file in src_list:
  31.         if not file.endswith(DENY_EXT):
  32.  
  33.             if file not in des_list:
  34.                 result.append(file)
  35.  
  36.     return result
  37.  
  38. # check if file or folder is fully downloaded
  39. def completed_download(move_list):
  40.     contol_list = []
  41.     for torrent in move_list:
  42.         if finished_torrent = str(torrent).find('100.0 %'):
  43.             return torrent
  44.         else:
  45.             continue
  46.  
  47. # copies the folders and files
  48. def move_file(controled_move_list):
  49.     for file controled_move_list:
  50.         try:
  51.             shutil.copytree(SRC_DIR + file, DES_DIR + file, symlinks=False,
  52.                             ignore=None, ignore_dangling_symlinks=False)
  53.         except OSError:
  54.             shutil.copy(SRC_DIR + file, DES_DIR + file)
  55.  
  56.         print('Copy of ' + file + ' completed.')
  57.  
  58.  
  59. if __name__ == '__main__':
  60.     move_list = get_move_list()
  61.     controled_move_list = completed_download()
  62.     move_file(move_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement