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: [fb2k v2] Playcount 2003 (Read 5769 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[fb2k v2] Playcount 2003

It's been awhile since I've churned out some nonsense so here we go...

This is a cheap clone of foo_playcount with some differences but lets get the common stuff out of the way first...

Plays are tracked in exactly the same way as foo_playcount does it. One minute of playback or when the track ends if less a minute long. Records are remembered for 4 weeks if a track is not part of the media library/loaded playlist.

Now for the differences....

First of all, database records are bound to %path%|%subsong%

But that is not fixed. You can edit it to anything you like in the advanced preferences. Changing this value demands an immediate restart and any previously saved data is gone forever. You have been warned!!

What else is different?

While first played/last played/added are done automatically, you can modify the value(s) for any selection from the context menu in YYYY-MM-DD HH:MM:SS format. You can fake playcounts as well. I don't care. Ratings go up to 10 and there is a field for loved tracks.

These title format fields can be used in any panel/playlist/search
Code: [Select]
%2003_added%
%2003_first_played%
%2003_last_played%
%2003_playcount%
%2003_loved% (1 or blank)
%2003_rating% (up to 10 via the context menu)

There are no warnings/errors for entering gibberish values via the context menu. It just ignores you.

If you want to import foo_playcount data, do that from the Library menu>Playcount 2003>Import foo_playcount.

Known issue: statistics do not survive copies/moves when using the default %path%|%subsong% pattern. I'm not really sure how to handle that. If using tags, it should survive tag updates.

Re: [fb2k v2] Playcount 2003

Reply #1
Would it be possible to also add a %2003_time% variable that contains current system time in a format like "2024-02-13 14:29:59" ?
Precision in seconds would be good enough.

Re: [fb2k v2] Playcount 2003

Reply #2
0.1-Beta.2

Fixes an issue where no feedback was provided after a foo_playcount import.

The supported field list has been updated:

Full date/time strings
Code: [Select]
%2003_now%
%2003_added%
%2003_first_played%
%2003_last_played%

Unix time stamps (number of seconds since 1st January 1970)
Code: [Select]
%2003_now_ts%
%2003_added_ts%
%2003_first_played_ts%
%2003_last_played_ts%

Numbers
Code: [Select]
%2003_playcount%
%2003_loved%
%2003_rating%

Re: [fb2k v2] Playcount 2003

Reply #3
Great!

Found some time to test and the real-time variables work perfectly and the variables are both availalble in PSS and ELP. As a side note I would have been able to use these realtime variables to fix the remaining de-minimize issue I had with foo_vis_spectrum_analyzer, since %2003_now% / %2003_now_ts% would allow me to detect that fooBar returned from having been minimized and issue a screen repaint from PSS.

One of the main issues I have is the fact there is no way (as far as I know of) to communicate between CUI PSS splitters and ELP (or the other way around). Globals from PSS are not accessible in ELP, and globals (field definitions) in ELP are not accessible in PSS.

Would it be possible to add a function in this or a derivative plugin that allows me to send a name and value (from PSS or ELP) that are published/updated and thus available in both PSS and ELP in a similar way that %2003_now% is available in both PSS/ELP ?


Re: [fb2k v2] Playcount 2003

Reply #5
Any possibility to add the %played_times% counterparts, like foo_enhanced_playcount? Having all in a single plugin would be great (also the possibility to fake listens, thus being able to import them from Spotify or ListenBrainz)

Re: [fb2k v2] Playcount 2003

Reply #6
It's something to think about. I was trying to keep this simple.

I think an array of timestamps isn't really compatible with the free form editing currently provided so I'm thinking a simple/advanced checkbox. Switching modes would cause immediate data loss like changing the title format pattern does now.

The current way of doing things would be the "simple" mode. No data loss for existing users.

Switching to "advanced" would mean no editing via the context menu. The playcount would be the timestamp array length and the first played/last played would be extracted from the highest/lowest values. With the loss of context menu editing does come the possibility of importing JSON arrays via file. I'll give it some thought.

edit: one other thing: I know foo_enhanced_playcount provides an array of full date/time strings. I fail to see the point of that. It's useless to title formatters within fb2k so i'd keep it minimal and provide timestamps only. Only javascripters can make use of it.

Re: [fb2k v2] Playcount 2003

Reply #7
It think only timestamps is good enough, since the dates can be easily converted in JS anyway, so I don't see it as a loss.
Having the possibility to get all timestamps for JS and single first/last value for TF is perfect.

Btw, some services, like ListenBrainz, allow to also "hate" a track. In my case I use a %FEEDBACK% tag which can be -1 (hate), 0|null (unset) or 1 (loved). Maybe you also want to consider that, instead of a single loved tag or multiple tags

Code: [Select]
$select($add(%FEEDBACK%,2),X,,❤)
In CUI:
Code: [Select]
$puts(t,$select($add(%FEEDBACK%,2),$rgb(0,0,0),,$rgb(255,34,34)))
$set_style(text,$get(t),$get(t))

Re: [fb2k v2] Playcount 2003

Reply #8
I appreciate having the time since last playback and current time stuff in Title Formatting, but you knew that already. Thanks again!
Think millionaire, but with cannons.

Re: [fb2k v2] Playcount 2003

Reply #9
It think only timestamps is good enough, since the dates can be easily converted in JS anyway, so I don't see it as a loss.
Having the possibility to get all timestamps for JS and single first/last value for TF is perfect.

I don't have a release ready just yet but the changelog details it some more.

https://jscript-panel.github.io/other/playcount2003/

Also, a command line JSON file importer has been added.

Re: [fb2k v2] Playcount 2003

Reply #10
Any plan to add the title formatting similar to the $jsp3_since function?

Re: [fb2k v2] Playcount 2003

Reply #11
$jsp3_since is exclusive to the title format functions in that component. It's not possible to make them globally available.

I suppose another %2003_something% field could yield the same result if I hardcoded the input to just last played. I'll think about it.

Re: [fb2k v2] Playcount 2003

Reply #12
$jsp3_since is exclusive to the title format functions in that component. It's not possible to make them globally available.

I suppose another %2003_something% field could yield the same result if I hardcoded the input to just last played. I'll think about it.
About this, I was thinking of another thing currently only available scripting. Since a global TF is not allowed, would a %2003_plays_year% be possible?
i.e. total num of plays only this year (not as a period, but just the current year). Or the previous one.

Obviously it would be interesting to be able to do that via TF for any year, but just for the current or previous year would be interesting. Since that allows to easily create an autoplaylist of your most played tracks this year without requiring JS (I know I already coded scripts for that but sure some people would prefer to use plain TF).

Something like this, which would output the top tracks from 2023:
Code: [Select]
%2003_plays_prev_year% GREATER 10 AND %2003_rating% GREATER 5 SORTED DESCENDING BY %2003_plays_prev_year%

I think this and the other things you have already added complete the most basic stats for foobar2000 compared to other players regarding playback history.

Re: [fb2k v2] Playcount 2003

Reply #13
Obviously it would be interesting to be able to do that via TF for any year

That bit is impossible. You'd need a $function that takes parameters and I can't make those global as mentioned above.

%2003_playcount_this_year% and %2003_playcount_last_year% are absolutely doable but I do wonder about the performance implications of iterating over the array on every track. My collection is too small and I have no dummy data to test so if I implement it, you'll have to suck it and see. But if you're already doing it in JS with enhanced playcount data, I guess this can't be any slower.

Re: [fb2k v2] Playcount 2003

Reply #14
Retrieving all playcounts within an specific year for 80k tracks takes 7 secs. (1 less if I discard the last.fm plays, which you don't have)
Filtering that handleList first with a query like '%LAST_PLAYED% SINCE 2023', reduces time to 600 ms.

EDIT: not claiming anyway that's the fastest implementation, sure it can be optimized more.



Re: [fb2k v2] Playcount 2003

Reply #17
So I had a quick play with foo_enhanced_playcount earlier and used it to download some plays from my last.fm account. Scripters can parse that data and dump it a JSON file so it can imported in to this component.

I knocked this up for JSP3...

Code: [Select]
var tfo_id = fb.TitleFormat("%path%|%subsong%");
var tfo_lastfm = fb.TitleFormat("%lastfm_played_times_js%");

var items = plman.GetPlaylistItems(plman.ActivePlaylist);

var dump = [];
for (var i = 0; i < items.Count; i++) {
var item = items.GetItem(i); // GetItem is JSP3 only, SMP uses items[i]

var arr = JSON.parse(tfo_lastfm.EvalWithMetadb(item)).map(function (item) {
// foo_enhanced_playcount uses JS timestamps with millisecond accuracy, we don't want that
return item / 1000;
});

var obj = {
"id" : tfo_id.EvalWithMetadb(item),
"2003_plays" : arr,
};

dump.push(obj);
}

var str = JSON.stringify(dump);
// can't remember if SMP writes BOM by default or not?????? It has to be disabled. JSP3 does not write BOM at all
utils.WriteTextFile("z:\\dump.json", str);

Re: [fb2k v2] Playcount 2003

Reply #18
0.1-Beta.5

https://jscript-panel.github.io/other/playcount2003/

This enforces some stricter validation on user imported values. Shouldn't be an issue with genuine data as described in the readme. But supplying timestamps that exceeded the max allowed value may have ended up as garbage dates. Now they should be silently ignored.

Re: [fb2k v2] Playcount 2003

Reply #19
0.1-Beta.6

Statistics can now survive moves/copies using the default %path%|%subsong% pattern.

Caveats:
- files must be moved/copied with file operations. Doing it manually or via any other means will not be tracked

- cuesheets/other tracks with multiple chapters are not supported. I only get a path from the SDK file operation callback and I'm assuming a subsong index of zero for every one. I'm not capable of the sort of hacks that would be necessary to determine how many subsongs a given path has.

As I keep mentioning, tag based patterns should be fine if you want to change it in the Preferences.

https://jscript-panel.github.io/other/playcount2003/

Re: [fb2k v2] Playcount 2003

Reply #20
0.1-Beta.7 fixes the stupidest bug with the foo_playcount importer. Apologies for being a buffoon.

https://jscript-panel.github.io/other/playcount2003/

Re: [fb2k v2] Playcount 2003

Reply #21
Thanks for the update. I was about to report why the foo_playcount import part doesn't work on my end. With the latest update update, it's working as expected.

Request, can the HH:MM:SS section of the %..._ago% fields be truncated/removed?

Another request, how can I make the exported JSON from Last.fm Playcount Sync compatible with this playcount2003?
Since, in my case, the lfm has more completed entries than foo_playcount. Perhaps I could just sync it with masstagger.
I understand that this question may appear unusual considering that the component is no longer supported, thus it is understandable if it is not possible.

Re: [fb2k v2] Playcount 2003

Reply #22
Use title formatting to display up to d - that strips away the HH:MM:SS

Code: [Select]
$substr(%2003_added_ago%,0,$strstr(%2003_added_ago%,d))

As for the last.fm JSON, you can't do anything with it. I'll knock up a bit javascript that can do it later on.

Re: [fb2k v2] Playcount 2003

Reply #23
Thanks for the response and the code snippets!