Functionality fixes
- Handle permissions correctly - Ensure the right key is fetched for the torrent files - Stop and delete the torrent upon move
This commit is contained in:
parent
bce5d25000
commit
7da53cc393
1 changed files with 10 additions and 4 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue