🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
24 messages
24 total messages Started by matija Sun, 22 Jun 2003 11:54
[dialog] X-Now-Playing script v0.45
#126816
Author: matija
Date: Sun, 22 Jun 2003 11:54
313 lines
11800 bytes
here you go, this one is slightly better and - hopefully - bug free :)



// X-Now-Playing script for winamp 2.x
// version: 0.45
// date: 2003-06-22
// author: mkrnic [at] public [dot] srce [dot] hr

// please note that the script is applied just before dialog sends your
// message. if you write a message while something is playing and send
// it when your speakers are silent, the song name won't be displayed.

// the script is not guaranteed to work at all and it might crash
// dialog if you reload it and try sendind any posts. i've had that
// happen a couple of times, it's a dialog scripting quirk; after
// recompiling, restart dialog completely. if you lose anything
// valuable because of this script, it's your problem, not mine.

// this script was tested on win2k and winxp machines with winamp
// 2.90 and 2.91. it might not work elsewhere (most notably win9x
// systems, i don't know of anyone who uses these anymore), though
// it should be just fine with any winamp 2.x.

// it's imperative that you turn off song title scrolling in taskbar
// inside winamp's preferences, otherwise you'll get garbage.

// don't mind the warnings when compiling; they don't affect the
// script in any way and are dependant on the true/false choices.

// future plans:
// - winamp 3 support. not that you should be using it at all because
//   it's a slow and bloated piece of software crap :(
// - stripping of any file extension, not just mp3 
// - NOT adding the skin name and/or previous/next song because it's
//   impossible to get details on these from outside winamp, and i'm
//   _not_ going to write a special winamp plugin just for this ;)
                                                                     
// changes to the source code and/or using it for coding your own
// scripts are allowed as long as you notify me about it by e-mail
// and send me your code so i can see what you've created :)


// ----------------------------------------------------------------------


program OnBeforeSendingMessage;


// ----------------------------------------------------------------------


const

  // set this to true if you want x-headers and/or song names applied
  // to e-mails, too.
  cApplyToEmails = false;


  // set this to false if you wish not to add the x-header at all.
  cAddXHeader = true;

  // the name of the x-header.                                                               
  // DO *NOT* ADD COLONS OR SPACES IN THE HEADER NAME!
  // IF YOU DON'T KNOW WHAT YOU'RE DOING, LEAVE THIS AS IT IS!
  cXHeaderName = 'X-Now-Playing';


  // set this to true if you want the current song to be added to the
  // end of the post.
  cAddSongNameToEndOfPost = false;

  // set this to false if you don't want an empty line before the
  // song name at the end of the post.
  cAddEmptyLineToEndOfPost = true;

  // the text shown before the song name at the end of the post.  
  cEndOfPostText = 'Now playing: ';


  // used when nothing is playing.
  cNothing = 'nothing';          


  // set this to false if you want X-Now-Playing: song name
  // instead of X-Now-Playing: "song name".  
  cIncludeQuotationMarks = true;

  // set this to false if you don't want your winamp version to be
  // shown in round brackets after the song name.
  cIncludeWinampVersion = true;

  // set this to false to have song_name.mp3.  
  cStripMp3Extension = true;


  // set this to true if you want a messagebox asking to include
  // the currently playing song in your post.
  // yes, it's stupid, but i use it for debugging, and so could
  // you if you want to mess around with the source code :)
  // please note that the song name is always added to the end
  // of the message if you specified so; the messagebox has no
  // effect here - as i said, it's for debugging purposes only.
  cShowMessageBox = false;

  // the messagebox shows
  // Insert X-Now-Playing: song_name (Winamp version) ?
  // by default; you can do some localization here :))
  cMessageBoxPrompt = 'Insert';

  // the title of the message box.  
  cMessageBoxTitle = 'Insert X-Header?';
                              


// ----------------------------------------------------------------------


// there's nothing for you to change down below, go away :)


// ----------------------------------------------------------------------



const
  winampWindowTitle = 'Winamp v1.x';

  WM_USER = 1024;
  WM_WA_IPC = WM_USER;
  IPC_GETVERSION = 0;

  MB_YESNO = 4; 
  IDYES = 6;
  IDNO = 7;


