//SCRIPT INFO================================================================================================== BlockOpen (* SCRIPT INFO: Following until 'SCRIPT BEGINS HERE...' is documentation. Please see 'USER OPTIONS' in the body of the script. --------------------------------------------- SCRIPT: Imdb Movie(soundtrack) Script AUTHOR: Ivek23 VERSION: 0.1.1.2 DATE: 01/02/2016 NEW_VERSION: 0.1.2.3 UPDATE: 14/12/2021 --------------------------------------------- *) // //BlockOpen //BlockClose //SCRIPT INFO================================================================================================== BlockClose //SCRIPT BEGINS HERE... //SCRIPT CONSTANTS============================================================================================= BlockOpen //Some useful constants Const pauseBeforeLoad = 0; // Pause before loading (in millisecond) //Script types stMovies = 0; stPeople = 1; stPoster = 2; //Script modes smSearch = 0; smNormal = 1; smCast = 2; smReview = 3; smCredits = 4; smBusiness = 5; smSoundtracks = 6; smGenreindex = 7; smAwards = 8; smReleases = 9; smMiscellaneous = 10; smPoster = 11; smFinished = 12; //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; //pfPID = 0; pfName = 1; pfTransName = 2; pfAltNames = 3; pfBirthday = 4; pfBirthplace = 5; pfGenre = 6; pfBio = 7; pfDeathDate = 8; pfRating = 9; pfDateAdded = 10; pfModDate = 11; pfComment = 12; pfBookmark = 13; pfVisible = 14; pfGenres = 15; pfAge = 16; pfFilmography = 17; pfCareer = 18; pfAwards = 19; pfPhoto = 20; pfImageList = 21; //Credits types ctActors = 0; ctDirectors = 1; ctWriters = 2; ctComposers = 3; ctProducers = 4; //Image types itPoster = 0; itScreenShot = 1; itFrontCover = 2; itDiscImage = 3; itPhoto = 4; //Script data //SCRIPT_VERSION_OLD = '0.1.1.3'; SCRIPT_VERSION = '0.1.2.3'; SCRIPT_NAME = 'Imdb Movie Script(soundtrack)'; SCRIPT_DESC = '[EN] Get Movie Information from Imdb.com(soundtrack)'; SCRIPT_LANG = $09; //English SCRIPT_TYPE = stMovies; BASE_URL = 'http://www.imdb.com'; BASE_URL_MOVIE = 'http://www.imdb.com/title/'; BASE_URL_PERSON = 'http://www.imdb.com/name/'; BASE_URL_SUF = '/'; RATING_NAME = 'Imdb Movie Script'; SEARCH_STR = 'http://www.imdb.com/find?q=%s&s=tt'; //SEARCH_STR = 'http://www.imdb.com/find?s=tt&q=%s'; //CODE_PAGE = 28591; //Use 0 for Autodetect CODE_PAGE = 65001; //Use 0 for Autodetect //BlockOpen (* //28591=ISO 8859-1 Latin 1; Western European (ISO). Use: 65001=Unicode (UTF-8) | 0=for Autodetect *) //BlockClose //Image Options //MAX_IMAGE_HEIGTH = 750; //Heigth limit of the stored posters. MAX_IMAGE_HEIGTH = 500; //Heigth limit of the stored posters. MAX_SEARCHLIST_HEIGTH = 200; //Heigth limit of the search list posters. //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 //SCRIPT CONSTANTS============================================================================================= BlockClose //SCRIPT GLOBAL VARIABLES=======================================================================================BlockOpen //Global variables Var ELI:Integer; MovieID,fullinfo:String; Mode:Byte; ExtraLinks : array [smCast..smPoster] of String; //SCRIPT GLOBAL VARIABLES=======================================================================================BlockClose //OBLIGATORY CALLBACK FUNCTIONS=================================================================================BlockOpen //Functions function GetScriptVersion:String; //BlockOpen Begin Result:=SCRIPT_VERSION; End; //BlockClose function GetScriptName:String; //BlockOpen Begin Result:=SCRIPT_NAME; End; //BlockClose function GetScriptDesc:String; //BlockOpen Begin Result:=SCRIPT_DESC; End; //BlockClose function GetRatingName:String; //BlockOpen Begin Result:=RATING_NAME; End; //BlockClose function GetScriptLang:Cardinal; //BlockOpen Begin Result:=SCRIPT_LANG; End; //BlockClose function GetCodePage:Cardinal; //BlockOpen Begin Result:=CODE_PAGE; End; //BlockClose //OBLIGATORY CALLBACK FUNCTIONS=================================================================================BlockClose //USER FUNCTIONS AND PROCEDURES=================================================================================BlockOpen function GetBaseURL:AnsiString; //BlockOpen Begin Result:=BASE_URL; End; //BlockClose function GetDownloadURL:AnsiString; //BlockOpen Begin LogMessage('Function GetDownloadURL BEGIN ====================== |'); LogMessage('Global Var-Mode |'+IntToStr(Mode)+' |'); If (Mode=smSearch) Then Result:=SEARCH_STR Else Result:=ExtraLinks[Mode]; LogMessage('Global Var-Result '+Result); LogMessage('Function GetDownloadURL END ====================== |'); End; //BlockClose function GetDownloadMethod:Byte; //BlockOpen Begin LogMessage(' Function GetDownloadMethod BEGIN ====================== |'); LogMessage(' Global Var-Mode 1 | '+IntToStr(Mode)+' |'); Result := dmGET; LogMessage(' Function GetDownloadMethod END ====================== |'); End; //BlockClose function GetPrefixMode:Byte; //BlockOpen Begin Result:=pmBegin; End; //BlockClose function GetScriptType:Byte; //BlockOpen Begin Result:=SCRIPT_TYPE; End; //BlockClose function GetCurrentMode:Byte; //BlockOpen Begin Result:=Mode; End; //BlockClose function HTMLValue(HTML:String;StartPos,EndPos:Integer;StartValue,EndValue:String):String; //BlockOpen Var ValueStart,ValueEnd:Integer; Begin ValueStart := PosFrom(StartValue, HTML, StartPos); If (ValueStart>0) and ((ValueStart0) and ((ValueStartMainPage '; Fullinfo:=Fullinfo+'Reference '; Fullinfo:=Fullinfo+'Cast&Crew '; Fullinfo:=Fullinfo+'Awards '; Fullinfo:=Fullinfo+'ReleaseDates '; Fullinfo:=Fullinfo+'TechSpecs '; Fullinfo:=Fullinfo+'ParentsGuide '; Fullinfo:=Fullinfo+'PlotKeywords '; Fullinfo:=Fullinfo+'PlotSummary '; Fullinfo:=Fullinfo+'FilmLocations '; Fullinfo:=Fullinfo+'Taglines '; Fullinfo:=Fullinfo+'CompanyCredits '; Fullinfo:=Fullinfo+'Connections '; Fullinfo:=Fullinfo+'Soundtracks '; Fullinfo:=Fullinfo+'MiscSites '; Fullinfo:=Fullinfo+'MiscPhoto '; Fullinfo:=Fullinfo+'PhotoGallery '; Fullinfo:=Fullinfo+'IMDb Top 250 '; Fullinfo:=Fullinfo+'Lowest Rated '; If Fullinfo <> '' then IMDB_URL:=Fullinfo; If IMDB_URL <> '' then AddCustomFieldValueByName('IMDb Movie Url',IMDB_URL); If IMDB_URL <> '' then AddCustomFieldValueByName('MoviesUrl',IMDB_URL); ////If IMDB_URL <> '' then LogMessage(' Get result Fullinfo-IMDB_URL (CF~IMDb Movie Url~ ):'+#13+IMDB_URL+'||'); LogMessage('**IMDB Movie END =====================||'); //Get ~Soundtracks URL~ ExtraLinks[smSoundtracks]:=MovieURL+'soundtrack'; If ExtraLinks[smSoundtracks] <> '' then LogMessage(' Get result Soundtracks URL: '+ExtraLinks[smSoundtracks]); //~Soundtracks~ If Pos('Soundtracks',HTML) >0 Then Begin //EndPos:=Pos('

