View Single Post
  #2560  
Old 22.02.2023, 23:46
Nimboid Nimboid is offline
Vacuum Cleaner
 
Join Date: Jan 2023
Location: UK
Posts: 18
Default Mixcloud.com Packagizer Puzzle - Inconsistency or Incomprehension?

Getting tired of editing filenames of topic-related links from Mixcloud, I've written an Event Script, which normalises the commonly encountered variations to what I want. That part is actually working fine, but while I was at it, I thought I might as well influence the package name too, by checking it matches my preferred format, or perhaps by parsing and expanding a #abbreviation_tag. Here I have encountered behaviour I don't understand, related to interaction between the 'Information overwrites packagizer rules' checkbox found on the 'Analyse and Add Links' dialog, and the script. Script and screenshots follow:

Code:
//FHK 2023 02 19 - Normalise spelling/capitalisation of PoTP file captures from Mixcloud
// Trigger required: Packagizer Hook

String.prototype.includes = function(str2) {
    return this.indexOf(str2) > -1;
}
var packLink = link;
var inPack;
var inHost;
var inName;
var outName;
var outPack;
var subst;
var regex;

var inPack = packLink.getPackageName();
alert(state + " 1 inPack: " + inPack);

inHost = packLink.getHost();
if (inHost.includes("mixcloud.com")) {
    inName = packLink.getName();

    regex = new RegExp("(pick of the pops)|(potp)", 'gi')
    subst = "Pick of The Pops";
    outName = inName.replace(regex, subst);

    if (outName.includes(subst)) {
        packLink.setName(outName);

        if (inPack.includes("PoTP")) {
            // leave as-is
        } else {
            //alert(inPack + " does not include 'PoTP'");
            alert(state + " 2 Setting Package to 'PoTP '")
            packLink.setPackageName("PoTP ");

        }

    }
    outPack = packLink.getPackageName();
    alert(state + " 3 Confirmed outPack set to: " + outPack);
}
Case 1:
**External links are only visible to Support Staff**

Above: Null Package name, checkbox unset.

Below: Script receives default Package name. Script sets new Package name as intended.
Nothing to argue about.

**External links are only visible to Support Staff**

Case 2:
**External links are only visible to Support Staff**

Above: New Package name supplied, checkbox unset.

Below: Script receives default Package name, not user-supplied one. Where did 'wibble' go? Is there a method to access 'wibble', otherwise why is this field enabled in this situation?
Shouldn't script be given a chance to decide whether to use it to contribute to built-in packagizer rules?

**External links are only visible to Support Staff**

Case 3:
**External links are only visible to Support Staff**

Above: Null Package name, checkbox set.

Below: Script receives default Package name. Script sets new Package name as intended.
Nothing to argue about.

**External links are only visible to Support Staff**

Case 4:
**External links are only visible to Support Staff**

Above: New Package name supplied, checkbox set.

Below: Script does receive user-supplied Package name 'wibble'. Debug alert()s show Package name is changed by script - and read back as confirmation.
When Packagizer state is 'AFTER', Package name is still read as what the script set on the "BEFORE" pass. But the main LinkGrabber pane shows that the Package name set in reality is 'wibble', despite twice having read back a different value during the script's 2 passes. If this is intended behaviour, perhaps the PackageName() method should return a status value to signal success or failure reason?

**External links are only visible to Support Staff**

As things stand, my script either (case 2) has the ability to change the package name, but is unable to receive input from the user to influence its behaviour, or (case 4) it is able to receive user input, is able to manipulate that information, but is prevented from applying any modification. This seems over-restrictive to me.

Test link:
<**External links are only visible to Support Staff****External links are only visible to Support Staff**[0]=AT3eXG8WEU6WO5zKysBFAXRpf0zFCNOEAF2ZrUHaXeDB9rYFAAdpkQldG41VxqWYguzbB_gOTxHoljswA5SJm46su_W6GxhxRrJ OLGpbwoWuuWRfJd_5Pj6_YB7oijkjZkXx21a4UoP8hfD0HOJxYlLfb9Pw1XbBbO5TQ6QwuPeef3OCsvoZRm6Qvd21n-HUldG84FQUPgDYPu8Q937UoDU>

PS, What processes happen between "BEFORE" and "AFTER" in a Packager Hook script?

Last edited by Nimboid; 23.02.2023 at 01:27. Reason: Added Test Link
Reply With Quote