// ----------------------------------------------------------------------

            
function findWindow(c1, c2: PChar): Cardinal; external 'FindWindowA@user32.dll stdcall';
function getWindowTextLength(hWnd: Cardinal): Integer; external 'GetWindowTextLengthA@user32.dll stdcall';
function getWindowText(hWnd: cardinal; lpString: PChar; nMaxCount: Integer): Integer; external 'GetWindowTextA@user32.dll stdcall';
function sendMessage(hWnd: cardinal; Msg: word; wParam: word; lParam: integer): integer; external 'SendMessageA@user32.dll stdcall';

function messageBox(hWnd: Cardinal; lpText, lpCaption: PChar; uType: longword): Integer; external 'MessageBoxA@user32.dll stdcall';


// ----------------------------------------------------------------------


function findWinampHWND : cardinal;
begin
  result := findWindow (winampWindowTitle, null);
end;


// ----------------------------------------------------------------------
                      

function winampVersion : string;

var version : integer;
    major, minor1, minor2 : word;

begin
  version := sendMessage (findWinampHWND, WM_WA_IPC, 0, IPC_GETVERSION);
  
  major := version shr 12;
  minor1 := (version shl 4) shr 12;
  minor2 := (version shl 8) shr 8;
  
  result := 'Winamp ' + inttostr(major) + '.' + inttostr(minor1) + inttostr(minor2);
end;

                                                                         
// ----------------------------------------------------------------------


function winampSong : string;

var titleLen  : integer;
    tempInt   : integer;
    tempStr   : string;
    plNum     : integer;
    tempmp3   : string;
    winampHWND: cardinal;

begin
  // used in case winamp is not running or the window is not found
  tempStr := cNothing;

  winampHWND := findWinampHWND;

  // if winamp's window is found...
  if winampHWND <> 0 then
    begin
      // find the caption text of winamp's window
      titleLen := getWindowTextLength (winampHWND) + 2;
      setLength (tempStr, titleLen);
      getWindowText (winampHWND, pchar(tempStr), titleLen);
      setLength (tempStr, length(tempStr));

      // this comes after the song name
      tempInt := pos (' - Winamp', tempStr);
      
      // and the first space is after the playlist number
      plNum := pos (' ', tempStr) + 1;
      
      // if there's no ' - Winamp' in the title, then winamp is started
      // but isn't playing anything (that is, the title is in the form of
      // "Winamp 2.91"), so we'll leave the song name as "nothing"
      if tempInt <> 0 then
        begin
          // the window title is "x. song artist - song name - Winamp", where the x
          // is the playlist position, but we don't want that, so we'll remove both
          // unnecessary things
          tempStr := copy (tempStr, plNum, tempInt - plNum);

          // check if the string ends with '.mp3' and remove it if specified
          if cStripMp3Extension then
            begin
              tempmp3 := lowerCase (copy (tempStr, length(tempStr) - 3, 4));
              if tempmp3 = '.mp3' then tempStr := copy (tempStr, 1, length(tempStr) - 4);
            end;  

          // "artist - song name" ?
          if cIncludeQuotationMarks then
            tempstr := '"' + tempstr + '"';

          // (")artist - song name(") (Winamp 2.91) ?
          if cIncludeWinampVersion then
            tempstr := tempstr + ' (' + winampVersion + ')';

        end // if tempInt <> 0
      else
        tempStr := cNothing;

    end; // if winampHWND <> 0

  result := tempStr;
end;


// ----------------------------------------------------------------------


function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;    

var tempSong : string;

