Script loading as addon but not as a menu item in tools

To discuss development of addons / skins / customization of MediaMonkey v5 / v2024

Moderators: jiri, drakinite, Addon Administrators

Shakadula5153
Posts: 159
Joined: Mon Nov 23, 2015 5:35 pm

Script loading as addon but not as a menu item in tools

Post by Shakadula5153 »

I have a script but for the life of me I cannot get mm5 to add it as a menu item so I may execute it. Missing something basic.

Thoughts
Lenovo Laptop:
LENOVO_MT_83DM_BU_idea_FM_Yoga 7 2-in-1 16AHP9
64 bit OS
Windows 11
2 TB SSD, 16 Gig RAM,

Software

* Primary Apps: MediaMonkey 5 GOLD, Ultimate Guitar Tabs

Mobile is Motorola RAZR+ 2024.
Peke
Posts: 18403
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Script loading as addon but not as a menu item in tools

Post by Peke »

Hi,
Please open support Ticket and supply sample of script, so that we can peek. Unless you want to release it here so that others can tweak it too?
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Shakadula5153
Posts: 159
Joined: Mon Nov 23, 2015 5:35 pm

Re: Script loading as addon but not as a menu item in tools

Post by Shakadula5153 »

Here you go. It should only execute one time: Don't need a menu item cause I can't figure that out so one time executable works for me.

JSON:

Code: Select all

{
  "id": "appendyear",
  "title": "Append Year to Title",
  "description": "Appends the Year to track titles (runs once only)",
  "version": "1.4.0",
  "author": "Shaka",
  "type": "script",
  "files": [
    { "filename": "AppendYear.JS", "type": "script" }
  ]
}

AppendYear:

// AppendYear.JS
// Appends year to track titles once, then never again.

app.listen(app.events.startup, async () => {
    try {
        // Check flag
        let alreadyRun = await app.settings.get("AppendYear", "done");
        if (alreadyRun === "true") {
            console.log("AppendYearToTitle already executed, skipping.");
            return;
        }

        let sql = `
            UPDATE Songs
            SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
            WHERE Year IS NOT NULL
              AND Year > 0
              AND SongTitle NOT LIKE '% (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
        `;
        await app.db.execute(sql);

        console.log("AppendYearToTitle executed. Marking as done.");
        await app.settings.set("AppendYear", "done", "true");

        // Popup confirmation
        ui.messageBox("AppendYearToTitle executed successfully!");

    } catch (e) {
        ui.messageBox("Error in AppendYearToTitle: " + e);
    }
});
Lenovo Laptop:
LENOVO_MT_83DM_BU_idea_FM_Yoga 7 2-in-1 16AHP9
64 bit OS
Windows 11
2 TB SSD, 16 Gig RAM,

Software

* Primary Apps: MediaMonkey 5 GOLD, Ultimate Guitar Tabs

Mobile is Motorola RAZR+ 2024.
Shakadula5153
Posts: 159
Joined: Mon Nov 23, 2015 5:35 pm

Re: Script loading as addon but not as a menu item in tools

Post by Shakadula5153 »

trying something new.

Update Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';

I am executing this in the SQLITE editor but no updates are happening. When I query with no update I get the results I want but changing to update has no effect. Thoughts?

Again, this is a ONE time execution.
Lenovo Laptop:
LENOVO_MT_83DM_BU_idea_FM_Yoga 7 2-in-1 16AHP9
64 bit OS
Windows 11
2 TB SSD, 16 Gig RAM,

Software

* Primary Apps: MediaMonkey 5 GOLD, Ultimate Guitar Tabs

Mobile is Motorola RAZR+ 2024.
Shakadula5153
Posts: 159
Joined: Mon Nov 23, 2015 5:35 pm

Re: Script loading as addon but not as a menu item in tools

Post by Shakadula5153 »

Update: I got my update to work on my test machine and now I am working on my production machine. Problem is this debug version I am using is clugie. I get errors when I exit and have to close from a test box stating to continue in safe mode etc. Anyway I am going to install the standard version of MM to see is that helps. Update: Installed standard version and it still noes not work and throws runtime error 217 when exiting application. SQL Editor also does not work.

Also in this version of MM my SQL Editor does not work. I get the editor but it will not let me type into the sql command box. GEEEZZZZZZZ,

So my new SQL code to concatenate Year to title is:

UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';

So I should get "I Got You Babe (6507) From "I Got You Babe"

Running version 2024.2.0.3167. I think this is 32 bit. Don't I want 64bit?
Lenovo Laptop:
LENOVO_MT_83DM_BU_idea_FM_Yoga 7 2-in-1 16AHP9
64 bit OS
Windows 11
2 TB SSD, 16 Gig RAM,

Software

* Primary Apps: MediaMonkey 5 GOLD, Ultimate Guitar Tabs

Mobile is Motorola RAZR+ 2024.
Shakadula5153
Posts: 159
Joined: Mon Nov 23, 2015 5:35 pm

Re: Script loading as addon but not as a menu item in tools

Post by Shakadula5153 »

figured it out. Reinstalled MM5. SQL works fine new.

Please disregard thread.
Lenovo Laptop:
LENOVO_MT_83DM_BU_idea_FM_Yoga 7 2-in-1 16AHP9
64 bit OS
Windows 11
2 TB SSD, 16 Gig RAM,

Software

* Primary Apps: MediaMonkey 5 GOLD, Ultimate Guitar Tabs

Mobile is Motorola RAZR+ 2024.
Alim_online

Re: Script loading as addon but not as a menu item in tools

Post by Alim_online »

If the script shows up as an add-on but not under Tools, you need to append your operator to a menu, e.g.:

def menu_func(self, context):
self.layout.operator("myaddon.my_operator")

def register():
bpy.utils.register_class(MyOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)


Otherwise it won’t appear in Tools.
christopher.wanko
Posts: 17
Joined: Fri Jan 27, 2012 8:53 am

Re: Script loading as addon but not as a menu item in tools

Post by christopher.wanko »

Shakadula5153 wrote: Sun Sep 14, 2025 4:29 am UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';
This is bugging me. You presumably want the year only once in the song title? What if your song title is formatted like "I Got You Babe - 1971 " ? Your SQL won't match. Your SQL *only* matches on the presence of your formatting rule. Are you sure this is what you want to have happen?

For example, you might prefer to leave any prior year formats alone for the time being:

UPDATE songs
SET songtitle = songtitle || ' (' || SUBSTR(CAST(year AS TEXT), 1, 4) || ')'
WHERE year IS NOT NULL AND year > 0 AND SUBSTR(year,1,4) BETWEEN '1900' AND '2025'
AND songtitle NOT LIKE '%'||SUBSTR(year,1,4)||'%'
;;

Just consider this.

--#
Post Reply