1
This commit is contained in:
156
steampozor/steampozor
Executable file
156
steampozor/steampozor
Executable file
@ -0,0 +1,156 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from stat import S_ISDIR
|
||||
import paramiko
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
HOST = '192.168.89.4'
|
||||
PORT = 22
|
||||
|
||||
VERSION = '0.1.0'
|
||||
AUTHORS = 'SaddyDEAD'
|
||||
|
||||
PATH_ON_SERVER='/games/SteamLibrary/steamapps/common'
|
||||
PATH_ON_PC='/home/saddydead/.local/share/Steam/steamapps/common'
|
||||
LIST_STEAM_FILES=[
|
||||
'SteamLinuxRuntime',
|
||||
'SteamLinuxRuntime_soldier',
|
||||
'SteamLinuxRuntime_sniper',
|
||||
'Proton - Experimental',
|
||||
'Steam.dll'
|
||||
]
|
||||
|
||||
ART = '''
|
||||
███████╗████████╗███████╗ █████╗ ███╗ ███╗██████╗ ██████╗ ███████╗ ██████╗ ██████╗
|
||||
██╔════╝╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██╔══██╗██╔═══██╗╚══███╔╝██╔═══██╗██╔══██╗
|
||||
███████╗ ██║ █████╗ ███████║██╔████╔██║██████╔╝██║ ██║ ███╔╝ ██║ ██║██████╔╝
|
||||
╚════██║ ██║ ██╔══╝ ██╔══██║██║╚██╔╝██║██╔═══╝ ██║ ██║ ███╔╝ ██║ ██║██╔══██╗
|
||||
███████║ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██║ ╚██████╔╝███████╗╚██████╔╝██║ ██║
|
||||
╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝
|
||||
'''
|
||||
|
||||
clear = lambda: os.system('clear')
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.load_system_host_keys()
|
||||
ssh.connect(HOST)
|
||||
client = ssh.open_sftp()
|
||||
|
||||
def print_hat():
|
||||
clear()
|
||||
print(ART)
|
||||
print('______________________________________________________________________________________')
|
||||
print(f'''
|
||||
created by {AUTHORS}
|
||||
version - {VERSION}
|
||||
''')
|
||||
print('______________________________________________________________________________________')
|
||||
|
||||
def print_action():
|
||||
print('Choose action:')
|
||||
print('''
|
||||
1) Download game
|
||||
2) Exit
|
||||
''')
|
||||
print('______________________________________________________________________________________')
|
||||
|
||||
def list_games():
|
||||
return delete_not_games(client.listdir(path=PATH_ON_SERVER))
|
||||
|
||||
def delete_not_games(inplist: list):
|
||||
result = inplist.copy()
|
||||
for i in inplist:
|
||||
for j in LIST_STEAM_FILES:
|
||||
if i == j:
|
||||
result.remove(i)
|
||||
return list(result)
|
||||
|
||||
def get_recursive(path, dest, pbar):
|
||||
item_list = client.listdir_attr(path)
|
||||
dest = str(dest)
|
||||
if not os.path.isdir(dest):
|
||||
os.makedirs(dest, exist_ok=True)
|
||||
for item in item_list:
|
||||
mode = item.st_mode
|
||||
if S_ISDIR(mode):
|
||||
get_recursive(path + "/" + item.filename, dest + "/" + item.filename, pbar)
|
||||
else:
|
||||
client.get(path + "/" + item.filename, dest + "/" + item.filename, callback=pbar)
|
||||
|
||||
def choose_game():
|
||||
while True:
|
||||
clear()
|
||||
print_hat()
|
||||
|
||||
print('Choose game:')
|
||||
|
||||
index = 0
|
||||
games = list_games()
|
||||
for j in games:
|
||||
print(f'{index}) {j}')
|
||||
index+=1
|
||||
|
||||
print('C to cancel')
|
||||
|
||||
inp = input('-> ')
|
||||
|
||||
if inp == 'c' or inp == 'C':
|
||||
return
|
||||
else:
|
||||
try:
|
||||
if int(inp) not in range(index):
|
||||
continue
|
||||
except:
|
||||
continue
|
||||
|
||||
if os.path.exists(f'{PATH_ON_PC}/{games[int(inp)]}'):
|
||||
clear()
|
||||
print_hat()
|
||||
|
||||
print()
|
||||
print('GAME ALREADY EXISTS')
|
||||
print()
|
||||
input('Press any key to exit')
|
||||
return
|
||||
|
||||
download_game(games[int(inp)])
|
||||
|
||||
return
|
||||
|
||||
def download_game(game):
|
||||
clear()
|
||||
print_hat()
|
||||
|
||||
print(f'Downloading {game}...')
|
||||
|
||||
with tqdm(unit='iB', unit_scale=True, unit_divisor=1024) as pbar:
|
||||
def progress(amt, tot):
|
||||
pbar.total = tot
|
||||
pbar.update(amt - pbar.n)
|
||||
get_recursive(f'{PATH_ON_SERVER}/{game}', f'{PATH_ON_PC}/{game}', progress)
|
||||
|
||||
print()
|
||||
input('Press any key to exit')
|
||||
|
||||
def main():
|
||||
print_hat()
|
||||
|
||||
print_action()
|
||||
|
||||
inp = input('-> ')
|
||||
|
||||
if inp == '1':
|
||||
choose_game()
|
||||
elif inp == '2':
|
||||
clear()
|
||||
client.close()
|
||||
exit()
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
main()
|
||||
Reference in New Issue
Block a user