Help - Search - Members - Calendar
Full Version: foo_txt date formatting error?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
Mr_Rabid_Teddybear
Hello,
Trying to write formatting string for foo_text to write me a foobar logfile.
According to helpfile (foo_text 1.3.5a) using %_system_date% should return the current date as specified in systems regional options:
QUOTE
Note: %_system_time% and %_system_date% use system date formatting (see control panel>regional options)


Today is 7. december 2003. I'm running Windows XP here. It's an english version of this OS but I have specified all norwegian regional settings in control panel, so the date should be returned like this (and is, in other progs):

07.12.2003 (or 07.12.03)

but foo_text still insist on writing the date to my logfile with american formatting, like this:

12/07/03

This is a bit annoying. Would be grateful if anybody could help me out here..... I need correct time & date info in my logfile and I want it displayed with the formatting I'm used to.
musicmusic
You're right, I though that's where it got it from but apparently not ph34r.gif. I don't know how i missed that since I live in the UK ...

I'll see what i can do tomorrow to add some fields for numerical versions of day/month/year (if that would be ok) or a version of %_system_date% that has correct formatting. Which would you prefer, bearing in mind that the former would not allow for any word representations of the date.
anza
I'd like numerical versions of days, months and years. After all, they could be easily formatted to words with simple pieces of code, like for example $if($stricmp(%_month%,1),January) or $replace($num(%_month%,2),01,January,02,February). IMHO that would make it more configurable. Of course, a fixed version of %_system_date% would be nice, too smile.gif

edit: added the other title formatting code.
Mr_Rabid_Teddybear
Thanks for quick response! smile.gif

What I would like see returned in my logfile is a representation of time/date like this:

01:12:04 - 08.12.2003 (or 01:12:04 - 08.12.03 would be OK too)

(We're also using 24 hour clock in Norway, but the time formatting seems to be working just fine.)
Anyway, yes, numeric representation is all I need. How much work you would like to put into this for the benefit of other peoples possible needs is all up to you I guess biggrin.gif - but I personally don't need text formatting of time/date.
--------------------

By the way - if I might be so bold wink.gif - I try another Q when we're at it.
I found this to be a working string for "playing" for my purposes:
CODE

[%_system_time%] - [%_system_date%]$char(13)$char(10)
$if(%_ispaused%,Paused,Now Playing):$char(13)$char(10)
                                    Codec: [%__codec%] [%__bitrate%] kbps / Time: [%_time_total_seconds%] seconds$char(13)$char(10)
Artist: [%artist%]$char(13)$char(10)
Title: [%title%]$char(13)$char(10)
Album: [%album%]$char(13)$char(10)
Date: [%date%]

When I play from file I get something useful out for source like:
QUOTE
1:12:02 - 12/08/03
Now Playing:
                                     Codec: musepack 206 kbps / Time: 94 seconds
Artist: The Magnetic Fields
Title: Absolutely Cuckoo
Album: 69 Love Songs Vol. 1
Date: 1999

...but when I play from audio-CD's this returns nothing to identify the source as an audio-CD, just a empty codec field, so the Q is: Do you know any smarter way to set this up? (tagging of audio CD's i get with foo_freedb)
anza
Try this one:
$if($stricmp($left(%_path_raw%,7),'cdda://'),CDDA,%__codec%)
witt
@musicmusic,

Can you please add support for UTF-8 without BOM(Byte Order Mark)?
PHP doesn't ignore the UTF-8 BOM...
Mr_Rabid_Teddybear
QUOTE(anza @ Dec 7 2003, 05:04 PM)
Try this one:
$if($stricmp($left(%_path_raw%,7),'cdda://'),CDDA,%__codec%)

Thanks for string - works like a bullet tongue.gif
If you/someone could help me out with a string that only will display 'kbps' when bitrate info is present all I still need is the correct date formatting and I'm all set smile.gif smile.gif smile.gif
anza
QUOTE(Mr_Rabid_Teddybear @ Dec 8 2003, 09:30 AM)
[...] If you/someone could help me out with a string that only will display 'kbps' when bitrate info is present [...]