begin

  // apply to usenet posts only or e-mails, too?
  if ((not isEmail) or (isEmail and cApplyToEmails)) then
    begin

      // get the song name
      tempSong := winampSong;

      // add x-header?
      if cAddXHeader then
      begin
        // yes, i know the stuff below could've been solved with just one
        // message.insert, but it's impossible to read such a logical evaluation ;)

        // a messagebox asking you if you wish to include the x-header in your post
        if cShowMessageBox then
          begin
            if messageBox(null, cMessageBoxPrompt + ' ' + CXHeaderName + ': ' + tempSong + ' ?', CMessageBoxTitle, MB_YESNO) = IDYES then
              // insert the x-header at the beginning of the message, dialog (or perhaps
              // the news server) will sort it out as necessary.
              message.insert (1, cXHeaderName + ': ' + tempSong);
          end
        else
          // if you don't want to show the message box, the header is always added
          message.insert (1, cXHeaderName + ': ' + tempSong);      
          
      end; // if cAddXHeader
  
      // add song name to end of post?
      if cAddSongNameToEndOfPost then
        begin
          // add one empty line?
          if cAddEmptyLineToEndOfPost then message.add ('');

          // the song name
          message.add (cEndOfPostText + tempSong);
        end; // if cAddSongToEndOfPost
        
    end; // if ((not isEmail) or (isEmail and cApplyToEmails))


  // if this is set to false, sending messages will *always* fail
  // use this for debugging along with the messagebox.
  result := true;
end;


// ----------------------------------------------------------------------

begin
end.




-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#126844
Author: Gandalf il Grigio
Date: Sun, 22 Jun 2003 22:04
15 lines
1869 bytes
news.software.readers ~ 22/6/2003 ~ matija:

>           message.insert (1, cXHeaderName + ': ' + tempSong);

Excuse me... what does that �1� mean? Is it an index?
I'd like the X-Now-Playing between the other X-Headers, is this possible?

TIA,
G
-- 
 _____ Farewell! _     _ ___  ~ ICQ# 16553733 mailto:gandalf*ithn.net
|   __|___ ___ _| |___| |  _| ~ 40tude Dialog http://snurl.com/dialog
|  |  | .'|   | . | .'| |  _| ~ Google Groups http://snurl.com/ggroup
|_____|__,|_|_|___|__,|_|_|   ~ ITHNetiquette http://snurl.com/ithnet
Re: [dialog] X-Now-Playing script v0.45
#126847
Author: matija
Date: Sun, 22 Jun 2003 23:40
24 lines
2222 bytes
Gandalf il Grigio, completely geschtonkenflapped, wrote:
>>           message.insert (1, cXHeaderName + ': ' + tempSong);
> 
> Excuse me... what does that �1� mean? Is it an index?

     yes. the first line actually has index 0, but i haven't
     tried using it :)


> I'd like the X-Now-Playing between the other X-Headers, is this possible?

     i have it between NNTP-Posting-Date and X-Face. try changing
     the index and see what happens.

     anyway, i'll do some debugging to see what are the exact lines
     included in the message before sending. maybe i can sort the
     x-headers alphabetically, since dialog leaves them unsorted.


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#126996
Author: Gandalf il Grigio
Date: Tue, 24 Jun 2003 14:39
15 lines
1767 bytes
news.software.readers ~ 23/6/2003 ~ matija:

>  try changing the index and see what happens.

I'm trying with 11 instead of 1, let's see :)

BTW, many thanks for the script, I do like it ^__^

G
-- 
Farewell!
�"G for Grand!" they shouted, and the old man smiled.�

ICQ# 16553733 ~ 40tude Dialog: http://snurl.com/dialog
Re: [dialog] X-Now-Playing script v0.45
#127074
Author: Tarkus
Date: Wed, 25 Jun 2003 03:04
12 lines
1747 bytes
On Sun, 22 Jun 2003 13:54:57 +0200, matija wrote:

> here you go, this one is slightly better and - hopefully - bug free :)

Let's see if it works with STP2...
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "Floyd Echoes In The Gardens CD 2 - Track  1"
Re: [dialog] X-Now-Playing script v0.45
#127075
Author: Tarkus
Date: Wed, 25 Jun 2003 03:26
21 lines
1972 bytes
On Wed, 25 Jun 2003 03:04:20 GMT, Tarkus wrote:

> On Sun, 22 Jun 2003 13:54:57 +0200, matija wrote:
> 
>> here you go, this one is slightly better and - hopefully - bug free :)
> 
> Let's see if it works with STP2...
> -- 
> 
> Now playing: "Floyd Echoes In The Gardens CD 2 - Track  1"

