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: Official Playback Statistics component (Read 59059 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Official Playback Statistics component

Reply #51
question after the latest version of play back statistics I have decided to convert all my current tags ie play_counter to play_count, this is working fine, how ever it does not put the play count information in the database and simply comes up as another tag...

if there a way I can convert my play count tag data to the playback statistics?
any help apreciated...

Official Playback Statistics component

Reply #52
The no pop-up dialog would be a big selling point for me switching to the official version (I hate that dialog  ), except that I have no idea how to read the date tags.  Could someone please post a bit of code to translate the number into a useable date and time (including weekday, if possible)?

Also, I made a request a couple of years back to the unofficial version which got implemented, so, here I go again...

When using foo_dsp_continuator, short tracks don't get tagged by foo_playcount.  Could an option be added to tag short tracks (<30secs) as soon as they begin, instead of waiting for a certain amount to be played?

Official Playback Statistics component

Reply #53
C'mon folks!  Any reply to my previous post.  ^^^

The unofficial plugin has been behaving oddly of late.  When writing the tag, it sometimes makes the music pause or stutter, then I find my track has been played three times within a matter of seconds.

Official Playback Statistics component

Reply #54
How do you import data from the previous playcount plugin? play_counter appears to be automatically imported but first_played and last_played appear to be ignored. first_played_timestamp and last_played_timestamp aren't ignored, but I think it's impossible to convert first_played to a win32 FILETIME with masstagger, and I don't see how to update the playcount plugin's database from the file tags in batch (without playing each file once), so I can't import 2/3 of my old plugin's playcount data.

Official Playback Statistics component

Reply #55
Since I couldn't find any information about the timestamps for the official playback statistics component, I worked through them myself.

General information:
180000000000 is 1601-01-01 00:00:00 any lower number gives invalid timestamp errors [Edit: as noted below this number is probably related to timezone, all numbers should then be adjusted by the number of hours from GMT, in this case GMT - 5 hours]

The last seven digits are probably some fraction of a second

180010000000 is 1601-01-01 00:00:01
180600000000 is 1601-01-01 00:01:00
216000000000 is 1601-01-01 01:00:00

126230400000000000 is 400 years, approximately (400*365.25*24*60*60)
126227988000000000 is 2001-01-01 00:00:00
126543348000000000 is 2002-01-01 00:00:00
126858708000000000 is 2003-01-01 00:00:00
127174068000000000 is 2004-01-01 00:00:00
127490292000000000 is 2005-01-01 00:00:00
127805652000000000 is 2006-01-01 00:00:00

10000000 is one second
600000000 is one minute
36000000000 is one hour
864000000000 is one day
315576000000000 is one year on average
315360000000000 is one year, non-leap year
316224000000000 is one year, leap year

Here are some scripts for converting old format data to the new format (assuming you are using tags and not the database). They all will only work for dates/times after 2001-01-01 00:00:00 as I didn't need to overcomplicate them to work for me (this way I only had to account for one leap year).

To convert FIRST_PLAYED to FIRST_PLAYED_TIMESTAMP (format: 200Y-MM-DD HH:MM:SS):
Code: [Select]
$add($select($substr(%first_played%,4,4),
126227988000000000,126543348000000000,126858708000000000,127174068000000000,127490292000000000,
127805652000000000),$mul($select($substr(%first_played%,6,7),0,31,$ifequal($substr(%first_played%,4,4),4,60,59),
$ifequal($substr(%first_played%,4,4),4,91,90),$ifequal($substr(%first_played%,4,4),4,121,120),
$ifequal($substr(%first_played%,4,4),4,152,151),$ifequal($substr(%first_played%,4,4),4,182,181),
$ifequal($substr(%first_played%,4,4),4,213,212),$ifequal($substr(%first_played%,4,4),4,244,243),
$ifequal($substr(%first_played%,4,4),4,274,273),$ifequal($substr(%first_played%,4,4),4,305,304),
$ifequal($substr(%first_played%,4,4),4,335,334)),864000000000),$mul($sub($substr(%first_played%,9,10),1), 864000000000),$mul($substr(%first_played%,12,13),36000000000),$mul($substr(%first_played%,15,16),
600000000),$mul($substr(%first_played%,18,19),10000000))


To convert LAST_PLAYED to LAST_PLAYED_TIMESTAMP (format: 200Y-MM-DD HH:MM:SS):
Code: [Select]
$add($select($substr(%last_played%,4,4),
126227988000000000,126543348000000000,126858708000000000,127174068000000000,127490292000000000,
127805652000000000),$mul($select($substr(%last_played%,6,7),0,31,$ifequal($substr(%last_played%,4,4),4,60,59),
$ifequal($substr(%last_played%,4,4),4,91,90),$ifequal($substr(%last_played%,4,4),4,121,120),
$ifequal($substr(%last_played%,4,4),4,152,151),$ifequal($substr(%last_played%,4,4),4,182,181),
$ifequal($substr(%last_played%,4,4),4,213,212),$ifequal($substr(%last_played%,4,4),4,244,243),
$ifequal($substr(%last_played%,4,4),4,274,273),$ifequal($substr(%last_played%,4,4),4,305,304),
$ifequal($substr(%last_played%,4,4),4,335,334)),864000000000),$mul($sub($substr(%last_played%,9,10),1),
864000000000),$mul($substr(%last_played%,12,13),36000000000),$mul($substr(%last_played%,15,16),600000000),
$mul($substr(%last_played%,18,19),10000000))


To convert PLAY_DATE and PLAY_TIME to a timestamp (date format: DDMMYY; time format: HHMMSS)
Code: [Select]
$add($select($substr(%play_date%,6,6), 126227988000000000,126543348000000000,126858708000000000,127174068000000000,127490292000000000,
127805652000000000),$mul($select($substr(%play_date%,3,4),0,31,$ifequal($substr(%play_date%,6,6),4,60,59),
$ifequal($substr(%play_date%,6,6),4,91,90),$ifequal($substr(%play_date%,6,6),4,121,120),
$ifequal($substr(%play_date%,6,6),4,152,151),$ifequal($substr(%play_date%,6,6),4,182,181),
$ifequal($substr(%play_date%,6,6),4,213,212),$ifequal($substr(%play_date%,6,6),4,244,243),
$ifequal($substr(%play_date%,6,6),4,274,273),$ifequal($substr(%play_date%,6,6),4,305,304),
$ifequal($substr(%play_date%,6,6),4,335,334)),864000000000),$mul($sub($left(%play_date%,2),1), 864000000000),$mul($left(%play_time%,2),36000000000),$mul($substr(%play_time%,3,4),600000000),
$mul($substr(%play_time%,5,6),10000000))


These scripts will all blindly overwrite any existing data in the target tags. I have not thoroughly tested them, especially for any date before 2005-01-01 as none of my existing tags had data for any earlier dates. I had some errors in my accounting of days in early versions of these scripts, but I think that I've found and fixed them all. If you notice that any particular months convert incorrectly (probably one or two days off from expected), let me know.

Edit: Yeah, the 180000000000 is related to time zone, I didn't really bother to think about that (I did determine it was 5 hours, but I didn't really care because my script works for me). Plus if anyone wants to use these scripts, they'll have to remove all of the line breaks I added. All of the statistics that I cared about were stored with the files as I have a tendency to lose my configs (like having the unofficial statistics plugin bringing down my computer and corrupting my foobar config).

