Enhanced DVD Empire Script for DVD cataloguers

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
KaraGarga
Posts: 50
Joined: 2004-04-03 03:33:22
Location: Turkey
Contact:

Enhanced DVD Empire Script for DVD cataloguers

Post by KaraGarga »

Hi! I'm newbie in scripting :)

I examine dmitry501's DVD Empire script and made some enhancement on it. (Thanks dmitry501 for writing it)

This script parses nearly all info about DVD. It is especially for DVD cataloguers :D

It cannot be fully tested, but seems working well...

Image

FULL SIZE

DVD Empire Script Features:

Imports:
  • cast
  • director
  • producer
  • studio
  • lenght
  • synopsis
  • edition type
  • movie year
  • DVD release year
  • DVD features
  • first two audio lang and info
  • video info
  • chapter number
  • upc code
  • subtitles
  • region number
  • customer rating


I suggest editing default language file Main Window features like

Code: Select all

;***************
;* Main window *
;***************
[MainWindow]

;Movie infos
MainWindow.FrmMovie.LMedia.Caption=Location:
MainWindow.FrmMovie.LMediaType.Caption=DVD Type:
MainWindow.FrmMovie.LSource.Caption=Acquired from:
MainWindow.FrmMovie.LDate.Caption=Date Added:
MainWindow.FrmMovie.LBorrower.Caption=Loan Status:
MainWindow.FrmMovie.LRating.Caption=Rating:
MainWindow.FrmMovie.LOriginalTitle.Caption=DVD Title:
MainWindow.FrmMovie.LTranslatedTitle.Caption=Translated Title:
MainWindow.FrmMovie.LDirector.Caption=Director:
MainWindow.FrmMovie.LProducer.Caption=Producer:
MainWindow.FrmMovie.LCountry.Caption=Studio:
MainWindow.FrmMovie.LCategory.Caption=Category:
MainWindow.FrmMovie.LYear.Caption=Movie Year:
MainWindow.FrmMovie.LLength.Caption=Length:
MainWindow.FrmMovie.LLengthMin.Caption=minutes
MainWindow.FrmMovie.LActors.Caption=Casting:
MainWindow.FrmMovie.LURL.Caption=URL:
MainWindow.FrmMovie.LDescription.Caption=SYNOPSIS:
MainWindow.FrmMovie.LComments.Caption=DVD FEATURES:
MainWindow.FrmMovie.LVideoFormat.Caption=Audio 1:
MainWindow.FrmMovie.LVideoKbps.Caption=chp.s
MainWindow.FrmMovie.LAudioFormat.Caption=Audio 2:
MainWindow.FrmMovie.LAudioKbps.Caption=st RG
MainWindow.FrmMovie.LResolution.Caption=UPC Code:
MainWindow.FrmMovie.LFramerate.Caption=Edition Type:
MainWindow.FrmMovie.LFramerateFPS.Caption=
MainWindow.FrmMovie.LSize.Caption=Release Date:
MainWindow.FrmMovie.LSizeMB.Caption=(m:d:y)
MainWindow.FrmMovie.LDisks.Caption=DVDs
MainWindow.FrmMovie.LDisksFront.Caption=
MainWindow.FrmMovie.LLanguages.Caption=Video Type:
MainWindow.FrmMovie.LSubtitles.Caption=Subtitles:
and save this file another name with .LNG file extension and put Languages folder.


Script code:

Code: Select all

// GETINFO SCRIPTING
// www.dvdempire.com - by dmitry501
// edited and enhanced by KaraGarga
program From_dvdempire;
var
  MovieName: string;
  MovieName2: string;
// -------------------------------------------------------------------------------------------------------
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
  i: Integer;
begin
  result := -1;
  if StartAt < 0 then
    StartAt := 0;
  for i := StartAt to List.Count-1 do
    if Pos(Pattern, List.GetString(i)) <> 0 then
    begin
      result := i;
      Break;
    end;
end;
// -------------------------------------------------------------------------------------------------------
function GetLines(Page: TStringList; LineNr: Integer): String;
var Value, Line: String;
    StartPos, EndPos : Integer;
begin
  Value := '';
  Line := Page.GetString(LineNr);
  If Pos(' ',Line) > 0 Then Begin
    Value := StringReplace(Line, '•', '');
    HTMLDecode(Value);
    HTMLRemoveTags(Value);
    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);
      If Pos(' ',Line) > 0 Then Begin
        Value := Value + ',' + StringReplace(Line, '•', '');
        HTMLDecode(Value);
        HTMLRemoveTags(Value);
      end;
    until Pos(' ',Line) < 1
  end;
  result := Trim(Value);
end;
// -------------------------------------------------------------------------------------------------------
procedure GetInfo(Page: TStringList; ItemID: String);
var Line, Value, Value2, Value3 : String;
    LineNR, EndPos, StartPos : Integer;
