Help - Search - Members - Calendar
Full Version: Problems with "copy name" command
Hydrogenaudio Forums > Hosted Forums > foobar2000 > General - (fb2k)
cyborg
I have a problem with html playlist creation. I managed to make "Copy Name" command that creates a correct html playlist for a single song, but it won't work on many songs. Here's the code that I use:

CODE
// Artistin ja kappaleen esitystapa
$puts(artisti,[$if2(%artist%,%artist%) - ]$if(%title%,%title%,%_filename%))

// Mikä formaatti?
$puts(Koodekki,$caps2($codec()  ))
$if($strcmp(%__codec%,CDDA),$puts(Koodekki,'Audio CD'  ))

// Tiedonsiirto nopeus
$puts(TSN,[[%__bitrate%] 'kbps'] )

// Tulostetaan tiedoston koko
$puts(Tkoko,'<>' $if($greater(%_filesize%,1048576),$num($left($num($muldiv(%_filesize%,100,1048576),6),4),1).$right($muldiv(%_filesize%,100,1048576),2) MB,$num($left($num($muldiv(%_filesize%,100,1024),6),4),1).$right($muldiv(%_filesize%,100,1024),2) kB))
$if($not(%_filesize%),$puts(Tkoko,))

// Extrainfon käsittely
$puts(text_extrainfo,[%__extrainfo%] )
$if($and($strcmp(%__codec%,WavPack),%__compression%),$puts(text_extrainfo,%__compression% ))
$if($and($strcmp(%__codec%,Musepack),%quality%),$puts(text_extrainfo,'Quality' %quality% ))
$if($and($not(%quality%),$strcmp(%__codec%,Musepack)),$puts(text_extrainfo,))
$if($and($strcmp(%__codec%,Vorbis),%quality%),$puts(text_extrainfo,'Quality' %quality% ))
$if($and($not(%quality%),$strcmp(%__codec%,Vorbis)),$puts(text_extrainfo,))
$if($and($strcmp(%__codec%,Monkey''s Audio),%__compression%),$puts(text_extrainfo,%__compression% ))
$if(%__mod_samples%,$puts(text_extrainfo,%__mod_samples% 'Module Samples' ))
$if($and($strcmp(%__codec%,OptimFROG),%__mode%),$puts(text_extrainfo,%__mode% ))
$if($and($strcmp(%__codec%,DualStream),%__mode%),$puts(text_extrainfo,%__mode% ))
$if($and($not(%__extrainfo%),$strcmp(%__codec%,MP3)),$puts(text_extrainfo,))
$if($and($not(%__extrainfo%),$strcmp(%__codec%,MP2)),$puts(text_extrainfo,))

// Tarkistetaan onko tiedosto Matroska tai MP4 tiedoston sisällä
$if($strcmp($ext(%_filename_ext%),mka),$puts(container, 'Matroska Container' ))
$if($strcmp($ext(%_filename_ext%),mp4),$puts(container, 'MP4 Container' ))

// HTML koodin alkuosat
'<html>'$crlf()
'<head>'$crlf()
$crlf()
'  <title>Soittolista</title>'$crlf()
$crlf()
'<body bgcolor="#F5F5E6" text="#000000">'$crlf()
$crlf()
'<H1>Soittolista</H1>'$crlf()
$crlf()
'<p>'$crlf()
$num(%_playlist_number%,$len(%_playlist_total%)).
[$get(artisti) '&lt;&gt;' ]
[$get(Koodekki)]
[$get(TSN)]
[$caps2($get(text_extrainfo))]
[$get(container)]
['&lt;&gt;' %_length% ]
[$get(Tkoko)]$crlf()
'</p>'$crlf()
$crlf()
'<FONT SIZE="+2" COLOR=blue>&copy; cyborg</FONT>'$crlf()
$crlf()
'</body>'$crlf()
$crlf()
'</html>'$crlf()

Here is the html file that it produces for one song:
CODE
<html>
<head>

 <title>Soittolista</title>

<body bgcolor="#F5F5E6" text="#000000">

<H1>Soittolista</H1>