Official Playback Statistics component

Reply #56
General information:
180000000000 is 1601-01-01 00:00:00 any lower number gives invalid timestamp errors

180000000000 is also equal to 5 hours, which means you're probably in the eastern time zone, and this script also only returns correct dates for people in the eastern time zone, though that's not a big deal for me since most of the data I want is relative anyways.

Now that it's possible (but ugly) to convert first/last played times to the required format, how can I import the data without playing each file for one minute (which also wipes the correct last_played data and increments the play_count by one)?

Official Playback Statistics component

Reply #57
In addition, when you use %last_played% the value in LAST_PLAYED takes precedence over the value in LAST_PLAYED_TIMESTAMP, so while the timestamp is updated with this plugin, the LAST_PLAYED value is the one displayed. You have to delete the LAST_PLAYED tag to get %last_played% to display the LAST_PLAYED_TIMESTAMP. Of course, you could use %last_played_timestamp%, but there won't be any formatting done so you just get the number.

Official Playback Statistics component

Reply #58
There is a new version  versinon nr. 1.3.2) on the server.
Does anybody know what is new?

Thanx

Official Playback Statistics component

Reply #59
Reworked the code to make it easier to modify for different time zones and also ran them through more thorough testing.

In the part of the code that is "$mul(10000000,$add($mul(5,3600)" change the 5 to an appropriate offset value for your data. All of these only work for dates on or after 2001-01-01 00:00:00.