[%__bitrate%kbps] Should work fine.
kode54
QUOTE(anza @ Dec 7 2003, 05:39 PM)
I'd like numerical versions of days, months and years. After all, they could be easily formatted to words with simple pieces of code, like for example $if($stricmp(%_month%,1),January) or $replace($num(%_month%,2),01,January,02,February). IMHO that would make it more configurable. Of course, a fixed version of %_system_date% would be nice, too smile.gif

edit: added the other title formatting code.

Or $select(%_month%,January,February,etc)
musicmusic
QUOTE(anza @ Dec 8 2003, 12:39 AM)
I'd like numerical versions of days, months and years. After all, they could be easily formatted to words with simple pieces of code, like for example $if($stricmp(%_month%,1),January) or $replace($num(%_month%,2),01,January,02,February).
I was actually thinking more along the lines of day of the week, i.e. monday, tuesday etc. It would be considerably more fun to make a script to extract that from the date tongue.gif. Doesn't matter anyway, see below.

-----
Ok i uploaded a temporary version with proper date stuff
download source compiled with 0.7.5 sdk

You now have the following special fields for all your date formatting needs..
QUOTE
- %_system_date% => current user date formatting
- %_system_long_date% => current user date formatting
- %_system_time% => current user time formating
- %_system_year%
- %_system_month%
- %_system_day%
- %_system_day_of_week% => number 1 - 7 (Mon through to Sun)
- %_system_hour%
- %_system_minute%
- %_system_second%


I did both since it made no sense to leave broken %_system_date% in there.. I set them to obey user settings rather than system settings, i think that should be ok.

QUOTE(witt @ Dec 8 2003, 04:18 AM)
@musicmusic,

Can you please add support for UTF-8 without BOM(Byte Order Mark)?
PHP doesn't ignore the UTF-8 BOM...
I was wondering if someone would ask for that.. smile.gif I will do it for next version ok, which will go on main page, probably some time this week.

QUOTE(anza @ Dec 8 2003, 01:04 AM)
Try this one:
$if($stricmp($left(%_path_raw%,7),'cdda://'),CDDA,%__codec%)

There's also this script from one of the default strings, which may be more complete in some circumtances:
CODE
$puts(ext,$upper($if2($ext(%__referenced_file%),$ext(%_path%))))
$puts(codec,$if(%__codec%,$caps2(%__codec%),$get(ext)))
$if($strcmp($get(codec),),
$if($stricmp($left(%_path_raw%,7),'cdda://'),$puts(codec,CDDA),)
,)
Mr_Rabid_Teddybear
QUOTE(musicmusic @ Dec 8 2003, 10:47 AM)
QUOTE(anza @ Dec 8 2003, 01:04 AM)
Try this one:
$if($stricmp($left(%_path_raw%,7),'cdda://'),CDDA,%__codec%)

There's also this script from one of the default strings, which may be more complete in some circumtances:
CODE
$puts(ext,$upper($if2($ext(%__referenced_file%),$ext(%_path%))))
$puts(codec,$if(%__codec%,$caps2(%__codec%),$get(ext)))
$if($strcmp($get(codec),),
$if($stricmp($left(%_path_raw%,7),'cdda://'),$puts(codec,CDDA),)
,)


Hmmmm, for some reason I can't seem to make this last string output anything (anza's does)........

..........well, doesn't matter. Thanks to the help of you people I now got foo_text to output a logfile perfectly fitted for my needs. Date formatting in new version behaves exemplary.

biggrin.gif biggrin.gif biggrin.gif
witt
QUOTE(musicmusic @ Dec 9 2003, 03:47 AM)
QUOTE(witt @ Dec 8 2003, 04:18 AM)
@musicmusic,

