HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: fjara on 2023-09-12 01:40:27

Title: foo_skipcount (discussion)
Post by: fjara on 2023-09-12 01:40:27
Skip Counter
foo_skipcount Upload thread (https://hydrogenaud.io/index.php/topic,124742.0.html)


This was made for my personal use as I've wanted to keep track of this for a long time to help curate playlists and understand what I like and don't like of my current music. This is my first fb2k component and first I've really touched C++ in a decade or so and it took me about a week to complete. Let me know if there are improvements, optimizations, or features you'd like to see. Source code is attached in the other thread.

Targets version 80, so it works with 1.5/1.6/2.0 x86 and x64.

Current version: 1.1.0

Features:

    Custom column in playlists: Use the pattern %skip_count%
    Context menu available to reset the skip counter on tracks.
    Settings (Under Tools) to modify which actions cause skips to count, how long the track needs to play before a skip does not count, and if you want skips to count if you do the action from a paused or stopped state.
Title: Re: foo_skipcount (discussion)
Post by: regor on 2023-09-12 09:25:18
Thank you! Something like this has been asked many times.

I think a variable storing dates could be handy.
https://hydrogenaud.io/index.php/topic,115227.0.html

%skip_times_js% - JS timestamp list: [1344117517000, 1355172047000, 1514957893431]
%skip_times_raw% - raw foobar timestamps: [129885911170000000, 129996456470000000, 131594314934316754]
%last_skipped% - Single date: "2018-04-04 15:58:37

The array of times for scripting with JS or SMP.
Last skipped could be used to create really interesting playlists (like "add a track only if it was not skipped this week").
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-09-12 13:56:51
I will add that, I built this referencing a lot off of foo_enhanced_playcount and I wasn't sure it was within my ability at the time. Now that I have the base of it completed, it should be less daunting and I certainly see utility in including those.
Title: Re: foo_skipcount (discussion)
Post by: Daeron on 2023-09-13 16:47:47
I think there is a conflict with foo_skip as that also uses %skip_count%:
https://www.foobar2000.org/components/view/foo_skip/release/1.27

Not sure what is the right solution here, perhaps a user configurable name for the tag used? Or just renaming it to %skip_counter% by default?

Or perhaps foo_skip's developer can add an option to not populate the same field as it's not strictly necessary for that component to function (asked there too).
https://hydrogenaud.io/index.php/topic,30361.msg1032711.html#msg1032711

Otherwise thanks for the component, looks very promising.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-09-13 17:10:45
Good catch, thank you. I will keep tabs on it and potentially update my field name on next release (soon).
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-09-17 20:00:17
Alright, got the new version all set. I saw that Case changed the field name on f00_skip. I tried to implement a custom set field name, and although it worked, it required a restart as I couldn't get it to update otherwise, so it is fortunate that I do not need it. Let me know if there are any crashes/bugs.
Title: Re: foo_skipcount (discussion)
Post by: Daeron on 2023-09-23 01:19:20
Seems to work well now that the field name conflict is resolved.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-09-23 21:01:20
Updated to 1.9. Upload topic post with full changelog (https://hydrogenaud.io/index.php/topic,124742.msg1033154.html#msg1033154)

Note that the settings for logging skips was modified to a dropdown list and likely needs to be re-applied. Added a grace timer for each action so at the very beginning of the track it is possible to now count a skip. Added context menu to clear all but the most recent skip.
Title: Re: foo_skipcount (discussion)
Post by: Air KEN on 2023-09-23 23:39:44
Plaese change component version.

Skip count  1.7.0  foo_skipcount (2023-09-23)

(https://i.imgur.com/5TlX3F4.png)
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-09-24 00:00:36
Thanks, sorry about that I did not build it into the x64 component. Upload thread has updated file in new post.
Title: Re: foo_skipcount (discussion)
Post by: Air KEN on 2023-09-24 00:49:58
Thanks.

Reply #3 Corrected 1.9.0 component file
https://hydrogenaud.io/index.php/topic,124742.msg1033162.html#msg1033162
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-09-27 05:57:45
Released 1.9.1 to remove a console debugging statement that would spam foobar's console.
Title: Re: foo_skipcount (discussion)
Post by: Stem75 on 2023-11-09 21:53:31
Is it possible to make it count when you double click a song in the playlist to play, other than the one it is currently playing;

Stupid question 1, where is the log file saved so i can make a backup of it;

Stupid question 2, can i somehow read the counts in Mp3Tag;
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2023-11-12 04:21:02
I will look into whether it is possible, my gut feeling is no, but I will let you know once I'm more confident.

I believe the data is stored with other things in metadb.sqlite of %APPDATA%/Roaming/foobar2000 (folder has a -v2 at the end if you are on v2).

I have a few tag/counts related things on my to-do list that foo_playcount does: copy-pasting statistics between files, writing the counts to tags, importing counts from tags and exporting to xml.

I push it up my priority list now that I know there is interest in it
Title: Re: foo_skipcount (discussion)
Post by: Stem75 on 2023-11-12 19:49:27
That's good news. Thank you and keep up the good work.
Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-02-21 17:47:11
Have been playing with this for my wrapped script and just noticed that there are skip_times_raw and skip_times_js tags but not skip_times with timestamps like  "2018-01-02 23:38:13".

Not sure if that's intended or you forgot to add it (since you said you were referencing foo_enhanced_playcount).

Everything else works like a charm
Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-02-21 20:48:34
By the way, is there some way to log automatic skips by foo_skip? Since they don't involve user intervention.

EDIT: about the previous post, the details panel does in fact show a %skip_times% but the tag is not available at other places or has another name.
Title: Re: foo_skipcount (discussion)
Post by: marc2k3 on 2024-02-21 22:32:25
What you see in the Properties dialog is not title formatting. While info displayed there is usually similar, the implementation is quite separate. It's a perfectly reasonable feature request to make though.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-02-22 18:42:54
Hey, I just released a semi-beta version of 2.0 on github and the upload thread (https://hydrogenaud.io/index.php/topic,124742.0.html). I am not going to put it on the foobar2000 website repository just yet in case there are problems as I added and changed quite a bit.

I can added a date-time column, I wasn't sure if there would be anyone that would use it. I will add it in 2.0.1. I do not know exactly how foo_skip works currently, but I will check it out and see what is possible.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-02-28 17:04:19
2.0.1 is out, I will be putting it up on the fb2k repo shortly. I fixed some bugs with how I changed things in the initial in 2.0.0 and I added double-click track selection skip logging stuff and %skip_times% for date time timestamps field.


Quote
is there some way to log automatic skips by foo_skip?

There is probably a way to do this if I lookup the values that Skip Track keeps, if it were for timestamp logging it would be possible but much harder. I talked to Case and with how it works there is nothing for me to hook into so I'd have to be checking constantly. Not impossible but probably out of my ability at the this time. I will add it as a potential future update to look at.

As always, please let me know of any crashes, bugs, or issues regarding foo_skipcount and I will fix ASAP. Thanks!
Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-02-28 17:24:02
What a pity. Just a note, it could be "easier" to just mimic the same query used on Skip Track and always add a timestamp when such query applies. i.e. doing the same than Skip Track but just for increasing the counter, and letting the other plugin to do its thing. No need to hook anything then. The query could be copied/pasted by the user (if it's not possible to be retrieved from the other plugin).

In my limited usage everything seems to be working now, except some minor thing. For tracks with a single skip, latest skip is right but oldest skip is empty. That's technically wrong, both should be the same for skip arrays of length 1.

EDIT: is it right that changing any config hangs the entire process like 6-7 seconds?
Title: Re: foo_skipcount (discussion)
Post by: marc2k3 on 2024-02-28 18:13:26
This line of code is the culprit.

https://github.com/Fjara-h/foo_skipcount/blob/15e90af0638c3544e79cb5f3ab6700a5d36f879b/src/preferences.cpp#L159

As for why it's deemed necessary, only fjara can answer that. :P
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-02-28 20:13:19
I'm unable to recreate that issue, but that API usage is indeed not useful, I believe I had added it originally to update fields based on the activated settings but scrapped it. I've updated, let me know if there are still issues. Will updated with less-prio things soon

Looking at the single-skip issue, I also do not see that myself. Does it resolve it self if you clear the timestamps and then re-skip once? This is what I am seeing on my test client and effectively the same thing on my main install.
(https://i.imgur.com/43tYlpG.png)
Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-03-20 20:37:49
Have found another bug, which crashed my scripts. I'm pretty sure it was working fine on previous versions.

%SKIP_TIMES_JS% output is not always a valid JSON value. Sometimes outputs an array [] and other times values like "1710492645000" . The properties panel displays the right values, but tags get through other components or SMP are wrong.
Spoiler (click to show/hide)

The config issue is now gone.

About oldest vs latest in single skipped tracks. Current situation (for a track skipped before updating):
Spoiler (click to show/hide)
Note the tags are fine now, the properties\detail panel is not. Reloading info does nothing.

With a new track, skipped after update, the situation is the same.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-04 12:50:48
Thanks for the report. I will update ASAP, I've been sick.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-07 22:23:42
About oldest vs latest in single skipped tracks. Current situation (for a track skipped before updating):

Note the tags are fine now, the properties\detail panel is not. Reloading info does nothing.

With a new track, skipped after update, the situation is the same.

Can you test this release (https://github.com/Fjara-h/foo_skipcount/releases/tag/2.0.3-beta) to see if the change I made fixes this problem? If that does not fix it, I have another idea that should address it but isn't exactly what I would prefer to write it as.

%SKIP_TIMES_JS% output is not always a valid JSON value. Sometimes outputs an array [] and other times values like "1710492645000" . The properties panel displays the right values, but tags get through other components or SMP are wrong.

Test this release (https://github.com/Fjara-h/foo_skipcount/releases/tag/2.0.4-beta) to see if it properly displays the JS field now. (this one includes 2.0.3-beta changes, but I wanted to separate them)
Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-04-08 00:23:46
Quote
Can you test this release to see if the change I made fixes this problem? If that does not fix it, I have another idea that should address it but isn't exactly what I would prefer to write it as.

Tracks skipped before and after update still have with the bug.
Spoiler (click to show/hide)

Quote
to see if it properly displays the JS field now. (this one includes 2.0.3-beta changes, but I wanted to separate them)
Spoiler (click to show/hide)
With b4, %SKIP_TIMES_JS% is ok now as TF. Note %SKIP_TIMES_RAW% and %SKIP_TIMES% still require the same fix.

Also note the image now shows a track with 2 skips and the oldest skip is also not shown at the properties panel, although the tag is retrieved fine as TF. That seems to be a regression, since previously only tracks with a single skip had the 'oldest skip' bug.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-08 03:50:43
Okay thanks for the info
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-08 06:03:33
Alright, try this release (https://github.com/Fjara-h/foo_skipcount/releases/tag/2.0.4b-beta) and let me know.

I deleted my database file and then installed 1.9.1, 2.0, and 2.0.1, skipped a track once and then loaded this version and I did not see the oldest track skip missing, let me know if it does for you still, I will be very confused if it is, but shall see.

Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-04-08 08:58:46
All time tags are now valid JSON on TF.

The properties panel still missing oldest skip. Tried on new tracks after update (I'm using foobar 1.6 btw).
Spoiler (click to show/hide)

And now there is another bug, all times tags are overwritten with every new skip and only output a single timestamp now. Compare the previous image with new one and you will see the old timestamp is gone.
Spoiler (click to show/hide)
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-08 16:29:23
Okay, this is on me, I should have tested more thoroughly and asked more questions. I am fairly sure I figured out the original problem and reverted the regression area. Test this new beta release (https://github.com/Fjara-h/foo_skipcount/releases/tag/2.0.4c-beta) and please verify for me that the JSON, oldest skip, and overwriting timestamp display are all fixed. I debugged on my 1.6, but I want to confirm its all good
Title: Re: foo_skipcount (discussion)
Post by: regor on 2024-04-12 23:38:10
All problems now fixed on my side too, although there is one thing I just noticed when there are no skips on a track.

%OLDEST_SKIP% and %LATEST_SKIP% output "Never" instead of being empty and returning "?" when using without brackets. While I understand why you added that fallback value, it is not consistent with the way any other tag works.

For ex. using "%OLDEST_SKIP% PRESENT" as query, will return the entire library (which is not intended for tracks never skipped).
And "%OLDEST_SKIP% MISSING" outputs nothing. Etc.

I would say both should be empty (i.e. "?") if there are no skips.

Finally, something similar happens with %SKIP_COUNT%, which returns zero if there are no skips. But it is consistent with any of the playcount plugins, which also return zero.
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-13 01:53:59
Appreciate it, I will be addressing those and then releasing a new version. Thanks
Title: Re: foo_skipcount (discussion)
Post by: marc2k3 on 2024-04-13 02:55:42
You should not write a literal ? with metadb_display_field_provider. You should be returning false from process_field when there is no data like this...

https://github.com/jscript-panel/FB2K/blob/5dea4df06b2154f258a3b88841b8454311e9979e/PlaybackStatistics/MetadbDisplayFieldProvider.cpp#L34-L57

edit: I'm basing what I do on foo_sample from the SDK...

https://github.com/reupen/foobar2000-sdk-unmodified/blob/092ae1bf9a99b884bb55fd5344d80bc5e175b3f4/foobar2000/foo_sample/rating.cpp#L237-L252
Title: Re: foo_skipcount (discussion)
Post by: fjara on 2024-04-16 18:14:22
Yep, I had figured I was doing something incorrectly and I was going to check how to properly. Thanks for pointing that out. 2.0.5 will be released shortly