RSS plugin should use guid for history management
Please complete the following tasks.
- [X] Web browser cache cleared
- [X] Link provided to install script if applicable
- [X] Not using broken rtinst install script
- [X] Web browser, ruTorrent, PHP and OS version provided
Tell us about your environment
ruTorrent: v4.2.9
Tell us how you installed ruTorrent
using https://github.com/crazy-max/docker-rtorrent-rutorrent/releases/tag/4.2.9-0.9.8_2-0.13.8_2-r0
Describe the bug
Using rss plugin with feed which sometimes changes final link maintaining the same guid (like Jackett does), history is not managed the correct way because it refers to final download url (link element) instead of guid which (if present and valid) shuold be used as history reference because is unique and it doesn't change.
Steps to reproduce
- add rss feed from jackett
- load some torrent -> torrent are loaded and marked as loaded in the UI
- wait a couple of hours
- reload feed
- torrent previous loaded not marked as loaded anymore since link element has changed (for the same torrents already loaded)
Expected behavior
rss plgin shuold handle correctly the torrent already loaded. This bug causes also rssmanager is not working properly because if the torrent has been already loaded, completed and removed from active torrent list, it is loaded again.
Additional context
No response
@de666 Thanks for this!
Currently, the <link> is used to identify a rss item.
However, according to the spec, using the <guid> as the item-identifer instead, seems to be correct:
https://www.rssboard.org/rss-specification#hrelementsOfLtitemgt
I am not sure if only changing rRSSHistory will be enough, though:
https://github.com/Novik/ruTorrent/blob/2d67a00b4fde90b4a652c130ed76ac2fc4383fb3/plugins/rss/rss.php#L301
If no one else wants to take this on, I think, I would, eventually.
@TrimmingFool Version 4.3 will be released in the near future. Would you like to sneak this important change in?
Is this related to this problem that same torrent gets added over and over again?
I think so, that was the same issue I had and I came up to the conclusion that was the reason. Indeed it make sense when you have an RSS with links which change every time even if pointing to the same torrent hash.
Torrent hash is not always present in RSS, that's why I suggested to use guid as torrent identifier and I think it should be used as is, without checking also other fields like date (as you pointed out).
Anyway, assuming the following:
- guid filed is unique (otherwise the RSS is malformed)
- guid is not necessarly a valid link, I saw some RSS with torrent hash in guid
- when guid is not present, url/link can be used in place of guid (the current plugin implementaion already do this)
The behaviour shuold be:
- If guid is present, do not check or modify the guid (current behaviour has to be modified) https://github.com/Novik/ruTorrent/blob/25679a45a1e2ca9f7a9e01cab5cc554b8eaa7230/plugins/rss/rss.php#L216
- Manage and store internally both guid and link/url (this is already done) https://github.com/Novik/ruTorrent/blob/25679a45a1e2ca9f7a9e01cab5cc554b8eaa7230/plugins/rss/rss.php#L196 https://github.com/Novik/ruTorrent/blob/25679a45a1e2ca9f7a9e01cab5cc554b8eaa7230/plugins/rss/rss.php#L197
- Use guid as torrent internal dictionary key (currently link is used and should be changed to guid, whatever it is) https://github.com/Novik/ruTorrent/blob/25679a45a1e2ca9f7a9e01cab5cc554b8eaa7230/plugins/rss/rss.php#L221
- When checking if torrent was already loaded or marked check ONLY the guid (dictionary key)
I think this will cover all the use cases
I have used my change for some time now and guid is saved to file. I forget that this was added to development branch so after every update I find out that the torrents I already deleted getting added again because the guid checking is missing from master branch. I dont even really know why did this go to development branch. It was not that big of a change and only thing it did is add guid to the history file and add checking if the guid exist and if not check by url like always. For my opinion my addition did exactly what OP asked for.
I dont even really know why did this go to development branch.
Everything in the development branch goes to master eventually. I'm just waiting for some work to be completed on the port checker plugin to tag ruTorrent v5.3. Your addition will be included in that release.
For my opinion my addition did exactly what OP asked for.
There is a criteria for hotfixes. Your addition requires a minor version bump.