Can you please add support for UTF-8 without BOM(Byte Order Mark)?
PHP doesn't ignore the UTF-8 BOM...
I was wondering if someone would ask for that.. smile.gif I will do it for next version ok, which will go on main page, probably some time this week.

Thank you.
Now I can use PHP&UTF-8 without any hack smile.gif
bluenet
The download link seem not work to me,is these any another link supply? blink.gif
musicmusic
QUOTE(witt @ Dec 13 2003, 02:46 AM)
Thank you.
Now I can use PHP&UTF-8 without any hack smile.gif

No problem smile.gif

QUOTE(bluenet @ Dec 13 2003, 04:21 AM)
The download link seem not work to me,is these any another link supply? blink.gif

Probably stupid lycos was down. Try again, here this time.

If it still don't work try here.
bluenet
QUOTE(musicmusic @ Dec 13 2003, 04:28 AM)
QUOTE(witt @ Dec 13 2003, 02:46 AM)
Thank you.
Now I can use PHP&UTF-8 without any hack smile.gif

No problem smile.gif

QUOTE(bluenet @ Dec 13 2003, 04:21 AM)
The download link seem not work to me,is these any another link supply? blink.gif

Probably stupid lycos was down. Try again, here this time.

If it still don't work try here.

I try the two link many time,bu not work.It seem not work for Asia
Can you upload to upload forum?Thinks

And a little request,will it open source laugh.gif
musicmusic
QUOTE(bluenet @ Dec 13 2003, 02:14 PM)
I try the two link many time,bu not work.It seem not work for Asia

Really? That sucks ohmy.gif Maybe your isp has a broken link with uk/europe somewhere ? I uploaded it here for you.

QUOTE
And a little request,will it open source
Its there already, on the webpage with the dll..
Mr_Rabid_Teddybear
Sorry to bother you again, but I got one more Q:
Using this in formattingstring
CODE

$select(%_system_day_of_week%,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)

renders all weekdays Monday 'till Saturday to my logfile... but not Sunday, on which I get only a blank field.
Clearly there's something I have done wrong, but what?
Would appreciate any help. rolleyes.gif
musicmusic
QUOTE(Mr_Rabid_Teddybear @ Dec 28 2003, 05:38 AM)
Sorry to bother you again, but I got one more Q:
Using this in formattingstring
CODE

$select(%_system_day_of_week%,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)

renders all weekdays Monday 'till Saturday to my logfile... but not Sunday, on which I get only a blank field.

Sorry, it was zero-indexed, $select starts at 1 so Sunday got left out.

Please try version 1.3.6a.

Correct string for you should now be $select(%_system_day_of_week%,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) (but first day of week may really depend on your locale)
Mr_Rabid_Teddybear
Thank you! All seems OK now.
And if anyone should be interested, these are my current formatting strings for a logfile:

Playing:
ŻŻŻŻŻŻŻŻ
CODE

[%_system_time%] $select(%_system_day_of_week%,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) [%_system_date%]$char(13)$char(10)
$if(%_ispaused%,Paused,Now Playing):$char(13)$char(10)
                                     Codec: $if($stricmp($left(%_path_raw%,7),'cdda://'),CDDA,%__codec%) [%__bitrate% kbps] / Time: [%_time_total_seconds% seconds]$char(13)$char(10)
Artist: [%artist%]$char(13)$char(10)
Title: [%title%]$char(13)$char(10)
Album: [%album%]$char(13)$char(10)
Date: [%date%]


Stopped:
ŻŻŻŻŻŻŻŻ
CODE

[%_foobar2000_version%] playback order: [%_playback_order_state%]$char(13)$char(10)
$select(%_stop_reason%,Stopped.,Stopped '('end of playlist')',Track info pending...,Stopped.) [%_system_time%] $select(%_system_day_of_week%,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) [%_system_date%]


rolleyes.gif
anza
Btw you can nowadays use $crlf() for new lines smile.gif
Mr_Rabid_Teddybear
Everythings good here......... wink.gif My logfile formatting strings has evolved considerably, taking more stuff into account, so if anyones interested, here they are:

