Skip to Content
It is currently June 20th, 2018, 1:00 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 68 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
PostPosted: November 11th, 2004, 7:53 am 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
*** This PAL is now complete. Please read further down for script ***

I have done a search and only found one request for this.
Not sure if it is possible to do, and if it is, if there is already a script out there.

If it is possible and there is not a script. I will try and do one. I am still very new to pal and all I have learnt is from looking at FesterHead's scripts. So I am not sure how far I will get :D .
I guess it would work something like this:-
Code:
On start of song
  Check if it's a request
     If it is
        check if there is a dedication
          If there is
            Change  Title to <Artist - Title> + ~Request~ + Requested By + Dedication
          else
            Change  Title to <Artist - Title> + ~Request~
Loop


It looks so simple when I look at it like this, but I guess it is not :cry: .
I have looked at FesterHead's "Title Changer" script and think that is my best bet on finding out how to do this.

If anyone has any suggestions or can help out it would be greatly appreciated.

Many thanks.


Last edited by xgeek on November 12th, 2004, 9:12 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 9:31 am 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
Okay been playing and it is not too bad. I think I will get there on this :D

So far I have this, but now I am stuck.

I can't access the name or message like this:-
WriteLn(ActivePlayer.GetSongInfo['name']);
WriteLn(ActivePlayer.GetSongInfo['msg']);

They are the db names for who requested the song & the dedication message

but
WriteLn(ActivePlayer.GetSongInfo['requestID'])
does echo the requestID

Is there anyway to get this info with a ActivePlayer.GetSongInfo command?
Or do I have to mess with MySql :shock:

Cheers

Code:
PAL.Loop := True;
PAL.WaitForPlayCount(1); {Wait for 1 songs to play}
PAL.LockExecution;

// Instantiate a Song Info object
var Song : TSongInfo;

Song := TSongInfo.Create;

WriteLn(ActivePlayer.GetSongInfo['name']);
WriteLn(ActivePlayer.GetSongInfo['msg']);
if (ActivePlayer.GetSongInfo['requestID']) then
  begin
     Song['artist'] := ActivePlayer.GetSongInfo['artist'] + ' - ' + ActivePlayer.GetSongInfo['title'];
     Song['title'] := '~Requested Song~';
     Encoders.SongChange(Song);
  end;
 

Song.Free;

PAL.UnlockExecution;
   
// Be nice.  Release data structures
Song.Free;


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 1:33 pm 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
Well so for so good. I am just really stuck on retrieving the requester & message.

Still not sure if I can get it via a ActivePlayer.GetSongInfo command or if I need to use MySQL.

Other than that it works great :lol:

If anyone can advise if the ActivePlayer.GetSongInfo command can get the last bit of info I need. If not can someone help me with the MySQL part.

I know the information is in the requestlist table
And I know I need to search for (ActivePlayer.GetSongInfo['requestID']) within the ID field

Once I have found the right record I then need to assign
name to Requested_by
msg to Dedication_Message

Many thanks for any help on this.


Code:
PAL.Loop := True;

WriteLn('Waiting for next song to start');
PAL.WaitForPlayCount(1); {Wait for 1 songs to play}
WriteLn('New song started');

// Not sure if I need this, but without it sometimes the injection does not happen.
// Not sure if when (ActivePlayer.GetSongInfo['requestID']) gets called it is while the crossfade is happening and it gets the wrong answer
PAL.WaitForTime(T['+00:00:05']); //Wait 5 secs
//PAL.LockExecution;

// Test variables so I can test my logic before I get the MySQL code working
var Requested_by : String = 'Anonymous';
var Dedication_Message : String = 'None';

// Requested_by := 'Xgeek';
// Dedication_Message := 'Some Message';

// Instantiate a Song Info object
var Song : TSongInfo;
Song := TSongInfo.Create;