Sweet.  :)

Great script - thanks for sharing!
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "Floyd Echoes In The Gardens CD 2 - Track  5"
Re: [dialog] X-Now-Playing script v0.45
#127167
Author: Henrik Walther
Date: Thu, 26 Jun 2003 22:45
10 lines
1371 bytes
On Sun, 22 Jun 2003 13:54:57 +0200, matija wrote:

> here you go, this one is slightly better and - hopefully - bug free :)

How should the script look if you would like it to pull playing MP3 from
MusicMatch Jukebox ? Is it possible at all ?

-- 
Henrik Walther
Re: [dialog] X-Now-Playing script v0.45
#127189
Author: Aries
Date: Fri, 27 Jun 2003 08:04
15 lines
1810 bytes
Gliding through the portals of cyberworld on Fri, 27 Jun 2003 00:45:38 
+0200, Aries came across Henrik Walther exclaiming:

> On Sun, 22 Jun 2003 13:54:57 +0200, matija wrote:

>> here you go, this one is slightly better and - hopefully - bug free :)

> How should the script look if you would like it to pull playing MP3 from
> MusicMatch Jukebox ? Is it possible at all ?

Or even using windows media player/midi or wav ?
-- 
Val at copelands.co.uk - posting from her desktop
http://www.copelands.co.uk/val/
Re: [dialog] X-Now-Playing script v0.45
#127243
Author: matija
Date: Sat, 28 Jun 2003 18:58
16 lines
2014 bytes
Aries, completely geschtonkenflapped, wrote:
>> How should the script look if you would like it to pull playing MP3 from
>> MusicMatch Jukebox ? Is it possible at all ?
> 
> Or even using windows media player/midi or wav ?

     it's possible, but it complicates things a bit and i can't
     quite see why i should go and download some software that
     does everything that winamp does, but worse :))


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#127250
Author: Gandalf il Grigio
Date: Sat, 28 Jun 2003 21:55
22 lines
2185 bytes
news.software.readers ~ 24/6/2003 ~ Gandalf il Grigio:

>>  try changing the index and see what happens.
> I'm trying with 11 instead of 1, let's see :)

Well, I eventually found a �bug�... since the script adds the header also
to the email messages (I use Dialog as the default mailreader, too), and
since an email message has less headers, it inserts the header in the
message body (after the first line, usually) :/

Now, could you use a flag to avoid inserting the header in email
messages? Or maybe check if the header is inserted between other headers
or in the body (and in this case, move it a little higher)?

My scripting abilities are near 0, so I cannot help you ^___^;

G
-- 
Farewell... ~ ICQ# 16553733 ~ Dialog: snurl.com/dialog

�"G for Grand!" they shouted, and the old man smiled.�
Re: [dialog] X-Now-Playing script v0.45
#127264
Author: Andreas Loch
Date: Sun, 29 Jun 2003 00:21
47 lines
3106 bytes
Samstag, 28. Juni 2003 23:55, Gandalf il Grigio:

> news.software.readers ~ 24/6/2003 ~ Gandalf il Grigio:

>>> try changing the index and see what happens.
>> I'm trying with 11 instead of 1, let's see :)
>
> Well, I eventually found a �bug�... since the script adds the
> header also to the email messages (I use Dialog as the default
> mailreader, too), and since an email message has less headers, it
> inserts the header in the message body (after the first line,
> usually) :/
>
> Now, could you use a flag to avoid inserting the header in email
> messages?

This flag already exists:

  // set this to true if you want x-headers and/or song names applied
  // to e-mails, too.
  cApplyToEmails = false;

I think you changed it into "cApplyToEmails = true;" and now the
script also works for emails.

But you could set the header position for email and news seperately.
To do this, replace the occurences of the line

| message.insert (1, cXHeaderName + ': ' + tempSong);

with the following code

| if isEmail then begin //this is for emails
|   message.insert (8, cXHeaderName + ': ' + tempSong); end
| else begin            //this is for usenet postings
|   message.insert (11, cXHeaderName + ': ' + tempSong);
| end;

