Solved

lyrics search

Posted on 1999-01-10
6
232 Views
Last Modified: 2010-04-06
does anybody know how to search and retrieve cd lyrics from the lyrics server at www.lyrics.ch? I have a couple of http components but dont know how to do what i want.

thanks for your help
cando
0
Comment
Question by:cando
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Can't help you, but your project seems to be interesting..,

Will the result of your work will be freeware?   :-)

Regards, Madshi.
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 500 total points
Comment Utility
cando

This is a unit I created to search yahoo for but I have addapted it to do your search, you just need to copy and paste this unit and then included it in your projects uses clause

uses
Windows, Forms, ..., LyFind;

unit LyFind;

interface

uses
  Classes;

type
  TFindWebThread = class(TThread)
  protected
    strAddr, strStatus: string;
    procedure Execute; override;
    procedure AddToList;
    procedure ShowStatus;
  public

    strUrl: string;
  end;

implementation

{ TFindWebThread }

uses
  WinInet, WebMainFrm, SysUtils;

procedure TFindWebThread.AddToList;
begin
  Form1.SearchMemo.Items.Add (strAddr);//this adds the found url to a memo called searchmemo on form1
end;

procedure TFindWebThread.Execute;
var
  hHttpSession, hReqUrl: HInternet;
  Buffer: array [0..1023] of Char;
  nRead: Cardinal;
  strRead: string;
  nBegin, nEnd: Integer;
begin
  strRead := '';
  hHttpSession := InternetOpen ('FindWeb',
    INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  try
    hReqUrl := InternetOpenURL (hHttpSession, PChar(StrUrl),
      nil, 0,0,0);
    strStatus := 'Connected to ' + StrUrl;
    Synchronize (ShowStatus);
    try
      // read all the data
      repeat
        InternetReadFile (hReqUrl, @Buffer,
          sizeof (Buffer), nRead);
        strRead := strRead + string (Buffer);
        strStatus := 'Retrieved ' + IntToStr (Length (strRead)) +
          ' of ' + StrUrl;
        Synchronize (ShowStatus);
      until nRead = 0;
    finally
      InternetCloseHandle (hReqUrl);
    end;
  finally
    InternetCloseHandle (hHttpSession);
  end;
  // extract the HTTP headers
  strStatus := 'Extracting headers from ' + StrUrl;
  Synchronize (ShowStatus);
  strRead := LowerCase (strRead);
  repeat
    // find the initial part HTTP reference
    nBegin := Pos ('href="http', strRead);
    if nBegin <> 0 then
    begin
      // get the remaining part of the string
      strRead := Copy (strRead, nBegin + 6,
        Length (strRead) - nBegin - 6);
      // find the end of the HTTP reference
      nEnd := Pos ('>', strRead);
      strAddr := Copy (strRead, 0, nEnd - 2);
      // add the URL if 'lyrics' is not in it
      if (strAddr <> '') and (Pos ('lyrics', strAddr) = 0) then
        Synchronize (AddToList);
    end;
  until nBegin = 0;
  strStatus := 'Done with ' + StrUrl;
  Synchronize (ShowStatus);
end;

procedure TFindWebThread.ShowStatus;
begin
  Form1.StatusBar1.SimpleText := strStatus; //this is to keep you updated on the form1 statusbar
end;

end.

then on a button click on the form you useing to search add this

procedure TForm1.SerButClick(Sender: TObject);
var
  FindThread: TFindWebThread;
begin
    FindThread := TFindWebThread.Create (True);
    FindThread.FreeOnTerminate := True;
    FindThread.strUrl :=
    'http://search.lyrics.ch/query/normal?' +
    ArtistEdit.Text + AlbumEdit.Text + SongEdit.Text';
    FindThread.Resume;
end;

remember that the unit I gave you must be in this forms uses clause

uses
Windows, Forms, ..., LyFind;

if you have problems don't reject the answer, let me know and I will mail you a working example...also this was written in delphi 4 and not tested on delphi 3 yet but I will test it for on D3...

Later
BoRiS
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
cando

I tested it and it works fine but here is the new button click procedure on the mainform

procedure TForm1.Button1Click(Sender: TObject);
var
FindThread: TFindWebThread;
begin
    FindThread := TFindWebThread.Create (True);
    FindThread.FreeOnTerminate := True;
    FindThread.strUrl :=
    'http://search.lyrics.ch/query/normal?' + 'artist=' +
    ArtistEdit.Text + '&album=' + AlbumEdit.Text + '&song=' + SongEdit.Text;
    FindThread.Resume;
end;

also you may need to check the edit for spaces and replace them with + signs

Later
BoRiS
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:cando
Comment Utility
I seem to be having trouble with the piece that recieves the data, there are variable problems. If you would send me a working example, that would be great.

cando
cando@ix.netcom.com
0
 

Author Comment

by:cando
Comment Utility
I seem to be having trouble with the piece that recieves the data, there are variable problems. If you would send me a working example, that would be great.

cando
cando@ix.netcom.com
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
cando

I have mailed it to you....

Later
BoRiS
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now