// Check if current song has a request ID
if (ActivePlayer.GetSongInfo['requestID']) then
  Begin
       WriteLn('Song is a Request');
     // Do some MySQL stuff here to get the "Requested by" & "Dedication Message"
     // Assign "Requested by" to Requested_by
     // Assign "Dedication Message" to Dedication_Message
     
     // Test Requested_by. If null Requested_by = "Anonymous"
     // Test Dedication_Message. If null Dedication_Message = "None"
     // Maybe even need to parse the message to strip out line feeds?
     
     
      If ((Requested_by = 'Anonymous') and (Dedication_Message = 'None')) then
         Begin
           WriteLn('Request without Dedication');
           WriteLn(Requested_by);
           WriteLn(Dedication_Message);
           Song['artist'] := ActivePlayer.GetSongInfo['artist'] + ' - ' + ActivePlayer.GetSongInfo['title'];
           Song['title'] := '~Requested~';
           Encoders.SongChange(Song);
         End
     else
         Begin
           WriteLn('Request with Dedication');
           WriteLn(Requested_by);
           WriteLn(Dedication_Message);
           Song['artist'] := ActivePlayer.GetSongInfo['artist'] + ' - ' + ActivePlayer.GetSongInfo['title'];
           Song['title'] := '~Requested by ' + Requested_by + ' : Dedication:- ' + Dedication_Message + '~';
           Encoders.SongChange(Song);
        End;
  End;
 
// PAL.UnlockExecution;
WriteLn('Done....');

// Release data structures
Song.Free;

// I just added this so my Debug text does not get cleared before I can read it.
PAL.WaitForTime(T['+00:00:10']); //Wait 10 secs


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 1:54 pm 
Offline
Alumni
Alumni

Joined: March 11th, 2003, 1:34 pm
Posts: 9959
Location: Maui, HI
Once you've identified the current song is a request and have the requestid you need to do a lookup in the database to get the dedication stuff.

Example (untested and uncompiled):
Code:
var reqInfo : TDataSet = Query('SELECT name, msg FROM requestlist WHERE id = ' + THE_REQUEST_ID, [], true);

var Requested_by : String = reqInfo['name'];
var Dedication_Message : String = reqInfo['msg'];


Mght add this as an option to my title changer PAL because it's a cool idea.

_________________
- Steve Kunitzer
- SVS (Spacial Volunteer Support) / Forum Administrator

Image
Image


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 3:29 pm 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
:D :D :D That was the final piece of the puzzle.
Hope you don't mind but I used your pal header as a template for this one.

It works great, but I still have one small problem. And that is with line feeds in the message. For every line feed Winamp displays a square box like a Wingdings font :? .
So I need to work on a parser for Dedication_Message.

Other than that it does what I need. It would be great if someone with more experience could give it the once over to see if I have made any noobie errors.

Any feedback is more than welcome.

Many thanks :D

Code:
{
  Insert Request Dedication information into encoded stream : script by Xgeek (aka Xgeek)
  $Id: Inject Request Dedication.pal,v 0.05 2004/11/12

  * This script would not have been possible without the help from FesterHead. Thank You!!!

  What this PAL does:
    * On song change checks to see if the song was requested, and if it was:
    * If no dedication information it will inject ~Requested~ in the title stream after Artist - Title
    * If dedication information it will inject ~Requested by <Name> : Who had this to say:- <Message>~ in the title stream after Artist - Title


  What is configurable:
    * Nothing


  PAL built to run continuously:
    * Switch to a desktop with the 'PAL Scripts' window visible

    * Click '+' (Add new PAL script)

    * Check the 'Automatically start script' box

    * Click the folder icon and navigate to this script

    * Click 'OK'

    * Highlight PAL and click 'Start selected PAL script' (VCR type play button)

    * Save settings by clicking the 'File' menu item and selecting 'Save Configuration'
}

PAL.Loop := True;

WriteLn('New song started');

WriteLn('Waiting 5 Seconds before checking if it is a Request');
// Wait a few seconds just in case this song is a Jingle. If it is, and it is under 10 seconds the script will still get the correct info for the song after.
PAL.WaitForTime(T['+00:00:05']); //Wait 5 secs
PAL.LockExecution;

// Instantiate a Song Info object
var Song : TSongInfo;
Song := TSongInfo.Create;

WriteLn('Checking if song has been Requested......');
if ((ActivePlayer.GetSongInfo['requestID']) = 0) then WriteLn('Song is not a Request');

// Check if current song has a request ID
if ((ActivePlayer.GetSongInfo['requestID']) > 0) then
  Begin
      WriteLn('Song is a Request');
      var reqInfo : TDataSet = Query('SELECT name, msg FROM requestlist WHERE id = ' + ActivePlayer.GetSongInfo['requestID'], [], true);
      var Requested_by : String = reqInfo['name'];
      var Dedication_Message : String = reqInfo['msg'];
      reqInfo.Free;
     
      If (Requested_by = '') then Requested_by := 'Anonymous';
      If (Dedication_Message = '') then Dedication_Message := 'Nothing...';

      If ((Requested_by = 'Anonymous') and (Dedication_Message = 'Nothing...')) then
         Begin
           WriteLn('Song is a Request without Dedication');
           WriteLn(Requested_by); // This should aways echo Anonymous
           WriteLn(Dedication_Message); // This should aways echo Nothing...
           Song['artist'] := ActivePlayer.GetSongInfo['artist'] + ' - ' + ActivePlayer.GetSongInfo['title'];
           Song['title'] := '~Requested~';
           Encoders.SongChange(Song);
         End
     else
         Begin
           WriteLn('Song is a Request with a Dedication');
           WriteLn(Requested_by);
           WriteLn(Dedication_Message);
           Song['artist'] := ActivePlayer.GetSongInfo['artist'] + ' - ' + ActivePlayer.GetSongInfo['title'];
           Song['title'] := '~Requested by ' + Requested_by + ' : Who had this to say:- ' + Dedication_Message + '~';
           Encoders.SongChange(Song);
        End;
  End;
 
PAL.UnlockExecution;
WriteLn('Done....');

// Release data structures
Song.Free;

WriteLn('Waiting for next song to start');
PAL.WaitForPlayCount(1); {Wait for 1 songs to play}
{
  **************
  * Change log *
  **************

  Revision 0.05  2004/11/12 xgeek
  }


Last edited by xgeek on November 12th, 2004, 7:08 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 3:53 pm 
Offline
Alumni
Alumni

Joined: March 11th, 2003, 1:34 pm
Posts: 9959
Location: Maui, HI
I don't mind you or anybody using my template.
If you put your PALs under CVS control and use keywords you can get the Id and log section filled out automatically :)

Nice to see some code commented and indented.
Makes it easier to read and understand.

Yes. I image the line breaks would show up funny kine.
Yes. You will need to parse/replace the line breaks.
Not sure how long the title can be so be careful of really long dedications as results may be unpredicatble.

Couple ideas:
* Make sure to free reqInfo, too.
* Might want to use a PAL.WaitForPlayCount(1) at the end to keep the request info until song change rather than rebuilding every 10 seconds.
* might want to change the initial check to see if the request id is > 0 rather than interpreting it as a boolen. Since 0 is false and non-zero is true there may in the future be problems if a requestid is negative. That probably won't happen, though, and it's just personal preference speaking.

_________________
- Steve Kunitzer
- SVS (Spacial Volunteer Support) / Forum Administrator

Image
Image


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 4:16 pm 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
Okay changes made. And code above updated.

Cheers :D

FesterHead wrote:
Couple ideas:
* Make sure to free reqInfo, too.
Done. But I got a compile error when I added it under song.Free;. So I added it in the IF statement just under the last time that reqInfo is used.

* Might want to use a PAL.WaitForPlayCount(1) at the end to keep the request info until song change rather than rebuilding every 10 seconds.
Hmm I have one at the top :? . Are you saying I need to add another one at the bottom. As it is the script only runs once on a song change

* might want to change the initial check to see if the request id is > 0 rather than interpreting it as a boolen. Since 0 is false and non-zero is true there may in the future be problems if a requestid is negative. That probably won't happen, though, and it's just personal preference speaking.
Done.


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 6:35 pm 
Offline
Alumni
Alumni

Joined: March 11th, 2003, 1:34 pm
Posts: 9959
Location: Maui, HI
The free needs to be within the same scope as the instantiation.
You solved it just fine.

I'm suggesting eliminating all waits (timed and play counts) from the top and only include the wait at the bottom.
Code:
// lock execution

//  do your stuff

// unlock execution

// wait for 1 song to play

There should be no problems with jingles/ditties/... if wrapped around a lock/unlock

_________________
- Steve Kunitzer
- SVS (Spacial Volunteer Support) / Forum Administrator

Image
Image


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 7:29 pm 
Offline
Senior User
Senior User

Joined: March 24th, 2004, 9:00 am
Posts: 213
Location: The Land Of The Legal Music
another addition could be a word filter :D
i like to keep stuff clean 8)