To convert PLAY_DATE and PLAY_TIME to timestamps (date format: DDMMYY; time format: HHMMSS):
Code: [Select]
$mul(10000000,$add($mul(5,3600),$select($put(x_year,$substr(%play_date%,6,6)),12622780800,
12654316800,12685852800,12717388800,12749011200,12780547200),$mul($select($substr(%play_date%,3,4),
0,31,$ifequal($get(x_year),4,60,59),$ifequal($get(x_year),4,91,90),$ifequal($get(x_year),4,121,120),
$ifequal($get(x_year),4,152,151),$ifequal($get(x_year),4,182,181),$ifequal($get(x_year),4,213,212),
$ifequal($get(x_year),4,244,243),$ifequal($get(x_year),4,274,273),$ifequal($get(x_year),4,305,304),
$ifequal($get(x_year),4,335,334)),86400),$mul($sub($left(%play_date%,2),1),86400),
$mul($left(%play_time%,2),3600),$mul($substr(%play_time%,3,4),60),$substr(%play_time%,5,6)))


To convert FIRST_PLAYED to timestamp (format: 200Y-MM-DD HH:MM:SS):
Code: [Select]
$mul(10000000,$add($mul(5,3600),$select($put(x_year,$substr(%first_played%,4,4)),12622780800,
12654316800,12685852800,12717388800,12749011200,12780547200),$mul($select($substr(%first_played%,6,7),
0,31,$ifequal($get(x_year),4,60,59),$ifequal($get(x_year),4,91,90),$ifequal($get(x_year),4,121,120),
$ifequal($get(x_year),4,152,151),$ifequal($get(x_year),4,182,181),$ifequal($get(x_year),4,213,212),
$ifequal($get(x_year),4,244,243),$ifequal($get(x_year),4,274,273),$ifequal($get(x_year),4,305,304),
$ifequal($get(x_year),4,335,334)),86400),$mul($sub($substr(%first_played%,9,10),1),86400),
$mul($substr(%first_played%,12,13),3600),$mul($substr(%first_played%,15,16),60),$substr(%first_played%,18,19)))


To convert LAST_PLAYED to timestamp (format: 200Y-MM-DD HH:MM:SS):
Code: [Select]
$mul(10000000,$add($mul(5,3600),$select($put(x_year,$substr(%last_played%,4,4)),12622780800,
12654316800,12685852800,12717388800,12749011200,12780547200),$mul($select($substr(%last_played%,6,7),
0,31,$ifequal($get(x_year),4,60,59),$ifequal($get(x_year),4,91,90),$ifequal($get(x_year),4,121,120),
$ifequal($get(x_year),4,152,151),$ifequal($get(x_year),4,182,181),$ifequal($get(x_year),4,213,212),
$ifequal($get(x_year),4,244,243),$ifequal($get(x_year),4,274,273),$ifequal($get(x_year),4,305,304),
$ifequal($get(x_year),4,335,334)),86400),$mul($sub($substr(%last_played%,9,10),1),86400),
$mul($substr(%last_played%,12,13),3600),$mul($substr(%last_played%,15,16),60),$substr(%last_played%,18,19)))

