?
Solved

lyrics search

Posted on 1999-01-10
6
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1355815
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 1500 total points
ID: 1355816
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
ID: 1355817
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:cando
ID: 1355818
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
ID: 1355819
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
ID: 1355820
cando

I have mailed it to you....

Later
BoRiS
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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