//SCRIPT INFO================================================================================================== BlockOpen (*Following until 'SCRIPT CONSTANTS...' is documentation. Please see 'USER OPTIONS' in the body of the script. --------------------------------------------- AUTHORS: VVV_Easy Contact Web: http://contactbyweb.com/vvv-easy --------------------------------------------- CHANGE LOG : V 1.2.0.3 (20/10/2018) Improvement of search stored URL. Better script flow control. Only get FULL_AKA in MediaType='Movie'. More Ivek23 corrections. V 1.2.0.2 (07/10/2018) Managed IMDB url's not finish in BASE-URL-SUF='/' and principal page download errors. V 1.2.0.1 (19/09/2018) Ivek23: Corrected parts of the code 18-19/9/2018 forum alerts. Removed PRESERVE-PVD-DESCRIPTION-SETTING. V 1.2.0.0 (11/09/2018) VVV: PVdBScriptConfig.ini -> Bug corrected "GET-FULL-FEATURES" Ivek23: ParsePage_IMDBMovieCREDIT (Full Cast and Crew section) = Repaired pieces of code for transmitting actors information Ivek23: ParsePage_IMDBSearchTitle = Corrected missing posters in search movies results. Ivek23: ParsePage_IMDBMovieMPAA = Corrected parts of the code. Ivek23: ParsePage = Added compatibility with CustomFields ~IMDbID~, ~Updated~ (last needed because is not possible save in ~moddate~). Ivek23,VVV: ParsePage_IMDBMovieBASE = Corrected to the API evolution. Now get "keywords" in ~tags~ (not in ~category~). Get ~origlang~. Added compatibility with CustomFields ~Bottom 100~, ~Metascore~, ~User Reviews~ New script parameter PRESERVE-PVD-DESCRIPTION-SETTING = Avoid double use of ~description~ and ~comment~ using only the user check fields table selection otherwise try get "Storyline" and "plot_Summary". Ivek23,VVV: ParsePage_IMDBMovieTECHNICAL = Added compatibility with CustomFields ~ImdbTechSpecs~ (original PVD ~features~ can be disabled in the program check fields table) V 1.1.0.0 (08/08/2018) Ivek23,VVV: Movie Technical Specs page retreive in Features field (base page or full). V 1.0.0.2 (06/08/2018) VVV: Set the AddAward( ... Year ...) = EventYear (same in People script) V 1.0.0.1 (01/08/2018) VVV: Change values of CHEAT-PREFIX-URL and DUMMY-HTML-FILE. Little improvements. V 1.0.0.0 (20/05/2018) VVV: Initial public release --------------------------------------------- FIELD USE: The Personal Video DataBase field names in comments are enclosed in "~" so they are easier to find in the script. The WEB_SPECIFIC commentary points out the specific text for Web fields. Use Log PVdB debug Window for looking search errors. Important note: This scripts don't use the GET PVdB function for download page (this allows use HTTPS pages). For do that it use a specific program "PVdBDownPage" AutoHotKey script. You can get it from the authors page: http://vvveasy.altervista.org/personal-video-database/ NEEDED EXTERNAL FILES IN SCRIPTS FOLDER: • %Path%\PVdBDownPage.exe FOOTNOTES: 1.Control the use of standard fields using the "Overwrite Fields" plugin preferences in the main program PVD: Preferences > Plugins > 'Script Name' > Overwrite fields to control how these items are to be updated. 2.Hits for adapt the Script. 2.1. Search WEB_SPECIFIC comentary for adapt the specific Web text of fields. 2.2. Script execution: 0) Get results of "Obligatory callback Functions" 1) GetDownloadURL (Obligatory callback Functions) = This function should return URL that should be downloaded byd by the main application and then passed to the script’s ParsePage function as text. It may have several modes selon the Script mode (Global Var Mode = smSearch, smNormal, smFinished). 2) ParsePage (Obligatory callback Functions) = This function receives the text of the download web page passeded to the main application in the GetDownloadURL function. It has several modes selon the Script mode (Global Var Mode = smSearch, smNormal, smFinished). KNOWN ISSUES: 1. For compiling cuestions functions must be defined in the script before use (not in order of execution). 2. For the search texts for locating the fields in Web page Null '' value it's not valid. You must replaces all escaped HTML characters (like <>&") with normal characters (like <, >,$, "). 3. If desired, you needs Custom Fields ~IMDB_Votes~,~TOP_250~ for storing the number of votes and TOP250 IMDB list. 4. If not or bad MPAA USA then get Spain certification (if exist) and convert in USA-KODI values. If even this fails try to get of the "user" folders name. s try to get of the "user" folders name. SCRIPT STRUCTURE: 1.Script data and user options constants 2.Some useful generic constants 3.Global variables 4.Obligatory PVD callback Functions GetScriptVersion, GetScriptName, GetScriptDesc, GetBaseURL, GetScriptLang, GetScriptType, GetCurrentMode, GetDownloadURL. (Note: ParsePage is at the end of the file for compiling cuestions). 5.Optional PVD callback Functions GetRatingName ,GetCodePage, GetDownloadMethod, GetPrefixMode; 6.User Functions an procedures (with their constans) 7.Obligatory PVD callback function ParsePage (at the end of the file for compiling cuestions) *) //SCRIPT INFO================================================================================================== BlockClose //SCRIPT CONSTANTS============================================================================================= BlockOpen Const //Script types----------------------------------------------------------------------------------------------------------- stMovies = 0; stPeople = 1; stPoster = 2; stScreenShots = 3; stCover = 4; //Script Obligatory Infos---------------------------------------------------------------------------------------------- SCRIPT_NAME = 'IMDB [EN][HTTPS] (Connections)'; //The most complete information provider SCRIPT_DESC = 'IMDB download Movie Connections info [EN]'; SCRIPT_VERSION = '1.2.0.3'; SCRIPT_TYPE = stMovies; SCRIPT_LANG = $09; //English //$0a es-Spanish $0c fr-French $09 en-English RATING_NAME = 'IMDB'; //PVD has ~imdbrating~ for this value CODE_PAGE = 65001; //28591=ISO 8859-1 Latin 1; Western European (ISO). Use: 65001=Unicode (UTF-8) | 0=for Autodetect Autodetect //Script Options------------------------------------------------------------------------------------------------------- //Retreive Data Config GET_FULL_MPAA = True ; //Download Certification provider page for retreive the MPAA info. Otherwise only the info of the principal movie page. GET_FULL_AKA = True ; //Download 'Also Known As' provider page for retreive the info. Otherwise only the info of the principal movie page. GET_FULL_CREDIT = True ; //Download Cast or Credit provider page for retreive the info. Otherwise only the info of the principal movie page. PEOPLE_LIMIT = 25; //Limit of number of actors (cast) or of credits (crew) retrieved. GET_FULL_AWARDS = True ; //Download Awards provider page for retreive the info. Otherwise doesn't do nothingh because no info in the principal movie page. EVENTS_LIMIT = 100; //Limit of number of events (USA Academy Awards, Golden Globes, etc) to retrive awards. GET_FULL_FEATURES = True ; //Download Technical Specs for retreive the original movie features (Runtime, Sound Mix, Color, Aspect Ratio, etc). GET_FULL_CONNECTIONS = True ; //Download Connections provider page for retreive the MovieConnections info. Otherwise only the Followed by info of the Connections provider page. MAX_IMAGE_HEIGTH = 1200; //Heigth limit of the stored posters. //Process Data Config PRESERVE_PVD_DESCRIPTION_SETTING = True ; //Avoid double use of ~description~ and ~comment~ using only the user check fields table selection otherwise try get "plot_summary" //Process Behaviour Config BYPASS_SILENT = True ; //Ensure critical ShowMessage alerts bypassing Silent PVdB preferences CHECK_WEBSITE = False ; //Add to SearchResult List the true HTTPS links 'Just to check the website' with the browser POSTER_IN_SEARCH = True ;//Download and show movie posters in the list of the SearchResult SEARCH_ENGINE = True ; //If there isn't provider search results, try with Bing search engine INTERNET_TEST_ITERATIONS = 6; //Attempts before to alert user that not internet connection detected. Increase if the provider has low speed. //Script data------------------------------------------------------------------------------------------------------------ //Used Web URL BASE_URL_PRE = 'http://www.imdb.com/title/'; //The traditional BASE_URL_PREFIX used to get movie ID if the movie is stored for instance 'http://www.imdb.com/title/ tt0068646/'. BASE_URL_PRE_TRUE = 'https://www.imdb.com/title/'; //True actual link to movie ID 'httpS://www.imdb.com/title/ tt0068646/' BASE_URL_PERSON_PRE = 'http://www.imdb.com/name/'; //The traditional BASE_UR to person ID 'httpS://www.imdb.com/name/ nm0094036/' BASE_URL_PERSON_PRE_TRUE = 'https://www.imdb.com/name/'; //True actual link to person ID 'httpS://www.imdb.com/name/ nm0094036/' BASE_URL_SUF = '/'; //Suffix in the link after MovieID o PersonID 'http://www.imdb.com/title/ tt0068646 /' BASE_URL_IMAGE_PRE = 'http://ia.media-imdb.com/images/M/'; //IMDB posters format: Full image: 'https://ia.media-imdb.com/images/M/MV5BMTI2MjI4NTgyNF5BMl5BanBnXkFtZTcwOTM5NzQ5MQ@@.jpg. BASE_URL_IMAGE_PRE_TRUE = 'https://m.media-amazon.com/images/M/'; //Resized image: 'https://ia.media-imdb.com/images/M/MV5BMTI2MjI4NTgyNF5BMl5BanBnXkFtZTcwOTM5NzQ5MQ@@._V1_UY50_CR0,0,34,50_AL_.jpg // where the two last number are width and heigth BASE_URL_MPAA ='http://www.imdb.com/title/%IMDB_ID/parentalguide?ref_=tt_stry_pg#certification'; //Certification provider page. WEB_SPECIFIC. BASE_URL_AKA ='https://www.imdb.com/title/%IMDB_ID/releaseinfo?ref_=tt_dt_dt#akas'; //Also Known As provider page. WEB_SPECIFIC. BASE_URL_CAST ='https://www.imdb.com/title/%IMDB_ID/fullcredits?ref_=tt_cl_sm#cast'; //Cast provider page. WEB_SPECIFIC. BASE_URL_AWARDS='https://www.imdb.com/title/%IMDB_ID/awards?ref_=tt_awd'; //Awards provider page. WEB_SPECIFIC. BASE_URL_TECH='https://www.imdb.com/title/%IMDB_ID/technical?ref_=tt_spec'; //Technical Specifications provider page. WEB_SPECIFIC. BASE_URL_CONNECTIONS='https://www.imdb.com/title/%IMDB_ID/movieconnections/?tab=mc&ref_=tt_trv_cnn'; //Connections provider page. WEB_SPECIFIC. BASE_URL_SEARCH_PROV ='https://www.imdb.com/search/title?title=%s&title_type=feature&release_date=%y,%y&view=simple'; //Search string for '%s' title and '%y' year. WEB_SPECIFIC //BASE_URL_SEARCH_PROV = 'https://www.imdb.com/search/title?title=%s&title_type=feature&release_date=%y,%y&countries=%C2%B7%C2%B7%C2%B7%C2%A0Common+Countries%C2%A0%C2%B7%C2%B7%C2%B7&languages=%C2%B7%C2%B7%C2%B7%C2%A0Common+Languages%C2%A0%C2%B7%C2%B7%C2%B7&view=simple' //Not used because not improvement results. WEB_SPECIFIC //BASE_URL_SEARCH_PROV = 'http://www.imdb.com/find?q=%s&s=tt&view=simple'; //Ivek23 proposition BASE_URL_PERSON_SEARCH_PROV ='https://www.imdb.com/search/name?name=%s&sort=starmeter+desc&ref_=rlm'; //Search string for '%s' name. WEB_SPECIFIC MAX_SEARCHLIST_HEIGTH = 200; //Heigth limit of the search list posters. BASE_URL_SEARCH_ENGI = 'http://www.bing.com/Search?q=%s%20+(%y)+site%3A%p'; // Search string: '%s' title , '%y' year and '%p' web information provider. //Download HTTPS needed parameters BASE_URL_ROUNDABOUT = 'ROUNDABOUT'; //Used for cheat GET PVdB funtion and rondabout the "https" fail. BASE_DOWNLOAD_FILE_NO_BOM = 'Tmp\downpage-UTF8_NO_BOM.htm'; //File to store curl page download in UTF8 without BOM and then it's not necesary use GET PVdB funtion to download. BASE_DOWNLOAD_FILE_IMAGE_NAME = 'Tmp\downimage-BIN'; //File to store curl image download in binary and then it's not necesary use GET PVdB funtion to download. CHEAT_PREFIX_URL = 'http://httpbin.org/response-headers?key='; //Working http URL used for cheat GET PVdB funtion when it returns for SearchList choice. DUMMY_HTML_FILE = 'portable.bat'; //Any existing PVdV file (little) not used. If adapted, it may external file 'C:\Windows\notepad.exe' //Script movie modes.---------------------------------------------------------------------------------------------------- smSearch = 0; //Entry mode and search list mode (AddSearchResult) smNormal = 1; //This scripts download with external program (not with GetDownloadURL) so it only make one pass to ParsePage for retrieve all info, credits, poster, etc. other field modes aren't necesary. //Movie PVdB fields in http://www.videodb.info/help/hlp_scripting.html#fields: //Certification (AddValueField): ~mpaa~ //Credits (AddMoviePerson): ~Directors~,~Writers~,~Composers~,~Photographers~,~Actors~,~Producer~.Same that smCast.hat smCast. //Votes (AddValueField): ~rating~,~imdbrating~,~orname~,~orating~ and related custom PVdB fields ~IMDB_Votes~,~TOP_250~,~FilmAffinity_Votes~. //Poster (AddValueImageURL): ~poster~,~screenshots~,~froncover~,~cdcover~ //Review (AddValueField): ~comment~,~tags~ //Awards (AddAwards). smSearchList = 8; //Used in ParsePage for demands download the https link returned by user in the window of (AddSearchResult)SearchResult) smFinished = 9; //For set script finish. //Parse results (return of Script)--------------------------------------------------------------------------------------- prError = 0; //An error acquired while processing data prFinished = 1; //Script has finished gathering data prList = 2; //A list of search results is available. Use with (AddSearchResult) prListImage = 3; //A list of image search results is available. Use with? prDownload = 4; //Another URL needs to be downloaded //Download methods------------------------------------------------------------------------------------------------------- dmGET = 0; dmPOST = 1; //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 CONSTANTS============================================================================================= BlockClose //SCRIPT GLOBAL VARIABLES=======================================================================================BlockOpen Var Mode:Byte; DownloadURL:String; StoredURL:String; MediaType:String; //'Movie''TVSeries''TVEpisode' //SCRIPT GLOBAL VARIABLES=======================================================================================BlockClose //OBLIGATORY CALLBACK FUNCTIONS=================================================================================BlockOpen 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 GetBaseURL:AnsiString; //BlockOpen Begin Result := BASE_URL_ROUNDABOUT; //Used for cheat GET PVdB funtion and rondabout the "https" fail. End; //BlockClose Function GetScriptLang:Cardinal; //BlockOpen Begin Result:=SCRIPT_LANG; End; //BlockClose Function GetScriptType:Byte; //BlockOpen Begin Result:=SCRIPT_TYPE; End; //BlockClose Function GetCurrentMode:Byte; //BlockOpen Begin Result:=Mode; End; //BlockClose Function GetDownloadURL:AnsiString; //BlockOpen Var curPos:Integer; ScriptPath,MovieID:String; Begin LogMessage('Function GetDownloadURL BEGIN======================|'); LogMessage('Global Var-Mode|'+IntToStr(Mode)+'|'); LogMessage('Global Var-DownloadURL|'+DownloadURL+'|'); //Comprobation of needed external files. ScriptPath:=GetAppPath+'Scripts\'; If Not(FileExists(ScriptPath+'PVdBDownPage.exe')) Then Begin ShowMessage ('This script needs the external file for work.'+Chr(13)+'• PVdBDownPage.exe'+Chr(13)+'Read script text for futher information',SCRIPT_NAME); Mode:=smFinished; Result:=''; //If error returns empty string exit; End; If (Mode=smSearch) Then Begin //Get stored URL if exist. StoredURL:=GetFieldValueXML('url'); LogMessage('Stored URL is: '+StoredURL+' ||'); //Standarize the URL StoredURL:=LowerCase(StoredURL); StoredURL:=StringReplace(StoredURL,'https','http',True,True,False); StoredURL:=StringReplace(StoredURL,' ',BASE_URL_SUF,True,True,False)+BASE_URL_SUF; //Asure that the URLs always finish BASE_URL_SUF (even in the last position //Get IMDB ID if exist. curPos:=Pos(BASE_URL_PRE,StoredURL); If 0Go to function ParsePage for parse the film information Result:=GetAppPath+DUMMY_HTML_FILE; //Any existing little file for cheating PVdB automatic download (little).). LogMessage('Function GetDownloadURL END====================== with Mode='+IntToStr(Mode)+' Result='+Result+'|'); exit; End Else Begin //The movie URL not exist, search mode needed. Download the search page. //ShowMessage('No IMDB URL.',SCRIPT_NAME); LogMessage(' No IMDB URL.'); Mode:=smSearch; //->Go to function ParsePage for search the URL (in this funtion you can't not use user funtions)ntions) DownloadURL:=''; //Has not movie URL. Result:=GetAppPath+DUMMY_HTML_FILE; //Any existing little file for cheating PVdB automatic download (little).). LogMessage('Function GetDownloadURL END====================== with Mode='+IntToStr(Mode)+' Result='+Result+'|'); exit; //Go to the End; End; //Not other modes working needs in this function. //smNormal = 1; //This scripts download with external program (not with GetDownloadURL) so it only make one pass to ParsePage for retrieve all info, credits, poster, etc. other field modes aren't necesarye pass to ParsePage for retrieve all info, credits, poster, etc. other field modes aren't necesary //smSearchList = 8; //Used in ParsePage for demands download the https link returned by user in the window of (AddSearchResult)(AddSearchResult) Result:=GetAppPath+DUMMY_HTML_FILE; //Any existing little file for cheating PVdB automatic download (little). LogMessage('Function GetDownloadURL END====================== with Mode='+IntToStr(Mode)+' Result='+Result+'|'); exit; End; //BlockClose Function GetRatingName:String; //BlockOpen Begin Result:=RATING_NAME; End;//BlockClose Function GetCodePage:Cardinal; //BlockOpen Begin Result:=CODE_PAGE; End; //BlockClose //OBLIGATORY CALLBACK FUNCTIONS=================================================================================BlockClose //USER FUNCTIONS AND PROCEDURES=================================================================================BlockOpen Function DownloadPage(URL:AnsiString):String; //BlockOpen //Returns the URL page text. If error returns empty string Var i:Integer; ScriptPath,WebText:String; Begin LogMessage(Chr(9)+Chr(9)+'Function DownloadPage BEGIN======================|'); LogMessage(Chr(9)+Chr(9)+'Global Var-DownloadURL|'+DownloadURL+'|'); LogMessage(Chr(9)+Chr(9)+' Local Var-URL|'+URL+'|'); ScriptPath:=GetAppPath+'Scripts\'; //LogMessage(Chr(9)+Chr(9)+' Local Var-ScriptPath|'+ScriptPath+'|'); //Delete the ancient dowloaded page file. Needed for wait to curl download included in PowerShell command. While FileExists(ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM) Do Begin FileExecute('cmd.exe', '/C del "'+ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM+'"'); LogMessage(Chr(9)+Chr(9)+' Waiting 1s for delete:'+ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM); wait (1000); End; //Download the URL page. LogMessage(Chr(9)+Chr(9)+' Download with PVdBDownPage in file:|'+ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM+' the information of:|'+URL+'||'); FileExecute(ScriptPath+'PVdBDownPage.exe', '"'+URL+'" "'+ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM+'"'); //Wait download finish and exist the downloaded page. i:=0; // INTERNET_TEST_ITERATIONS While Not(FileExists(ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM)) Do Begin LogMessage(Chr(9)+Chr(9)+' Waiting 2s for exists of:'+ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM); wait (2000); i:=i+1; If i=INTERNET_TEST_ITERATIONS Then Begin //if 2=MessageBox('Demasiados intentos fallidos de conexión a internet.'+Chr(13)+ 'Reintentar o Cancelar?',SCRIPT_NAME,5) then begin if 2=MessageBox('Too many faulty attempts to internet connection.'+Chr(13)+ 'Retry or Cancel?',SCRIPT_NAME,5) then begin LogMessage(Chr(9)+Chr(9)+'Function DownloadPage END with NOT INTERNET connection ===============|'); Result:=''; Exit; End; i:=0; End; End; LogMessage(Chr(9)+Chr(9)+' Now present complete page file: '+ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM); WebText:=FileToString(ScriptPath+BASE_DOWNLOAD_FILE_NO_BOM); WebText:=ConvertEncoding(WebText, 65001); //65001 utf-8 Unicode (UTF-8) ---> https://msdn.microsoft.com/en-us/library/dd317756(VS.85).aspxbrary/dd317756(VS.85).aspx //LogMessage(Chr(9)+Chr(9)+' Local Var-WebText|'+WebText+'|'); //Debug statement Result:=WebText; //Some download data comprobations. if (Pos('404 Not Found',Result)>0) then begin //Banned IP. WEB_SPECIFIC. If BYPASS_SILENT Then ShowMessage('The URL is not in use (404 Not Found).'+Chr(13)+'Go to the provider web in order to in order to'+Chr(13)+'find the good page',SCRIPT_NAME); LogMessage(Chr(9)+Chr(9)+' 404 Not Found|'); Result:=''; //Fatal error End; if (Pos('404 Error - IMDb',Result)>0) then begin //Banned IP. WEB_SPECIFIC. If BYPASS_SILENT Then ShowMessage('The URL is not in use (404 Error - IMDb).'+Chr(13)+'Go to the provider web in order to in order to'+Chr(13)+'find the good page',SCRIPT_NAME); LogMessage(Chr(9)+Chr(9)+' 404 Error - IMDb|'); Result:=''; //Fatal error End; if (Pos('Page not found',Result)>0) then begin //Banned IP. WEB_SPECIFIC. If BYPASS_SILENT Then ShowMessage('The URL is not in use (Page not found).'+Chr(13)+'Go to the provider web in order to in order to'+Chr(13)+'find the good page',SCRIPT_NAME); LogMessage(Chr(9)+Chr(9)+' Page not found|'); Result:=''; //Fatal error End; if (Pos('405 Method not allowed',Result)>0) then begin //Banned IP. WEB_SPECIFIC. //If BYPASS_SILENT Then ShowMessage('La URL tiene problemas de HTTP metodo (405 Method not allowed).'+Chr(13)+'Ir a la página del proveedor para'+Chr(13)+'encontrar la página buena',SCRIPT_NAME); If BYPASS_SILENT Then ShowMessage('The URL has HTTP method problems (405 Method not allowed).'+Chr(13)+'Go to the provider web in order to in order to'+Chr(13)+'find the good page',SCRIPT_NAME); LogMessage(Chr(9)+Chr(9)+' 405 Method not allowed|'); Result:=''; //Fatal error End; if (Pos('Too many request',Result)>0) then begin //Banned IP. WEB_SPECIFIC. //If BYPASS_SILENT Then ShowMessage('El proveedor ha prohibido su IP (Demasiadas peticiones).'+Chr(13)+'Ir a la página del proveedor y resolver el captcha para'+Chr(13)+'demostrar que no es un robot',SCRIPT_NAME); If BYPASS_SILENT Then ShowMessage('The provider has banned your IP (Too many request).'+Chr(13)+'Go to the provider web and resolve the captcha in order to'+Chr(13)+'demostrate you are not a robot',SCRIPT_NAME); LogMessage(Chr(9)+Chr(9)+' Banned IP|'); Result:=''; //Fatal error End; LogMessage(Chr(9)+Chr(9)+'Function DownloadPage END======================|'); exit; End; //BlockClose Function DownloadImage(URL:AnsiString;OutPutFile:AnsiString):Integer; //BlockOpen //Returns 1 or 0 if the downloaded image file exists in Exit. Var i:Integer; ScriptPath:String; Begin LogMessage(Chr(9)+Chr(9)+'Function DownloadImage BEGIN======================|'); LogMessage(Chr(9)+Chr(9)+'Global Var-DownloadURL|'+DownloadURL+'|'); LogMessage(Chr(9)+Chr(9)+' Local Var-URL|'+URL+'|'); LogMessage(Chr(9)+Chr(9)+' Local Var-OutPutFile|'+OutPutFile+'|'); ScriptPath:=GetAppPath+'Scripts\'; //Delete the ancient dowloaded page file. Needed for wait to curl download included in PowerShell command. While FileExists(OutPutFile) Do Begin FileExecute('cmd.exe', '/C del "'+OutPutFile+'"'); LogMessage(Chr(9)+Chr(9)+' Waiting 1s for delete:'+OutPutFile); wait (1000); End; //Download the URL page. LogMessage(Chr(9)+Chr(9)+' Download with PVdBDownPage in file:|'+OutPutFile+' the information of:|'+URL+'||'); FileExecute(ScriptPath+'PVdBDownPage.exe', '"'+URL+'" "'+OutPutFile+'"'); //Wait download finish and exist the downloaded page. i:=0; // INTERNET_TEST_ITERATIONS While Not(FileExists(OutPutFile)) Do Begin LogMessage(Chr(9)+Chr(9)+' Waiting 2s for exists of:'+OutPutFile); wait (2000); i:=i+1; If i=INTERNET_TEST_ITERATIONS Then Begin //In the images download the scritp can not ask to the user for internet conexion because perhaps the file doesn't exist. LogMessage(Chr(9)+Chr(9)+'Function DownloadImage END with NOT file downloaded ===============|'); Result:=0; exit; End; End; LogMessage(Chr(9)+Chr(9)+' Now present complete page file: '+OutPutFile); Result:=1; LogMessage(Chr(9)+Chr(9)+'Function DownloadImage END======================|'); exit; End; //BlockClose Function TextBetWeenFirst(_HTML:string;_ABegin,_AEnd:String):String; //BlockOpen //Returns the first extract part of a given _HTML between _Abegin and _AEnd and removes all tags from the result substring. //In order to avoid set the Pos variable in TextBetween Var _Pos:Integer; Begin _Pos:=0; Result:=TextBetWeen(_HTML,_ABegin,_AEnd,false,_Pos); Exit; End; //BlockClose Function ParsePage_BingSearch(HTML:String):Cardinal; //BlockOpen //Returns: // Result:=prDownload; (Global var-DownloadURL=IMDB page) if there is one results. // Result:=prList; if there are several results. (Don't work with Preferences/Plugings/Silent Mode). // Result:=prError; If not results Var curPos,endPos:Integer; ItemValue,ItemList:String; Title,Year,MovieURL:String; Begin LogMessage('Function ParsePage_BingSearch BEGIN======================|'); LogMessage('Global Var-Mode|'+IntToStr(Mode)+'|'); LogMessage('Global Var-DownloadURL|'+DownloadURL+'|'); //First manager the results, second other situation (No results or fail -> Finish) If ((Pos(BASE_URL_PRE, HTML)>0) Or (Pos(BASE_URL_PRE_TRUE, HTML)>0)) Then Begin //Not movie URL found. WEB_SPECIFIC LogMessage(' BASE_URL_PRE results detectes.'); ItemList:=TextBetWeenFirst(HTML,'
    '); //String which opens-closes thesearch List results. WEB_SPECIFIC curPos:=PosFrom('
  1. ',ItemList,curPos); //String which opens the Web result Movie info (Poster and details text). WEB_SPECIFIC While (0','',false,curPos); //String which opens-closes the Web result Movie link. WEB_SPECIFIC //LogMessage(' Parse Results ItemValue:'+ ItemValue+'||'); endPos:=LastPos('(', ItemValue); //Not use curPos for not loosing text position when searching in ItemValue If (0',ItemList,curPos); //String which opens the Web result HTML file data. WEB_SPECIFIC End; Result:=prList; //Don't work with Preferences/Plugings/Silent Mode. LogMessage(' After parsing Bing search Movies go to choose List Results'); LogMessage('Function ParsePage_BingSearch END=====================||'); Exit; End Else Begin if BYPASS_SILENT then ShowMessage('Not results even with Bing search engine.'+Chr(13)+'Try again or make an advanced search out of the script.'+Chr(13)+'Write the movie URL (http) in the PVdB manually (remember separated by spaces) and run again.',SCRIPT_NAME); Result:=prError; LogMessage(' Not results|'); LogMessage('Function ParsePage_BingSearch END=====================||'); Exit; End; End; //BlockClose Function ParsePage_IMDBSearchTitle(HTML:String):Cardinal; //BlockOpen //Returns: // Result:=prDownload; (Global var DownloadURL=IMDB page) if there is one results. // Result:=prList; if there are several results. (Don't work with Preferences/Plugings/Silent Mode). // Result:=prError; If not results Var curPos,ResultsNumber:Integer; ItemValue,ImageFile:String; Title,Year,MovieURL,PreviewURL:String; Begin LogMessage('Function ParsePage_IMDBSearchTitle BEGIN======================|'); LogMessage('Global Var-Mode|'+IntToStr(Mode)+'|'); LogMessage('Global Var-DownloadURL|'+DownloadURL+'|'); If (Pos('No results',HTML)<>0) Then Begin //WEB_SPECIFIC LogMessage(' No Movies results'); Result:=prError; End Else Begin LogMessage(' Parsing search Movies results'); curPos:=Pos('
    ',HTML); //String which opens the Web Search List data. WEB_SPECIFIC //Get first item ResultsNumber:=0; curPos:=PosFrom('
    ',HTML,curPos); //String which opens the Web Result List data. WEB_SPECIFIC While curPos>0 Do Begin ResultsNumber:=ResultsNumber+1; LogMessage(' Parsing search movie results in '+IntToStr(curPos)+' ...'); curPos:=PosFrom('
    ',HTML,curPos); //String which opens the Web URL+Title+URL+PreviewURL data. WEB_SPECIFIC //Get PreviewURL If POSTER_IN_SEARCH Then begin ItemValue:=TextBetWeen(HTML,'loadlate="','"',false,curPos); //Strings which opens/closes the data. WEB_SPECIFIC If (Pos('https://m.media-amazon.com/images/G/01/imdb/images/',ItemValue)>0) Then Begin PreviewURL:=TextBetWeenFirst(ItemValue,'https://m.media-amazon.com/images/G/01/imdb/images/','.'); //Get poster code. Strings which opens/closes the data. WEB_SPECIFIC If (Length(PreviewURL)>0) then begin PreviewURL:='https://m.media-amazon.com/images/G/01/imdb/images/' + PreviewURL //Base poster URL without '.jpg'. WEB_SPECIFIC ImageFile:=GetAppPath+'Scripts\'+BASE_DOWNLOAD_FILE_IMAGE_NAME+'-SearchResult-'+IntToStr(ResultsNumber)+'-.jpg' // Avoid HTTPS redirection: Download https image to file OutPutFile= If (1=DownloadImage(PreviewURL + '._V1_UY' + IntToStr(MAX_SEARCHLIST_HEIGTH) + '_.jpg',ImageFile)) then begin //Dowload in the selected user max size. WEB_SPECIFIC LogMessage(' Parse Results PreviewURL:'+PreviewURL + '._V1_UY' + IntToStr(MAX_SEARCHLIST_HEIGTH) + '_.jpg'+'||'); PreviewURL:=ImageFile; //Pass the downloaded file to PVD end else if (1=DownloadImage(PreviewURL +'.jpg',ImageFile)) then begin //Dowload in the web base size. WEB_SPECIFIC LogMessage(' Parse Results PreviewURL:' + PreviewURL + '.jpg'+'||'); PreviewURL:=ImageFile; //Pass the downloaded file to PVD end; end; end; If (Pos(BASE_URL_IMAGE_PRE_TRUE,ItemValue)>0) Then Begin PreviewURL:=TextBetWeenFirst(ItemValue,BASE_URL_IMAGE_PRE_TRUE,'.'); //Get poster code. Strings which opens/closes the data. WEB_SPECIFIC If (Length(PreviewURL)>0) then begin PreviewURL:=BASE_URL_IMAGE_PRE_TRUE + PreviewURL //Base poster URL without '.jpg'. WEB_SPECIFIC ImageFile:=GetAppPath+'Scripts\'+BASE_DOWNLOAD_FILE_IMAGE_NAME+'-SearchResult-'+IntToStr(ResultsNumber)+'-.jpg' // Avoid HTTPS redirection: Download https image to file OutPutFile= If (1=DownloadImage(PreviewURL + '._V1_UY' + IntToStr(MAX_SEARCHLIST_HEIGTH) + '_.jpg',ImageFile)) then begin //Dowload in the selected user max size. WEB_SPECIFIC LogMessage(' Parse Results PreviewURL:'+PreviewURL + '._V1_UY' + IntToStr(MAX_SEARCHLIST_HEIGTH) + '_.jpg'+'||'); PreviewURL:=ImageFile; //Pass the downloaded file to PVD end else if (1=DownloadImage(PreviewURL +'.jpg',ImageFile)) then begin //Dowload in the web base size. WEB_SPECIFIC LogMessage(' Parse Results PreviewURL:' + PreviewURL + '.jpg'+'||'); PreviewURL:=ImageFile; //Pass the downloaded file to PVD end; end; end; end; //Get MovieURL (Always must it has) MovieURL:=TextBetWeen(HTML,'','<',false,curPos); //Strings which opens/closes the data. WEB_SPECIFIC LogMessage(' Parse Results Title:'+Title+'||'); //Get Year curPos:=PosFrom('',HTML,curPos); //Strings which opens/closes the data. WEB_SPECIFIC Year:=IntToStr(StrToInt(Copy(HTML,curPos-5,4))); //5=length of "yyyy)" LogMessage(' Parse Results in Year:'+Year+'||'); AddSearchResult(Title,'',Year,MovieURL,PreviewURL); //Just to check the website (Only to check the web page) not PVdB valid result. if CHECK_WEBSITE then AddSearchResult(' '+#8729+' Just to check the website: '+StringReplace(MovieURL,CHEAT_PREFIX_URL,'',True,False,False),'','',StringReplace(MovieURL,CHEAT_PREFIX_URL,'',True,False,False),''); curPos:=PosFrom('
    ',HTML,curPos) //String which opens the Web Result item List data. WEB_SPECIFIC End; If ResultsNumber=1 Then Begin DownloadURL:=StringReplace(MovieURL,CHEAT_PREFIX_URL,'',True,False,False); //Eliminate the CHEAT_PREFIX_URL for get the true movie link DownloadURL:=StringReplace(DownloadURL,'http:','https:',True,True,False); //The direct url needed (no https redirection) Result:=prDownload; //One result in the DownloadURL. LogMessage(' After parsing search Movies, only one result detected'); End Else Begin Result:=prList; //Don't work with Preferences/Plugings/Silent Mode. LogMessage(' After parsing search Movies go to choose List Results'); End; End; LogMessage('Function ParsePage_IMDBSearchTitle END=====================||'); Exit; End; //BlockClose Function ParsePage_IMDBMovieBASE(HTML:String):Cardinal; //BlockOpen //Returns: // Result:=prFinished; Script has finished gathering data // Result:=prError; If ¿any big problem? with exit; //Retrieve: ~title~, ~year~, ~origtitle~, ~poster~ / ~imdbrating~, ~IMDB_Votes~ (Custom Field) / ~TOP_250~(Custom Field) / // If Not(GET_FULL_CREDIT): ~crew~ctDirectors,ctWriters,ctComposers,ctProducers(Not in base page), ctActors // ~description~ / ~category~ "keywords" / ~tagline~ / ~genre~ // If Not(GET_FULL_MPAA) ~mpaa~ // ~country~ / ~rdate~ in contry provider local IP geolocation // If Not(GET_FULL_AKA) ~aka~. // ~budget~ / ~money~ / ~studio~ "Production Co" // If Not(GET_FULL_FEATURES) ~features~ Var curPos,endPos,index:Integer; ItemValue,ItemList,ImageFile:String; titleValue:String; Name,Role,PersonURL:String; ItemArray:TWideArray; Begin LogMessage('Function ParsePage_IMDBMovieBASE BEGIN======================|'); Result:=prFinished; //It will change to prError if any big problem with exit; //Because the script don't retreives the data in the page order a token search for the first curPos position or block select is mandatory //Get ~title~, ~year~, ~origtitle~, ~poster~ //Get all "raw" title summary (in raw because we need the hidden links, we avoid "complete" token in strings which opens/closes) ItemList:=TextBetWeenFirst(HTML,'
    '); //WEB_SPECIFIC. If (Length(ItemList)>0) Then Begin titleValue:=TextBetWeenFirst(ItemList,'

    ','<'); //Strings which opens/closes the data. WEB_SPECIFIC AddFieldValueXML('title',titleValue); LogMessage(' Get result title:'+titleValue+'||'); ItemValue:=TextBetWeenFirst(ItemList,'(',')

    '); //Strings which opens/closes the data. WEB_SPECIFIC AddFieldValueXML('year',ItemValue); LogMessage(' Get result year:'+ItemValue+'||'); ItemValue:=TextBetWeenFirst(ItemList,'
    ','<'); //Strings which opens/closes the data. WEB_SPECIFIC If (Length(ItemValue)=0) Then ItemValue:=titleValue; //Provider hides the original title if same that title. WEB_SPECIFIC AddFieldValueXML('origtitle',ItemValue); LogMessage(' Get result origtitle:'+ItemValue+'||'); ItemValue:=TextBetWeenFirst(ItemList,BASE_URL_IMAGE_PRE_TRUE,'.'); //Get poster code. Strings which opens/closes the data. WEB_SPECIFIC If (Length(ItemValue)>0) then begin ItemValue:=BASE_URL_IMAGE_PRE_TRUE + ItemValue; //Base poster URL without '.jpg'. WEB_SPECIFIC ImageFile:=GetAppPath+'Scripts\'+BASE_DOWNLOAD_FILE_IMAGE_NAME+'-Poster.jpg' // Avoid HTTPS redirection: Download https image to file OutPutFile= If (1=DownloadImage(ItemValue + '._V1_UY' + IntToStr(MAX_IMAGE_HEIGTH) + '_.jpg',ImageFile)) then begin //Dowload in the selected user max size. WEB_SPECIFIC //AddImageURL(itPoster,ImageFile); //Get the photo from a file even if the next line we log the true URL. LogMessage(' Get result poster:'+ItemValue + '._V1_UY' + IntToStr(MAX_IMAGE_HEIGTH) + '_.jpg'+'||'); end else if (1=DownloadImage(ItemValue +'.jpg',ImageFile)) then begin //Dowload in the web base size. WEB_SPECIFIC //AddImageURL(itPoster,ImageFile); //Get the photo from a file even if the next line we log the true URL. LogMessage(' Get result poster:' + ItemValue + '.jpg'+'||'); end; end; End; //Get ~script info~ //Get ~rdate~ in contry provider local IP geolocation. See: http://sobizarre-en.blogspot.fr/2014/12/how-to-easily-defeat-imdb-geolocation.html //Get ~imdbrating~, ~IMDB_Votes~ (Two tries) ItemList:=TextBetWeenFirst(HTML,'