(*
SCRIPT INFO:
Following until 'SCRIPT BEGINS HERE...' is documentation.
Please see 'USER OPTIONS' in the body of the script.
---------------------------------------------
SCRIPT: Imdb People(genre) Script
AUTHOR: Ivek23
VERSION: 0.1.2.6
DATE: 17/08/2014
---------------------------------------------
TYPES AND FUNCTIONS
Additional types and functions that can be used in scripts:
Types
TWIDEARRAY : array of String
Field functions
procedure AddSearchResult(Title1, Title2, Year, URL, PreviewURL : String)
procedure AddFieldValue(AField: Integer; AValue : String)
procedure AddMoviePerson(Name, TransName, Role, URL : String; AType : Byte)
procedure AddPersonMovie(Title, OrigTitle, Role, Year, URL : String; AType : Byte)
procedure AddAward(Event, Award, Category, Recipient, Year: String; const Won : Boolean)
procedure AddAwardEx(Event, Award, Category, RecipientVal1, RecipientVal2, Year : String; const Won : Boolean);
procedure AddConnection(Title, OrigTitle, Category, URL, Year: String)
procedure AddEpisode(Title, OrigTitle, Description, URL, Year, Season, Episode : String)
String functions
function Pos(Substr : String; Str: String): Integer
function PosFrom(const SubStr, Str : String; FromIndex : Integer) : Integer
function LastPos(const SubStr, Str : String) : Integer
function PrevPos(const SubStr, Str : String; APos : Integer) : Integer
function RemoveTags(AText : String; doLineBreaks : Boolean) : String
function ExplodeString(AText : String; var Items : TWideArray; Delimiters : String) : Integer
function Copy(S: String; Index, Count: Integer): String
procedure Delete(var S: String; Index, Count: Integer)
procedure Insert(Source: String; var Dest: String; Index: Integer)
function Length(S: String): Integer
function Trim(S: String): String
function CompareText(S1, S2: String): Integer
function CompareStr(S1, S2: String): Integer
function UpperCase(S: String): String
function LowerCase(S: String): String
function AnsiString(S, OldPattern, NewPattern: String; All : Boolean; IgnoreCase : Boolean; WholeWord: Boolean): String
function StrToInt(const S: String): Integer
function IntToStr(const Value: Integer): String
function StrToFloat(const S: String): Extended
function FloatToStr(const Value: Extended): String
function CurrentDateTime : Extended
function DateToStr(Value : Extended) : String
function TimeToStr(Value : Extended) : String
function HTMLValues(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function HTMLValues2(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function TextBetween(const HTML : String; ABegin, AEnd : String; doLineBreaks : Boolean; var Pos : Integer) : String
function HTMLToText(const HTML : String) : String
procedure ShowMessage(const Msg, Head : String)
*)
//SCRIPT BEGINS HERE...
//Some useful constants
const
//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;
///Script modes
smSearch = 0;
smNormal = 1;
smBiography = 2;
smGenreindex = 3;
smAwards = 4;
smFilmography = 5;
smMiscellaneous = 6;
smPoster = 7;
smFinished = 8;
//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;
//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;
//Download methods
dmGET = 0;
dmPOST = 1;
//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;
//People fields
pfURL = 0;
pfName = 1;
pfTransName = 2;
pfAltNames = 3;
pfBirthday = 4;
pfBirthplace = 5;
pfGenre = 6;
pfBio = 7;
pfDeathDate = 8;
pfComment = 9;
pfBookmark = 10;
pfPid = 11;
pfCareer = 12;
//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;
//Script data
SCRIPT_VERSION = '0.1.2.6';
SCRIPT_NAME = 'Imdb People(genre) Script1';
SCRIPT_DESC = '[EN] Get People(genre) Information from Imdb.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stPeople;
BASE_URL = 'http://www.imdb.com';
RATING_NAME = 'Imdb People(genre) Script';
// SEARCH_STR = 'http://www.imdb.com/find?q=%s&s=nm&exact=true';
SEARCH_STR = 'http://www.imdb.com/find?q=%s&s=nm';
// SEARCH_STR = 'http://www.imdb.com/find?s=nm&q=%s';
CODE_PAGE = 65001; //Use 0 for Autodetect
//User Options
GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
GET_POSTER = False; //Set to False or True
//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smBiography..smPoster] of String;
//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;
function GetScriptName : String;
begin
Result := SCRIPT_NAME;
end;
function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;
function GetRatingName : String;
begin
Result := RATING_NAME;
end;
function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;
function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;
function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;
function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;
function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;
function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;
function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;
function GetCurrentMode : Byte;
begin
Result := Mode;
end;
function RemoveTagsEx(AText : String) : String;
var
B, E : Integer;
begin
Result := AText;
B := PosFrom('<', Result, 1);
E := PosFrom('>', Result, B);
while (B > 0) AND (B < E) do begin
Delete(Result, B, E - B + 1);
B := Pos('<', Result);
E := Pos('>', Result);
end;
end;
procedure ParsePeople(PeopleURL : String; HTML : String);
var
curPos, endPos : Integer;
URL, TmpStr, TmpStr0, TmpStr1 : String;
begin
//Get ~Awards URL~
endPos := Pos('class="link" >Awards', HTML);
if endPos > 0 then begin
curPos := PrevPos('Awards', HTML);
if endPos > 0 then begin
curPos := PrevPos('by Genre', HTML);
if endPos > 0 then begin
curPos := PrevPos('by Genre', HTML);
if endPos > 0 then begin
curPos := PrevPos('', HTML, EndPos);
curPos := PosFrom('Alternate Names:
', HTML, EndPos);
EndPos := PosFrom('', HTML, curPos);
TmpStr := TextBetween(HTML, 'Alternate Names:
', '', True, curPos);
TmpStr := StringReplace(TmpStr, ' | ', #13, true, false, true);
if Pos(', ', TmpStr) = 1 then Delete(TmpStr, 1, 2);
AddFieldValue(pfAltNames, TmpStr);
//Most Popular Titles Page
//~Genres~
If Pos('Genres', HTML) > 0 then begin
curPos := Pos('Genres', HTML);
EndPos := curPos;
TmpStr1:= HTMLValues2(HTML,
'