<aside> 💡 A weakness with this is that the server or remote computer always needs to be on.

</aside>

<aside> 💡 This only works if you have key-based SSH authentication set up. do ssh copy id

</aside>

How to configure key-based authentication for SSH


import os
from datetime import date
import time

time.sleep(4) # a little pause so that the system has time to create the file

# just used chat gtp for this 
def get_newest_mp4_file(directory):
    files = os.listdir(directory)
    mp4_files = [file for file in files if file.endswith(".mp4")]
    if mp4_files:
        newest_file = max(mp4_files, key=lambda x: os.path.getmtime(os.path.join(directory, x)))
        return newest_file
    else:
        return None

ssh_host = "192.168.0.xxx" # ip of the remote server
ssh_username = " " + "remote_username" # remote user, the first bit just leaves a space 

current_date = date.today() 
formatted_date = current_date.strftime("%Y-%m-%d") # the the formating right

video_file_placement = "/data/media/sda4/" 
filename = get_newest_mp4_file(video_file_placement + formatted_date) # gets the newest file form folder right folder
file = video_file_placement + formatted_date + "/" + filename # gets the right file 

remote_host_placment = "~/Desktop/" # path on remote host

# Her it is possile to add a idendety file to your command --> -i "path_to_file"
os.system("scp " + file + ssh_username + "@" + ssh_host + ":" + remote_host_placment) #send the right file with scp

Google-drive