May 23, 2013, 10:41:58 AM
 Pages: 1
FuzzyWuzzy
Guest
 « on: February 13, 2004, 12:58:55 AM »

would it be possible to have evillyrics upload the now playing file to a ftp, giving it the login name and stuff? cause i wanna inclue lyrics in my aim profile and i have a dynamic IP addy, so i cant direct link it
 Logged
EvilLyrics forum
 « on: February 13, 2004, 12:58:55 AM »

 Logged
Anonymous
Guest
 « Reply #1 on: February 15, 2004, 01:51:05 PM »

from AMIP (http://amip.toe9k/@#nowplaying.htm file in an ftp addy?   Anonymous80.129.153.29&template and /exec commands, it is possible now to use AMIP to put html with song info to your page via FTP or pass song info to php, perl, asp and other scripts running on your web server (for example to make image file with song information to use as a signature in the forums).

This feature still requires some third-party tool like FTP, internal support for this will appear in the future AMIP versions.

I recommend you to use cURL (http://curl.haxx.se/). cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. Curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and a busload of other useful tricks.

This manual assumes that you are using cURL, so, go to the page and grab win32 version.

It is recommended to use new AMIP Configurator from http://amip.tools-for.net/config/ since it has special Callbacks/Web presets where you can place commands.

1. Using AMIP to post the playing song information to your page via FTP

First we need to create our HTML page template, I'll take very simple example:

<html>
<title>My cool now-playing page</title>
<body>
<center><h1>Now playing:</h1></center>
<blockquote>
<!-- song name, note that you can use AMIP functions in templates (func_lc - lowercases the string) -->
<font size=+3>&func_lc(%name)</font><br><br>
<!-- album and other song information -->
Album: <b>%4</b><br>
Year: <b>%5</b><br>
Genre: <b>%7</b><br>
Bitrate: <b>%br</b><br>
File size: <b><font color=red>%fl</font> Mb</b>
</blockquote>
</body>
</html>

Create a directory, for example, C:\amipweb, create in.html in this directory, copy the above code into in.html. This will be the template. Of course, you can make a damn good page yourself, it's just an example.

Now let's set up AMIP options: make sure that IRC integration is enabled, actually we are not going to post anything to mIRC, but we need to use a preset. Choose any of the presets, make it active, put the following code in it:

/template:(c:\amipweb\in.html)c:\amipweb\out.html

Correct the paths and put in your parameters.

I'll explain the code:

/template command takes the file in the parenthesis (our HTML template file), replaces all the variables, functions, conditional statements, etc and creates the page with song information written in c:\amipweb\out.html file.

/exec command executes the application in the parenthesis and passes all the rest string to this application. So, all the rest lines consists of cURL arguments.

-B tells cURL that we are transferring ascii file;
-T out.htm tells cURL which file to upload to the FTP, you don't need to specify the directory in this case, because AMIP's /exec command automatically uses the working directory of the executed application (c:\amipweb\);
The last argument is the URL where to put the file. For example http://ftp://ftp.yourisp.com/web/. Note the trailing slash, it is required and represents the directory. BTW, you can upload the file with a different name, for example http://ftp://ftp.yourisp.com/web/nowplaying.html will upload our out.html file with nowplaying.html name.

If you've done all the things right, on every song change the file will be updated on your FTP and everyone will be able to see what you listening to on your web page.

If you are behind the proxy, it is not the problem! Read cURL manual and add the appropriate parameters to the /exec command in AMIP options.

2. Passing song information to the script (using cURL and PHP)

I think that you've already got the idea after reading the first section. The difference is that we need to pass the variables to the php script.

cURL supports GET and POST methods for passing variables to the scripts.

Here is what you can put to the AMIP's preset (one line):

/exec:(c:\amipweb\curl.exe) -G -d "title=&func_ue(%name)&album=&func_ue(%4)&bitrate=&func_ue(%br)&action=save" http://URL/np.php

Actually, it is very simple:

-G stands for the HTTP GET, remove it to use HTTP POST method.
-d is followed by the list of arguments in the "key=value" form separated by & character. AMIP's function &func_ue (URL encode) encodes the variables passed to the script. Instead of using & separator, you can define several -d arguments:

-d "title=&func_ue(%name)" -d "album=&func_ue(%4)" -d "bitrate=&func_ue(%br)" -d "action=save"

The last -d parameter will tell our sample script that we need to save this info. If the np.php script is called without any parameters, it will show the last played song info.

Don't forget to specify the URL of the np.php script in the end of /exec command.

Here is the sample np.php script:

<?php
# If the action is 'save' => Save the variables of the latest song to the npvars.txt
if(isset($_REQUEST['action']) &&$_REQUEST['action'] == 'save'){
$fp = @fopen("./npvars.txt", "w+"); # File opened if($fp){
foreach($_REQUEST as$key=>$value){ fputs($fp, "$key=$value\n");
}
fclose($fp); # Display error } else { print("Cannot open file to save variables!"); } # If no action is specified, show the info for the latest track } else {$SONG = array();
$vars = file("npvars.txt"); foreach($vars as $line){$line = rtrim($line); list($key, $val) = split("=",$line);
$SONG[$key] = $val; } # Something was already saved? if(count($SONG) > 1){
# Here you can do with the $SONG variables whatever you like, I'll just show some of them in the plain text print("Playing song:$SONG[title]<br>");
print("Album: $SONG[album]<br>"); print("Bitrate:$SONG[bitrate]<br>");
} else {
# Show something saying that nothing was played yet
print("I haven't played any song yet =(");
}
}
?>

If you need to pass a lot of variables, it is not convenient to write a long line in the preset. Instead of this it is possible to use the template with variables, and then pass it to cURL as a configuration file.

Here is the sample cURL config which equals by functionality to our previous cURL /exec call:

# Configuration file for cURL
# URL of the np script (!!!replace with your own!!!):
url = http://URL/np.php
# use HTTP GET
-G
# list of parameters to pass:
-d "title=&func_ue(%name)"
-d "album=&func_ue(%4)"
-d "bitrate=&func_ue(%br)"
# our np.php script needs action=save to save parameters
-d "action=save"

Save the above code into c:\amipweb\amipweb.conf.

New AMIP preset looks like this:

/template:(c:\amipweb\amipweb.conf) c:\amipweb\amipweb.out
/exec:(c:\amipweb\curl.exe) -K amipweb.out

The /template command parses amipweb.conf, replaces song variables and saves the result in amipweb.out. cURL is executed with -K parameter which tells it to use amipweb.out configuration file.

Using cURL and AMIP you can pass song information anywhere, read cURL manual for additional information.

3. Creating dynamic image signature

You can create dynamic image signatures using AMIPDS (AMIP Dynamic Signature) which can be dowloaded from http://amip.tools-for.net.

Some other links which may help:

http://whatsplaying.sourceforge.net/downloads.shtml (on this page you can find sample perl, php and ASP scripts for whatsplaying plug-in, you can then use them with AMIP).

http://www.thefinn.net/pages.html?page_id=2 (generates dynamic image signature from text, PHP+Font+background)

http://www.phpbb.com/phpBB/viewtopic.php?t=44858
http://www.phpbb.com/phpBB/viewtopic.php?t=74615

Two above links are the discussion of different plug-ins and tools which can be used to create dynamic signatures.

http://www.maniacalrage.net/thru.php?ID=18 (sample scripts from the CurrentlyHearing plug-ins).

http://www.dougk-ff7.net/sig.phps (PHP script to create dynamic image signature from the text file).
 Logged
EvilLyrics forum

 Logged
 Pages: 1