Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: [HELP] Script to insert %playback_time% into a custom tag (Read 1751 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[HELP] Script to insert %playback_time% into a custom tag

Can any guru here help me to make a script that can be executed in foobar2000 to insert the %playback_time%  into the "skip" tag when manually triggered?


Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #1
What exactly do you want to achieve? It sounds like you use Skip Track component, perhaps you have a worthy idea for an improvement.

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #2
The component doesn't have a menu action (which can be linked to a button) to add the skip tag with the current time for the playing track. i.e. an easy way to tag tracks to skip any part while playing them. Note tagger scrips are not capable of using the playback time for this.

I did it by myself using JS on my Playlist Tools script (which also exposes a main menu command and then can be linked to a DUI/CUI button); If that is added natively it would be great. In my case I added 3 cases:
- L. Click and playing time is below half track length: skip tag to skip from the beginning to current position. (replaces any Skip tag present)
- L. Click and playing time is over half track length: skip tag to skip from the current position to the end.  (replaces any Skip tag present)
- Shift + L. Click: adds new skip tag without replacing any previously value. (see 2 cases above)

I consider that covers almost every common use of the skip tag in an easy and smart way.
Spoiler (click to show/hide)
Code here:
https://github.com/regorxxx/Playlist-Tools-SMP/blob/main/main/tags/skip_tag_from_playback.js


Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #3
What exactly do you want to achieve? It sounds like you use Skip Track component, perhaps you have a worthy idea for an improvement.

I think it has been proposed already, but yes; my idea is to use masstagger (which unfortunately doesn't support %playback_time%) to make a hotkey to add the tag <SKIP> with the current playback time as the data; for example, I hit the key 'S' while the music is playing at 1:30 and the file gets tagged with '<SKIP> 1:30'  making the file skip at 1:30 next time.

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #4
I did it by myself using JS on my Playlist Tools script (which also exposes a main menu command and then can be linked to a DUI/CUI button)

This is great, I will try it! (although I'm a little puzzled to be honest)

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #5
Came back to thank you @regor!

The whole thing works, it was worth it. ;)

Saddly, I have another problem now...

X64 version?

EDIT: I will answer that myself: why do you need the x64 version if there are no perceptible changes only downsides, like not having great components working?

Going back to 32 bits as I write this. Much work ahead, but I'm not switching to x64 again any time soon.

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #6
I'm getting this error x4 times on every foobar start:


Spider Monkey Panel
Code: [Select]
Property value is wrong. Using default value as fallback:
'Partial Multi-value tag matching'

Wrong value: true

Replaced with: true

Value obey this condition: function isStringWeak(str) {
return (typeof str === 'string');
}

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #7
why do you need the x64 version
People with massive music libraries exceed the capabilities of 32 bits, which can only address 4GB of memory.
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #8
SMP unfortunately only has a x32 version. I would also prefer to use x64 but... so tired of asking for a x64 version instead of a completely new component.
Not joking, I would pay if anyone makes a simple port of SMP to 64 bits.

The check is for strings, but the setting is a boolean (true). Looks like a copy/paste error on my side (you can just ignore it, since all is right).

Line 78 at 'main\playlist_tools\playlist_tools_menu.js'.
To stop the popups, change this:
Code: [Select]
	bMultiple: ['Partial Multi-value tag matching', true, { func: isStringWeak }, true],
To this:
Code: [Select]
	bMultiple: ['Partial Multi-value tag matching', true, { func: isBoolean }, true],

Let me know if you need more guidance to use the skip tag thing. You need the button 'Playlist tools' which I presume you added per your error and at Scrip integration check you have the skip menu entry (which I think is enabled by default).

Then, you will have the menu entry available for DUI/CUI buttons like my gif.

Spoiler (click to show/hide)

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #9
Thanks regor, I've downgraded to version 4.2.0 and the error messages are gone.

Also I think I made it work like you in the gif, I made the button and it works. Also struggled to make it work with the default user interface instead of columns; but in the end I found how (I have 2 main foobar2000 installations).

At SMP, the devs say 64bit version is in the roadmap: https://github.com/TheQwertiest/foo_spider_monkey_panel/issues/209

I'm happy going back to my x86 foobar2000 since I got access to foobarcon and ambiophonic xtc components again. There is no better remote control app available and there is no ambiophonics component for x64.
I never had any issues with massive playlists crashing the player, so that is not my case.

This solution that regor shared is crucial for me, since I use skip track component A LOT (stupid bonus tracks attached to songs (20:00 songs mostly with silence), radio show boring parts/ads, never-ending intros, etc). I was tagging each radio show manually.

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #10
This is easily doable in JScript Panel 3 which has 32/64bit versions. I don't have a ready made script for it but if any existing user of it wanted this functionality, pasting this in an existing config window should do it...

Code: [Select]
var tfo_playback_time = fb.TitleFormat("%playback_time%");

function on_main_menu(index) {
    if (!fb.IsPlaying) return;

if (index == 1) {
var time = tfo_playback_time.Eval();
fb.CreateHandleList(fb.GetNowPlaying()).UpdateFileInfoFromJSON(JSON.stringify({
"SKIP" : time,
}));
}
}

You'd then have to bind a default UI button/columns UI button or keyboard shortcut in the main preferences to File>JScript Panel 3>1.

Up to 10 menu items are available which correspond with the index used in the code snippet above.

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #11
This is easily doable in JScript Panel 3 which has 32/64bit versions. I don't have a ready made script for it but if any existing user of it wanted this functionality, pasting this in an existing config window should do it...
That's not really how it works, since the SKIP tag follows a specific format, so I would recommend to first take a look at my JS files. Otherwise people is going to add garbage if using your code as is... Also keep in mind, it's not the same skipping the beginning of a song, the end, etc.
https://github.com/regorxxx/Playlist-Tools-SMP/blob/main/main/tags/skip_tag_from_playback.js

Quote
Thanks regor, I've downgraded to version 4.2.0 and the error messages are gone.
I will update it soon with the fix anyway.


 

Re: [HELP] Script to insert %playback_time% into a custom tag

Reply #13
If you only want to skip the beginning, yep. But people may also want to skip things at the end, if there is silence. So ideally you have to support both cases.

@elcosomalo the script was updated with the fix.