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: Play Counter (Read 340016 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Play Counter

Reply #50
Quote
Quote
That would be even better. Allowing people to have x tags added to a file when has been played y% through. Each of the tags being a combination of the information coming out of a time() function (timestamp, yearday, monthday, hour, etc..)


I'm not sure what you are saying.  I was thinking something along the line of being able to enter: YYMMDD.  Or if they wanted to preformat it MM-DD-YYYY, or DD/MM/YY.  You probably wouldn't want to use non-numbers in the format if you wanted to do what you had suggested (play_date LESS 040415).  But it would save having to have the various title formatting do it.  Up to the user though.

I think I went over the top with that

The main thing is for it to be possible to do three things (as far as I can think):
1. Display a nice date/time for the last time this song was played without having to resort to too much (or any) title-formatting. This is already possible given the way you have made the plugin.

2. Use a search of some sort to find songs last played on or after a certain day. This would be possible using YYMMDD instead of the current DDMMYY

3. Use a search to find songs last played more than a certain length of time ago (e.g. 24hrs). Just saying "the day before" doesn't work if it is just after midnight . I believe this would be best done with a timestamp in seconds as you can then get the current time and subtract the length you want. Neither of the above would allow this because ***this was incorrect! woops***

Play Counter

Reply #51
Ok what I meant in part 3 was assuming the split play_date and play_time fields, you couldn't say play_date LESS 040416 AND play_time LESS 2000  to get all tracks played before 8pm on 16-04-04. Of course this is irrelevant if you can choose the formatting to be: YYMMDDHHMM

If that was the case, the reason I was talking about

Quote
Allowing people to have x tags added to a file when has been played y% through.


was to allow one field to be play_date_readable (for e.g.) and one to be play_date_calculable.

obviously with better names

Play Counter

Reply #52
Quote
***this was incorrect! woops***


You caught it before I could point that out. 

The nice thing about formatting is that you could set the format for PLAY_DATE to YYMMDDHHMMSS, and easily use  "play_date GREATER 0404142000".  With a timestamp, you'd first have to figure out what the seconds past the epoch are (not very straight forward.
Santa is very jolly because he knows where all the bad girls live.  - Dennis Miller

Play Counter

Reply #53
Please, make the storage of the time format standard, and then just choose the way it would be displayed.  Not using a standard format means that you will have cases that make it impossible to determine the real date.

Example:
User stores the date as 10/08/2000.  In Europe this means August 10th, 2000.  In the US, it means October 8th, 2000.

Solution:
Always store the time in a well defined format.  I would suggest the W3 Date/Time format.  It is simple, well defined, a subset of the ISO 8601 standard, and the accuracy can be changed by where you truncate the date.  It is also easy to parse for simpler display.  (You may want to leave out the "T" in the middle for readability though.)

Play Counter

Reply #54
Quote
Please, make the storage of the time format standard, and then just choose the way it would be displayed. Not using a standard format means that you will have cases that make it impossible to determine the real date.


This is a tricky issue.  Say a common format is chosen.  Do we store timezone information?  We don't now, it's just the local time.  If we store timezone info, this complicates displaying a local time in the playlist (or wherever).  Or, we could store everything GMT, but displaying local time is still a problem.

My point is this:  There is no simple way to handle this when this info is expected to be used by TAGZ.  If someone were using this via C++, it's a different question, and I would store a timestamp.

Would it not be acceptable to allow the user to specify the format?  That is, you could choose to enter a format that produces ISO 8601.
Santa is very jolly because he knows where all the bad girls live.  - Dennis Miller

Play Counter

Reply #55
New version:

1.3 (Apr 16 2004):

1) Added support for specifying the date/time tags and format.  The tag name can be specified, or left blank to skip.  For either field, a format string can be specified.



The preference page lets you specify up to two tags, and each corresponding format.  If you don't change the preference page, it should work exactly as the previous version.

If you want something like teetee desired, you could change the first tag name to "PLAY_STAMP", and use a format that produces YYMMDDhhmmss, then blank out the fields for the second tag.

It's also possible to use the masstagger to combine (and reformat) the existing fields into a single field.  For example, use "Format value from other fields", specify PLAY_STAMP as the destination field name, and for the Formatting Pattern, use:

