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: Copy Command String question (Read 8251 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Copy Command String question

Hi guys. I did a search for this but couldn't find anything.

Just wondering is it possible to add a header and footer section to a copy string ?

I have some code setup to copy all my albums to html but I would like it to generate the whole page, in other words I would like a header at the top of the copy command that is only inserted once at the top. So it will put a <html> <head></head> etc etc etc at the top of the copy command only.

Does that make sense? Is it possible?

For anyone interested my copy command string is

Code: [Select]
// HTML Copy String

$if($strcmp($num(%TRACKNUMBER%,2),01),
'    </ul>'
'</div>' $crlf()
'<div id="Album">' $crlf()
'    <ul>' $crlf()
'        <li id="title">'
)

// 1. Line
$if($strcmp($num(%TRACKNUMBER%,2),01),
$if(%artist%,%artist%,'unknown artist') ' - '
$if(%album%,%album%,'unknown album')
'</li>' $crlf()
,)
'        <li>'$num(%TRACKNUMBER%,2). %TITLE%' - ' %_length%'</li>'



This then gets pasted in between the following:::

Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 

<html>

    <head>
 <title>Test Page</title>
 <style type="text/css" media="all">@import url("style.css");</style>
 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
 <meta http-equiv="expires" content="-1">
 <meta http-equiv= "pragma" content="no-cache">
 <meta name="robots" content="all">
    </head>
    
    <body>

    INSERT COPY CODE HERE !!!!!

    </body>
    
</html>


So instead of pasting it in between the html above i would like it to generate that aswell. Hope that makes sense.

Ohh btw it ends up generating the following page

Link to Music Page

Hope that makes sense.

Thanks in advanced.

Copy Command String question

Reply #1
Yes, you can do that alright.  Check if %_playlist_number% is equal to either 1 or %_playlist_total%.

Code: [Select]
$if($strcmp(%_playlist_number%,1),
Place header here
$crlf(),)
Place item string here
$if($strcmp(%_playlist_number%,%_playlist_total%),$crlf()
Place footer here
,)


edit: I've just realized this string doesn't work with partial selections. You'll either have to select all files in your playlist, or send your selection to a new playlist before you can issue the copy command.


Copy Command String question

Reply #3
ahh brilliant. Thanks for that. Yeah I always do a complete selection of the playlist so that code should work fine.

Will go fix it up now.

Thanks heaps. Will post my completed code here for others once I am done

Cheers.

Copy Command String question

Reply #4
My complete code

Code: [Select]
//HEADER
$if($strcmp(%_playlist_number%,1),

'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> '$crlf()

'<html>'$crlf()

'    <head>'$crlf()
'  <title>Foobar 0.8 - Music List</title>'$crlf()
'  <style TYPE="text/css">'$crlf()
'  <!-- '$crlf()
'  body'$crlf()
'  {'$crlf()
'      margin: 10px 0px 0px 0px;'$crlf()
'      padding: 0;'$crlf()
'      font-family: verdana, arial, sans-serif;'$crlf()
'      font-size: small;'$crlf()
'      color: #ccc;'$crlf()
'      background-color: #000000;'$crlf()
'      text-align: left;'$crlf()
'  }'$crlf()
'  #Album'$crlf()
'  {'$crlf()
'      margin: auto;'$crlf()
'      padding: 0px;'$crlf()
'      border-bottom: 0px;'$crlf()
'      border-top: 2px solid #ccc;'$crlf()
'      border-left: 2px solid #ccc;'$crlf()
'      border-right: 2px solid #ccc;'$crlf()
'      background: #666;'$crlf()
'      width: 615px;'$crlf()
'  }'$crlf()
'  #title'$crlf()
'  {'$crlf()
'      font-weight: bold;'$crlf()
'      border-bottom: 2px solid #ccc;'$crlf()
'      margin: 0px;'$crlf()
'      background: #4C5255;'$crlf()
'  }'$crlf()
'  #Album ul '$crlf()
'  {'$crlf()
'      border: 0;'$crlf()
'      margin: 0;'$crlf()
'      padding: 0;'$crlf()
'      text-align: left;'$crlf()
'      clear: left;'$crlf()
'  }'$crlf()
'  #Album ul li '$crlf()
'  {'$crlf()
'      display: block;'$crlf()
'      text-align: left;'$crlf()
'      padding: 0;'$crlf()
'      padding-left: 10px;'$crlf()
'  }'$crlf()
'  -->'$crlf()
'  </style>'$crlf()
'  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'$crlf()
'  <meta http-equiv="expires" content="-1">'$crlf()
'  <meta http-equiv= "pragma" content="no-cache">'$crlf()
'  <meta name="robots" content="all">'$crlf()
'    </head>'$crlf()$crlf()
    
'<body>'$crlf()
'<div id="Album">' $crlf()
'    <ul>' $crlf()


//BODY
$crlf(),)
$if($strcmp($num(%TRACKNUMBER%,2),01),
'    </ul>'
'</div>' $crlf()
'<div id="Album">' $crlf()
'    <ul>' $crlf()
'        <li id="title">'
)

$if($strcmp($num(%TRACKNUMBER%,2),01),
$if(%artist%,%artist%,'unknown artist') ' - '
$if(%album%,%album%,'unknown album')
'</li>' $crlf()
,)
'        <li>'$num(%TRACKNUMBER%,2). %TITLE%' - ' %_length%'</li>'


//FOOTER
$if($strcmp(%_playlist_number%,%_playlist_total%),$crlf()
'    </ul>'$crlf()
'</div>'$crlf()
'</body>'$crlf()
'</html>'$crlf()
,)


The output is similar to the following

http://members.ii.net/~u4996a/music.html

Keep in mind that it only really deals with full albums and they must be tagged properly (track # etc). Doesn't handle compilations very well.

Thanks for the help.

Copy Command String question

Reply #5
Sorry for the newbishness, but where in Foobar2k do I enter this code?

Copy Command String question

Reply #6
1. Enter preferrences, Display, Title formatting.
2. Click on "Copy command" in the right pane.
3. Enter any code you want into the space below.
4. Select all files in playlist, and issue the copy command. (Default command: Control-C)

Code will be copied into your Windows clipboard.

5. Open a text editor.
6. Paste from clipboard.
7. Save as text or HTML.


Copy Command String question

Reply #8
http://www.cs.fredonia.edu/~wiss9895/foobar2000/

Some of my lists are simply too big to be displayed all at once. I also tried javascript and expanding/collapsing "folders" of mp3s. This didn't work well because my list of files sometimes was bigger than 2MB. It would take a long time to load. With this script, it may turn out to be 2MB or bigger, BUT the server handles all the load and sends the client browser only what it needs.

This requires you have PHP installed on the server you are putting the playlist on. Save it has a .php file instead of .html.

It's pretty dirty code but you get the idea 
Quote
// Foobar2000
// PHP Generator v1 by Slash demodevil5@yahoo.com
//

$if($strcmp(%_playlist_number%,1),
'<?php'$crlf()
'// Request Varibles'$crlf()
'$field   = $_REQUEST["field"];'$crlf()
'$value   = $_REQUEST["value"];'$crlf()

'$value   = urldecode("$value");'$crlf()

'$value  = stripslashes("$value");'$crlf()

'// Variables'$crlf()
'$i = 0;'$crlf()
'$artist = array();'$crlf()
'$album   = array();'$crlf()
'$date = array();'$crlf()
'$number = array();'$crlf()
'$title   = array();'$crlf()
'$length   = array();'$crlf()

$crlf(),)

// Tracks
'$artist[$i]="'%artist%'";'
'$album[$i]="'%album%'";'
'$date[$i]="'%date%'";'
'$number[$i]="'%tracknumber%'";'
'$title[$i]="'%title%'";'
'$length[$i]="'%_length%'";'
'$i++;'

// Footer
$if($strcmp(%_playlist_number%,%_playlist_total%),$crlf()

'echo "<HTML><HEAD><TITLE>Music Collection Listing</TITLE>'$crlf()
'<link rel=\"stylesheet\" type=\"text/css\" href=\"bunny.css\">'$crlf()
'</HEAD><BODY><CENTER>";'$crlf()

'echo "<TABLE WIDTH=\"90%\"><TR><TD><CENTER><FONT SIZE=\"4\">Music Collection Listing</FONT><BR>Generated by '%_foobar2000_version%'<BR><B>'%_playlist_total%'</B> Files Total</CENTER></TD></TR></TABLE><BR>";'$crlf()

'if($field) {'$crlf()

'   if($field == "artist") {'$crlf()

'  echo "<TABLE WIDTH=\"90%\">";'$crlf()
'  echo "<TR><TD COLSPAN=\"2\"><B>$value</B> Albums</TD></TR>";'$crlf()

'  $previous_album = "";'$crlf()

'  for($j = 0; $j < $i; $j++) {'$crlf()
'  if($album[$j] != $previous_album) {'$crlf()
'    if($artist[$j] == $value) {'$crlf()
'     $passvalue = urlencode("$album[$j]");'$crlf()
'     echo "<TR><TD WIDTH=\"5%\">$date[$j]</TD><TD><A HREF=\"$PHP_SELF?field=album&value=$passvalue\">$album[$j]</A></TD></TR>";'$crlf()
'     $previous_album = $album[$j];'$crlf()
'    }'$crlf()
'  }'$crlf()
'  }'$crlf()

'   }'$crlf()
   
'   else if($field == "album") {'$crlf()
'  echo "<TABLE WIDTH=\"90%\">";'$crlf()
'  echo "<TR><TD COLSPAN=\"3\"><B>$value</B> Tracks</TD></TR>";'$crlf()

'  $previous_title = "";'$crlf()

'  for($j = 0; $j < $i; $j++) {'$crlf()
'  if($title[$j] != $previous_title) {'$crlf()
'    if($album[$j] == $value) {'$crlf()
'     echo "<TR><TD WIDTH=\"5%\">$number[$j]</TD><TD>$title[$j]</TD><TD WIDTH=\"10%\">$length[$j]</TD></TR>";'$crlf()
'     $previous_title = $title[$j];'$crlf()
'    }'$crlf()
'  }'$crlf()
'  }'$crlf()


'   }'$crlf()

'   else {'$crlf()
'  echo "Not Found. Press Back and try again";'$crlf()
'   }'$crlf()

'}'$crlf()

'else {'$crlf()
'   echo "<TABLE WIDTH=\"90%\">";'$crlf()
'   echo "<TR><TD COLSPAN=\"4\"><B>Artists</B></TD></TR>";'$crlf()

'   $x = 0;'$crlf()
'   $previous_name = "";'$crlf()

'   for($j = 0; $j < $i; $j++) {'$crlf()
'  if($artist[$j] != $previous_name) {'$crlf()
'  if($x == 0)'$crlf()
'    echo "<TR>";'$crlf()

'  $passvalue = urlencode("$artist[$j]");'$crlf()
'  echo "<TD><A HREF=\"$PHP_SELF?field=artist&value=$passvalue\">$artist[$j]</TD>";'$crlf()
'  $previous_name = $artist[$j];'$crlf()
'  $x++;'$crlf()
 
'  if($x == 4) {'$crlf()
'    echo "</TR>";'$crlf()
'    $x = 0;'$crlf()
'  }'$crlf()
'  }'$crlf()
'   }'$crlf()
'}'$crlf()

'echo "</TABLE></CENTER></BODY></HTML>";'$crlf()

'?>'$crlf()

,)

Copy Command String question

Reply #9
Is there just a way to make a quick and simple .txt file?


Copy Command String question

Reply #11
What are the default values, I replaced them.

Copy Command String question

Reply #12
[$num(%_playlist_number%,$len(%_playlist_total%)). ][%artist% - ]$if(%title%,['['%album%[ #[%disc%/]$num(%tracknumber%,2)]'] ']%title%,%_filename_ext%)[ '['%_length%']']

Copy Command String question

Reply #13
If you're going to throw a DOCTYPE on your file, why not make it valid XHTML 1.1? That way you're cutting-edge, and thus much more cool.

Copy Command String question

Reply #14
Just be grateful i didn't use Tables, Frames and Popups


 

Copy Command String question

Reply #16
I got this error on my complete file list (but not with a single album), maybe any tags are borked...

Code: [Select]
Parse error: parse error, unexpected '\"' in [...] on line [...]


I checked my php file and got this line:

Code: [Select]
$artist[$i]="Air";$album[$i]="Le Soleil est Pres de Moi 12"";$date[$i]="1996";$number[$i]="3";$title[$i]="Le Soleil est Pres de Moi (Automator Remix)";$length[$i]="6:18";$i++;


You forgot to point to the the "bunny" style sheet on http://www.cs.fredonia.edu/~wiss9895/foobar2000/bunny.css

If the copy command code is unchanged the style sheet has to be in the same directory as the php file.

Copy Command String question

Reply #17
Quote
$album[$i]="Le Soleil est Pres de Moi 12""


There are 2 quotes there, that's why its breaking. I guess you would have to change the album tag and remove the double quote at the end. I probably should have escaped " characters.. but thats a lot of work.

Copy Command String question

Reply #18
So, just started to use foobar200 because I have to remake my mp3 pages. I'm having a small problems with this whole "Copy Command" thing, and I hope you guys can help me.

I've tried to make a list that will show the information like this: directory/album - track_number - artist - track_title. And that works about right. But the hard part is that I'd like to add the number of track and the total playtime of the list to the bottom of the list. So there would be a line saying "Tracks: xxx, total playtime: hh:mm:ss". But just can't make it happen.
So if someone could help me with this, I'd be really happy :D

PS. sorry about my English, it's not my native tongue. Hope you still understand it :)

Copy Command String question

Reply #19
Check the 2nd reply. You need to add a check to see if it is the last file on the playlist- In other words, if playlist_number = playlist_total. Like this:

$if($strcmp(%_playlist_number%,%_playlist_total%),

Total Tracks, playtime, etc

,)

Copy Command String question

Reply #20
So, got it partly working now. Only problem is that I can't find an option which would show the total playtime of the playlist. Is that even possible? I can see the total playtime if I choose all the tracks and choose properties, but I can't find how to put that into the output file.

Copy Command String question

Reply #21
LordSlash5: I love that code...thanks.

But I need it to look a bit different.

I am a concert trader..so if you have any free time, could you rewrite this a bit?

I don't know how it works, but it uses some sort of database, right? Is it possible to add many playlists to the database?

If this works, or if it works in some kind of way, is it possible to list first the playlist name, and if you click that playlist name, it shows all different albums in that playlist, and if you click one album, it shows a list of all tracks on that album?
If you could do this, you would be the best!!

Copy Command String question

Reply #22
@ Strat:

//offtopic:

Saw the Test CD by accident in your list - is it a CD for testing your amp system setup? If so - where'd you get it? Would like to check my setup as well!!

Copy Command String question

Reply #23
[marked for deletion]