Official Playback Statistics component

Reply #60
hi, im using normal %last_played% tags in the playlist tree. where the tags already have the date. if i switch to this plugin, will all this code make the tree unusable when it has to process this code for every song?

Official Playback Statistics component

Reply #61
I don't know if it would make the tree unuseable, but if you are using the official playback statistics, you'd want to convert the tags into the new format so that they are being updated by the plugin correctly.

I wrote the above code for the mass tagging utility in foobar. Right click on a song > Tagging... > Manage Scripts > click on Add > select "Format value from other fields..." > type in or select the tag that you want to modify (such as LAST_PLAYED_TIMESTAMP) > paste my code into "Formatting pattern:" field (after removing all of the line breaks, because the code should all be on one line) > press OK > put a name for the script in the "Scripts" field > click on save.

You can then click on Run or use the right click menu to run the script on a song or a group of songs. Once you have confirmed that the conversion worked correctly (by comparing old tags' dates to new tags' dates), you then should delete/rename the old tags so that the new tags display properly in foobar (using %last_played%).

Edit: This will overwrite anything currently in LAST_PLAYED_TIMESTAMP, so if there is any data in the tag you should probably copy it to another tag until you are sure you don't want it.

Official Playback Statistics component

Reply #62
It seems that if Foobar is used to rename or move files with db-only tags, the stored playback statistics are lost! Even renaming the file back to it's original name doesn't help. Is this intended behaviour? And if so, is the only way around this to store the playback statistics in the file tags? If that is the case, what would be the easiest way to convert the tags stored in the db into file tags in masstagger?

Official Playback Statistics component

Reply #63
Reworked the code to make it easier to modify for different time zones and also ran them through more thorough testing.

In the part of the code that is "$mul(10000000,$add($mul(5,3600)" change the 5 to an appropriate offset value for your data. All of these only work for dates on or after 2001-01-01 00:00:00.


i am here:
Standard time zone:   UTC/GMT +1 hour
Daylight saving time:   +1 hour
Current time zone offset:   UTC/GMT +2 hours
Time zone abbreviation:   CEST - Central European Summer Time

Shall i use current real time offse without daylight savings, and, since it is plus and not minus how shall i adapt that piece of code?

thanks in advance

 

Official Playback Statistics component

Reply #64
Please allow me to choose to apply this plugin to music that is not in my database! (I am using it on newly downloaded music that hasn't been imported yet. I very frequently do that, so to update by database each and every time is a little unnecessary. Not to mention, I just don't like to use the database and you could allow me to do that if the old option was re-created.) In general, all of the settings on the unofficial version would be very handy! ... >_<

Official Playback Statistics component

Reply #65
Please allow me to choose to apply this plugin to music that is not in my database! (I am using it on newly downloaded music that hasn't been imported yet. I very frequently do that, so to update by database each and every time is a little unnecessary. Not to mention, I just don't like to use the database and you could allow me to do that if the old option was re-created.) In general, all of the settings on the unofficial version would be very handy! ... >_<

i like the fact that it tries to keep the statistics off the files, but it's just not sophisticated enough to track files that have been moved. maybe the move and rename options in foobar will allow you to keep the stats.

also, i think this might be considered a bug. lets say i run a script to convert old tags to the new tag scheme. if i do this and then synchronize the statistics with the file tags, the stats are wiped. this is fine, but when i reload the files in the database and then synchronize the statistics the tags are still wiped. it seems that the statistic tags are only updated properly in the database after a file has been played. shouldn't the this also happen when  the database is rescanned?