Code: [Select]
"$right(%play_date%,2)$substr(%play_date%,3,4)$left(%play_date%,2)%play_time%"


This would combine PLAY_DATE and PLAY_TIME into a PLAY_STAMP of the format mentioned above.

It will make more sense when you look at the pref page and formatting help dialog.

Play Count 1.3 (Binary)

Play Count 1.3 (Source)
Santa is very jolly because he knows where all the bad girls live.  - Dennis Miller

Play Counter

Reply #56
Very nice, thanks tboehrer :]

For those who want to use the W3 Date/Time format as Pamel suggested, I've saved you the (little) trouble so you can just paste this into the format:
Code: [Select]
%Y-%M-%DT$H:$M:$S$T


Edit:
you can also convert the older PLAY_DATE and PLAY_TIME tags to this format, as tboehrer pointed, using the Masstagger's "Format value from other fields"; use the following:
Code: [Select]
20$right(%play_date%,2)-$substr(%play_date%,3,4)-$left(%play_date%,2)T$left(%play_time%,2):$substr(%play_time%,3,4):$right(%play_time%,2)+08:00

Remember to replace the "+08:00" with whatever timezone $T gives you

Edit 2 (yeah I know; bored and nothing better to do..):

Formatting string writers, you can parse this into a nicer display
(namely, 2004-04-15T21:02:05+08:00 -> 2004.04.15 9:02:05 PM) with the following:
Code: [Select]
$if(%play_stamp%,
$left(%play_stamp%,4).
$substr(%play_stamp%,6,7).
$substr(%play_stamp%,9,10)$tab()

$if($greater($substr(%play_stamp%,12,13),12),
$sub($substr(%play_stamp%,12,13),12),
$if($strcmp($substr(%play_stamp%,12,13),00),12,
$num($substr(%play_stamp%,12,13),1)))
$substr(%play_stamp%,14,19)
$if($greater($substr(%play_stamp%,12,13),11), PM, AM))

What's nice about this one is that you can easily change the separaters if you don't like '-' (I find '.' the most visually appealing)

Edit 3: small fix in above title formatting (12 PM/AM)
f to c to f to c

Play Counter

Reply #57
I'm struggling to see the benefit of this new feature... would putting them in this said (^) format allow sorting? (Because at the moment PLAY_DATE is just treated as a numerical value when sorting.) Or is the benefit a better appearing/easier to read timestamp?

Steve

Play Counter

Reply #58
Okay,I'm trying to write a script that'll automatically rate my files according to number of plays. I'm new to Foobar, and I'd put myself in the 'Beginner' catagory of programming skill, but I really can't see anything wrong with this. Maybe one you funky people could help?

Quote
$if(%PLAY_COUNTER%>15,5,$if(%PLAY_COUNTER%>10,4,$if(%PLAY_COUNTER%>5,3,$if(%PLAY_COUNTER%>3,2,$if(%PLAY_COUNTER%>1,1,0)))))


The field to be endited, quite obviously is RATING. If anyone needs it explained in English I can do that, but I think its pretty obvious what I'm trying to achieve.

Steve

[EDIT] Atm, this returns 5 for every track [/EDIT]

Play Counter

Reply #59
You might want to give $ifgreater() a try.

I don't think you can use < directly as mathematical functions in TAGZ.

Hope this helps.  In case you have anymore questions, feel free to ask.

You can find a definition of $ifgreater in the titleformatting help.

edit: The usual late discovery of a typo

Play Counter

Reply #60
Quote
I'm struggling to see the benefit of this new feature... would putting them in this said (^) format allow sorting? (Because at the moment PLAY_DATE is just treated as a numerical value when sorting.) Or is the benefit a better appearing/easier to read timestamp?

Steve

The benefit of changing the PLAY_DATE field to at least YYMMDD is that you will then be able to sort by date across months (and years). With the default format, if you play something on 30th April (300404) and then something on 1st May (010504), they will be sorted wrong (10,504 < 300,404).

Using the full timestamp in W3 Date/Time format allows you to also sort by time (up to second accuracy). Also, if someone wrote a plugin using these timestamps for part of its functionality, it would be better if there was one format being used with all the possible information it.