Playing:
ŻŻŻŻŻŻŻŻ
CODE

[%_system_time%] $select(%_system_day_of_week%,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) [%_system_date%]$crlf()
$if(%_ispaused%, '||'  Paused, '>>'  Now Playing):$crlf()
$crlf()
[      Artist: %artist%$crlf()]
     $if(%title%,Title: %title%$crlf(),$if($stricmp($left(%_path_raw%,7),'http://'),Stream[: %_filename%]$crlf(),Sorry. Can''t show. No tag. Path is:$crlf()      '"'%_path_raw%'"'$crlf()))
[      Album: %album%$crlf()]
[      Albumartist: %albumartist%$crlf()]
[      Album artist: %album artist%$crlf()]
[      Date: %date%$crlf()]
[      Genre: %genre%$crlf()]
[      Tracknumber: %tracknumber%$crlf()]
[      Disk: %disc%$crlf()]
[      Track Gain: %__replaygain_track_gain%$crlf()]
[      Album Gain: %__replaygain_album_gain%$crlf()]
[      Comment: $iflonger(%comment%,105,$cut(%comment%,100)'(...)',%comment%)$crlf()]
$crlf()
$if($stricmp($left(%_path_raw%,7),'cdda://'),Source: CDDA,[Codec: $codec()])[ %__bitrate% kbps][ '/'$if($stricmp(%__codec%,'MP3'),$if(%__extrainfo%,[ %__extrainfo%], CBR),)[ %__mp3_stereo_mode%][ Profile: %__mpc_profile%][ '('%__mpc_encoder%')'][ sv%__mpc_streamversion%][ Nominal: %__bitrate_nominal% kbps][ '('%__vorbis_vendor%')'][ Profile: %__aac_profile%][ %__file_format%][ %__format%][ Version: %__version%][ Compression: %__compression%][ Mode: %__mode%][ Seektable: %__seektable%][ %__aac_header_type%]]$crlf()
[Tech: $div(%__samplerate%,1000) kHz[ %__bitspersample% bit][ $channels()]$crlf()]
[Time: %_length%$crlf()]
$if($stricmp($left(%_path_raw%,7),'http://'),[URL: '"'%_path_raw%'"'],$if($stricmp($left(%_path_raw%,7),'cdda://'),[Track: '"'%_filename_ext%'"'],[File: '"'%_filename_ext%'"']$if($stricmp($right(%_path_raw%,4),'.cue'), Cuesheet,[  $div(%_filesize%,1048576).$num($muldiv($mod(%_filesize%,1048576),100,1048576),2) MB])))


Stopped:
ŻŻŻŻŻŻŻŻ
CODE

[%_foobar2000_version%] [playback: %_playback_order_state%]$crlf()
$select(%_stop_reason%, '#'  Stopped., '#'  Stopped '('end of playlist')', '>|'  Track info pending..., '#'  Initialized.) [%_system_time%] $select(%_system_day_of_week%,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) [%_system_date%]

EDIT: Little brush over of code.

anza
A nice feature just occured to me. What about adding an option "also log files played". If it is enabled foo_text works as usual, but ALSO keeps up a log file of files that have been played fully (or perhaps a user definable percentage of the song has been played). If this is implemented, it should also have an separate formatting string box for the log file.
If the feature is disabled, the plugin would work just as it does now, so it creates only one .txt file and it can be used as a log file or a currently playing file or whatever.

This feature would be really nice for people like me, who use foo_text with Samurize or other programs like that, but would also like to have a log of songs played.

Of course ALL of this could be done with using two copies of foo_text and using $stricmp() and counting the percentage played, but I find it quite annoying to have two copies of the same plugin and it'd be cool if it was built in.
musicmusic
QUOTE(anza @ Jan 13 2004, 01:08 PM)
A nice feature just occured to me. What about adding an option "also log files played". If it is enabled foo_text works as usual, but ALSO keeps up a log file of files that have been played fully (or perhaps a user definable percentage of the song has been played). If this is implemented, it should also have an separate formatting string box for the log file.
If the feature is disabled, the plugin would work just as it does now, so it creates only one .txt file and it can be used as a log file or a currently playing file or whatever.