i tried to screw with the play counts by restarting foobar and messing with the slider. it only updated tags once after the file was loaded and 60 seconds of the track played, or less of the track length is under 60 seconds. it does this regardless if foobar restarted and playback is resumed. i don't think this behavior could be any better.

as for stats not updating on files not in the database, i hope someone can make an option for this, as well as reloading info and stats from file(s).

here is the masstagger script i put together that will convert YYYY-MM-DD hh:mm:ss tags to whatever format this plugin uses. the code is by iridium183.
stats format updater.mts

Official Playback Statistics component

Reply #66
I've been reading this thread to better understand the behavior of this component, and I'd like to record what I've learned in the wiki.  Before I do, is the following accurate?:

* Playback statistics are stored in the foobar database (database.fpl), and are retrievable by using %LAST_PLAYED%, %FIRST_PLAYED%, and %PLAY_COUNT%.  Stats can be written to tags through either a context menu or by enabling tag writing in foobar's advanced preferences section.

* When stats are written to the file's tags, they are given the names %LAST_PLAYED_TIMESTAMP% and %FIRST_PLAYED_TIMESTAMP%

* If you had previously written playback stats to your files using the unofficial foo_playcount, that component's %PLAY_COUNTER% value will be incorporated into the official foo_playcount's %PLAY_COUNT% value to retain playcount history.

* The official foo_playcount will not, however, incorporate the unofficial component's %FIRST_PLAYED% field.  The old value will remain in the tag and the new value will be written to the database.

* If %FIRST_PLAYED% or %LAST_PLAYED% is called, and values exist both in the file's tag and in the database, the file's tag will take precedence.

* %PLAY_COUNT% is increased by 1 when 60 seconds of a file have elapsed, whether consecutively or not.  This threshold is shorter for songs shorter than 60 seconds.

* %LAST_PLAYED% and %FIRST_PLAYED% are stored in the format YYYY-MM-DD HH:MM:SS


Is there anything else I should mention?

Official Playback Statistics component

Reply #67
* Playback statistics are stored in the foobar database (database.fpl), and are retrievable by using %LAST_PLAYED%, %FIRST_PLAYED%, and %PLAY_COUNT%.  Stats can be written to tags through either a context menu or by enabling tag writing in foobar's advanced preferences section.
The statistics are not stored in database.fpl, but in foobar2000.cfg. The rest is correct.

* If you had previously written playback stats to your files using the unofficial foo_playcount, that component's %PLAY_COUNTER% value will be incorporated into the official foo_playcount's %PLAY_COUNT% value to retain playcount history.
Yes, the component should import an existing play count value from file tags.

* The official foo_playcount will not, however, incorporate the unofficial component's %FIRST_PLAYED% field.  The old value will remain in the tag and the new value will be written to the database.
Yes, playback timestamps will not be imported.

* If %FIRST_PLAYED% or %LAST_PLAYED% is called, and values exist both in the file's tag and in the database, the file's tag will take precedence.
Yes, actual tags always take precedence over "virtual" fields provided by a component such as foo_playcount (see below).

* %PLAY_COUNT% is increased by 1 when 60 seconds of a file have elapsed, whether consecutively or not.  This threshold is shorter for songs shorter than 60 seconds.
Correct.

* %LAST_PLAYED% and %FIRST_PLAYED% are stored in the format YYYY-MM-DD HH:MM:SS
Not quite. foo_playcount actually stores those timestamps as Win32 FILETIME values (i.e. 100ns intervals since January 1, 1601). If you synchronize playback statistics to files, they will be stored in text form as %first_played_timestamp% and %last_played_timestamp% (and only in that case will you be able to access the raw timestamps in titleformatting scripts with these names). foo_playcount provides the fields %first_played% and %last_played% dynamically to titleformatting scripts using the date format you mentioned.

Official Playback Statistics component