I don't think sorting across timezones would work but that would be a lot rarer for an individual .

PS Thanks for the new version tboehrer

Play Counter

Reply #61
I would like an option like "only update in db", else i have to fill in all my file types in DB Only Mask

Play Counter

Reply #62
Quote
You might want to give $ifgreater() a try.

I don't think you can use < directly as mathematical functions in TAGZ.

Hope this helps.  In case you have anymore questions, feel free to ask.

You cam find a definition of $ifgreater in the titleformatting help.

Cheers - that works fine :-)

and Cheers teetee for that explanation. I'll give formatting a sorting a go later today... its a feature that I'd like to make use of.

Steve

Play Counter

Reply #63
Quote
Very nice, thanks tboehrer :]

For those who want to use the W3 Date/Time format as Pamel suggested, I've saved you the (little) trouble so you can just paste this into the format:
Code: [Select]
%Y-%M-%DT$H:$M:$S$T


Edit:
you can also convert the older PLAY_DATE and PLAY_TIME tags to this format, as tboehrer pointed, using the Masstagger's "Format value from other fields"; use the following:
Code: [Select]
20$right(%play_date%,2)-$substr(%play_date%,3,4)-$left(%play_date%,2)T$left(%play_time%,2):$substr(%play_time%,3,4):$right(%play_time%,2)+08:00

Remember to replace the "+08:00" with whatever timezone $T gives you

Edit 2 (yeah I know; bored and nothing better to do..):

Formatting string writers, you can parse this into a nicer display
(namely, 2004-04-15T21:02:05+08:00 -> 2004.04.15 9:02:05 PM) with the following:
Code: [Select]
$if(%play_stamp%,
$left(%play_stamp%,4).
$substr(%play_stamp%,6,7).
$substr(%play_stamp%,9,10)$tab()

$if($greater($substr(%play_stamp%,12,13),12),
$sub($substr(%play_stamp%,12,13),12),
$if($strcmp($substr(%play_stamp%,12,13),00),12,
$num($substr(%play_stamp%,12,13),1)))
$substr(%play_stamp%,14,19)
$if($greater($substr(%play_stamp%,12,13),11), PM, AM))

What's nice about this one is that you can easily change the separaters if you don't like '-' (I find '.' the most visually appealing)

Edit 3: small fix in above title formatting (12 PM/AM)

Cheers, this was a fantastic help. I used the standard formatting for play_stamp, and I used your code to convert the old tags.

I edited your script slightly  I changed the date around so it was in a nicer, British format: just because the tag is in that silly order doesn't mean I have to view it like that

Thanks alot,
Steve

Play Counter

Reply #64
Nice pointers guys!! I appreciate the AM/PM formatting... I was too lazy to figure it out myself.   

Linkin Posted on Apr 17 2004, 02:13 AM:
Quote
I would like an option like "only update in db", else i have to fill in all my file types in DB Only Mask


*.* should work.  I think...
Santa is very jolly because he knows where all the bad girls live.  - Dennis Miller

Play Counter

Reply #65
Please excuse my lack of title formatting skills, but I don't know where to place the string to show the counter (just the counter, not the last time played) at the far right of the playlist.

Here is my current formatting string:
Code: [Select]
 removed for thread space


If someone could tell me where in the string to put it, that would be great.

Thanks for the plugin, I'm looking forward to using it.

Play Counter

Reply #66
Quote
Quote
Very nice, thanks tboehrer :]

For those who want to use the W3 Date/Time format as Pamel suggested, I've saved you the (little) trouble so you can just paste this into the format:
Code: [Select]
%Y-%M-%DT$H:$M:$S$T


Edit:
you can also convert the older PLAY_DATE and PLAY_TIME tags to this format, as tboehrer pointed, using the Masstagger's "Format value from other fields"; use the following:
Code: [Select]
20$right(%play_date%,2)-$substr(%play_date%,3,4)-$left(%play_date%,2)T$left(%play_time%,2):$substr(%play_time%,3,4):$right(%play_time%,2)+08:00

Remember to replace the "+08:00" with whatever timezone $T gives you

