Deluge Label non-latin letter issue

Suggestions and discussion of future versions
Post Reply
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Deluge Label non-latin letter issue

Post by nemonein »

Hello.
I do not know that this is the right place to report this issue. If it is not appropriate, please excuse my ignorance.
Last year I reported this issue to transdroid team in July 2020, and they gave me an answer TODAY, that this might be an issue of DELUGE WEB-UI.

----
I'm using Deluge 2.0.3 on Ubuntu as a server(deluged) and thin client(Arch/KDE Neon, transdroid, etc).

There's a problem is on Label feature.
It's impossible to create(add) Label with non-latin characters(I tried with Korean, Chinese, and Japanese letters) on a thin client.
If I tried to add a label with those letters, it's silently ignored. It means, Label 'Music' is ok, but '음악' is not.
However, after creating a label with English(for example 'Music'), then I can manually edit the label.conf file, /var/lib/deluge/.config/deluge/label.conf(Music ➙ 음악), something like this.

Code: Select all

        "음악": {
            "apply_max": false,
            "apply_move_completed": true,
            "apply_queue": false,
            "auto_add": false,
            "auto_add_trackers": [],
            "is_auto_managed": false,
            "max_connections": -1,
            "max_download_speed": -1.0,
            "max_upload_slots": -1,
            "max_upload_speed": -1.0,
            "move_completed": true,
            "move_completed_path": "/Torrent/음악",
            "prioritize_first_last": false,
            "remove_at_ratio": false,
            "stop_at_ratio": false,
            "stop_ratio": 2.0
        },
Then, Deluge thin client works well with these labels.
But transdroid does not. Non-latin Labels are shown well on transdroid, but I could not set the label to a torrent.

As I said before, transdroid team says this might be related to deluge web-ui.
I hope you can find what is wrong and fix this.

Thank you for reading.
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge Label non-latin letter issue

Post by mhertz »

I honestly don't know anything about this, but quick peek at transdroid source looks like they use webUI json-rpc call 'label.set_torrent', which is the exact same as used when from deluge webUI adding a label to torrent, and which works with your example non-latin label, so the call works. It needs to be added to config file manually as you stated, because a check is in the code for needing match '[a-z0-9_-]' when adding new label, as else not saved to config-file, which we override by doing it manually. We can remove that part, but not helping this issue here with transdroid.

Btw, here's the formated call the webUI uses for your example non-latin label:

Code: Select all

i18:51:10.516 [DEBUG   ][deluge.ui.web.json_api     :202 ] json-request: b'{"method":"label.set_torrent","params":["287ce5be250c6613ab6021c4a483cbfc672683f8","\xec\x9d\x8c\xec\x95\x85"],"id":384}'
Would be interesting seeing what transdroid sends, I mean how call formated so failing, so I'd suggest enabling debug-logging for webUI(deluge-web -L debug -l webui.log) and then try adding label to torrent from transdroid. I'd guess it comes down to how the label is formated, as else looks same from transdroid source i.e.:

Code: Select all

static final String RPC_METHOD_SETLABEL = "label.set_torrent";
[...]
 if (label != null && hasMethod(client, RPC_METHOD_SETLABEL)) {
                client.sendRequest(RPC_METHOD_SETLABEL, torrentId, label);
Sorry no actual solution, and just a thought.

Edit: Sorry, the transdroid java code snippet above I believe is for the direct RPC deluged comunication, and so the webUI call snippet rather should be the following, I believe, but still the 'RPC_METHOD_SETLABEL' used, i.e. 'label.set_torrent', which I tested working through deluge webUI':

Code: Select all

SetLabelTask labelTask = (SetLabelTask) task;
                    params.put(task.getTargetTorrent().getUniqueID());
                    params.put(labelTask.getNewLabel() == null ? "" : labelTask.getNewLabel());
                    makeRequest(buildRequest(RPC_METHOD_SETLABEL, params), log);
                    return new DaemonTaskSuccessResult(task);
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Re: Deluge Label non-latin letter issue

Post by nemonein »

Thank you @mhertz.
I found something wrong in the 'deluge_label/core.py'.

Here's error messages, when I run deluge-gtk from a terminal, then try to add label '연습'.

Code: Select all

~]$ deluge-gtk
14:48:00.765 [ERROR   ][deluge.ui.client                  :169 ] RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: label.add(연습)
--------------------------------------------------------------------------------
Exception
Invalid label, valid characters:[a-z0-9_-]: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/deluge/core/rpcserver.py", line 326, in dispatch
    ret = self.factory.methods[method](*args, **kwargs)
  File "/usr/lib/python3/dist-packages/deluge/plugins/Label-0.3.egg/deluge_label/core.py", line 183, in add
    check_input(
  File "/usr/lib/python3/dist-packages/deluge/plugins/Label-0.3.egg/deluge_label/core.py", line 68, in check_input
    raise Exception(message)
Exception: Invalid label, valid characters:[a-z0-9_-]

--------------------------------------------------------------------------------
Unhandled error in Deferred:
14:48:00.766 [CRITICAL][twisted                           :147 ] Unhandled error in Deferred:

Traceback (most recent call last):
Failure: deluge.error.WrappedException: Invalid label, valid characters:[a-z0-9_-]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/deluge/core/rpcserver.py", line 326, in dispatch
    ret = self.factory.methods[method](*args, **kwargs)
  File "/usr/lib/python3/dist-packages/deluge/plugins/Label-0.3.egg/deluge_label/core.py", line 183, in add
    check_input(
  File "/usr/lib/python3/dist-packages/deluge/plugins/Label-0.3.egg/deluge_label/core.py", line 68, in check_input
    raise Exception(message)
Exception: Invalid label, valid characters:[a-z0-9_-]


14:48:00.766 [CRITICAL][deluge.log                        :90  ] twisted.internet.defer 
[Failure instance: Traceback (failure with no frames): <class 'deluge.error.WrappedException'>: Invalid label, valid characters:[a-z0-9_-]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/deluge/core/rpcserver.py", line 326, in dispatch
    ret = self.factory.methods[method](*args, **kwargs)
  File "/usr/lib/python3/dist-packages/deluge/plugins/Label-0.3.egg/deluge_label/core.py", line 183, in add
    check_input(
  File "/usr/lib/python3/dist-packages/deluge/plugins/Label-0.3.egg/deluge_label/core.py", line 68, in check_input
    raise Exception(message)
Exception: Invalid label, valid characters:[a-z0-9_-]

]
I hope this help you find the problem.
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Re: Deluge Label non-latin letter issue

Post by nemonein »

Oh, and I forgot to mention that.. to you and to transdroid team.
I don't use web ui for transdroid. I use 'Deluge 2 RPC' for server setting.

Well, first thing first.
Adding non-latin character label must be fixed first. I'm just a novice programmer, I changed the code like this.

Code: Select all

#RE_VALID = re.compile(r'[a-z0-9_\-\.]*\Z')
RE_VALID = re.compile(r'[^\x00-\x7F]+\Z')
Then, I can add non-latin letter label. However, transdroid still does not allow to set non-latin letter label.
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge Label non-latin letter issue

Post by mhertz »

Yes, good job fixing the label.add() issue(char-restrictions) through 'RE_VALID' in label's core.py.

If you could please do what I asked previously, but just with the debug-logging enabled for deluged instead of deluge-web, so we can see what it complains about hopefully.

Btw, when in GTKUI selecting to add label to torrent, then it's done through calling label.set_torrent RPC call as said, done here through client.py which just is a frontend for deluge UIs/client-scripts which simplyfies sending RPC commands to daemon for you. That works fine with non-latin as you also stated previously, and when enabling debug-logging for daemon, it just logs having distpatched RPC request label.set_torrent and not even show args used. I hacked the client.py(and transfer.py to see all, but nothing new, except in tupple etc) to print to terminal the send call, and it's just the RPC call with torrent_id and label added, nothing special. Strange it's not working through transdroid, and I have no idea why honestly.
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Re: Deluge Label non-latin letter issue

Post by nemonein »

I change the line in my /etc/systemd/system/deluged.service.

Code: Select all

#ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning
ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L debug
I add a label with Korean letters, then change a torrent label to it in Deluge thin client.
Here are the debug messages.

Code: Select all

....snip....
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
22:52:31 [DEBUG   ][deluge.configmanager          :94  ] Getting config: core.conf
----> Label Add
22:53:10 [DEBUG   ][deluge.config                 :483 ] Saving new config file /tmp/label.conf.oaist654
22:53:10 [DEBUG   ][deluge.config                 :497 ] Backing up old config file to /var/lib/deluge/.config/deluge/label.conf.bak
22:53:10 [DEBUG   ][deluge.config                 :505 ] Moving new config file /tmp/label.conf.oaist654 to /var/lib/deluge/.config/deluge/label.conf
----> Label Set
22:56:10 [DEBUG   ][deluge.config                 :483 ] Saving new config file /tmp/label.conf.rs71btth
22:56:10 [DEBUG   ][deluge.config                 :497 ] Backing up old config file to /var/lib/deluge/.config/deluge/label.conf.bak
22:56:10 [DEBUG   ][deluge.config                 :505 ] Moving new config file /tmp/label.conf.rs71btth to /var/lib/deluge/.config/deluge/label.conf
Then, I change the torrent's label to English titled Label but in Transdroid.

Code: Select all

22:56:10 [DEBUG   ][deluge.config                 :483 ] Saving new config file /tmp/label.conf.rs71btth
22:56:10 [DEBUG   ][deluge.config                 :497 ] Backing up old config file to /var/lib/deluge/.config/deluge/label.conf.bak
22:56:10 [DEBUG   ][deluge.config                 :505 ] Moving new config file /tmp/label.conf.rs71btth to /var/lib/deluge/.config/deluge/label.conf
----> Label(English) Set in Transdroid
23:01:13 [DEBUG   ][deluge.config                 :483 ] Saving new config file /tmp/label.conf.sksl4ff9
23:01:13 [DEBUG   ][deluge.config                 :497 ] Backing up old config file to /var/lib/deluge/.config/deluge/label.conf.bak
23:01:13 [DEBUG   ][deluge.config                 :505 ] Moving new config file /tmp/label.conf.sksl4ff9 to /var/lib/deluge/.config/deluge/label.conf
However, setting a Korean label in transdroid has no response. No debug messages at all.
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge Label non-latin letter issue

Post by mhertz »

Thanks, though somethings wrong with your logs, as the important info isn't there, but regardless doesn't matter as per your report about nothing logged when testing transdroid with non-latin chars. There's a label.set_torrent RPC dispatch message in log when succeded, and a fail message when not, so if no message at all, then seemingly transdroid not sending anything to deluge(in non-latin char case), but I don't know why. I read quickly that transdroid atleast also has a debug-logging mode, somewhere, so could you try enable that if can find, I haven't googled it sorry, and add non-latin label to a torrent and check if anything is logged regarding that i.e. something failing, as I don't think it's a deluge issue, but could be wrong however, though regardless deluge explicitly not allows such non-latin chars and you override, but would be fine to have working of-course anyway, I understand.
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Re: Deluge Label non-latin letter issue

Post by nemonein »

I asked them again, but it took more than a year for me to get their first response.
If I get a message from them, I'll let you know.
Anyway, at least now I can make a label with Korean letters, which is a big gift for me.

Thank you very much for your concern.
Post Reply