home *** CD-ROM | disk | FTP | other *** search
- {http://www.discogs.com}
-
- {?
- ARTIST=FORM;TYPE=artists:str|Q=%:str|btn=#:click
- /?}
-
- // demonstration of some automation
- // auto saves pictures a folder.jpg and also uses the apply button.
- Program Discogs;
-
- var
- slMain: TStringList;
- iRow: integer;
-
- //---
- procedure GetImage( sLine: string );
- var
- iPos: integer;
- sTmp: string;
- begin
- iPos := Pos( '"http:', sLine );
- if iPos > 0 then begin
- sTmp := Copy( sLine, iPos + 1, 99999 );
- iPos := Pos( '.jpg"', sTmp );
- if iPos = 0 then iPos := Pos( '.gif"', sTmp ); // maybe gif file
- if iPos > 0 then begin
- sTmp := Copy( sTmp, 1, iPos + 3 );
- on_setPicture( sTmp );
- on_SavePicture( 1, false );
-
- end;
- end;
- end;
-
- //---
- procedure GetArtistAlbum( sLine: string );
- var
- iPos: integer;
- begin
- sLine := on_cleanHTMLLine( sLine );
- iPos := RPos( ' - ', sLine );
- if iPos > 0 then begin
- on_setArtist( Trim( Copy( sLine, 1, iPos - 1 ) ) );
- on_setAlbum( Copy( sLine, iPos + 3, 9999 ) );
- end;
- end;
-
- //------
- procedure GetTracks;
- var
- iUpToRow: integer;
- sTrack, sArtist, sTmp, sTitle, sTime: string;
- iPos: integer;
- begin
- iUpToRow := iRow + 1;
- if not on_FindRow( iUpToRow, 0, '<P>', slMain ) then exit; // find last row with track info
-
- iRow := iRow + 4;
- while iRow <= iUpToRow do begin
-
- sTrack := on_cleanHTMLLine( slMain.Strings[ iRow ] ); // track no
- iRow := iRow + 1;
- sArtist := on_cleanHTMLLine( slMain.Strings[ iRow ] ); // performer or empty
- iRow := iRow + 1;
- sTmp := on_cleanHTMLLine( slMain.Strings[ iRow ] ); // title and time
-
- iPos := RPos( ' (', sTmp );
- if (iPos > 0) and (Pos( ':', sTmp ) > 0) then begin
- sTitle := Trim( Copy( sTmp, 1, iPos - 1 ) );
- sTime := Trim( Copy( sTmp, iPos + 2, 9999 ) );
- sTime := Copy( sTime, 1, Length( sTime ) - 1);
- end else begin
- sTitle := sTmp;
- sTime := '';
- end;
-
- if sArtist <> '' then sTitle := sArtist + ' / ' + sTitle;
-
- on_addTrack( sTrack, sTitle, '', sTime );
-
- iRow := iRow + 2; // move on
- if Pos( 'Producer -', slMain.Strings[ iRow + 1 ] ) > 0 then begin // producer lines skip
- iRow := iRow + 3;
- end;
- if Pos( 'Mixed By -', slMain.Strings[ iRow + 1 ] ) > 0 then begin // mixed by lines skip
- iRow := iRow + 3;
- end;
- if Pos( 'Remix -', slMain.Strings[ iRow + 1 ] ) > 0 then begin // remix lines skip
- iRow := iRow + 3;
- end;
- if Pos( 'Featuring -', slMain.Strings[ iRow + 1 ] ) > 0 then begin // Featuring lines skip
- iRow := iRow + 3;
- end;
- if Pos( 'Vocals -', slMain.Strings[ iRow + 1 ] ) > 0 then begin // Vocals lines skip
- iRow := iRow + 3;
- end;
- if Pos( 'Vocals -', slMain.Strings[ iRow + 1 ] ) > 0 then begin // background Vocals lines skip
- iRow := iRow + 3;
- end;
-
- end;
-
- end;
-
- begin
-
- on_Init; // clear values
-
-
- slMain := TStringList.Create;
- try
-
- iRow := 0;
- on_loadHTML( slMain ); // load page to stringlist
-
- // artist - album
- if on_FindRow( iRow, 0, 'href="/artist/', slMain ) then GetArtistAlbum( slMain.Strings[ iRow ] );
-
- // image if any
- if on_FindRow( iRow, 0, '/viewimages', slMain ) or
- on_FindRow( iRow, 0, '.jpg"', slMain ) then GetImage( slMain.Strings[ iRow ] );
-
- // generic stuff
- if on_FindRow( iRow, 0, 'Label:</TD>', slMain ) then on_setLabel( on_cleanHTMLLine( slMain.Strings[ iRow + 1 ] ) );
- if on_FindRow( iRow, 0, 'Released:</TD>', slMain ) then on_setYear( on_cleanHTMLLine( slMain.Strings[ iRow + 1 ] ) );
- if on_FindRow( iRow, 0, 'Genre:</TD>', slMain ) then on_setGenre( on_cleanHTMLLine( slMain.Strings[ iRow + 1 ] ) );
- if on_FindRow( iRow, 0, 'Style:</TD>', slMain ) then on_setStyles( on_cleanHTMLLine( slMain.Strings[ iRow + 1 ] ) );
- if on_FindRow( iRow, 0, 'Notes:</TD>', slMain ) then on_setComment( on_cleanHTMLLine( slMain.Strings[ iRow + 1 ] ) );
-
- // tracks
- if on_FindRow( iRow, 0, '<P><B>Tracklisting:</B><BR>', slMain ) then GetTracks;
-
- on_Apply;
-
- finally
- slMain.Free;
- end;
-
- end.
-