Help - Search - Members - Calendar
Full Version: %last_played% in 0.9.5.3
Hydrogenaudio Forums > Hosted Forums > foobar2000 > General - (fb2k)
orbtwin
in new 0.9.5.3 cwb_hooks is banned huh.gif . then one string i use for showing %last_played% doesn't work, showing only 'today' ... and this isn't correct.

then, if i only write %last_played% fb2k shows something like YY-MM-DD and hour, and it's a bit "absolutist" and ugly IMHO huh.gif

i managed to get work "old natural language timestamps code" without cwb_hook and it works in ng-playlist, but it doesn't in track_info_mod, showing incorrect times.

Otherwise, there some code for display %last_played% in a more natural or normal way?, without xxx days ago, cos i know it's impossible in new 0.9.5.3.
Mar2zz
You can substract year or month or day with $year $month or $day. Then you can make your own order.

_oao
QUOTE
You can substract year or month or day with $year $month or $day. Then you can make your own order.


Yeap! Since 0.9.5.3 these new title formatting functions were introduced:

QUOTE(Title Formatting Help)
- $year(time): Retrieves the year part (formatted as four digits) from a time/date string.
- $month(time): Retrieves the month part (formatted as two digits) from a time/date string.
- $day_of_month(time): Retrieves the day of month part (formatted as two digits) from a time/date string.
- $date(time): Retrieves the date part (formatted as YYYY-MM-DD) from a time/date string.
- $time(time): Retrieves the time part (formatted as HH:MM:SS or HH:MM) from a date/time string.
orbtwin
QUOTE(_oao @ Jun 8 2008, 10:50) *

QUOTE
You can substract year or month or day with $year $month or $day. Then you can make your own order.


Yeap! Since 0.9.5.3 these new title formatting functions were introduced:

QUOTE(Title Formatting Help)
- $year(time): Retrieves the year part (formatted as four digits) from a time/date string.
- $month(time): Retrieves the month part (formatted as two digits) from a time/date string.
- $day_of_month(time): Retrieves the day of month part (formatted as two digits) from a time/date string.
- $date(time): Retrieves the date part (formatted as YYYY-MM-DD) from a time/date string.
- $time(time): Retrieves the time part (formatted as HH:MM:SS or HH:MM) from a date/time string.




thanks for reply, but how, i.e, show the %last_played% in this way: 'Last Played On: 5 of July' or '15 of October'
or better: last night, Yesterday, last month etc...
thuan
For things like last month, last night,... you needs current date time which you can only get in either of Columns UI playlist views, then write some code for it and display it as a column. As for month display like in your first example you can simply use:
CODE
$select($month(%last_played%),January,...,December)
Please fill in the ellipsis part.

You should be able to figure out the rest. I'm too busy with "Mass effect" currently XD.
orbtwin
thanks thuan i'll give a try.
in fact using natural language timestamps without cwb_hooks version works well if i put it into ng_playlist. puttint whole code in global variable tab then using $get_global as column script.
for some reason it doesn't work in track_info_mod. I supose because this component is banned as foo_panels?.

otherwise thanks cool.gif

thuan
You could just use the 2nd version there, but it will only work in playlist as indicated because the system date time fields, provided by columns UI, only work in playlist view, it's not because of the ban or whatever.

There're some optimizations can be done to this code using new functions provided in foobar 0.9.5.3, but well I'm lazy currently so you should take a look first.
Frank Bicking
QUOTE(orbtwin @ Jun 8 2008, 01:33) *
in new 0.9.5.3 cwb_hooks is banned
QUOTE(orbtwin @ Jun 8 2008, 18:06) *
for some reason it doesn't work in track_info_mod. I supose because this component is banned as foo_panels?.

Just to clear up a misunderstanding, neither of those components is banned. foo_cwb_hooks and foo_ui_panels just became incompatible as foobar2000 kept moving forward in order to urge developers to come up with different approaches to certain problems, with their authors not showing any interest in renewing them.
orbtwin
i understand the resons for the new metadb_display_hooks is deprecated...

what i wanted to say is "incompatible" not banned, sorry!

otherwise i've tweaked my code again and i'm enough satisfied now: thanks thuan again rolleyes.gif rolleyes.gif

total plays:
CODE
$if(%play_count%,Played: %play_count% time$if($stricmp(%play_count%,1),,s),Never Played)


last played:
CODE
[/ Last Played: $select($day_of_month(%last_played%& #41;,1st,2nd,3rd,4th,5th,6th,7th,8th,9th,10th,11th,12th,13th,14th,15th,16th,17th,18th,19th,20th,21th
,22th,23th,24th,25th,26th,27th,28th,29th,30th,31th) $select($month(%last_played%),of January,of February,of March,of April,of May,of June,of July,of August,of September,of October,of November,of December), $year(%last_played%)]


first played:
CODE
$if(%first_played%,$puts(fpm,$substr(%first_played%,9,10)) / First Played: $num($get(fpm),1)$ifgreater(2,$get(fpm),st,$ifgreater(3,$get(fpm),nd,$ifgreater(4,$get(fpm),rd,th))) of $select($substr(%first_played%,6,7),January,February,March,April,May,June,July,Auguest,September,October,November,December)',' $substr(%first_played%,1,4))






kanak
You can simplify the "day" portion of your last played code somewhat by doing something along the lines of:

CODE

$put($day_of_month(%last_played%),day)
$ifgreater(day,3,th,$select(day,st,nd,rd))
Canar
QUOTE(kanak @ Jun 8 2008, 10:44) *
You can simplify the "day" portion of your last played code somewhat by doing something along the lines of:


Have you tried that code? It doesn't look quite right to me. It also doesn't consider the 20s, like 22nd, 21st, etc.
orbtwin
AFAIK only the First, Second and Third (1st, 2nd, 3rd) has different suffix, the rest has th.

First: 1st
Second: 2n
Third: 3rd
Fourth: 4th
...
Twenty Second: 22th

smile.gif
Canar
Twenty-first is 21st, twenty-second is 22nd, twenty-third is 23rd, and so on. I'm a native English speaker from Canada. Perhaps they do something different abroad.
kanak
QUOTE(Canar @ Jun 8 2008, 13:47) *

QUOTE(kanak @ Jun 8 2008, 10:44) *
You can simplify the "day" portion of your last played code somewhat by doing something along the lines of:


Have you tried that code? It doesn't look quite right to me. It also doesn't consider the 20s, like 22nd, 21st, etc.


You're right. I was merely simplifying the provided code (as i thought that was the behavior that he wanted).

Even if we do include checks for 21st, 22nd, 23rd, and 31st, i think it's much more concise to use $ifgreater with $select rather than having a gigantic $select.
orbtwin
thxs for yours explanations cool.gif
will someday fb2k suport for natural timestamps plays by default without tweaking code?
shakey_snake
If I had to guess, by what Peter says here, I would guess probably not.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.