and fit the index numbers to your needs.

Andreas
-- 
http://gigaschatten.de/
Now another way to explain acronyms to newbies:
"Install 40tude Dialog and hover the cursor over, dude."
[Loonie in news.software.readers]
Re: [dialog] X-Now-Playing script v0.45
#127273
Author: Gandalf il Grigio
Date: Sun, 29 Jun 2003 00:57
14 lines
1795 bytes
news.software.readers ~ 29/6/2003 ~ Andreas Loch:

>> Now, could you use a flag to avoid inserting the header in email
>> messages?
> This flag already exists:

Er, I'm so sorry, I didn't notice it ^___^;;;

G (shame on me! ;))
-- 
Farewell... ~ ICQ# 16553733 ~ Dialog: snurl.com/dialog

�"G for Grand!" they shouted, and the old man smiled.�
Re: [dialog] X-Now-Playing script v0.45
#127286
Author: Tarkus
Date: Sun, 29 Jun 2003 06:41
17 lines
1972 bytes
On Sun, 22 Jun 2003 13:54:57 +0200, matija wrote:

> here you go, this one is slightly better and - hopefully - bug free :)

I'm using this with STP, which emulates Winamp for external utilities.
Unfortunately, as you'll /No Doubt/ see below, it's cutting off the first
name of my groups, so No Doubt becomes Doubt, Rick Wakeman becomes
Wakeman, etc.  Is there anything I can do to stop that?

Thanks.
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "Doubt - Waiting Room"
Re: [dialog] X-Now-Playing script v0.45
#127342
Author: matija
Date: Sun, 29 Jun 2003 22:13
16 lines
2102 bytes
Tarkus, completely geschtonkenflapped, wrote:
> I'm using this with STP, which emulates Winamp for external utilities.
> Unfortunately, as you'll /No Doubt/ see below, it's cutting off the first
> name of my groups, so No Doubt becomes Doubt, Rick Wakeman becomes
> Wakeman, etc.  Is there anything I can do to stop that?

     that obviously happens because the script cuts off everything
     before the first space in the song name. STP doesn't include
     the playlist position while winamp does. i'll add another
     flag for this issue.


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#127343
Author: matija
Date: Sun, 29 Jun 2003 22:13
16 lines
2191 bytes
Gandalf il Grigio, completely geschtonkenflapped, wrote:
>>> Now, could you use a flag to avoid inserting the header in email
>>> messages?
>> This flag already exists:
> 
> Er, I'm so sorry, I didn't notice it ^___^;;;

     nothing to be sorry about. if you set the flag to false,
     you can't have the song name appended at the end of the
     e-mail. i'll make a workaround soon.


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#127384
Author: Tarkus
Date: Mon, 30 Jun 2003 06:13
22 lines
2346 bytes
On Mon, 30 Jun 2003 00:13:47 +0200, matija wrote:

> Tarkus, completely geschtonkenflapped, wrote:
>> I'm using this with STP, which emulates Winamp for external utilities.
>> Unfortunately, as you'll /No Doubt/ see below, it's cutting off the first
>> name of my groups, so No Doubt becomes Doubt, Rick Wakeman becomes
>> Wakeman, etc.  Is there anything I can do to stop that?
> 
>      that obviously happens because the script cuts off everything
>      before the first space in the song name. STP doesn't include
>      the playlist position while winamp does. i'll add another
>      flag for this issue.

Thank you.  I'm glad you were able to understand me, even while I was
geschtonkenflapped.  :)
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "- Little Boy"
Re: [dialog] X-Now-Playing script v0.45
#127812
Author: matija
Date: Sat, 05 Jul 2003 17:08
47 lines
3368 bytes
Tarkus, completely geschtonkenflapped, wrote:
> I'm using this with STP, which emulates Winamp for external utilities.
> Unfortunately, as you'll /No Doubt/ see below, it's cutting off the first
> name of my groups, so No Doubt becomes Doubt, Rick Wakeman becomes
> Wakeman, etc.  Is there anything I can do to stop that?

     ok, i'm still too lazy to fix yours and gandalf's problem,
     but i'll do it soon. i have also found a way to access the
     playlist outside winamp (no more window title grabbing!),
     so the next version of the script will have the option to
     display the previous and the next song in the playlist.

     however, STP (whatever that is) troubles me because i don't
     know if it will respond the same to IPC_GETPLAYLISTTITLE.
     can you give me a link or something? to be honest, i'd hate
     to bloat the script so that it handles two different
     code paths...

     in the meantime, if you haven't already figured it out,
     replace "plNum := pos (' ', tempStr) + 1;" with "plNum := 0;",
     that should get rid of your problem.


p.s. yes, i also managed to grab the current skin name :)
     any ideas on how this whole thing might look now? i was
     thinking about something like this:

     X-Now-Playing: "bar - bar" (Winamp 2.91 / skin name)
     X-Was-Playing: "foo - foo"
     X-Will-Be-Playing: "quux - quux"

     or, should you specify not to include the winamp version
     and add an X-Mp3-Player header,

     X-Mp3-Player: Winamp 2.91 / skin name
     X-Now-Playing: "bar - bar"
     X-Was-Playing: "foo - foo"
     X-Will-Be-Playing: "quux - quux"
     
     maybe include the skin name in parenthesis, and not
     delimited by a slash char?


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#127841
Author: Tarkus
Date: Sun, 06 Jul 2003 03:40
42 lines
2893 bytes
On Sat, 5 Jul 2003 19:08:13 +0200, matija wrote:

>      ok, i'm still too lazy to fix yours and gandalf's problem,

I'm just grateful you didn't forget about me.  :)

>      however, STP (whatever that is) troubles me because i don't
>      know if it will respond the same to IPC_GETPLAYLISTTITLE.
>      can you give me a link or something? to be honest, i'd hate
>      to bloat the script so that it handles two different
>      code paths...

Here ya go:

http://www.netean.com/stp/

>      in the meantime, if you haven't already figured it out,
>      replace "plNum := pos (' ', tempStr) + 1;" with "plNum := 0;",
>      that should get rid of your problem.

Just changed it, compiled, saved, restarted.  We'll see how it looks now.

>      or, should you specify not to include the winamp version
>      and add an X-Mp3-Player header,

I definitely prefer putting it in the header.

>      X-Mp3-Player: Winamp 2.91 / skin name
>      X-Now-Playing: "bar - bar"
>      X-Was-Playing: "foo - foo"
>      X-Will-Be-Playing: "quux - quux"
>      
>      maybe include the skin name in parenthesis, and not
>      delimited by a slash char?

The parenthesis sound like a good idea to me.
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "No Doubt - Hella Good "
Re: [dialog] X-Now-Playing script v0.45
#127842
Author: Tarkus
Date: Sun, 06 Jul 2003 03:53
18 lines
1990 bytes
On Sun, 06 Jul 2003 03:40:20 GMT, Tarkus wrote:

> Now playing: "No Doubt - Hella Good "

Sweet.  :)

Any way to get rid of that space before the last quote, or should I just
turn off quoting?

I was thinking this might look good, too:

Now playing: No Doubt - "Hella Good"
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "No Doubt - Making Out "
Re: [dialog] X-Now-Playing script v0.45
#127872
Author: matija
Date: Sun, 06 Jul 2003 13:30
28 lines
2405 bytes
Tarkus, completely geschtonkenflapped, wrote:
>> Now playing: "No Doubt - Hella Good "
> 
> Sweet.  :)
> Any way to get rid of that space before the last quote, or should I just
> turn off quoting?

     try

     tempInt := pos (' - Winamp', tempStr) - 1;