<p>
20. Adam - Danger [Mass In Orbit Remix] &lt;&gt; MP3  192 kbps &lt;&gt; 6:59 &lt;&gt; 9.61 MB
</p>

<FONT SIZE="+2" COLOR=blue>&copy; cyborg</FONT>

</body>

</html>

Here is the html file it produces for many songs:
CODE
<html>
<head>

 <title>Soittolista</title>

<body bgcolor="#F5F5E6" text="#000000">

<H1>Soittolista</H1>

<p>
20. Adam - Danger [Mass In Orbit Remix] &lt;&gt; MP3  192 kbps &lt;&gt; 6:59 &lt;&gt; 9.61 MB
</p>

<FONT SIZE="+2" COLOR=blue>&copy; Janne Silvennoinen</FONT>

</body>

</html>

<html>
<head>

 <title>Soittolista</title>

<body bgcolor="#F5F5E6" text="#000000">

<H1>Soittolista</H1>

<p>
21. Avanto - The Flute &lt;&gt; MP3  192 kbps &lt;&gt; 6:35 &lt;&gt; 9.05 MB
</p>

<FONT SIZE="+2" COLOR=blue>&copy; Janne Silvennoinen</FONT>

</body>

</html>

What should I do to make it work correctly? How can I make the script to add the html codes in start of the file and end of the file once? huh.gif
Synthetic Soul
Is your website using straight HTML, or can you use PHP, ASP, SHTML, etc.?

If so, why not just get Foobar to export the files in a list, and then include that file in a template page. This would be more adaptable anyway as it will be easier to amend the template if your site design changes than to adapt your Foobar script.

e.g.: your template would be something like:

CODE
<html>
<head>
<title>Soittolista</title>
</head>
<body>

<h1>Soittolista</h1>

<!-- #include virtual="playlist.inc" -->

</body>
</html>


And Foobar would export to playlist.inc.

NB: You should use CSS for formatting (remove formatting from BODY tag and completely ditch FONT tags!)


I have to ask: what is $if2(%artist%,%artist%) supposed to do?

Edit: spelunk
cyborg
I'm not using a web server, and I don't have a home page or anything like that. I just to wanted make html playlist creator, but I wasn't able to make it work correctly.

QUOTE
I have to ask: what is $if2(%artist%,%artist%) supposed to do?

It seems to be an error in my code, unsure.gif thanks for letting me know. biggrin.gif
Synthetic Soul
OK, then I suggest you use %_playlist_number% and %_playlist_total% to detirmine whether to write the header HTML and footer HTML respectively.

i.e.:

If the current item is the first item in the playlist write the header:

if$($strcmp(%_playlist_number%,1), ... <write header stuff>

If the current item is the last item in the playlist write the footer HTML:

if$($strcmp(%_playlist_number%,%_playlist_total%), ... <write footer stuff>


.. something like that.
cyborg
Thanks Synthetic Soul, I'll give it a try. laugh.gif
eliazu
@cyborg,

when you'll finish working on it, can you post it here?

thanx.
cyborg
@eliazu,

Sure, I'll post it tomorrow. smile.gif
cyborg
@Synthetic Soul,

QUOTE
OK, then I suggest you use %_playlist_number% and %_playlist_total% to detirmine whether to write the header HTML and footer HTML respectively.

i.e.:

If the current item is the first item in the playlist write the header:

if$($strcmp(%_playlist_number%,1), ... <write header stuff>

If the current item is the last item in the playlist write the footer HTML:

if$($strcmp(%_playlist_number%,%_playlist_total%), ... <write footer stuff>


.. something like that.

It worked, thanks for your help. biggrin.gif
cyborg
@eliazu,

Here is the copy command for html playlist:
QUOTE
// Artist and title formatting
// '&' is replaced with html code '&amp;' in artist and title information
$puts(artisti,[$replace(%artist%,'&','&amp;') - ]$if(%title%,$replace(%title%,'&','&amp;'),$replace(%_filename%,'&','&amp;')))

// Check if the file is inside Matroska or MP4 container
$if($strcmp($ext(%_filename_ext%),mka),$puts(container,' @ Matroska Container'))
$if($strcmp($ext(%_filename_ext%),mp4),$puts(container,' @ MP4 Container'))

// What format?
$puts(Koodekki, $caps2($codec()[$get(container)]  ))
$if($strcmp(%__codec%,CDDA),$puts(Koodekki, 'Audio CD'[$get(container)]  ))
$if($and($strcmp(%__codec%,Vorbis),%__vorbis_version%),$puts(Koodekki, $caps2($codec()) ['['[%__vorbis_version%]']'][$get(container)]  ))
$if($and($strcmp(%__codec%,Musepack),%__mpc_encoder%),$puts(Koodekki, $caps2($codec()) ['['[%__mpc_encoder%]']'][$get(container)]  ))
$if($and($strcmp(%__codec%,AAC),%__aac_profile%),$puts(Koodekki, $caps2($codec()) ['['[%__aac_profile%]']'][$get(container)]  ))
$if($strcmp(%__codec%,WavPack),$puts(Koodekki, $caps2($codec()) ['['['v.'%__version% %__format%]']'][$get(container)]  ))

// Bitrate
$puts(TSN,[[%__bitrate%] 'kbps'] )

// Filesize
$puts(Tkoko,'&lt;&gt;' $if($greater(%_filesize%,1048576),$num($left($num($muldiv(%_filesize%,100,1048576),6),4),1).$right($muldiv(%_filesize%,100,1048576),2) MB,$num($left($num($muldiv(%_filesize%,100,1024),6),4),1).$right($muldiv(%_filesize%,100,1024),2) kB))
$if($not(%_filesize%),$puts(Tkoko,))

// Extrainfo
$puts(text_extrainfo,[%__extrainfo%] )
$if($and($strcmp(%__codec%,WavPack),%__compression%),$puts(text_extrainfo,%__compression% ))
$if($and($strcmp(%__codec%,Musepack),%quality%),$puts(text_extrainfo,'Quality' %quality% ))
$if($and($not(%quality%),$strcmp(%__codec%,Musepack)),$puts(text_extrainfo,))
$if($and($strcmp(%__codec%,Vorbis),%quality%),$puts(text_extrainfo,'Quality' %quality% ))
$if($and($not(%quality%),$strcmp(%__codec%,Vorbis)),$puts(text_extrainfo,))
$if($and($strcmp(%__codec%,Monkey''s Audio),%__compression%),$puts(text_extrainfo,%__compression% ))
$if(%__mod_samples%,$puts(text_extrainfo,%__mod_samples% 'Module Samples' ))
$if($and($strcmp(%__codec%,OptimFROG),%__mode%),$puts(text_extrainfo,%__mode% ))
$if($and($strcmp(%__codec%,DualStream),%__mode%),$puts(text_extrainfo,%__mode% ))
$if($and($not(%__extrainfo%),$strcmp(%__codec%,MP3)),$puts(text_extrainfo,))
$if($and($not(%__extrainfo%),$strcmp(%__codec%,MP2)),$puts(text_extrainfo,))

// HTML header
// '&' is replace with html code '&amp;'
$puts(html_start,'<html>'$crlf()'<head>'$crlf()$crlf()'  <title>Soittolista</title>'$crlf()$crlf()'<body bgcolor="#336699" text="#FFFF00">'$crlf()$crlf()'<H1>'$replace(%_playlist_name%,'&','&amp;')'</H1>'$crlf()$crlf()'<p>'$crlf())

// HTML footer
$puts(html_end,'</p>'$crlf()$crlf()'<FONT SIZE="+2" COLOR=lime>&copy; cyborg</FONT>'$crlf()$crlf()'</body>'$crlf()$crlf()'</html>'$crlf())

$if($strcmp(%_playlist_number%,1),$get(html_start))
$num(%_playlist_number%,$len(%_playlist_total%)).
[$get(artisti) '&lt;&gt;' ]
[$get(Koodekki)]
[$get(TSN)]
[$caps2($get(text_extrainfo))]
['&lt;&gt;' %_length% ]
[$get(Tkoko)]'<BR>'$crlf()
$if($strcmp(%_playlist_number%,%_playlist_total%),$get(html_end))

Some of the text is still in finnish, but I'm sure you know how to change them. 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.