This feature would be really nice for people like me, who use foo_text with Samurize or other programs like that, but would also like to have a log of songs played.

I think multiple file support (with all of the current options per file) and an extra event "write on x% played" would be the best solution. It is planned for the next version, 1.5 or 2.0 or something, but that will probably be awhile..
QUOTE
Of course ALL of this could be done with using two copies of foo_text
That dont work very well with current version anyway due to the two prefs pages..
anza
That's nice to hear smile.gif
Mr_Rabid_Teddybear
QUOTE(anza @ Jan 13 2004, 05:08 AM)
A nice feature just occured to me. What about adding an option "also log files played". If it is enabled foo_text works as usual, but ALSO keeps up a log file of files that have been played fully (or perhaps a user definable percentage of the song has been played). If this is implemented, it should also have an separate formatting string box for the log file.
If the feature is disabled, the plugin would work just as it does now, so it creates only one .txt file and it can be used as a log file or a currently playing file or whatever.

This feature would be really nice for people like me, who use foo_text with Samurize or other programs like that, but would also like to have a log of songs played.

Of course ALL of this could be done with using two copies of foo_text and using $stricmp() and counting the percentage played, but I find it quite annoying to have two copies of the same plugin and it'd be cool if it was built in.

Hello again, nice people! biggrin.gif
I've also started using Samurize on my desktop now, and just want to join anza's request for the possibility for output of two different strings from foo_text: One to a "mymusic.log" with the formattingstrings I've posted above, and one "nowplaying.txt" for Samurize.
Thinking about it, they need very different strings and configurations, so the best might be if it was made so it was possible using two instances of the plugin.
I want my logfile in Unicode, while it seems necessary to output ANSI to Samurize, at least I could not get it to work good otherwise. In logfile I use append mode and want updating only on actual change: play, pause, stop and new track, otherwise the file gets very cluttered. For Samurize I use owerwrite mode and want constant updating, getting "time remaining" and such right in realtime. Would it maybe be possible to make a version that could load and run two different instances in foobar at the same time...?

This is my "Playing" for Samurize:

CODE
$if(%_ispaused%,Paused: ,Now Playing: )[%artist% - ]$if(%title%,['[ '%album%[' / '[CD%disc% ]#$num(%tracknumber%,2)]' ] - ']%title%,%_filename%) - [%date% - ][$codec() ][$if(%__bitrate_dynamic%,$num(%__bitrate_dynamic%,3) kbps ,%__bitrate% kbps )][$div(%__samplerate%,1000)kHz ][%__bitspersample%bit ][$channels() ]- $if($stricmp($left(%_path_raw%,7),'http://'),Streaming: ,)%_time_elapsed%['/'%_time_total%]


and "Stopped":

CODE
[%_foobar2000_version% ]$select(%_stop_reason%,stopped.,stopped '('end of playlist')',track info pending...,initialized.)


tongue.gif

Edit: Little brush over of code.
musicmusic
I never started anything on that multiple file foo_text, so its probably not happening any time soon..

I made you a version, as you requested, with the second config page as a popup dialogue box, available available here, and as such it should work ok if you place multiple copies in your foobar directory ( I havent tested it though )
Mr_Rabid_Teddybear
Just got home, had a few beers and now this additional pleasure. smile.gif You are fast, my good man!
Well, just had time for some preliminary testing so far, but all seems well, I can load both foo_text and foo_text#2 and output two different text"streams" (one ANSI, owerwrite etc. - one Unicode, append etc.). And yes, so far it seems to work unproblematic. Which basically means that my needs are well covered, so I have no further feature requests for now, so don't let me keep you from your good woork at foo_ui_columns....

Cheers! biggrin.gif
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.