> I was thinking this might look good, too:
> Now playing: No Doubt - "Hella Good"

     it would, but that would require hacking the string :/
     
     anyway, STP doesn't seem to be compliant with my new method,
     so i have to regretfully inform you that you'll have to stick
     with this script. the next version will have a completely
     different method of getting the currently playing song,
     so this is as far as it goes with STP. sorry :(


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Re: [dialog] X-Now-Playing script v0.45
#127895
Author: Tarkus
Date: Sun, 06 Jul 2003 20:46
11 lines
1924 bytes
On Sun, 06 Jul 2003 20:47:04 GMT, Tarkus wrote:

> Now playing: "Triumvirat - Spartacus"

Woohoo!
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "Triumvirat - Spartacus"
Re: [dialog] X-Now-Playing script v0.45
#127896
Author: Tarkus
Date: Sun, 06 Jul 2003 20:47
25 lines
2534 bytes
On Sun, 6 Jul 2003 15:30:06 +0200, matija wrote:

>      try
> 
>      tempInt := pos (' - Winamp', tempStr) - 1;

Thanks...we'll see how this message turns out.

>      anyway, STP doesn't seem to be compliant with my new method,
>      so i have to regretfully inform you that you'll have to stick
>      with this script. the next version will have a completely
>      different method of getting the currently playing song,
>      so this is as far as it goes with STP. sorry :(

Probably a dumb question, but you *did* enable Winamp emulation in STP,
didn't you?

In any case, I appreciate all that you've done, even if this is the end
of the road for STP.  :)
-- 
The UNofficial 40tude Dialog mailing list:
Email:  40tude_Dialog-subscribe@yahoogroups.com
Web:  http://groups.yahoo.com/group/40tude_Dialog/

Now playing: "Triumvirat - Spartacus"
Re: [dialog] X-Now-Playing script v0.45
#127898
Author: Jernej Simončič
Date: Sun, 06 Jul 2003 21:24
149 lines
8004 bytes
On Sun, 22 Jun 2003 13:54:57 +0200, matija wrote:

> here you go, this one is slightly better and - hopefully - bug free :)

As I don't use WinAmp,but foobar2000 <http://foobar2000.hydrogenaudio.org/>,
I made my own version of X-Now-Playing script, which uses foobar's titlebar.
For everybody interested, here it is:

======8<--------------------------------------------------------------------
program OnBeforeSendingMessage;

