how to add a download link?

Use this forum for everything concerning script usage
Post Reply
Wag
Newbie
Newbie
Posts: 1
Joined: Sat Jul 28, 2012 7:45 am

how to add a download link?

Post by Wag »

How to add a download link to mp3 files in my html_grouped.scx??I want to post my html export in my company NAS and make available for people to download files and possibly to play the files (using any html player) from the same html export, a download link and a play file link.

I dont even know how to write on the scripts simple html, it doesnt accept any changes, PLEASE HELP!!!!!!!!!!!!!This is one of the best organizers Ive ever seen, I dont want to find another one; I will attach my html_grouped.scx file in case a good hearted person can edit for me.... Please someone??

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: how to add a download link?

Post by jtclipper »

This is a simple modification of the original file that adds a link, save it as another filename in your scripts folder (for example html_grouped2.scx )

Code: Select all

{!%A%Y%L%R}

// the first line contains the sort order, it is optional

program HTML;
var
  sFile, sClass, sArtist, sAlbum: string;
  iRow: integer;
const

  _HEADER =
  '<html>' +
  '<head>' +
  '<title>HTML Export</title>' +
  '<style type="text/css">' +
  '    body { background: #578833; font-family : Verdana, Arial, Helvetica; color: #C9C487 }' +
  '    a { color: #FFFFFF; TEXT-DECORATION: none }' +
  '    a:hover { color: #00FF00; TEXT-DECORATION: underline }' +
  '    td { font-size: xx-small; height: 12 }' +
  '    .ttblheader { background : #3A627E; color : #5AAEC0 }' +
  '    .ttblmain { background : #44775F }' +
  '    .ttbleven { background : #759D62; color : #000000 }' +
  '    .ttblodd { background : #69838B; color : #000000 }' +
  '</style>' +
  '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' +
  '</head>' +
  '<body topmargin=5 leftmargin=10>' +
  '<br>' + #13#10;
  _PAGEFOOTER =
  '<br>' +
  '</body>' +
  '</html>';

  _TABLEHEADER =
  '<table class=ttblmain border="0" cellpadding="2" cellspacing="1">' + #13#10;

  _TABLEFOOTER =
  '</table>' + #13#10;

  _TABLEROWHEADER =
  '<tr class=ttblheader>' +
  '<td><b>#</b></td>' +
  '<td><b>File</b></td>' +
  '<td><b>Year</b></td>' +
  '<td><b>Genre</b></td>' +
  '<td><b>Track</b></td>' +
  '<td><b>Title</b></td>' +
  '<td><b>Duration</b></td>' +
  '<td><b>Bitrate</b></td>' +
  '<td><b>Encoder</b></td>' +
  '</tr>' + #13#10;

  function _field( sValue: string ): string;
  begin
    result := '<td>' + sys_HtmlStr( sValue ) + '</td>';
  end;

  function _field2( sValue: string ): string;
  begin
    result := '<td>' + sValue + '</td>';
  end;


begin
  if not ex_Init then exit;
  iRow := 0;
  sArtist := '#';
  sAlbum := '#';

  //write header
  ex_Write( _HEADER, 0 );


  //write data
  repeat
    ex_LoadFile;
    if ( iRow mod 2 ) = 0 then begin
       sClass := 'ttbleven';
    end else begin
       sClass := 'ttblodd';
    end;

    if gTag.Artist <> sArtist then begin //artist
       if iRow > 0 then ex_Write( _TABLEFOOTER, 0 );
       ex_Write( '<p>Artist: ' + sys_HtmlStr( gTag.Artist ) + '</p>', 1 );
       sArtist := gTag.Artist;
       iRow := 0;
    end;
    if gTag.Album <> sAlbum then begin //album
       if iRow > 0 then ex_Write( _TABLEFOOTER, 0 );
       ex_Write( '<p> Album: ' + sys_HtmlStr( gTag.Album ) + '</p>', 1 );
       ex_Write( _TABLEHEADER, 0 );
       ex_Write( _TABLEROWHEADER, 0 );
       sAlbum := gTag.Album;
       iRow := 0;
    end;

    ex_Write( '<tr class=' + sClass + '>', 0 );
    ex_Write( _field( IntToStr(iRow+1) ) +
              _field2( '<a href="file://' + gTag.Filename + '">' + gTag.Filename  + '</a>' ) +
              _field( gTag.Year     ) +
              _field( gTag.Genre    ) +
              _field( gTag.TrackF   ) +
              _field( gTag.Title    ) +
              _field( gTag.DurationF) +
              _field( gTag.Bitrate  ) +
              _field( gTag.EncoderUsed ), 1 );

    ex_Write( '</tr>' + #13#10, 0 );

    Inc( iRow );
  until not ex_Skip;
  if iRow > 0 then ex_Write( _TABLEFOOTER, 0 );
  ex_Write( _PAGEFOOTER, 0 );

  sFile := sys_SaveFileDialog( 'html file|*.html', '' );
  if sFile <> '' then ex_Save( sFile );

end.

Post Reply