Fixed the Query errors, added verify torrent

This commit is contained in:
Louis Lacoste 2022-10-11 16:24:07 +02:00
parent 9fdcebb067
commit eac1527d49

View file

@ -61,25 +61,50 @@ if verbose:
incompleteTorrentsList = [ incompleteTorrentsList = [
torrent for torrent in transmissionClient.get_torrents() if torrent.available != 100.0] torrent for torrent in transmissionClient.get_torrents() if torrent.available != 100.0]
# for incompleteTorrent in incompleteTorrentsList: lenIncompleteList = len(incompleteTorrentsList)
# print("------")
# print( for index, incompleteTorrent in enumerate(incompleteTorrentsList):
# f"Torrent name: {incompleteTorrent.name}\nTorrent data location: {incompleteTorrent.download_dir}") print(f"---{index:03d}/{lenIncompleteList} | {index/lenIncompleteList*100:.2f}%---")
print(
f"Torrent name: {transmissionClient.get_torrents()[1].name}\nTorrent data location: {transmissionClient.get_torrents()[1].download_dir}") # Extracting torrent ID, we'll use it because it doesn't change
newPath = input("Please enter the FULL PATH of the downloaded file: ") torrentId = incompleteTorrent.id
torrentId = transmissionClient.get_torrents()[1].id
filename = os.path.basename(newPath)
folderPath = pathlib.Path(os.path.dirname(newPath))
print(folderPath)
print(
f"After renaming, id: {torrentId} Torrent name: {filename}\nTorrent data location: {folderPath}")
if input("Validate? (y/N)").lower() == "y":
transmissionClient.move_torrent_data(ids=torrentId, location=folderPath)
#transmissionClient.rename_torrent_path(
# torrent_id=torrentId, location=transmissionClient.get_torrents()[1].download_dir, name=filename)
print( print(
f"Torrent name: {transmissionClient.get_torrents()[1].name}\nTorrent data location: {transmissionClient.get_torrents()[1].download_dir}") f"Torrent name: {transmissionClient.get_torrent(torrentId).name}\nTorrent data location: {transmissionClient.get_torrent(torrentId).download_dir}")
else: newPath = input("Please enter the FULL PATH of the downloaded file: ")
filename = os.path.basename(newPath)
folderPath = pathlib.Path(os.path.dirname(newPath))
print(folderPath)
print(
f"After renaming, id: {torrentId} \nNew torrent name: {filename}\nNew torrent data location: {folderPath}")
if input("Validate? (y/N)").lower() == "y":
# Changing the directory containing the data
transmissionClient.move_torrent_data(
ids=torrentId, location=folderPath)
# Retrieving the torrent name to change it
fileToRename = transmissionClient.get_torrent(torrentId).name.strip()
# If we do not strip it won't work
# the problem seems to occur because of trailing whitespaces
if verbose:
print(fileToRename)
print(transmissionClient.get_torrent(torrentId))
# Renaming the torrent
transmissionClient.rename_torrent_path(
torrentId, fileToRename, filename)
print(
f"Torrent name: {transmissionClient.get_torrent(torrentId).name}\nTorrent data location: {transmissionClient.get_torrent(torrentId).download_dir}")
if verbose:
print(
f"Verifying {transmissionClient.get_torrent(torrentId).name} data on {transmissionClient.get_torrent(torrentId).download_dir}.")
try:
transmissionClient.verify_torrent(torrentId)
except Exception as e:
print(
f"An error occured while verifying the data on the provided download directory : {e}")
else:
print("Skipping") print("Skipping")