//SCRIPT INFO================================================================================================== BlockOpen (* Following until 'SCRIPT BEGINS HERE...' is documentation. Please see 'USER OPTIONS' in the body of the script. --------------------------------------------- SCRIPT: AllMovie.com_new HTTPS(Related) SOURCE: AllMovie.com_new CO-AUTHORS: Ivek23 VERSION: 1.1.4.0 DATE: 03/03/2021 UPDATE: 05/03/2021 NEW_VERSION: 1.1.4.0 UPDATE: 14/12/2021 --------------------------------------------- FIELD USE: Field names in comments are enclosed in "~" so they are easier to find in the script. Use with your editor's search function to find applicable code sections. AllMovie data: PVD field: FN: Type/Comments: -------------- --------- -- ------------- RelatedMovies ~RelatedMovies~ memo Related Movies ~Related Movies~ memo Footnotes: 1. Control the use of standard fields using the "Overwrite Fields" plugin preferences in the main program. 2. Where data is saved to a standard field, the script also saves the data to custom field. This allows a number of options: i) Use the data saved to the standard field (normally the default) and ignore the custom field. Data saved to a non-existent custom field goes nowhere. ii) Ignore the data entirely by disabling the standard field in the "Overwrite fields" options. iii) Add the custom field to PVD and disable the standard field so it's free for use by another plugin or script. Some of these optional custom fields are named the same as their standard counterparts. To avoid confusion, you may wish to rename them (i.e., in the script, in PVD and your skin). For example, change "Year" to "AllMovie Year"—so as to not be confused with the standard field used by another source. 3. 'User Options' are set in the body of the script below. Recommended: Leave them all set to 'True' and use Preferences > Plugins > AllMovie > Overwrite fields to control how these items are to be updated. *) // //BlockOpen //BlockClose //SCRIPT INFO================================================================================================== BlockClose //SCRIPT BEGINS HERE... //SCRIPT CONSTANTS============================================================================================= BlockOpen //Some useful constants Const //Script types stMovies = 0; stPeople = 1; stPoster = 2; //Script modes smSearch = 0; smNormal = 1; smCast = 2; smReview = 3; smCredits = 4; smDVDReleases = 5; smRelated = 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; //This is 'Additional rating', not 'Rating' 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; //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.3'; SCRIPT_VERSION = '1.1.4.0'; SCRIPT_NAME = 'AllMovie.com_new_HTTPS(Related)'; SCRIPT_DESC = '[EN] Get Movie Information from AllMovie.com_new HTTPS Related page'; SCRIPT_LANG = $09; //English SCRIPT_TYPE = stMovies; BASE_URL = 'http://www.allmovie.com'; BASE_URL_SUF = '/'; BASE_URL_PRE = 'http://www.allmovie.com/movie/'; BASE_URL_PRE_TRUE = 'https://www.allmovie.com/movie/'; RATING_NAME = 'AllMovie'; SEARCH_STR = 'http://www.allmovie.com/search/movies/%s'; 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 //User Options GET_ACTORS = True; //Set to False to ensure ~ctActors~ not added even if 'Overwrite fields' setting allows GET_DURATION = True; //Set to False to ensure ~mfDuration~ not set even if 'Overwrite fields' setting allows //Note the program will overwrite this with the actual media duration in any case GET_POSTER = True; //Set to False if posters not wanted (or to handle bad image URL causing HTTP 404 error) GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows //Custom field names to use AWARDS_FIELD = 'All Awards tab'; RELEASES_FIELD = 'DVD Releases'; RELATED_FIELD = 'Related tab'; HTTPRELATED_FIELD = 'Related HTTP/503'; NORELATED_FIELD = 'No Related Movies'; //SCRIPT CONSTANTS============================================================================================= BlockClose //SCRIPT GLOBAL VARIABLES=======================================================================================BlockOpen //Global variables Var ELI,I:Integer; MovieName:String; StoredURL:String; Mode:Byte; ExtraLinks : array [smCast..smPoster] of String; TabMovieName,TabNumber:TwideArray; //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 RemoveTagsEx(AText:String):String; //BlockOpen Var B,E:Integer; Begin Result :=AText; B :=PosFrom('<',Result,1); E :=PosFrom('>',Result,B); While (B>0) AND (B',Result); End; End; //BlockClose function RemoveTagsEx1(AText:String):String; //BlockOpen Var B,E:Integer; Begin Result :=AText; B :=PosFrom('(',Result,1); E :=PosFrom(')',Result,B); While (B>0) AND (B '0' then AddCustomFieldValueByName('NUM ID:',GetFieldValueXML('num')); if GetFieldValueXML('num') <> '0' then LogMessage(' * Movie NUM ID: '+GetFieldValueXML('num')+' ||'); AddFieldValue(mfURL,MovieURL); StoredURL:=GetFieldValueXML('url'); LogMessage(' * Stored URL is: '+StoredURL); StoredURL:=LowerCase(StoredURL); StoredURL:=StringReplace(StoredURL,'https','http',True,True,False); StoredURL:=StringReplace(StoredURL,' ',BASE_URL_SUF,True,True,False)+BASE_URL_SUF; //Get AllMovie ID if exist. curPos:=Pos(BASE_URL_PRE,StoredURL); If 0 '' Then Begin ExplodeString(Date,DateParts,'-'); Date:=DateParts[2]+'.'+ DateParts[1]+'.'+DateParts[0]; Date:=StringReplace(Date,'01.','1.',True,True,False); Date:=StringReplace(Date,'02.','2.',True,True,False); Date:=StringReplace(Date,'03.','3.',True,True,False); Date:=StringReplace(Date,'04.','4.',True,True,False); Date:=StringReplace(Date,'05.','5.',True,True,False); Date:=StringReplace(Date,'06.','6.',True,True,False); Date:=StringReplace(Date,'07.','7.',True,True,False); Date:=StringReplace(Date,'08.','8.',True,True,False); Date:=StringReplace(Date,'09.','9.',True,True,False); AddCustomFieldValueByName('Update',Date); // Simple //AddCustomFieldValueByName('Updated',Date+' at '+TimeToStr(CurrentDateTime)); // Verbose AddCustomFieldValueByName('Updated0', Date + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION); // Annoying AddCustomFieldValueByName('AUpdated',Date+' at '+TimeToStr(CurrentDateTime)+' '+#9679+' '+SCRIPT_NAME+' '+SCRIPT_VERSION); // Annoying End Else LogMessage('date not found'); LogMessage('* Get result Date: '+DateParts[2]+'.'+ DateParts[1]+'.'+DateParts[0]+' at '+TimeToStr(CurrentDateTime)+#8729+SCRIPT_NAME+#8729+SCRIPT_VERSION); //LogMessage(' Get result Date: '+DateToStr(CurrentDateTime)+' at '+TimeToStr(CurrentDateTime)+' • '+SCRIPT_NAME+' '+SCRIPT_VERSION); // Get Related URL curPos:=Pos('
  • ',HTML); if curPos < 1 then Exit; LogMessage('Parsing search results...'); LogMessage('Global Var-Mode 0 | '+IntToStr(Mode)+' |'); LogMessage(' Parsing search results... BEGIN ===================== ||'); LogMessage(' Parsing search results...'); LogMessage(' Search Result START * *'); curPos:=PosFrom('',HTML,curPos); LogMessage(' ** Parse results complex StartURL:'+IntToStr(curPos)+'...'+IntToStr(endPos)); URL:=Copy(HTML,curPos+9,endPos-curPos-9)+'/'; URL:=StringReplace(URL,'https://','http://',True,True,False); LogMessage(' Parse Results URL: '+URL); // Title curPos:=PosFrom('">',HTML,curPos)+2; endPos:=PosFrom('',HTML,curPos); Title:=Copy(HTML,curPos,endPos-curPos); LogMessage(' Parse Results Title: '+Title); // Year curPos:=PosFrom('',HTML,curPos)+4; endPos:=PosFrom('',HTML,curPos); Year :=RemoveTags(Trim(Copy(HTML,curPos,endPos-curPos)),false); LogMessage(' Parse Results in Year: '+Year); // director endPos:=Pos('Directed by: ',HTML); if endPos>0 then curPos:=PosFrom('">',HTML,curPos)+2; endPos:=PosFrom(' ',HTML,curPos); director:=RemoveTags(Trim(Copy(HTML,curPos,endPos-curPos)),false); //director:=StringReplace(director,'Directed by: ','',True,False,True); ///LogMessage(' Parse Results in director: '+director); AddSearchResult(Title+' '+Year,'','',URL,''); LogMessage(' * Get results AddSearchResult:#'+IntToStr(index)+'| '+Title+' '+Year+' | '+URL+' ||'); curPos:=PosFrom('