kannibalox / pyrosimple

An overhauled fork of the pyrocore tools for rTorrent
https://kannibalox.github.io/pyrosimple/
GNU General Public License v3.0
52 stars 5 forks source link

custom fields #5

Closed TMD20 closed 2 years ago

TMD20 commented 2 years ago

I'm been looking through this code for a bit.

I think I'm starting to understand how it works a little bit. From what I can tell There is a class called torrentproxy, that stores some information on how to retrieve data from rtorrent via a descriptor class

The issue that I am seeing is that the fielddescriptor object created for a custom class . Does not have the right query setup

For example

command rtcontrol ratio=+0 custom_1=TV


At this line I added a print statement
        if rpc_fields is not None:
            self._rpc_cache.update(rpc_fields)
        if "hash" not in fields:
            self._fields["hash"] = self.rpc_call("d.hash")
        print(rpc_fields)

{'d.complete': 0, 'd.completed_bytes': 0, 'd.custom=1': '', 'd.custom=memo_alias': '', 'd.down.rate': 0, 'd.hash': '2345D93204EA6A904D0CAF60791D79C20E270943', 'd.is_active': 0, 'd.is_open': 0, 'd.is_private': 1, 'd.name': 'Vengeance.2022.BluRay.1080p.DTS-HD.MA.5.1.AVC.REMUX-FraMeSToR', 'd.priority': 0, 'd.ratio': 0, 'd.size_bytes': 30879977086, 'd.throttle_name': '', 'd.up.rate': 0}

d.custom=1 is not being set for some reason

`            for item in raw_items:
                ritem = RtorrentItem(
                    self,
                    fields={},
                    rpc_fields=dict(zip(args, item)),
                )

                if view.matcher:
                    if view.matcher.match(ritem):
                        items.append(ritem)
                        yield items[-1]
                else:
                    items.append(ritem)
                    yield items[-1]`

This ends up with no items being added The end result is an empty list

I can get it to work by switching this line accessor=lambda o: o.rpc_call("d.custom", [custom_name]), to accessor=lambda o: o.rpc_call(f"d.custom{custom_name}"),

kannibalox commented 2 years ago

Yep, your understanding is correct and this was indeed a bug. The tricky part is that d.custom1 and d.custom=1 are two distinct values, and the code wasn't properly distinguishing between the two. Now the custom_1 field should always reference d.custom1 as expected.