Page 1 of 1

[REQ] URL selection in SCRIPTS - howto...

Posted: 2005-02-08 11:59:40
by ABNormal
i'm preparing a little script (for importing audio-cd infos from Gracenote's CDDB).
I have a prob (i'm learning from already-written scripts)
Script works if a tree is shown for selection (i choose the right album and it imports all infos),.
As lots of websites, cddb directly goes to the final page if there is a unique choice (example: CURE - DISINTEGRATION shows 4 CDs and my script works, DIRE STRAITS - PLATINIUM website directly goes to this album's infos).
With this solution, it's clear that i have not written "maybe you're in the right page, analyze data without lookin' for other links).
now i show you my AnalyzeSearchPage script, and i hope u can teach me how to write it.
Ah... maybe should be important to know that search pages links are always www.gracenote.com/music/... the final pages are www.gracenote.com/xm/... so a URLBASE+ music means a picktree page, URLBASE+ xm is a database page.

my actual code (thx PIVELLO for original structure that i'm rebuiding) is:

Code: Select all

procedure AnalyzeSearchPage(Url: string);
var
  FilmId: string;
begin
  PageStr := RemoveExtraChars(Url);
  if pos('We were unable', PageStr) > 0 then
    ShowMessage('Title not found / Nessun film trovato.')
  else if pos('Si è verificato un errore',PageStr) > 0 then
    ShowMessage('Server not available, try later / Server non disponibile, prova più tardi')
  else
   begin
    if MovieUrl = UrlBase + '/music' then
     MovieUrl := PopulatePickTree(true)  
    else
     begin
      PopulatePickTree(false);           
      if not PickTreeExec(MovieUrl) then 
       exit;
     end
    AnalyzeMoviePage;
   end;
end;
i'ld appreciate a little help
thx
ABN

Posted: 2005-02-08 13:03:31
by antp
You have to see if the contents of the page is a list result or a page containing directly the info. You cannot do the test on the URL for that since you only know the URL that you sent to the site, not the real page URL.

Posted: 2005-02-08 16:32:37
by ABNormal
ok let's imagine 3 only cases, readin text page:
1) "not found" in page text (0 titles)-> give error message & exit
2) "titles found" in page (2 or more titles)-> do a tree list, choose link and analyse
3) (else) "Original Title" (well, 'Track Title" in CDDB) in page (1 found and already into destination page)-> directly analyze this page.

how have i to translate this into a script selection?


thx
ABN

Posted: 2005-02-08 18:43:56
by antp
depends of how AnalyzeMoviePage works.
I guess it reads the contents of PageStr.

Code: Select all

if pos('We were unable', PageStr) > 0 then
    ShowMessage('Title not found / Nessun film trovato.')
  else if pos('Si è verificato un errore',PageStr) > 0 then
    ShowMessage('Server not available, try later / Server non disponibile, prova più tardi')
  else if pos('Track Title', PageStr) > 0 then
    AnalyzeMoviePage
  else
    begin
     [...etc...] here we use the treeview