diff --git a/transmission_move_music.py b/transmission_move_music.py index 7b79387..698e2af 100644 --- a/transmission_move_music.py +++ b/transmission_move_music.py @@ -49,7 +49,7 @@ class FileType(Enum): if self is FileType.music: return Path("/home/storage/music/Anime/") elif self is FileType.video: - return Path("/home/storage/video/Anime/") + return Path("/home/storage/video/") elif self is FileType.application: return Path("/home/storage/applications/") elif self is FileType.image: @@ -78,10 +78,12 @@ def main(): assert source.exists() client = transmissionrpc.Client("localhost", port=9091, - username="transmission", password=rpc_pass) + user="transmission", password=rpc_pass) + # Returns a dictionary with the torrent_id as key + filelist = client.get_files(torrent_id)[int(torrent_id)] filelist = {filelist[item]["name"]: filelist[item]["size"] for item in - client.get_files(torrent_id)} + filelist} filetype = FileType.detect(filelist) @@ -92,9 +94,13 @@ def main(): dest_path = destination / source.name source.rename(dest_path) - permissions = dest_path.st_mode | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH + + permissions = dest_path.stat().st_mode + permissions = permissions | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH dest_path.chmod(permissions) + client.stop_torrent(torrent_id) + client.remove_torrent(torrent_id) print("Moved {} to {}".format(source, dest_path))