Reply #68
Thanks foosion -- though it appears the wiki is locked.

Official Playback Statistics component

Reply #69
I know this has been discussed before, so excuse me if this is something you've considered and decided against.  But I would really like the option for a multi-value %PLAY_STAMP% field that contains timestamps for every time a track is played.  With the new file properties dialog, these won't take up tons of room (which was an earlier concern), and the data could prove useful (for instance, in my hotness code).

I know it's arguably frivolous, but giving us the option would be nice.

edit: Also, can the wiki page for this component be unlocked so that I can add that info from a few posts ago?  Or can someone else add it?  Those are important facts about the way the component behaves, it's a shame that you have to mine the forum to learn them.

Official Playback Statistics component

Reply #70
I had been using the old playcount component until a few months ago when I finally made the switch to 0.9.x, but I didn't realize that the datestamp formats had changed. I'm trying to figure out exactly how to convert the legacy data into the new format and having a bit of trouble.

The biggest part of the problem stems from the fact that I've been using the new official component for a few months, and I can't just blindly convert all the old datestamps over without clobbering the more recent data. (I think? Or can I?) The official component wasn't configured to automatically write to tags, so the most recent datestamps exist only in the database. The old data from the 0.8.x playcount component are in FIRST_PLAYED/LAST_PLAYED tags, in YYYY-MM-DD HH:MM:SS format.

From what I've been able to figure out so far, I just need to convert all the old FIRST_PLAYED tags to FIRST_PLAYED_TIMESTAMP with the snippet a few posts above this one, then remove the FIRST_PLAYED tag so that %first_played% will use the internally-calculated value instead of the physical tag. However, I tested this out on a few files, and foobar is ignoring the new FIRST_PLAYED_TIMESTAMP tag which I just wrote to the file, and reporting the value for %first_played% that it had in the database before, even after reloading the info from disk. Am I doing something wrong? Is there any way I can wipe all the timestamps from the database and get foobar to just use whatever it sees in the file tags after I convert them to the new format? Keeping the metadata with the files themselves rather of tucking them away in a seperate database/config file is my preferred method, so I certainly won't mind syncing the stats with the file tags first if I have to.

Official Playback Statistics component

Reply #71
walla: The amount of seconds since January 1st 1970 00:00.
EDIT: typo
Wrong. It is not a UNIX time, which is quite easy to see, if you try to interpret the number as such (year 4,058,128,518). Try Win32 FILETIME instead.


Sorry I didn't understand whats on the linked page. How kann I show the date and time last played in tags?
You can see this correct in properties - properties tab

Iridium: Do I understand your description correct you added a script which add the right time tag?

Official Playback Statistics component

Reply #72
@Gob the .mts doesn't work for me

How can I get rid of the useless timestamp tags? and have instead last_played/First played?

Official Playback Statistics component

Reply #73
@Gob the .mts doesn't work for me

How can I get rid of the useless timestamp tags? and have instead last_played/First played?



i'm not too sure what you're asking here. are you sure you're using my mts for the right purpose? and what are the useless tags you are trying to get rid of?

Official Playback Statistics component

Reply #74
Sorry I was a bit angry    Now I feel ashamed.
So for example I have a a track:

Quote
Artist Name : Ensiferum
Track Title : Goblins' Dance
Album Title : Ensiferum
Date : 2001
Genre : Metal
Track Number : 12
<FIRST_PLAYED_TIMESTAMP> : 128097358089062500
<LAST_PLAYED_TIMESTAMP> : 128106551782812500
<PLAY_COUNT> : 4


On properties tab:
Quote
Played : 4 times
First Played : 2006-12-04 20:56:48
Last Played : 2006-12-15 12:19:38


I loaded your script and ran it. As you can see there are the timestamp tags.But there is no date.
So I thought it didn't work. Maybe I have done something wrong?

Please give me some adwise.
Sorry for beeing so stupid.