Edit 2 (yeah I know; bored and nothing better to do..):

Formatting string writers, you can parse this into a nicer display
(namely, 2004-04-15T21:02:05+08:00 -> 2004.04.15 9:02:05 PM) with the following:
Code: [Select]
$if(%play_stamp%,
$left(%play_stamp%,4).
$substr(%play_stamp%,6,7).
$substr(%play_stamp%,9,10)$tab()

$if($greater($substr(%play_stamp%,12,13),12),
$sub($substr(%play_stamp%,12,13),12),
$if($strcmp($substr(%play_stamp%,12,13),00),12,
$num($substr(%play_stamp%,12,13),1)))
$substr(%play_stamp%,14,19)
$if($greater($substr(%play_stamp%,12,13),11), PM, AM))

What's nice about this one is that you can easily change the separaters if you don't like '-' (I find '.' the most visually appealing)

Edit 3: small fix in above title formatting (12 PM/AM)

Cheers, this was a fantastic help. I used the standard formatting for play_stamp, and I used your code to convert the old tags.

I edited your script slightly  I changed the date around so it was in a nicer, British format: just because the tag is in that silly order doesn't mean I have to view it like that

Thanks alot,
Steve

Silverbolt I'm undermiming you again

I've edited your formatting script again  Here's mine now:
Quote
$ifgreater(%PLAY_COUNTER%,0,$if(%play_stamp%,
$substr(%play_stamp%,6,7).
$substr(%play_stamp%,9,10).
$left(%play_stamp%,4)$tab()

$if($greater($substr(%play_stamp%,12,13),12),
$sub($substr(%play_stamp%,12,13),12),
$if($strcmp($substr(%play_stamp%,12,13),00),12,
$num($substr(%play_stamp%,12,13),1)))
$substr(%play_stamp%,14,19)
$if($greater($substr(%play_stamp%,12,13),11), PM, AM)),)


Did this because when the track hasn't been played loadsa horrible random stuff was being displayed in Last Played collumn. There is probably a better way of scripting it, but this was the only way I could think of.

Steve

Play Counter

Reply #67
@Addicted:

That seems to be the global script... go to Collumns, add collumn, call it what you like, and in the display tab, paste the script.

Steve

Play Counter

Reply #68
Sorry, I dont use columns..... just the default playlist with the above formatting string...

(edit spelling)

Play Counter

Reply #69
@addicted

You can add this at the end of you code or where ever you want it!!
Code: [Select]
$if(%play_counter%,
$repeat('0',$sub($len2(1000),$len2(%play_counter%)))%play_counter%,0000)

Play Counter

Reply #70
Thanks a lot..... I even figured out how to set it's color and add a "pipe" on the left side.

Play Counter

Reply #71
I'd love this plugin if it was able to put the stats on a separate (plain text?) file and that could be then accessed through some sort of interface.
The only problem I can figure would be knowing what songs are really played. Perhaps it should track them by paths, but then, if I rename a file it would b0rk the statistics. Perhaps it would be somehow possible to see changes made by foobar's masstagger/renamer, as that's the only way I rename my files.

Play Counter

Reply #72
Quote
Perhaps it would be somehow possible to see changes made by foobar's masstagger/renamer, as that's the only way I rename my files.

It is possible to get notifications of files being moved by masstagger and similar plugins (if there were any), so that's not a problem. If the play counts are stored in an external file, path and subsong index should be used as key.

Play Counter

Reply #73
Quote
Quote

(anza @ Apr 20 2004, 01:06 PM)
Perhaps it would be somehow possible to see changes made by foobar's masstagger/renamer, as that's the only way I rename my files. 


It is possible to get notifications of files being moved by masstagger and similar plugins (if there were any), so that's not a problem. If the play counts are stored in an external file, path and subsong index should be used as key.



I wouldn't hold your breath for me changing it to write to an external file... but hey... I posted the source. 
Santa is very jolly because he knows where all the bad girls live.  - Dennis Miller

Play Counter

Reply #74
Quote
I wouldn't hold your breath for me changing it to write to an external file... but hey... I posted the source.  

Thanks, I already have enough plugins of my own to keep me busy.