something like "If decication contain FUCK - DO replace FUCK, ****"
LOL!


bas


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 9:38 pm 
Offline
Alumni
Alumni

Joined: March 11th, 2003, 1:34 pm
Posts: 9959
Location: Maui, HI
Do that in the web code before allowing the dedication.
Fix the wound at the source.

_________________
- Steve Kunitzer
- SVS (Spacial Volunteer Support) / Forum Administrator

Image
Image


Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2004, 10:23 pm 
Offline
Senior User
Senior User

Joined: March 24th, 2004, 9:00 am
Posts: 213
Location: The Land Of The Legal Music
how to? any top-of-head ideas/codes? i would appreciate alot :)

_________________
Best Regards
- Always Remember, An Audio Cd Is 1411Kbps... ;)
My Audio Quality Kicks 977-Hitz Off The Air 8)


Top
 Profile  
Reply with quote  
PostPosted: November 12th, 2004, 11:24 am 
Offline
Alumni
Alumni

Joined: March 11th, 2003, 1:34 pm
Posts: 9959
Location: Maui, HI
A good place to start is Google and some search criteria such as "php bad word filter" (sans quotes):
http://www.google.com/search?hl=en&q=ph ... ord+filter

_________________
- Steve Kunitzer
- SVS (Spacial Volunteer Support) / Forum Administrator

Image
Image


Top
 Profile  
Reply with quote  
PostPosted: November 12th, 2004, 4:12 pm 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
By using FesterHeads search info I came up with this. It works okay and is a simple script.

If you want to censor dedication text for bad words you will need to edit 1 file and add a new file.

First edit req/req.dedication.php and add this under <?

Code:
#####################################
## Mod to Filter banned words from request messages
include('filter.php');
$result = Filter($rmessage,1);
#####################################

Save and upload the file.

Second copy and paste this code into a text file. Then save the text file as filter.php

You will need to add the bad words to the script before uploading it. Once you have added the words you want censored upload it to /req/

Code:
<?php

/***************************************************************
**
** Word Filter
**
** Author...: leapinglangoor [ leapinglangoor@yahoo.co.in ]
** Updated..: 22 Aug 2004
** Version..: v2.1
**

****************************************************************

This function does all the work. If $replace is 1 it will replace all bad words with the wildcard replacements.  If $replace is 0 it will not replace anything. In either case, it will return 1 if it found bad words or 0 otherwise.Be sure to fill the $bads array with the bad words you want filtered.

***************************************************************/

function Filter(&$text, $replace)
       {
    //fill this array with the bad words you want to filter and their replacements
    $bads = array (
        array("Fool","F**l"),
        array("crap","c***")
    );

    if($replace==1)
       {
              //we are replacing
        $remember = $text;
         
    for($i=0;$i<sizeof($bads);$i++)
       {
    //go through each bad word
    $text = eregi_replace($bads[$i][0],$bads[$i][1],$text); //replace it
    }

    if($remember!=$text) return 1;                 //if there are any changes, return 1
         
    } else {                             

        //we are just checking
        for($i=0;$i<sizeof($bads);$i++)
              {
        //go through each bad word
        if(eregi($bads[$i][0],$text)) return 1; //if we find any, return 1
        }     
         
    }
}

?>


Last edited by xgeek on November 12th, 2004, 7:14 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: November 12th, 2004, 6:09 pm 
Offline
Senior User
Senior User

Joined: March 24th, 2004, 9:00 am
Posts: 213
Location: The Land Of The Legal Music
xgeek ur the 2nd god! MANY MANY MANY thanx!

_________________
Best Regards
- Always Remember, An Audio Cd Is 1411Kbps... ;)
My Audio Quality Kicks 977-Hitz Off The Air 8)


Top
 Profile  
Reply with quote  
PostPosted: November 12th, 2004, 7:00 pm 
Offline
Junior User
Junior User

Joined: October 25th, 2004, 3:14 am
Posts: 74
Okay I could not find a way to parse the line feeds via pal. I spent about 5 hours looking at scripts and searching. So I gave up and decided to do it server side.

If you use this script and want to remove line feeds from the dedication so winamp displays them okay. Add this just under <? in /req/req.dedication.php

Code:
#####################################
## Mod to strip Line Feeds from the request message
$rmessage = preg_replace("#\r\n#"," ",$rmessage);
#####################################


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group