Skip to main content
Topic: foo_text_ftp (Read 10187 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foo_text_ftp

I've made a small addition to foo_text so that it will upload the file it generates to an FTP server.

Since this is my first foray into using MSVC++ I'd like some of the other plugin developers to give it the once over. I had to learn how to do things as I went so I'm sure there are things I'm not doing the most optimal way.

Most of the changes are in write.cpp with other changes just ones to get the preferences working. Since I just copied how musicmusic set his up I'm not to worried about those

http://www.dragva.com/eng/foo_text_ftp.zip - The .dll is in the .zip file too

One problem I did notice but couldn't figure out was that on quitting fb2k the file is written locally but not uploaded 

Thanks for any suggestions you have.

foo_text_ftp

Reply #1
Just what I was looking for; excellent.

Not a big suggestion but it might be useful if it could be temporarily written locally, uploaded, and deleted locally.

foo_text_ftp

Reply #2
Slightly off-topic - if you want a dynamic image which should contain the currently playing song as well as its position, here is a PHP file which will output a PNG file using the GD library. You will also have to set up Apache (.htaccess provided) or IIS to render the PNG as PHP script:

PHP script (playing.png):

Code: [Select]
<?php

  // Set-up header information
  Header('Content-type: image/png');
  Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
  Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
  Header('Pragma: no-cache');

  // Set-up image dimenstions
  $img_width = 521;
  $img_height = 50;

  // Create image
  $image = imagecreate($img_width, $img_height);

  // Set-up colors
  $black = imagecolorallocate($image, 0, 0, 0);
  $white = imagecolorallocate($image, 255, 255, 255);
  $red = imagecolorallocate($image, 255, 0, 0);
  $grey = imagecolorallocate($image, 204, 204, 204);
  $green = imagecolorallocate($image, 128, 220, 0);

  // Set-up background color and borders
  imagefilledrectangle($image, 0, 0, $img_width, $img_height, $white);
  imageline($image, 0, 0, $img_width, 0, $black);                                  // Border top
  imageline($image, $img_width - 1, 0, $img_width - 1, $img_height - 1, $black);    // Border right
  imageline($image, 0, $img_height - 1, $img_width, $img_height - 1, $black);      // Border bottom
  imageline($image, 0, 0, 0, $img_height, $black);                                  // Border left

  $song_info = @file("foobar2000.txt");

  // Set-up font
  $font = 'cour.ttf';

  // Print text and progress bar
  if(trim($song_info[0]) == '') {
    ImageTTFText ($image, 9, 0, 10, 19, $black, $font, 'Currently, I am not listening to music.');
    imagefilledrectangle($image, 10, 30, 10, 40, $grey);
  }
  else {
    if(trim($song_info[0]) == '0') {
      ImageTTFText ($image, 9, 0, 10, 19, $black, $font, 'Currently, I am not listening to music.');
      imagefilledrectangle($image, 10, 30, 10, 40, $grey);
    }
    elseif(trim($song_info[0]) == '1') {
      if(trim($song_info[2]) == '') {
        if(strlen(trim($song_info[1])) > 40) {
          $song_info[1] = trim(substr(trim($song_info[1]),0,37)) . '...';
        }
        ImageTTFText ($image, 9, 0, 10, 19, $black, $font, 'I am currently listening to "' . trim($song_info[1]) . '".');
        imagefilledrectangle($image, 10, 30, $song_info[3] + 10, 40, $grey);
      }
      else {
        if(strlen(trim($song_info[1])) > 17) {
          $song_info[1] = trim(substr(trim($song_info[1]),0,14)) . '...';
        }
        if(strlen(trim($song_info[2])) > 17) {
          $song_info[2] = trim(substr(trim($song_info[2]),0,14)) . '...';
        }
        ImageTTFText ($image, 9, 0, 10, 19, $black, $font, 'I am currently listening to "' . trim($song_info[1]) . '" by "' . trim($song_info[2]) . '".');
        imagefilledrectangle($image, 10, 30, $song_info[3] + 10, 40, $grey);
      }
    }
    elseif(trim($song_info[0]) == '2') {
      if(trim($song_info[2]) == '') {
        if(strlen(trim($song_info[1])) > 42) {
          $song_info[1] = trim(substr(trim($song_info[1]),0,39)) . '...';
        }
        ImageTTFText ($image, 9, 0, 10, 19, $black, $font, 'The playback of "' . trim($song_info[1]) . '" is paused.');
        imagefilledrectangle($image, 10, 30, $song_info[3] + 10, 40, $grey);
      }
      else {
        if(strlen(trim($song_info[1])) > 18) {
          $song_info[1] = trim(substr(trim($song_info[1]),0,15)) . '...';
        }
        if(strlen(trim($song_info[2])) > 18) {
          $song_info[2] = trim(substr(trim($song_info[2]),0,15)) . '...';
        }
        ImageTTFText ($image, 9, 0, 10, 19, $black, $font, 'The playback of "' . trim($song_info[1]) . '" by "' . trim($song_info[2]) . '" is paused.');
        imagefilledrectangle($image, 10, 30, $song_info[3] + 10, 40, $grey);
      }
    }
  }
  imageline($image, 10, 30, 510, 30, $black);      // Border top
  imageline($image, 510, 30, 510, 40, $black);      // Border right
  imageline($image, 10, 40, 510, 40, $black);      // Border bottom
  imageline($image, 10, 30, 10, 40, $black);        // Border left

  // Return image and free-up memory
  imagepng($image);
  imagedestroy($image);

?>

Apache Config (.htaccess):

Code: [Select]
<Files playing.png>
  ForceType application/x-httpd-php
</Files>

Upload those two files together with "cour.ttf" (or whatever font you want to use, but make sure you change it in "playing.png") to your server.

Next step is to set up the text writer to output to "foobar2000.txt" each minute for example using this for "Playing":

Code: [Select]
$if(%_ispaused%,2,1)
$crlf()
$if2(%title%,%_filename_ext%)
$crlf()
$if2(%artist%,)
$crlf()
$if(%_time_total_seconds%,$mul($div($mul(%_time_elapsed_seconds%,100),%_time_total_seconds%),5),500)

Stopped:

Code: [Select]
0
$crlf()
$crlf()
$crlf()
0

On quit:

Code: [Select]
0


0

Currently, the progress calculation is done in fb2k, but you could also modify the PHP file to do it for you. Notice that if you change the dimensions of the image, you will also have to change the calculation in fb2k.

The result looks like this:



My image script is a bit more complicated, since it is blingual (German on some sites and English on the rest) and fetches the file from my local computer where the fb2k.txt file is updated each second. If my PC is not accessible it prints that I am not listening to music.

foo_text_ftp

Reply #3
eng
Thank you for your work. I was already getting tired from AMIP loosing unicode chars.

Sebastian Mares
Thank you for the script. I just like it.
Sharing delusions since 1991.

foo_text_ftp

Reply #4
Has anyone worked on a port for this plugin foo_text_ftp for Foobar 0.9? I just don't like AMIP. This plugin was entirely better for my purposes. Anyone?

foo_text_ftp

Reply #5
Has anyone worked on a port for this plugin foo_text_ftp for Foobar 0.9? I just don't like AMIP. This plugin was entirely better for my purposes. Anyone?


same here...
Is there a foo_text(_ftp) version for fb2k 0.9? AMIP is nice, but it doesen't support informations like cuesheet-tracks, replaygain and so on. i would really like this.

thanks

foo_text_ftp

Reply #6
You can pass any foobar variable to AMIP, see AMIP Wrapper settings dialog in foobar, in AMIP use %s for this string.

foo_text_ftp

Reply #7
You can pass any foobar variable to AMIP, see AMIP Wrapper settings dialog in foobar, in AMIP use %s for this string.


any foobar variable? the only thing i know is %s, which returns ARTIST - TITLE. that's it... there is no way to change the settings to display the other foobar variables. or am I blind?

foo_text_ftp

Reply #8

You can pass any foobar variable to AMIP, see AMIP Wrapper settings dialog in foobar, in AMIP use %s for this string.


any foobar variable? the only thing i know is %s, which returns ARTIST - TITLE. that's it... there is no way to change the settings to display the other foobar variables. or am I blind?


Yeah, that's what I thought too. I think it would be much easier with an updated foo_text_ftp plugin.

foo_text_ftp

Reply #9
You can pass any foobar variable to AMIP, see AMIP Wrapper settings dialog in foobar, in AMIP use %s for this string.


Unicode strings?
Sharing delusions since 1991.

 
SimplePortal 1.0.0 RC1 © 2008-2019