begin
  // URL
  SetField(fieldURL,'http://www.dvdempire.com/Exec/v4_item.asp?item_id=' + ItemID);
  // Name
 LineNr := FindLine('<title>DVD Empire - Item - ', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('Item - ',Line)+7;
    Value := copy(Line, StartPos, pos('  /  ', Line) - StartPos);
    SetField(fieldOriginalTitle,Value);
  end;
    //Rating
  LineNr := FindLine('<b>Rating:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr+3);
    StartPos := Pos('(<b>',Line)+4;
    Value := copy(Line, StartPos, pos('</b>', Line) - StartPos);
    SetField(fieldRating,Value);
  end;
  // Year
  LineNr := FindLine('<b>Production Year:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('</b>',Line)+5;
    Value := Copy(Line, StartPos,4);
    SetField(fieldYear, Value);
  end;
// Movie Lenght
  LineNr := FindLine('<b>Length:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('</b>',Line)+4;
    Value := Copy(Line, StartPos,4);
    SetField(fieldLength, Value);
  end;
// Region Type
  LineNr := FindLine('<font color="#c02020">Region', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('</font></b>',Line)-30;
    Value := Copy(Line, StartPos,30);
    Value:=StringReplace(Value, 'Region', '');
    Value:=StringReplace(Value, ' ', '');
    HTMLDecode(Value);
    HTMLRemoveTags(Value);
    SetField(fieldAudioBitrate, Value);
  end;
// Edition Type
  LineNr := FindLine('<b>Production Year:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr+3);
    StartPos := Pos('<b>',Line)+3;
    Value := copy(Line, StartPos, pos(' / <font color=', Line) - StartPos);
    HTMLDecode(Value);
    HTMLRemoveTags(Value);
    SetField(fieldFramerate, Value);
  end;
 // DVD Release Year
  LineNr := FindLine('<b>Release Date:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('</b>',Line)+5;
    Value := copy(Line, StartPos, pos('<br>', Line) - StartPos);
    SetField(fieldSize, Value);
  end;
  // UPC Code
  LineNr := FindLine('<b>UPC Code:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('</b>',Line)+5;
    Value := copy(Line, StartPos, pos('<br>', Line) - StartPos);
    SetField(fieldResolution, Value);
  end;
  // Chapter Numbers
  LineNr := FindLine('<b>Chapters:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    StartPos := Pos('</b>',Line)+5;
    Value := copy(Line, StartPos, pos('<br>', Line) - StartPos);
    SetField(fieldVideoBitrate, Value);
  end;
  // DVD Release Studio
  LineNr := FindLine('<b>Studio:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 1);
    Value:=StringReplace(Value, '									', '');
    SetField(fieldCountry, Value);
  end;
  // Video Type
  LineNr := FindLine('<b>Video:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := GetLines(Page, LineNr+6);
    SetField(fieldComments, Value);
  end;
  // Director
  LineNr := FindLine('<b>Directors:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := GetLines(Page, LineNr+1);
    Value:=StringReplace(Value, '• ', '');
    SetField(fieldDirector, Value);
  end;
  // Producer
  LineNr := FindLine('<b>Producers:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := GetLines(Page, LineNr+1);
    Value:=StringReplace(Value, '• ', '');
    SetField(fieldProducer, Value);
  end;
  // Actors
  LineNr := FindLine('<b>Actors:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := GetLines(Page, LineNr+1);
    Value:=StringReplace(Value, '• ', '');
    SetField(fieldActors, Value);
  end;
   // Description
  LineNr := FindLine('<b> Synopsis</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 16)+Page.GetString(LineNr + 17)+Page.GetString(LineNr + 18);
    Value:=StringReplace(Value, '>i<', '> <');
    HTMLDecode(Value);
    HTMLRemoveTags(Value);
    SetField(fieldDescription,Value);
  end;
// Product Information
  LineNr := FindLine('<b>Features:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 8)+Page.GetString(LineNr + 9)+Page.GetString(LineNr + 10)+Page.GetString(LineNr + 11)+Page.GetString(LineNr + 12)+Page.GetString(LineNr + 13)+Page.GetString(LineNr + 14)+Page.GetString(LineNr + 15)+Page.GetString(LineNr + 16)+Page.GetString(LineNr + 17)+Page.GetString(LineNr + 18)+Page.GetString(LineNr + 19);
    Value:=StringReplace(Value, '									', '');
    Value:=StringReplace(Value, '  ', '');
    Value:=StringReplace(Value, '<br>', #13#10);
    Value:=StringReplace(Value, 'Video:', '');
    HTMLDecode(Value);
    HTMLRemoveTags(Value);
    SetField(fieldComments, '* * * * * *  DVD FEATURES  * * * * * *'+#13#10+#13#10+Value);
  end;
// Video Information
  LineNr := FindLine('<b>Video:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 7);
    SetField(fieldLanguages, Value);
  end;
// Audio Information
  LineNr := FindLine('<b>Audio:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 7);
    Value:=StringReplace(Value, '<br>', '');
    SetField(fieldVideoFormat, Value);
  end;
// Language Information
  LineNr := FindLine('<b>Audio:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 8);
    Value:=StringReplace(Value, '<br>', '');
    SetField(fieldAudioFormat, Value);
  end;
// Subtitle Information
  LineNr := FindLine('<b>Subtitles:</b>', Page, 0);
  if LineNr > -1 then
  begin
    Value := Page.GetString(LineNr + 7);
    SetField(fieldSubtitles, Value);
  end;
// Picture
  Line := 'http://images.dvdempire.com/gen/movies/' + ItemID + 'h.jpg';
  GetPicture(Line, False);
end;
// -------------------------------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr, StartPos, EndPos, L: Integer;
  Line: string;
  ItemID, MovieAddress, MovieTitle : string;
begin
  PickTreeClear;
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  LineNr := FindLine('<title>DVD Empire - Item -', Page, 0);
  if LineNr >-1 then begin
    LineNr := FindLine('item_id', Page, 0);
    Line := Trim(Page.GetString(LineNr));
    StartPos := pos('item_id=', Line) + 8;
    ItemID := copy(Line, StartPos, pos('&tab=', Line) - StartPos);
    GetInfo(Page,ItemID);
  end else begin
    LineNr := FindLine('Matches Found<br>', Page, 0);
    if LineNr >-1 then begin
      Line := Page.GetString(LineNr);
      StartPos := pos('<b>', Line) + 3;
      L := StrToInt('0'+ Copy(Line, StartPos, pos('</b>', Line) - StartPos),1);
      PickTreeAdd(IntToStr(L)+' Matches found', '');
      If L>0 Then begin
        // Find Films
          LineNr := FindLine('searchID=', Page, LineNr);
          LineNr := LineNr + 1;
        repeat
          LineNr := FindLine('searchID=', Page, LineNr);
          if LineNr >-1 then begin
            Line := Trim(Page.GetString(LineNr));
            LineNr := LineNr + 1;
            If pos('<img src="', Line) <1 Then Begin
              StartPos := pos('item_id=', Line) + 8;
              ItemID := copy(Line, StartPos, pos('">', Line) - StartPos);
              MovieAddress := 'http://www.dvdempire.com/Exec/v4_item.asp?item_id=' + ItemID;
              StartPos := pos('">', Line) + 2;
              MovieTitle := copy(Line, StartPos, 500);
              HTMLDecode(Movietitle);
              HTMLRemoveTags(MovieTitle);
              PickTreeAdd(MovieTitle, MovieAddress);
            end;
          end;
        until (LineNr <1 );
      end;
    end;
    Page.Free;
    if PickTreeExec(Address) then
     begin
      Page := TStringList.Create;
      Page.Text := GetPage(Address);
      ItemID :=copy(Address, 51, 8);
      GetInfo(Page,ItemID);
    end;
  end;
  DisplayResults;
end;
// -------------------------------------------------------------------------------------------------------
// Begin program
begin
  PickListClear;
  MovieName := GetField(fieldOriginalTitle);
  if MovieName = '' then MovieName := GetField(fieldTranslatedTitle);
  if Input('Import from www.dvdempire.com', 'Enter the title of the movie:', MovieName) then begin
      MovieName2:=MovieName;
      MovieName:=StringReplace(MovieName, '’', Chr(39));
      MovieName:=AnsiLowerCase(MovieName);
      MovieName:=AnsiUpFirstLetter(MovieName);
      if pos('The ', MovieName)=1 then MovieName:=StringReplace(MovieName, 'The ', '');
      AnalyzePage('http://www.dvdempire.com/Exec/v5_search_item.asp?string='+UrlEncode(MovieName));
  end
end.
Thanks antp for this amazing and flexiple program :grinking:
Last edited by KaraGarga on 2004-09-21 12:46:33, edited 1 time in total.
shagasaur
Posts: 2
Joined: 2004-09-16 14:59:44

DVD Empire Script Enhancement

Post by shagasaur »

The only thing that this script does not do is to update the "Original Title" from the information at dvdempire.com. This would be a great enhancement for me. Is this possible?? I've checked the script over, and being a novice at script writing, I did not understand any of it! :(

Thanks
KaraGarga
Posts: 50
Joined: 2004-04-03 03:33:22
Location: Turkey
Contact:

Post by KaraGarga »

As a newbie I forgot to include Original Title :hihi:

I updated the script above. Please try this one :)
shagasaur
Posts: 2
Joined: 2004-09-16 14:59:44

Post by shagasaur »

:grinking: Very Cool! Thanks!
Post Reply