Soundtracks

',HTML); curPos:=PosFrom('" class="soundTrack soda odd">',HTML,EndPos); //If curPos>0 Then Begin If 0'); EndPos:=PosFrom('
',HTML,curPos); //ItemValue:=Copy(HTML,curPos,endPos-curPos); ItemValue:=Trim(Copy(HTML,curPos,endPos-curPos)); ItemValue:=StringReplace(ItemValue,'',+'">',True,False,True); ItemValue:=StringReplace(ItemValue,'','',True,False,True); ItemValue:=StringReplace(ItemValue,'
','
',True,False,True); ItemValue:=StringReplace(ItemValue,'soundTrack soda odd">',#160#8226#160,True,False,True); ItemValue:=StringReplace(ItemValue,'soundTrack soda even">',#160#8226#160,True,False,True); ItemValue:=StringReplace(ItemValue,'','',True,False,True); ItemValue:=RemoveTagsEx1(ItemValue); If ItemValue <> '' then ItemValue:=#160#160#9679#160#160+'Soundtrack Credits'+#160#160#9679#13+#160#8226#160+ItemValue; //ItemValue:='Plot Summary '+ItemValue; If ItemValue <> '' then AddCustomFieldValueByName('Soundtrack Credits',ItemValue); If ItemValue <> '' then AddCustomFieldValueByName('Imdb Soundtracks',ItemValue); End; End; LogMessage(' ParseMovie END** ====================== |'); LogMessage(' Parse Results for ParseMovie END* ====================== |'); End; //BlockClose procedure ParseSearchResults(HTML:String); //BlockOpen Var curPos,endPos,index:Integer; Title,URL:String; //Preview:String; ItemStart,ItemEnd:Integer; Rid1:String; Begin curPos:=Pos('',HTML); If curPos < 1 Then Exit; LogMessage('Parsing search results...'); LogMessage('Global Var-Mode 0 | '+IntToStr(Mode)+' |'); LogMessage('Parse Results for Search Results BEGIN ====================== |'); LogMessage(' Parsing search results...'); LogMessage(' Search Result START * *'+#13#10); curPos:=Pos('"> ',HTML,curPos); Title:=RemoveTags(Copy(HTML,curPos,endPos-curPos),false); //Title:=RemoveTags(Trim(Copy(HTML,curPos,endPos-curPos)),false); //Title:=StringReplace(Title,') - ',') '+#13,true,false,true); //Title:=StringReplace(Title,' - ','
',true,false,true); //LogMessage(' Get result Title:'+Title+'||'); AddSearchResult(Title,'','',URL,''); //AddSearchResult(Title,'','',URL,Preview); //LogMessage(' Get results AddSearchResult:#'+IntToStr(index)+'|'+Title+'|'+URL+' ||'); //LogMessage(' Get results AddSearchResult:#'+IntToStr(index)+'|'+Title+'|'+URL+' | '+Preview+' ||'); curPos :=PosFrom('">
',HTML,curPos)+3; endPos:=PosFrom('
',HTML); if ItemStart>0 then begin ItemEnd:=PosFrom('',HTML,ItemStart); Rid1:=HTMLValue(HTML,ItemStart,ItemEnd,'">',''); //Rid1:=HTMLValue(HTML,ItemStart,ItemEnd,'">',' '); LogMessage(' Rid1: '+Rid1+#13); end; //*) AddSearchResult('','','','',''); AddSearchResult('',' "Search Results" on Imdb.com ','','',''); AddSearchResult(' '+Rid1,'','','',''); AddSearchResult(' ====== ','','','',''); LogMessage(' Search Result END * *'+#13#10); LogMessage('Parse Results for Search Results END ====================== |'); End; //BlockClose function NextMode(curMode:Integer):Integer; //BlockOpen Var I:Integer; Begin Result:=smFinished; if curMode < Low(ExtraLinks) - 1 then curMode:=Low(ExtraLinks) - 1; for I:=curMode + 1 to High(ExtraLinks) do if ExtraLinks[I] <> '' then begin Result:=I; Break; End; End; //BlockClose //USER FUNCTIONS AND PROCEDURES==================================================================================BlockClose //OBLIGATORY CALLBACK PRINCIPAL FUNCTION=========================================================================BlockOpen function ParsePage(HTML:String;URL:AnsiString):Cardinal; //BlockOpen Begin LogMessage('Function ParsePage BEGIN ====================== |'); LogMessage('Global Var-Mode | '+IntToStr(Mode)+' |'); Wait (pauseBeforeLoad); HTML:=HTMLToText(HTML); //HTML:=StringReplace(HTML,'http://imdb.com','http://www.imdb.com',True,True,False); HTML:=StringReplace(HTML,'imdb.com','www.imdb.com',True,True,False); LogMessage(' Parsing search Movie search results'); //(* If (0 0 Then Begin ParseSearchResults(HTML); LogMessage(' Parse Results for Search Results'); Result := prList; LogMessage(' -------- ParsePage complete Result ( '+IntToStr(Result)+' )'); //LogMessage('Function ParsePage smSearch-prList END ====================== | '); LogMessage('Function ParsePage smSearchList END ====================== |'); Exit; End Else ParseMovie(URL,HTML); LogMessage(' Parse Results for ParseMovie:|'+URL+' |'); LogMessage('Function ParsePage NORMAL END ====================== |'); LogMessage(' ** Provider data info retreived Ok in '+DateToStr(CurrentDateTime)+' '+TimeToStr(CurrentDateTime)+' (~Updated~)'); Mode:=NextMode(Mode); if Mode <> smFinished then Result:=prDownload Else Result:=prFinished; LogMessage(' * Function ParsePage NORMAL END ====================== |'); LogMessage(' -------- ParsePage completed with Result ('+IntToStr(Result)+')'); LogMessage(' Function ParsePage END ====================== |'); End; Begin Mode:=smSearch; for ELI:=Low(ExtraLinks) to High(ExtraLinks) do ExtraLinks[ELI] := ''; End. //BlockClose //OBLIGATORY CALLBACK PRINCIPAL FUNCTION=========================================================================BlockClose { History of changes to the script for downloading movies from IMDb.com BASE_URL = 'http://www.imdb.com'; BASE_URL_PERSON = 'http://www.imdb.com/name/'; BASE_URL_SUF = '/'; BASE_URL_PRE = 'http://www.imdb.com/'; BASE_URL_PRE_TRUE = 'https://www.imdb.com/'; WEB_URL = 'http://web.archive.org'; WEB_URL_PRE = 'http://web.archive.org/web/'; --------------------------------------------- SCRIPT: Imdb Movie(soundtrack) Script AUTHOR: Ivek23 VERSION: 0.1.1.2 DATE: 01/02/2016 NEW_VERSION: 0.1.1.3 UPDATE: 19/01/2019 NEW_VERSION: 0.1.2.3 UPDATE: 14/12/2021 --------------------------------------------- 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) }