(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
(* Script: Add X-Now-Playing based on infromation from foobar2000 <http://foobar2000.hydrogenaudio.org/>         *)
(* Version: 0.1                                                                                                  *)
(* Author: Jernej Simoncic <jernej simoncic at guest arnes si>                                                   *)
(*                                                                                                               *)
(* Usage: The script directly inserts the text from your foobar2000 titlebar; use it's excellent formatting      *)
(* formatting functions to fit the text to your needs; the script won't add anything if the titlebar starts with *)
(* foobar2000 - as this normally means that the player is stopped                                                *)
(* You can set exactly what is added to the message below                                                        *)
(*                                                                                                               *)
(* Tested with foobar2000 0.667 on Win2k.                                                                        *)
(*                                                                                                               *)
(* ToDo:                                                                                                         *)
(*  - 8-bit/unicode character processing                                                                         *)
(*                                                                                                               *)
(* Use this script at your own risk.                                                                             *)
(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)

const
  EMail = 1; News = 2; XHeader = 1; EndOfMessage = 2;

  (* * * * * * * * * * * * * * * * * * * * * * * * * * SETTINGS * * * * * * * * * * * * * * * * * * * * * * * * * *)
  UseWith = EMail + News;  //EMail: e-mail messages; News: newsgroup posts
  AddTo = XHeader + EndOfMessage; //XHeader, EndOfMessage 
  XHeaderText = 'X-Now-Playing: %song%'; //the x-header text to add
  EndMessageText = '%n%Now playing: %song%'; //text to add to end of message
  //In both XHeaderText and EndMessageText, %song% will be replaced by the song title; if %song% doesn't appear
  //in the text, song title is added at the end
  //You can also use %n% in the EndMessageText to represent a line break
  (* * * * * * * * * * * * * * * * * * * * * * * * * END OF SETTINGS  * * * * * * * * * * * * * * * * * * * * * * *)
  
  fb2kWindowClass = 'FOOBAR2000_CLASS'; //don't change unless you know what you're doing

function FindWindow(lpClassName, lpWindowName: PChar): Cardinal; external 'FindWindowA@user32.dll stdcall';
function GetWindowTextLength(hWnd: Cardinal): Integer; external 'GetWindowTextLengthA@user32.dll stdcall';
function GetWindowText(hWnd: cardinal; lpString: PChar; nMaxCount: Integer): Integer; external 'GetWindowTextA@user32.dll stdcall';
function MessageBox(hWnd: Cardinal; lpText, lpCaption: PChar; uType: longword): Integer; external 'MessageBoxA@user32.dll stdcall';

procedure MsgBox(text: String);
begin
  MessageBox(null,text,'',0);
end;

function GetFB2kTitle: string;
var handle: Cardinal;
    tlen: Integer;
    title: String;
begin

  title := '';
  handle := FindWindow(fb2kWindowClass, null);;

  if (handle <> 0) then
  begin
    tlen := getWindowTextLength (handle)+1;
    SetLength(title, tlen);
    GetWindowText(handle, pchar(title), tlen);
    SetLength(title, Length(title)-1);
  end;
  
  Result := title;
end;

(*drop-in replacement for the missing StringReplace; acts as if [rfReplaceAll] was specified*)
function StringReplace(text,old,new: String): String;
begin

  while (Pos(old,text) > 0) do
    text := Copy(text,1,Pos(old,text)-1) + new + Copy(text,Pos(old,text)+Length(old),Length(text));
    
  Result := text;
end;

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;    
var song, text: String;
    i: Integer;
begin

  if (((not isEmail) and ((UseWith and News) = News)) or (isEmail and ((UseWith and EMail) = EMail))) then
  begin
    song := GetFB2kTitle();
    
    if (song = '') then
      exit;
    if (Copy(song,1,10) = 'foobar2000') then
      exit;

    if ((AddTo and XHeader) = XHeader) then
    begin
      if (Pos('%song%',XHeaderText) > 0) then
        text := StringReplace(XHeaderText,'%song%',song{,[rfReplaceAll]})
      else
        text := XHeaderText + song;
        
      //clean 8-bit characters from header
      for i := 127 to 255 do
      	if (Pos(Chr(i),text) > 0) then
      	  text := StringReplace(text,Chr(i),'_');  
      
      //sanity checks
      if (Copy(text,1,2) <> 'X-') then
      	text := 'X-' + text;
      if (Pos(': ', text) > 2) and (Pos(': ',text) < (Length(text)-3)) then
        for i := 0 to Message.Count - 1 do
          if (Message.Strings[i] = '') then //insert as the last x-header
          begin
            Message.Insert(i, text);
            break;
          end;
    end;
  
    if ((AddTo and EndOfMessage) = EndOfMessage) then
    begin
      if (Pos('%song%', EndMessageText) > 0) then
        text := StringReplace(EndMessageText,'%song%',song{,[rfReplaceAll]})
      else
      	text := EndMessageText + song;
      
      text := StringReplace(text,'%n%',#13#10{,[rfReplaceAll]});
      	
      Message.Add(text);
    end;
    
  end;

  Result := True;
end;

begin
end.
======8<--------------------------------------------------------------------

-- 
Jernej Simon�i�, <jernej simoncic at guest arnes si>
http://www2.arnes.si/~sopjsimo/

Now playing: Yoko Kanno, Ilaria Graziano - Ghost In The Shell ~ Stand Alone Complex OST [16] - ????�? [Monochrome]
Re: [dialog] X-Now-Playing script v0.45
#127900
Author: matija
Date: Sun, 06 Jul 2003 21:30
21 lines
2323 bytes
Tarkus, completely geschtonkenflapped, wrote:
>>      anyway, STP doesn't seem to be compliant with my new method [...]
>>      so this is as far as it goes with STP. sorry :(
> 
> Probably a dumb question, but you *did* enable Winamp emulation in STP,
> didn't you?

     yes. it seems to emulate the window title and the standard
     playback commands, but nothing else.


> In any case, I appreciate all that you've done, even if this is the end
> of the road for STP.  :)

     well, it does its work properly, and that's all you need :)


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove SPAMISEVIL to reply
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads