View Single Post
Old 01-14-2022, 07:10 AM   #287
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,495
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
[...]
In an Action Chain, if I run this once, it produces the standardidentifier and does not delete the url: identifier. If I run it on a book that has both standard and url: identifiers it does delete the url:. Do I need to make it two separate actions/templates?
I verified that an Action Chains single field edit will replace the ids with the result of the template. Example: given identifiers of
Code:
ao3:1, goodreads:16967, uri:https://archiveofourown/works/12345, x:y
and the action chain
Spoiler:
Code:
{
  "ActionsChainMenus": {
    "Menus": [
      {
        "active": true,
        "chain_settings": {
          "chain_links": [
            {
              "action_name": "Single Field Edit",
              "action_settings": {
                "col_name": "identifiers",
                "template": "program:\n\tlist_difference($identifiers, 'ao3:1', ',')",
                "value_type": "template"
              },
              "comment": ""
            }
          ],
          "refresh_gui": true
        },
        "image": "",
        "menuText": "Test identifiers",
        "subMenu": ""
      }
    ]
  },
  "schemaVersion": 1.8
}

then the result is
Code:
goodreads:16967, uri:https://archiveofourown/works/12345, x:y
The ao3:1 identifier is removed. I can't say why it doesn't work for you. I suggest you put print() statements in it so you can verify exactly the result of the template.

FWIW: the
Code:
n = re(u, '^^https://standardebooks.org/ebooks/()', '\1');
is strange. The \1 will always result in the empty string because the grouping () contains no pattern, so why is it there? I also don't know why there are two ^ anchors in the front. I think you mean
Code:
n = re(u, '^https://standardebooks.org/ebooks/(.*)$', '\1');
chaley is offline   Reply With Quote