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

Title Formating

I'm using v0.9.6.1

I was wondering if there was a way to show when I last played a song included in this code.

Example: Last Played: 22 Minutes Ago 03:30AM, Last Played: Friday 02 03:30AM, Last Played: Yesterday 12:45PM


Code: [Select]
[Last Played: $puts(lp,[%last_played%])
$if($get(lp),$puts(hour,$left($right($get(lp),8),2))
$ifgreater($get(hour),12,$puts(hour,$sub($get(hour),12))
$puts(meridian,PM),
$ifequal($get(hour),12,$puts(meridian,PM),
$puts(meridian,AM)))$left($get(lp),11)
$num($get(hour),2)$right($get(lp),6) $get(meridian))]


If it's possible and if one wouldn't care; could you provide a separate code so I don't misalign my columns? Or would there be a way to tab() to make it all all align?


edit- Fixed the code so it didn't make the topic 50 miles wide.. :x

Title Formating

Reply #1
No there isn't.

There was a component which made it possible, once but it was obsoleted by the foobar2000 dev team because it caused quite a few problems, most notably re-draw glitches.
Do a search for cwb_hooks and you'll find all sorts of discussion pertaining to this.
elevatorladylevitateme

Title Formating

Reply #2
No there isn't.

There was a component which made it possible, once but it was obsoleted by the foobar2000 dev team because it caused quite a few problems, most notably re-draw glitches.
Do a search for cwb_hooks and you'll find all sorts of discussion pertaining to this.


Oh I see, I also got to see why from Peter and understand. Thank you for answering my question.


(sorry for posting in the wrong place mods  )

Title Formating

Reply #3
Code: [Select]
$if(%play_count%,$select($add($mod($add($day_of_month(%last_played%),
$div($add($mul($replace($month(%last_played%),01,13,02,14),26),26),10),
$mod($year(%last_played%),100),$div($mod($year(%last_played%),100),4),
$div($year(%last_played%),400),$div($year(%last_played%),20)),7),1),Saturday,Sunday,
Monday,Tuesday,Wednesday,Thursday,Friday)', '$select($month(%last_played%),January,February,March,April,May,June,July,August,September,
October,November,December)' '$num($day_of_month(%last_played%),1)$if($or($greater($right($day_of_month(%last_played%),1),3),
$strcmp($right($day_of_month(%last_played%),1),0)),th,$select($right($day_of_month(%last_played%),1)
,st,nd,rd))', '$year(%last_played%),'N/A')


I don't know if this is exactly what you're looking for but I thought I'd post this anyway.  This is the best I can do with regular title formatting.  It returns the day of the week, the month and and the day of the month for the last played timestamp in natural language.  As far as I know it is impossible to get times in relative terms as in your example (i.e. yesterday or 22 minutes ago).

Title Formating

Reply #4
day of the week code is inaccurate

if anyone uses the above code, consider changing:

Code: [Select]
$select($add($mod($add($day_of_month(%last_played%),
$div($add($mul($replace($month(%last_played%),01,13,02,14),26),26),10),
$mod($year(%last_played%),100),$div($mod($year(%last_played%),100),4),
$div($year(%last_played%),400),$div($year(%last_played%),20)),7),1),Saturday,Sunday,
Monday,Tuesday,Wednesday,Thursday,Friday)


to:

Code: [Select]
$select(
$add(
$mod(
$add(
$mul(2,$sub(3,$mod($left($year(%last_played%),2),4))),
$right($year(%last_played%),2),
$div($right($year(%last_played%),2),4),
$select($month(%last_played%),$ifequal($mod($year(%last_played%),4),0,6,0),$ifequal($mod($year(%last_played%),4),0,2,3),3,6,1,4,6,2,5,0,3,5),
$day_of_month(%last_played%)),
7),
1),
Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
)


edit: 0-day code, changed $add(...,1) for $select() which starts from 1

Title Formating

Reply #5
Thanks a lot, that works perfect. I figured the Today and Yesterday thing was going to be a long stretch.

If anyone is able, can you do me one more favor? I can't seem to take the date out of the code I provided above, I would just like the custom time displayed. (I keep trying and it's breaking the whole thing)

Title Formating

Reply #6
insert this before the last comma (before N/A):

Code: [Select]
[', '$ifgreater($left($time(%last_played%),2),12,
$num($sub($left($time(%last_played%),2),12),2)$substr($time(%last_played%),3,5) PM,
$left($time(%last_played%),5) AM)]

Title Formating

Reply #7
I tried the AM/PM time code in the big script above and it seems to be popping up randomly and disappearing randomly (It's hard to explain)


But anyway I tried it by it's self in its own column and it's doing the same thing (was making sure it wasn't a fault of myn with adding it to the already huge script)

Thanks again for helping me out again 2E7AH, but is the problem above something wrong with the code or is it a possible bug?

Title Formating

Reply #8
i don't know where you put the code, but i found problems with the $time(%last_modified%) function in item details and lyrics show (more precisely they are refreshing in random intervals and showing the result in a glimpse)

testing in track info or track info mod shows expected and correct results:



so starchaos here is the compiled code from Moltar with additional changes and above note:

Code: [Select]
$if(%play_count%,

// inserted correct week day code (delete this line)

$select(
$add(
$mod(
$add(
$mul(2,$sub(3,$mod($left($year(%last_played%),2),4))),
$right($year(%last_played%),2),
$div($right($year(%last_played%),2),4),
$select($month(%last_played%),$ifequal($mod($year(%last_played%),4),0,6,0),$ifequal($mod($year(%last_played%),4),0,2,3),3,6,1,4,6,2,5,0,3,5),
$day_of_month(%last_played%)),
7),
1),
Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
)

// insert code (delete this line)

', '$select($month(%last_played%),January,February,March,April,May,June,July,August,September,
October,November,December)' '$num($day_of_month(%last_played%),1)$if($or($greater($right($day_of_month(%last_played%),1),3),
$strcmp($right($day_of_month(%last_played%),1),0)),th,$select($right($day_of_month(%last_played%),1)
,st,nd,rd))', '$year(%last_played%)

// inserted AM/PM code (delete this line)

[', '$ifgreater($left($time(%last_played%),2),12,
$num($sub($left($time(%last_played%),2),12),2)$substr($time(%last_played%),3,5) PM,
$left($time(%last_played%),5) AM)]
,'N/A')

Title Formating

Reply #9
I'm sorry 2E7AH, I should have mentioned that I was trying to put the code in the DUI playlist view element in my OP. 





The above screen shot shows where I'm using the code and what is happening (this is with the latest code). As  far as I know everything is working fine besides the time (it's doing the random thing again)

Title Formating

Reply #10
it's nothing wrong with the code, it's probably core bug like you thought, so nothing to do until fix

strange though that only track info (mod) shows correct output

Title Formating

Reply #11
it's nothing wrong with the code, it's probably core bug like you thought, so nothing to do until fix

strange though that only track info (mod) shows correct output


Do you think Peter or any other devs would look over this or should I create a new topic? Thanks again by the way I really really appreciate your time. 

Title Formating

Reply #12
hey, don't mention
no need for new topic, as posts are parsed

 

Title Formating

Reply #13
Problem with $time() is known, will be fixed in next release of foobar2000.
Full-quoting makes you scroll past the same junk over and over.