I’m out of my depth but really want to include a card on my dashboard the lists the last 10 items Transmission has completed. I have the Transmission integration working and I know the even transmission_downloaded_torrent will list the name of the torrent. I also believe this post shows how to do what I want, but I can’t quite work out what I need to change!!
That has worked an absolute treat!
I have 1 follow up question, which probably isn’t even possible but is there a way to trim the result?
So as an example the download in questions are…
example (2020) season 1 (1080p bla bla bla)
example (2021) season 2 729p bla bla bla
example (2022) season 3 (420p bla bla bla)
I want to trim the end of the torrent name to make it a bit tidier, so it just shows:
example (2020) season 1
example (2021) season 2
example (2022) season 3
I know this is increadably picky but my OCD is kicking in now
That’s fine in theory, but there are a lot of variables to consider.
What if i download something called:
Another example (2020) season 1 729p bla bla bla
That’s only going to show: “Another example (2020)” which isn’t what i want
I think i would need to slice it after either 1080p, 720p or 480p (and the preceeding ‘(’ if there is one).
Nobody knows what those “variables” are so you will have to provide numerous examples so that we can examine them and devise a technique that always truncates the string correctly. Fact is, that can be a challenge in itself, apart from your original request to simply record and display the last 10 downloads.
Given that 1080p, 720p and 480p end with 0p followed by a space, this version truncates the name immediately after the first occurance of 0p so it should work the way you requested.
|Name||Time|
|:----|:-:|:----|
{% for x in state_attr('sensor.recent_torrent_downloads', 'downloads') | default([], true) -%}
|{{x.name[:x.name.find('0p ') + 2]}}||{{x.time|as_timestamp|timestamp_custom}}|
{% endfor -%}