Skip to content

Commit

Permalink
fix(export): Un-imported files not deselected
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatterson committed Oct 11, 2024
1 parent 86b1965 commit 77bf36b
Show file tree
Hide file tree
Showing 21 changed files with 172 additions and 77 deletions.
1 change: 1 addition & 0 deletions src/prunerr/downloadclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ def add_torrent(
self,
self.client.add_torrent(torrent=response.raw, **kwargs),
)
added_torrent.update()
self.items.append(added_torrent)
return added_torrent

Expand Down
32 changes: 18 additions & 14 deletions src/prunerr/downloaditem.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ def __init__(self, download_client, torrent):
Reconstitute the native Python representation.
"""
self.download_client = download_client
super().__init__(fields=torrent.fields)
self.files = []
self.files_by_relative = {}
for rpc_file in super().get_files():
item_file = PrunerrDownloadItemFile(self, rpc_file)
self.files.append(item_file)
self.files_by_relative[item_file.relative] = item_file
super(utils.PrunerrComponent, self).__init__(fields=torrent.fields)
self.update(torrent)

@property
def details(self) -> dict:
Expand All @@ -73,17 +68,26 @@ def details(self) -> dict:
details["imported"] = f"{round(self.imported_portion * 100)}%"
return details

def update(self):
def update(self, torrent: typing.Optional[transmission_rpc.Torrent] = None):
"""
Update cached values when this download item is updated.
:param torrent: The underlying torrent object from ``transmission_rpc``.
"""
super().update()
super(utils.PrunerrComponent, self).__init__(
fields=self.download_client.client.get_torrent(
if torrent is None:
torrent = self.download_client.client.get_torrent(
self.fields["hashString"],
).fields,
)
self.clear()
)
super(utils.PrunerrComponent, self).__init__(fields=torrent.fields)

self.files = []
self.files_by_relative = {}
for rpc_file in super().get_files():
item_file = PrunerrDownloadItemFile(self, rpc_file)
self.files.append(item_file)
self.files_by_relative[item_file.relative] = item_file

super().update()

def clear(self):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,71 +1,9 @@
{
"arguments": {
"torrent-added": {
"addedDate": 0,
"bandwidthPriority": 0,
"doneDate": 0,
"downloadDir": "/media/Library/seeding/Sonarr/Videos/Series",
"error": 0,
"errorString": "",
"eta": -1,
"files": [
{
"bytesCompleted": 0,
"length": 1073741824,
"name": "Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER/Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER.mkv"
},
{
"bytesCompleted": 0,
"length": 10240,
"name": "Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER/Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER.nfo"
}
],
"fileStats": [
{
"bytesCompleted": 0,
"priority": 0,
"wanted": true
},
{
"bytesCompleted": 0,
"priority": 0,
"wanted": true
}
],
"id": 2,
"isFinished": false,
"isStalled": true,
"leftUntilDone": 0,
"metadataPercentComplete": 1,
"name": "Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER",
"hashString": "8b8060bf22c942b1b6cabb8e5b840e445b840e44",
"peersConnected": 0,
"peersGettingFromUs": 0,
"peersSendingToUs": 0,
"percentDone": 1,
"priorities": [0, 0],
"queuePosition": 2,
"rateDownload": 0,
"rateUpload": 0,
"recheckProgress": 0,
"seedRatioLimit": 4,
"seedRatioMode": 0,
"sizeWhenDone": 1073741824,
"startDate": 0,
"status": 6,
"totalSize": 1073741824,
"trackers": [
{
"announce": "udp://tracker.private.example.com:6969/announce",
"id": 0,
"scrape": "udp://tracker.private.example.com:6969/scrape",
"tier": 0
}
],
"uploadRatio": 0,
"uploadedEver": 0,
"wanted": [1, 1],
"webseedsSendingToUs": 0
"hashString": "8b8060bf22c942b1b6cabb8e5b840e445b840e44"
}
},
"result": "success"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"arguments": {
"fields": [
"activityDate",
"addedDate",
"bandwidthPriority",
"comment",
"corruptEver",
"creator",
"dateCreated",
"desiredAvailable",
"doneDate",
"downloadDir",
"downloadedEver",
"downloadLimit",
"downloadLimited",
"editDate",
"error",
"errorString",
"eta",
"etaIdle",
"files",
"fileStats",
"hashString",
"haveUnchecked",
"haveValid",
"honorsSessionLimits",
"id",
"isFinished",
"isPrivate",
"isStalled",
"labels",
"leftUntilDone",
"magnetLink",
"manualAnnounceTime",
"maxConnectedPeers",
"metadataPercentComplete",
"name",
"peer-limit",
"peers",
"peersConnected",
"peersFrom",
"peersGettingFromUs",
"peersSendingToUs",
"percentDone",
"pieces",
"pieceCount",
"pieceSize",
"priorities",
"queuePosition",
"rateDownload",
"rateUpload",
"recheckProgress",
"secondsDownloading",
"secondsSeeding",
"seedIdleLimit",
"seedIdleMode",
"seedRatioLimit",
"seedRatioMode",
"sizeWhenDone",
"startDate",
"status",
"trackers",
"trackerStats",
"totalSize",
"torrentFile",
"uploadedEver",
"uploadLimit",
"uploadLimited",
"uploadRatio",
"wanted",
"webseeds",
"webseedsSendingToUs"
],
"ids": ["8b8060bf22c942b1b6cabb8e5b840e445b840e44"]
},
"method": "torrent-get"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"arguments": {
"torrents": [
{
"addedDate": 0,
"bandwidthPriority": 0,
"doneDate": 0,
"downloadDir": "/media/Library/seeding/Sonarr/Videos/Series",
"error": 0,
"errorString": "",
"eta": -1,
"files": [
{
"bytesCompleted": 0,
"length": 1073741824,
"name": "Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER/Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER.mkv"
},
{
"bytesCompleted": 0,
"length": 10240,
"name": "Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER/Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER.nfo"
}
],
"fileStats": [
{
"bytesCompleted": 0,
"priority": 0,
"wanted": true
},
{
"bytesCompleted": 0,
"priority": 0,
"wanted": true
}
],
"id": 2,
"isFinished": false,
"isStalled": true,
"leftUntilDone": 0,
"metadataPercentComplete": 1,
"name": "Foo.Series.1970.S01E02.Grault.Episode.Title.WEB-DL.x265.HEVC-RELEASER",
"hashString": "8b8060bf22c942b1b6cabb8e5b840e445b840e44",
"peersConnected": 0,
"peersGettingFromUs": 0,
"peersSendingToUs": 0,
"percentDone": 1,
"priorities": [0, 0],
"queuePosition": 2,
"rateDownload": 0,
"rateUpload": 0,
"recheckProgress": 0,
"seedRatioLimit": 4,
"seedRatioMode": 0,
"sizeWhenDone": 1073741824,
"startDate": 0,
"status": 6,
"totalSize": 1073741824,
"trackers": [
{
"announce": "udp://tracker.private.example.com:6969/announce",
"id": 0,
"scrape": "udp://tracker.private.example.com:6969/scrape",
"tier": 0
}
],
"uploadRatio": 0,
"uploadedEver": 0,
"wanted": [1, 1],
"webseedsSendingToUs": 0
}
]
},
"result": "success"
}

0 comments on commit 77bf36b

Please sign in to comment.