Advertisement
Guest User

Untitled

a guest
Aug 17th, 2011
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.25 KB | None | 0 0
  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Antoine Potten, KaraGarga, baffab, Thermal Ions, bad4u, Sancho
  8. Title=IMDB
  9. Description=Import data & picture from IMDB (optional image from Amazon)
  10. Site=us.imdb.com
  11. Language=EN
  12. Version=3.70
  13. Requires=3.5.0
  14. Comments=Based on the script made for version 3.3/3.4 by Antoine Potten, Danny Falkov, Kai Blankenhorn, lboregard, Ork, Trekkie, Youri Heijnen
  15. License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  16. GetInfo=1
  17.  
  18. [Options]
  19. ActorsLayout=0|0|0=Only actor names, separated by commas|1=Only actor names, separated by linebreaks|2=Actors names with character names between parenthesis separated by commas|3=Actors names with character names between parenthesis separated by linebreaks|4=Actor names like on IMDB page, with "...." and separated by linebreaks
  20. AllActors=0|0|0=Only import actors from main page (does not work if you import producer name)|1=Import all possible actors|2=Import 10 first actors (does not work with ActorLayout=4)
  21. AspectRatio=1|1|0=Do not import picture aspect ratio|1=Import picture aspect ratio to video format field|2=Import picture aspect ratio to resolution field
  22. Awards=2|0|0=Do not import awards|1=Import awards to Description field, after the summary|2=Import awards to Comments field, after comments
  23. BatchMode=2|0|0=Normal working mode, prompts user when needed|1=Does not display any window, takes the first movie found|2=Same as 1, but it uses the URL field if available to update movie information
  24. Classification=2|0|0=Do not import classification/certification|1=Import classification to MediaType field|2=Append classification to Comments field
  25. CommentType=2|0|0=Standard Type (Only one comment from main page)|1=Detailed Type (10 most useful comments from comments page)|2=No user comment, clear current field contents|3=No user comment, keep current field contents (may cause problem for multiple imports on the same movie if other options append text to the comment field)
  26. DescriptionSelection=2|0|0=Take the short summary, from main page (faster)|1=Show a list of available summaries|2=Take the longest summary
  27. GetTagline=1|1|0=Do not get tagline|1=Put it in Description field, before the summary|2=Put it in the Comment field, before the comments
  28. GoogleSearch=0|0|0=Use IMDB's website search function for results list|1=Use Google to search IMDB's website for a different results list (maybe useful for batch mode or as a workaround when script cannot read IMDB's results page)|2=Use Google to search IMDB's website for exact matches on film titles (sets movie name into quotation marks - more precise, but maybe some titles can't be found)
  29. HideAkaTitles=0|0|0=Show 'aka' titles on result list (= other titles for the film)|1=Hide 'aka' titles on result list
  30. ImageKind=1|3|0=No image|1=IMDB small image, from the main movie page, no image if none available|2=IMDB small image, from the main movie page, "No Poster Available" if none available|3=IMDB large image, from link on main movie page, else small image, else "No Poster Available"|4=Cover from "Merchandising Link" page, else "DVD detail" page, else small image|5=Cover from "DVD detail" page, else "Merchandising Link", else small image
  31. MPAA=2|0|0=Do not import MPAA rating|1=Import MPAA rating to MediaType|2=Append MPAA rating and info to Comments
  32. MultipleValuesCountry=1|1|0=Only take first value for Country|1=Take full list, separated by commas|2=Take full list, separated by slashes|3=Do not import Country
  33. MultipleValuesCategory=1|1|0=Only take first value for Category|1=Take full list, separated by commas|2=Take full list, separated by slashes|3=Do not import Category
  34. MultipleValuesLanguages=1|1|0=Only take first value for Languages|1=Take full list, separated by commas|2=Take full list, separated by slashes|3=Do not import Languages
  35. MultipleValuesAudioFormat=1|1|0=Only take first value for Audio Format|1=Take full list, separated by commas|2=Take full list, separated by slashes|3=Do not import Audio Format / Sound Mix
  36. PopularSearches=1|1|0=Do not use the popular searches page, directly show full search results|1=Show popular searches first, I'll click on "Find more" if needed (much faster)
  37. Producer=0|0|0=Do not get producer, put writer in the producer field instead|1=Get producer
  38. Trivia=0|0|0=Do not import trivia|1=Import short trivia to Description field, after the summary|2=Import short trivia to Comments field, after the comments|3=Import full trivia to Description field, after the summary|4=Import full trivia to Comments field, after the comments
  39. UserRatings=0|0|0=Import value to ratings field only (default)|1=Import value and number of votes to Media Type field|2=Import value and number of votes to comments field
  40. ConvertToASCII=0|0|0=Do not change special characters and accents.|1=Replace special characters and accents by basic ASCII characters
  41. EpisodeTitleSearch=0|0|0=Use "Find more" button on results list for next result pages if available (default)|1=Use "Find more" button on results list for episode title search instead
  42.  
  43. ***************************************************)
  44.  
  45. program IMDB;
  46.  
  47. uses
  48. StringUtils1;
  49.  
  50. // ***** Manually set UserCountry to your required Classification Country below *****
  51. const
  52. //UserCountry = '';
  53. { Delete the line above and remove the "//" in front of one the
  54. following lines, or add your country if it is not listed }
  55. //UserCountry = 'USA';
  56. //UserCountry = 'Canada';
  57. //UserCountry = 'Mexico';
  58. //UserCountry = 'Brazil';
  59. //UserCountry = 'Argentina';
  60. //UserCountry = 'Australia';
  61. //UserCountry = 'India';
  62. //UserCountry = 'Italy';
  63. UserCountry = 'Spain';
  64. //UserCountry = 'Portugal';
  65. //UserCountry = 'France';
  66. //UserCountry = 'Germany';
  67. //UserCountry = 'Netherlands';
  68. //UserCountry = 'UK';
  69. //UserCountry = 'Ireland';
  70. //UserCountry = 'Finland';
  71. //UserCountry = 'Norway';
  72. //UserCountry = 'Sweden';
  73. //UserCountry = 'Switzerland';
  74.  
  75. PopularTitleSearchURL = 'http://www.imdb.com/find?tt=1;q=';
  76. FullTitleSearchURL = 'http://www.imdb.com/find?more=tt;q=';
  77. EpisodeTitleSearchURL = 'http://www.imdb.com/find?s=tt;ttype=ep;q=';
  78.  
  79. var
  80. MovieName: string;
  81. MovieURL: string;
  82. MovieNumber: string;
  83. UpdateFile: TStringList;
  84.  
  85. function ConvertToASCII(AText: string): string;
  86. begin
  87. Result := AText;
  88. if GetOption('ConvertToASCII') = 1 then
  89. begin
  90. if StringUtils1_Version > 5 then
  91. Result := Cp1252ToASCII(AText)
  92. else
  93. ShowMessage('The "ConvertToASCII" option requires a newer version of StringUtils1.pas (at least version 6).' + #13#10 + 'Run the "Update Scripts" script to get it.');
  94. end;
  95. end;
  96.  
  97. // ***** analyzes IMDB's results page that asks to select a movie from a list *****
  98.  
  99. procedure AnalyzeResultsPage(Address: string);
  100. var
  101. PageText: string;
  102. Value: string;
  103. begin
  104. PageText := ConvertToASCII(GetPage(Address));
  105. if ((GetOption('BatchMode') = 2) and (GetField(fieldURL)<>'')) or (pos('<title>IMDb', PageText) = 0) then
  106. begin
  107. AnalyzeMoviePage(PageText)
  108. end
  109. else
  110. begin
  111. if Pos('<b>No Matches.</b>', PageText) > 0 then
  112. begin
  113. if GetOption('BatchMode') = 0 then
  114. ShowMessage('No movie found for this search.');
  115. Exit;
  116. end;
  117. if GetOption('BatchMode') = 0 then
  118. begin
  119. PickTreeClear;
  120. repeat
  121. Value := TextBefore(PageText, '</b> (Displaying', '<p><b>');
  122. if Value <> '' then
  123. begin
  124. HTMLRemoveTags(Value);
  125. HTMLDecode(Value);
  126. PickTreeAdd(Value, '');
  127. end;
  128. Value := TextBetween(PageText, '<table><tr>', '</table>');
  129. PageText := RemainingText;
  130. until not AddMovieTitles(Value);
  131. Value := TextBefore(PageText, '"><b>more titles</b></a>', '<a href="');
  132. if Value <> '' then
  133. PickTreeMoreLink('http://www.imdb.com' + Value);
  134. if GetOption('EpisodeTitleSearch') > 0 then
  135. PickTreeMoreLink(EpisodeTitleSearchURL + UrlEncode(MovieName));
  136. if PickTreeExec(Address) then
  137. AnalyzeResultsPage(Address);
  138. end
  139. else
  140. begin
  141. Value := TextBetween(PageText, '.</td><td valign="top">', '</a>');
  142. if Value <> '' then
  143. AnalyzeResultsPage('http://www.imdb.com' + TextBetween(Value, '<a href="', '" onclick="'));
  144. end;
  145. end;
  146. end;
  147.  
  148. // ***** analyzes Google's results page that asks to select a movie from a list *****
  149.  
  150. procedure AnalyzeGooglesResultsPage(GoogleAddress: string);
  151. var
  152. PageText: string;
  153. Value: string;
  154. Address: string;
  155. begin
  156. PageText := GetPage(GoogleAddress);
  157. Address := '';
  158. if Pos('did not match any documents', PageText) > 0 then
  159. begin
  160. ShowMessage('No movie found for this search');
  161. Exit;
  162. end;
  163. if GetOption('BatchMode') = 0 then
  164. begin
  165. PickTreeClear;
  166. PickTreeAdd('Google`s search results for "' + MovieName + '" on IMDB:', '');
  167. repeat
  168. Value := TextBetween(PageText, '<h3 class=r>', '</a>');
  169. PageText := RemainingText;
  170. Address := TextBetween(Value, '<a href="', 'maindetails"');
  171. if (GetOption('AllActors') = 1) or (GetOption('Producer') = 1) then
  172. if Address <> '' then
  173. Address := Address + 'combined';
  174. HTMLRemoveTags(Value);
  175. HTMLDecode(Value);
  176. if (Pos(') - ', Value) = 0) and (Value <> '') and (Address <> '') then
  177. PickTreeAdd(Value, Address);
  178. until Value = '';
  179. if PickTreeExec(GoogleAddress) then
  180. AnalyzeResultsPage(GoogleAddress);
  181. end
  182. else
  183. begin
  184. Value := TextBetween(PageText, '<h3 class=r>', '</a>');
  185. Address := TextBetween(Value, '<a href="', 'maindetails"');
  186. if (GetOption('AllActors') = 1) or (GetOption('Producer') = 1) then
  187. if Address <> '' then
  188. Address := Address + 'combined';
  189. if Address <> '' then
  190. AnalyzeResultsPage(Address);
  191. end;
  192. end;
  193.  
  194. // ***** adds the movie titles found on IMDB's results page *****
  195.  
  196. function AddMovieTitles(List: string): Boolean;
  197. var
  198. Value: string;
  199. Address: string;
  200. begin
  201. Result := False;
  202. Value := TextBetween(List, '.</td><td valign="top">', '</td>');
  203. if GetOption('HideAkaTitles') = 1 then
  204. Value := StringReplace(Value, TextAfter(Value, '<p class="find-aka">'), '')
  205. else
  206. Value := StringReplace(Value, 'aka', ' | aka');
  207. List := RemainingText;
  208. while Value <> '' do
  209. begin
  210. Address := TextBetween(Value, '<a href="/title/tt', '/');
  211. // ##########
  212. // if (GetOption('AllActors') = 1) or (GetOption('Producer') = 1) then
  213. // Address := Address + '/combined'
  214. // else
  215. // Address := Address + '/';
  216. Address := Address + '/combined';
  217. // ##########
  218. HTMLRemoveTags(Value);
  219. HTMLDecode(Value);
  220. // if GetOption('HideAkaTitles') = 1 then
  221. // Value := Value + ')';
  222. PickTreeAdd(Value, 'http://www.imdb.com/title/tt' + Address);
  223. Result := True;
  224. Value := TextBetween(List, '.</td><td valign="top">', '</td>');
  225. if GetOption('HideAkaTitles') = 1 then
  226. Value := StringReplace(Value, TextAfter(Value, '<br>&#160;'), '')
  227. else
  228. Value := StringReplace(Value, 'aka', ' | aka');
  229. List := RemainingText;
  230. end;
  231. end;
  232.  
  233. // ***** analyzes the page containing movie information *****
  234.  
  235. procedure AnalyzeMoviePage(PageText: string);
  236. var
  237. Value, Value2, Value3, ValueAlt, FullValue: string;
  238. p, Count: Integer;
  239. begin
  240. MovieNumber := TextBetween(PageText, '<input type="hidden" name="auto" value="legacy/title/tt', '/');
  241. if MovieNumber = '' then
  242. MovieNumber := TextBetween(PageText, '<input type="hidden" name="auto" value="legacy/title/tt', '/combined"');
  243. if MovieNumber = '' then
  244. MovieNumber := TextBetween(PageText, '<link rel="canonical" href="http://www.imdb.com/title/tt', '/');
  245. // #########
  246. // if ((GetOption('AllActors') = 1) or (GetOption('Producer') = 1)) and (Pos('<div id="tn15" class="maindetails">', PageText) > 0) then
  247. // PageText := ConvertToASCII(GetPage('http://www.imdb.com/title/tt' + MovieNumber + '/combined'));
  248. if Pos('/combined"', TextBetween(PageText, '<link rel="canonical"', '/>')) = 0 then
  249. PageText := ConvertToASCII(GetPage('http://www.imdb.com/title/tt' + MovieNumber + '/combined'));
  250. // #########
  251. MovieURL := 'http://imdb.com/title/tt' + MovieNumber;
  252. // URL
  253. if CanSetField(fieldURL) then
  254. SetField(fieldURL, MovieURL);
  255. // OriginalTitle & TranslatedTitle & Year
  256. if CanSetField(fieldOriginalTitle) or CanSetField(fieldYear) or CanSetField(fieldTranslatedTitle) then
  257. begin
  258. Value := TextBetween(PageText, '<title>', '</title>');
  259. ValueAlt := TextBetween(PageText, '<span class="title-extra">','<i>');
  260. p := Pos('></span', ValueAlt);
  261. if p > 0 then
  262. ValueAlt := '';
  263. p := Pos(' (1', Value);
  264. if p = 0 then
  265. p := Pos(' (2', Value);
  266. Value2 := Copy(Value, 0, p-1);
  267. Value := Copy(Value, p+2, Length(Value));
  268. HTMLDecode(Value2);
  269. HtmlDecode(ValueAlt);
  270.  
  271. if CanSetField(fieldTranslatedTitle) then
  272. SetField(fieldTranslatedTitle, Value2);
  273.  
  274. if CanSetField(fieldOriginalTitle) then
  275. if ValueAlt <> '' then
  276. SetField(fieldOriginalTitle, ValueAlt)
  277. else
  278. SetField(fieldOriginalTitle, Value2);
  279. if Pos('/', Value) > 0 then
  280. Value2 := TextBefore(Value, '/', '')
  281. else
  282. Value2 := TextBefore(Value, ')', '');
  283. if CanSetField(fieldYear) then
  284. SetField(fieldYear, Value2);
  285. end;
  286.  
  287. // Picture
  288. if CanSetPicture then
  289. begin
  290. case GetOption('ImageKind') of
  291. 2: if not ImportSmallPicture(PageText) then
  292. ImportPictureNotAvailable(PageText);
  293. 3: if not ImportLargePicture(PageText) then
  294. if not ImportSmallPicture(PageText) then
  295. ImportPictureNotAvailable(PageText);
  296. 4: if not ImportMerchandisingPicture then
  297. if not ImportDvdDetailsPicture then
  298. ImportSmallPicture(PageText);
  299. 5: if not ImportDvdDetailsPicture then
  300. if not ImportMerchandisingPicture then
  301. ImportSmallPicture(PageText);
  302. else
  303. ImportSmallPicture(PageText);
  304. end;
  305. end;
  306. // Director
  307. if CanSetField(fieldDirector) then
  308. begin
  309. Value := TextBetween(PageText, '<h5>Director:', '</div>');
  310. if Value = '' then
  311. Value := TextBetween(PageText, '<h5>Director', '</div>');
  312. if Pos(':<', Value) > 0 then
  313. Value := '<' + TextAfter(Value, ':<');
  314. if Pos('<p>', Value) > 0 then
  315. Value := TextBetween(Value, '<p>', '</p>');
  316. Value := StringReplace(Value, '<br/>', ',');
  317. HTMLRemoveTags(Value);
  318. HTMLDecode(Value);
  319. Value := StringReplace(Value, ', more', '');
  320. Value := StringReplace(Value, ', (more)', '');
  321. Value := StringReplace(Value, ' ', '');
  322. Value := StringReplace(Value, #13, '');
  323. Value := StringReplace(Value, #10, '');
  324. Value := StringReplace(Value, #9, '');
  325. Value := StringReplace(Value, ',', ', ');
  326. if Copy(Value, Length(Value) - 1, 2) = ', ' then
  327. Value := Copy(Value, 0, Length(Value) - 2);
  328. SetField(fieldDirector, Value);
  329. end;
  330. // Actors
  331. if CanSetField(fieldActors) then
  332. begin
  333. Value := FullTrim(TextBetween(PageText, '<table class="cast">', '</table>'));
  334. if Value <> '' then
  335. begin
  336. FullValue := '';
  337. Count := 0;
  338. case GetOption('ActorsLayout') of
  339. 0, 1:
  340. while Pos('<tr', Value) > 0 do
  341. begin
  342. Value2 := TextBetween(Value, '<tr', '</tr>');
  343. Value := RemainingText;
  344. if Pos('rest of cast', Value2) > 0 then
  345. Continue;
  346. if FullValue <> '' then
  347. FullValue := FullValue + #13#10;
  348. TextBefore(Value2, '</td>', '');
  349. Value2 := FullTrim(TextBetween(Value2, '<td class="nm">', '</td>'));
  350. HTMLRemoveTags(Value2);
  351. if Value2 <> '' then
  352. begin
  353. FullValue := FullValue + Value2;
  354. Count := Count + 1;
  355. end;
  356. // ###
  357. if (Count = 15) and (GetOption('AllActors') = 0) then
  358. Break;
  359. // ###
  360. if (Count = 10) and (GetOption('AllActors') = 2) then
  361. Break;
  362. end;
  363. 2, 3:
  364. while Pos('<tr', Value) > 0 do
  365. begin
  366. Value2 := TextBetween(Value, '<tr', '</tr>');
  367. Value := RemainingText;
  368. if Pos('rest of cast', Value2) > 0 then
  369. Continue;
  370. if FullValue <> '' then
  371. FullValue := FullValue + #13#10;
  372. TextBefore(Value2, '</td>', '');
  373. Value2 := FullTrim(TextBetween(Value2, '<td class="nm">', '</td>'));
  374. HTMLRemoveTags(Value2);
  375. if Value2 <> '' then
  376. begin
  377. FullValue := FullValue + Value2;
  378. Value2 := FullTrim(TextBetween(RemainingText, '"char">', '</td>'));
  379. if Value2 <> '' then
  380. FullValue := FullValue + ' (as ' + Value2 + ')';
  381. Count := Count + 1;
  382. // ###
  383. if (Count = 15) and (GetOption('AllActors') = 0) then
  384. Break;
  385. // ###
  386. if (Count = 10) and (GetOption('AllActors') = 2) then
  387. Break;
  388. end;
  389. end;
  390. 4:
  391. begin
  392. FullValue := Value;
  393. FullValue := StringReplace(FullValue, ' <tr><td align="center" colspan="4"><small>rest of cast listed alphabetically:</small></td></tr>', '');
  394. FullValue := StringReplace(FullValue, '> <', '><');
  395. FullValue := StringReplace(FullValue, '</tr>', #13#10);
  396. end;
  397. end;
  398. HTMLRemoveTags(FullValue);
  399. HTMLDecode(FullValue);
  400. case GetOption('ActorsLayout') of
  401. 0, 2:
  402. FullValue := StringReplace(FullValue, #13#10, ', ');
  403. end;
  404. SetField(fieldActors, FullValue);
  405. end;
  406. end;
  407. //Country
  408. if CanSetField(fieldCountry) then
  409. begin
  410. SetField(fieldCountry, ImportList(PageText, GetOption('MultipleValuesCountry'), '/country/'));
  411. end;
  412. //Category
  413. if CanSetField(fieldCategory) then
  414. begin
  415. SetField(fieldCategory, ImportList(PageText, GetOption('MultipleValuesCategory'), '/Genres/'));
  416. end;
  417. // Language
  418. if CanSetField(fieldLanguages) then
  419. begin
  420. SetField(fieldLanguages, ImportList(PageText, GetOption('MultipleValuesLanguages'), '/language/'));
  421. end;
  422. // Audio Format
  423. if CanSetField(fieldAudioFormat) then
  424. begin
  425. SetField(fieldAudioFormat, ImportList(PageText, GetOption('MultipleValuesAudioFormat'), '/search/title?sound_mixes='));
  426. end;
  427. // Aspect Ratio
  428. begin
  429. Value := '';
  430. Value := TextBetween(PageText, '<h5>Aspect Ratio:</h5>', '</div>');
  431. if Pos('<p>', Value) > 0 then
  432. Value := TextBetween(Value, '<p>', '</p>');
  433. if Pos('<a ', Value) > 0 then
  434. Value := TextBefore(Value, '<a ', '');
  435. HTMLRemoveTags(Value);
  436. HTMLDecode(Value);
  437. Value := FullTrim(Value);
  438. Value := StringReplace(Value, ', more', '');
  439. Value := StringReplace(Value, ', (more)', '');
  440. Value := StringReplace(Value, ' more', '');
  441. if (CanSetField(fieldVideoFormat)) and (GetOption('AspectRatio') = 1) then
  442. SetField(fieldVideoFormat, Value);
  443. if (CanSetField(fieldResolution)) and (GetOption('AspectRatio') = 2) then
  444. SetField(fieldResolution, Value);
  445. end;
  446. // Description
  447. if CanSetField(fieldDescription) then
  448. begin
  449. Value := TextBetween(PageText, '<h5>Plot:</h5>', '</div>');
  450. if Value = '' then
  451. Value := TextBetween(PageText, '<h5>Plot Summary:</h5>', '</div>');
  452. if Pos('<p>', Value) > 0 then
  453. Value := TextBetween(Value, '<p>', '</p>');
  454. Value := StringReplace(Value, '<div class="info-content">', '');
  455. Value := StringReplace(Value, Textbetween(Value, '| <a class="tn15more inline" href="synopsis">', '</a>'), '');
  456. Value := StringReplace(Value, Textbetween(Value, '<a class="tn15more inline" href="synopsis">', '</a>'), '');
  457. Value := StringReplace(Value, '| <a class="tn15more inline" href="synopsis"></a>', '');
  458. Value := StringReplace(Value, '<a class="tn15more inline" href="synopsis"></a>', '');
  459. Value := StringReplace(Value, '&raquo;', '');
  460. if (Value = #13#10 + #13#10) or (Value = #13#10) then
  461. Value := '';
  462. if (GetOption('DescriptionSelection') = 0) and (Pos('<a class="tn15more inline"', Value) > 0) then
  463. Value := TextAfter(Value, #13#10);
  464. if Value <> '' then
  465. SetField(fieldDescription, ImportSummary(Value));
  466. end;
  467. // Length
  468. if CanSetField(fieldLength) then
  469. begin
  470. Value := TextBetween(PageText, '<h5>Runtime:</h5>', '</div>');
  471. if Pos('<p>', Value) > 0 then
  472. Value := TextBetween(Value, '<p>', '</p>');
  473. Value := TextBefore(Value, ' min', '');
  474. HTMLRemoveTags(Value);
  475. Value := FullTrim(Value);
  476. if Value <> '' then
  477. begin
  478. if Pos(':', Value) > 0 then
  479. SetField(fieldLength, TextAfter(Value, ':'))
  480. else
  481. SetField(fieldLength, Value);
  482. end;
  483. end;
  484. // Writer (Producer Field)
  485. if CanSetField(fieldProducer) then
  486. begin
  487. if GetOption('Producer') = 1 then
  488. begin
  489. Value := TextBetween(PageText, 'Produced by</a></h5>', '</table>');
  490. FullValue := '';
  491. Value2 := TextBetween(Value, '<a href="/name/', '</a>');
  492. while Value2 <> '' do
  493. begin
  494. Value := RemainingText;
  495. Value2 := TextAfter(Value2, '">');
  496. if FullValue <> '' then
  497. FullValue := FullValue + ', ';
  498. FullValue := FullValue + Value2;
  499. Value2 := TextBetween(Value, '<a href="/name/', '</a>');
  500. end;
  501. HTMLDecode(FullValue);
  502. SetField(fieldProducer, FullValue);
  503. end
  504. else
  505. begin
  506. Value := TextBetween(PageText, '<h5>Writer', '</div>');
  507. if Pos(':<', Value) > 0 then
  508. Value := '<' + TextAfter(Value, ':<');
  509. if Pos('<p>', Value) > 0 then
  510. Value := TextBetween(Value, '<p>', '</p>');
  511. Value := StringReplace(Value, '<br/>', ',');
  512. Value := StringReplace(Value, '>more<', '><');
  513. HTMLRemoveTags(Value);
  514. HTMLDecode(Value);
  515. if Value <> '' then
  516. begin
  517. Value := StringReplace(Value, '..., more', '');
  518. Value := StringReplace(Value, ', more', '');
  519. Value := StringReplace(Value, '...', '');
  520. Value := StringReplace(Value, ' &', '');
  521. Value := StringReplace(Value, ' ', '');
  522. Value := StringReplace(Value, #13, '');
  523. Value := StringReplace(Value, #10, '');
  524. Value := StringReplace(Value, #9, '');
  525. Value := StringReplace(Value, ',', ', ');
  526. Value := FullTrim(StringReplace(Value, ' and, ', ', '));
  527. if Value <> '' then
  528. while StrGet(Value, Length(Value)) = ',' do
  529. begin
  530. Delete(Value, Length(Value), 1);
  531. Value := FullTrim(Value);
  532. end;
  533. SetField(fieldProducer, Value);
  534. end;
  535. end;
  536. end;
  537. // Comments
  538. if CanSetField(fieldComments) then
  539. begin
  540. if (GetOption('CommentType') = 1) then
  541. begin
  542. Value := TextAfter(PageText,'/rg/title-nav-item/usercomments/');
  543. if (Value <> '') or (Pos('href="usercomments" class="link"', PageText) > 0) then
  544. begin
  545. Value2 := '';
  546. FullValue := ConvertToASCII(GetPage(MovieURL+'/usercomments'));
  547. FullValue := TextAfter(FullValue, 'review useful:</small><br>');
  548. while FullValue <> '' do
  549. begin
  550. Value := TextBetween(FullValue, '<b>', '<div');
  551. Value2 := Value2 + #13#10 + #13#10 + TextBefore(Value, '</b>', '');
  552. Value := RemainingText;
  553. Value2 := Value2 + #13#10 + 'Date: ' + TextBetween(Value, '<small>', '</small>');
  554. Value := RemainingText;
  555. Value := 'Author: ' + TextBetween(Value, 'comments">', '<br>');
  556. HtmlRemoveTags(Value);
  557. Value2 := Value2 + #13#10 + Value;
  558. Value := RemainingText;
  559. Value := TextBetween(Value, '<p>' + #13#10, #13#10 + '</p>');
  560. Value := StringReplace(Value, #13#10, ' ');
  561. Value := StringReplace(Value, '<br><br>', #13#10);
  562. Value := StringReplace(Value, '<br>', #13#10);
  563. HtmlDecode(Value);
  564. Value2 := Value2 + #13#10 + #13#10 + FullTrim(Value);
  565. FullValue := TextAfter(FullValue, 'review useful:</small><br>');
  566. end;
  567. HTMLRemoveTags(Value2);
  568. HTMLDecode(Value2);
  569. SetField(fieldComments, 'USER COMMENTS:' + Value2 + #13#10);
  570. end;
  571. end
  572. else
  573. if (GetOption('CommentType') = 0) then
  574. begin
  575. Value := TextAfter(PageText, '/comments">');
  576. if Value <> '' then
  577. begin
  578. Value := TextBetween(Value, '<p>', '</p>');
  579. Value := StringReplace(Value, #13#10, ' ');
  580. Value := StringReplace(Value, '<br>', #13#10);
  581. HTMLRemoveTags(Value);
  582. HTMLDecode(Value);
  583. Value := FullTrim(Value);
  584. while Pos(' ', Value) > 0 do
  585. Value := StringReplace(Value, ' ', ' ');
  586. while Pos(#13#10, Value) = 1 do
  587. Delete(Value, 1, 2);
  588. SetField(fieldComments, Value + #13#10);
  589. end;
  590. end
  591. else
  592. if (GetOption('CommentType') = 2) then
  593. SetField(fieldComments, '');
  594. end;
  595. // TagLine
  596. if GetOption('GetTagline') > 0 then
  597. begin
  598. Value := TextBetween(PageText, '<h5>Tagline:</h5>', '</div>');
  599. if Pos('<p>', Value) > 0 then
  600. Value := TextBetween(Value, '<p>', '</p>');
  601. if Pos('<a', Value) > 0 then
  602. Value := TextBefore(Value, '<a', '');
  603. Value := TextAfter(Value, #13#10);
  604. HTMLRemoveTags(Value);
  605. HTMLDecode(Value);
  606. Value := FullTrim(Value);
  607. if Value <> '' then
  608. begin
  609. if StrGet(Value, 1) <> '"' then
  610. Value := '"' + Value + '"';
  611. case GetOption('GetTagline') of
  612. 1:
  613. begin
  614. if GetField(fieldDescription) <> '' then
  615. Value := Value + #13#10 + #13#10 + GetField(fieldDescription);
  616. SetField(fieldDescription, Value);
  617. end;
  618. 2:
  619. begin
  620. if GetField(fieldComments) <> '' then
  621. Value := Value + #13#10 + #13#10 + GetField(fieldComments);
  622. SetField(fieldComments, Value);
  623. end;
  624. end;
  625. end;
  626. end;
  627. // Trivia
  628. if GetOption('Trivia') > 0 then
  629. begin
  630. sleep(50);
  631. Value := MovieUrl;
  632. FullValue := ConvertToASCII(GetPage(Value+'/trivia'));
  633. case GetOption('Trivia') of
  634. 1,2:
  635. Value := TextBetween(FullValue, '<div class="sodatext">', '</div>');
  636. 3,4:
  637. Value := TextBetween(FullValue, '<div class="list">', '<div id="sidebar">');
  638. end;
  639. if Value <> '' then
  640. begin
  641. Value := StringReplace(Value, #13#10, '');
  642. while Pos(' ', Value) > 0 do
  643. Value := StringReplace(Value, ' ', '');
  644. while Pos('<span class="linksoda">', Value) > 0 do
  645. begin
  646. Value := StringReplace(Value, TextBetween(Value, '<span class="linksoda">', '</div>'), '');
  647. Value := StringReplace(Value, '<span class="linksoda"></div>', '');
  648. end;
  649. Value := StringReplace(Value, 'Link this trivia', '');
  650. Value := StringReplace(Value, '<div class="sodatext">', #13#10 + '- ');
  651. HTMLRemoveTags(Value);
  652. HTMLDecode(Value);
  653. case GetOption('Trivia') of
  654. 1,3:
  655. begin
  656. if GetField(fieldDescription) <> '' then
  657. Value := GetField(fieldDescription) + #13#10 + #13#10 + 'IMDB TRIVIA: ' + Value
  658. else
  659. Value := 'IMDB TRIVIA: ' + Value;
  660. SetField(fieldDescription, Value);
  661. end;
  662. 2,4:
  663. begin
  664. if GetField(fieldComments) <> '' then
  665. Value := GetField(fieldComments) + #13#10 + #13#10 + 'IMDB TRIVIA: ' + Value
  666. else
  667. Value := 'IMDB TRIVIA: ' + Value;
  668. SetField(fieldComments, Value);
  669. end;
  670. end;
  671. end;
  672. end;
  673. // Awards
  674. if (GetOption('Awards') > 0) then
  675. begin
  676. ImportAwards();
  677. end;
  678. // Rating
  679. if CanSetField(fieldRating) then
  680. begin
  681. // (Remove the "//" of the next two lines beginning with "Value" and add "//" to the following two lines beginning with Value
  682. // if you would like to import arithmetic ratings instead of IMDB's user ratings)
  683. // Value := ConvertToASCII(GetPage(MovieURL + '/ratings'));
  684. // Value := TextBetween(Value, 'Arithmetic mean = ', '. ');
  685. Value := TextBetween(PageText, '<h5>User Rating:</h5>', '</b>');
  686. Value := TextBetween(Value, '<b>', '/');
  687. if Value <> '' then
  688. SetField(fieldRating, Value);
  689. end;
  690. if GetOption('UserRatings') > 0 then
  691. begin
  692. Value := TextBetween(PageText, '<a href="ratings" class="tn15more">', '</a>');
  693. if Value <> '' then
  694. Value := 'User Rating: ' + GetField(fieldRating) + ' out of 10 (with ' + Value + ')';
  695. if (GetOption('UserRatings') = 1) and (Value <> '') and (CanSetField(fieldMediaType)) then
  696. SetField(fieldMediaType, Value);
  697. if (GetOption('UserRatings') = 2) and (Value <> '') then
  698. SetField(fieldComments, GetField(fieldComments) + #13#10 + #13#10 + Value);
  699. end;
  700. // Classification
  701. if GetOption('Classification') > 0 then
  702. begin
  703. if UserCountry = '' then
  704. ShowMessage('Country not set for classification selection - Click "Editor" tab in the scripting window, then select your country by modifying the required line as explained in the first lines of the code')
  705. else
  706. begin
  707. Value := TextBetween(PageText, '<a href="/search/title?certificates=', '</div>');
  708. Value := TextBetween(Value, UserCountry + ':', '</a>'); if Value <> '' then
  709. begin
  710. if GetOption('Classification') = 1 then
  711. SetField(fieldMediaType, Value)
  712. else
  713. SetField(fieldComments, GetField(fieldComments) + #13#10 + #13#10 + 'Classification: ' + Value);
  714. end;
  715. end;
  716. end;
  717. // MPAA rating
  718. if (GetOption('MPAA') > 0) then
  719. begin
  720. Value := FullTrim(TextBetween(PageText, '<h5><a href="/mpaa">MPAA</a>:</h5>', '</div>'));
  721. if Pos('<p>', Value) > 0 then
  722. Value := TextBetween(Value, '<p>', '</p>');
  723. HTMLRemoveTags(Value);
  724. Value := FullTrim(Value);
  725. // Value := TextAfter(Value, #13#10);
  726. if Value <> '' then
  727. begin
  728. if GetOption('MPAA') = 1 then
  729. SetField(fieldMediaType, TextBetween(Value, 'Rated ', ' '))
  730. else
  731. SetField(fieldComments, GetField(fieldComments) + #13#10 + #13#10 + Value);
  732. end;
  733. end;
  734. end;
  735.  
  736. // ***** Imports lists like Genre, Country, etc. depending of the selected option *****
  737.  
  738. function ImportList(PageText: string; MultipleValues: Integer; StartTag: string): string;
  739. var
  740. Value, Value2: string;
  741. begin
  742. if MultipleValues = 0 then
  743. begin
  744. Value := TextBetween(PageText, StartTag, '</a>');
  745. Value2 := TextAfter(Value, '">');
  746. end
  747. else
  748. begin
  749. Value := TextBetween(PageText, StartTag, '</div>');
  750. Value2 := TextBefore(Value, '<a class="tn15more inline"', '');
  751. if Value2 = '' then
  752. Value2 := Value;
  753. Value2 := TextAfter(Value2, '">');
  754. HTMLRemoveTags(Value2);
  755. if MultipleValues = 1 then
  756. Value2 := StringReplace(Value2, ' | ', ', ');
  757. if MultipleValues = 2 then
  758. Value2 := StringReplace(Value2, ' | ', ' / ');
  759. if MultipleValues = 3 then
  760. Value2 := '';
  761. end;
  762. Value2 := StringReplace(Value2, #13#10, '');
  763. Value2 := StringReplace(Value2, ' , ', ', ');
  764. HTMLDecode(Value2);
  765. Result := FullTrim(Value2);
  766. end;
  767.  
  768. // ***** functions to import the different pictures kinds, depending of the option selected by user *****
  769.  
  770. //Import small picture from IMDB movie main page
  771. function ImportSmallPicture(PageText: string): Boolean;
  772. var
  773. Value: string;
  774. begin
  775. Result := False;
  776. Value := TextBetween(PageText, '<div class="photo">', '</div>');
  777. if (Value <> '') and (Pos('"Poster Not Submitted"', Value) = 0) then
  778. begin
  779. Value := TextBetween(Value, 'src="', '"');
  780. if Value <> '' then
  781. begin
  782. GetPicture(Value);
  783. Result := True;
  784. end;
  785. end;
  786. end;
  787.  
  788. //Import large image from link on IMDB movie main page
  789. function ImportLargePicture(PageText: string): Boolean;
  790. var
  791. Value: string;
  792. begin
  793. Result := False;
  794. Value := TextBetween(PageText, '<div class="photo">', '</div>');
  795. if (Value <> '') and (Pos('"Poster Not Submitted"', Value) = 0) and (Pos('<a name="poster" href="/rg/action-box-title/primary-photo', Value) > 0) then
  796. begin
  797. Value := TextBetween(Value, 'href="/rg/action-box-title/primary-photo', '"');
  798. if Value <> '' then
  799. begin
  800. Value := 'http://www.imdb.com' + Value;
  801. Value := GetPage(Value);
  802. Value := TextBetween(Value, '<div class="primary">', '</div>');
  803. if (Value <> '') and (Pos(' src="', Value) > 0) then
  804. begin
  805. Value := TextBetween(Value, ' src="', '"');
  806. GetPicture(Value);
  807. Result := True;
  808. end;
  809. end;
  810. end;
  811. end;
  812.  
  813. //Image not available, import "No Poster Available" icon
  814. function ImportPictureNotAvailable(PageText: string): Boolean;
  815. var
  816. Value: string;
  817. begin
  818. Result := False;
  819. Value := TextBetween(PageText, '<div class="photo">', '</div>');
  820. if (Value <> '') and (Pos('"Poster Not Submitted"', Value) > 0) then
  821. begin
  822. Value := TextBetween(Value, 'src="', '"');
  823. if Value <> '' then
  824. begin
  825. GetPicture(Value);
  826. Result := True;
  827. end;
  828. end;
  829. end;
  830.  
  831. //Image from DVD Details Page
  832. function ImportDvdDetailsPicture: Boolean;
  833. var
  834. Value, PageText: string;
  835. begin
  836. Result := False;
  837. PageText := ConvertToASCII(GetPage(MovieUrl+'/dvd'));
  838. Value := TextBefore(PageText, '.jpg alt="', '<table class="dvd_section" cellpadding="10"><tr>');
  839. if Value <> '' then
  840. begin
  841. Value := TextBetween(Value, '<a href="', '">');
  842. if Value <> '' then
  843. Result := ImportFromAmazonRedirect('http://www.imdb.com' + Value);
  844. end;
  845. end;
  846.  
  847. //Image from Merchandising Links (/sales) Page
  848. function ImportMerchandisingPicture: Boolean;
  849. var
  850. Value, PageText: string;
  851. begin
  852. Result := False;
  853. PageText := ConvertToASCII(GetPage(MovieUrl+'/sales'));
  854. Value := TextBefore(PageText, '.jpg" width=', '<td class=w_rowtable_colcover><a href="');
  855. if Value <> '' then
  856. begin
  857. Value := TextBefore(Value, '"><img', '');
  858. if Value <> '' then
  859. Result := ImportFromAmazonRedirect('http://www.imdb.com' + Value);
  860. end;
  861. end;
  862.  
  863. function ImportFromAmazonRedirect(Url: string): Boolean;
  864. var
  865. Value, PageText: string;
  866. begin
  867. Result := False;
  868. PageText := ConvertToASCII(GetPage(Url));
  869. Value := TextBetween(PageText, '<td id="prodImageCell"', '" id="prodImage"');
  870. // Value := StringReplace(TextAfter(Value, ' src="'), '_AA240', '');
  871. Value := StringReplace(Value, TextBetween(Value, '_AA', '_'), '');
  872. Value := StringReplace(TextAfter(Value, ' src="'), '_AA', '');
  873. if Value <> '' then
  874. begin
  875. GetPicture(Value);
  876. Result := True;
  877. end;
  878. end;
  879.  
  880. // ***** Gets summaries for the movie, based on the plot outline given in parameter (that contains the URL to more summaries) *****
  881.  
  882. function ImportSummary(PlotText: string): string;
  883. var
  884. Address, Value, Value2, Value3, Value4, PageText, Longest: string;
  885. begin
  886. Address := TextBetween(PlotText, '<a class="tn15more inline" href="', '" ');
  887. if (Address = '') or (GetOption('DescriptionSelection') = 0) or (GetOption('DescriptionSelection') = 3) then
  888. begin
  889. Value3 := FullTrim(TextBefore(PlotText, '<a class="tn15more inline"', ''));
  890. if Value3 = '' then
  891. Value3 := FullTrim(PlotText);
  892. HTMLRemoveTags(Value3);
  893. HTMLDecode(Value3);
  894. end;
  895. if (Address <> '') and (GetOption('DescriptionSelection') > 0) then
  896. begin
  897. PageText := ConvertToASCII(GetPage('http://www.imdb.com' + Address));
  898. PickListClear;
  899. Longest := '';
  900. Value := TextBetween(PageText, '<p class="plotpar">', '</p>');
  901. PageText := RemainingText;
  902. while Value <> '' do
  903. begin
  904. Value := TextBefore(Value, '<i>', '');
  905. Value := FullTrim(StringReplace(Value, #13#10, ' '));
  906. Value := StringReplace(Value, '<br>', #13#10);
  907. HTMLRemoveTags(Value);
  908. HTMLDecode(Value);
  909. while Pos(' ', Value) > 0 do
  910. Value := StringReplace(Value, ' ', ' ');
  911. if Length(Value) > Length(Longest) then
  912. Longest := Value;
  913. PickListAdd(FullTrim(Value));
  914. Value := TextBetween(PageText, '<p class="plotpar">', '</p>');
  915. PageText := RemainingText;
  916. end;
  917. if (GetOption('BatchMode') > 0) or (GetOption('DescriptionSelection') = 2) then
  918. Value4 := Longest
  919. else
  920. begin
  921. if not PickListExec('Select a description for "' + GetField(fieldOriginalTitle) + '"', Value4) then
  922. Value4 := '';
  923. end;
  924. end;
  925. if Value3 <> '' then
  926. begin
  927. if Value4 <> '' then
  928. begin
  929. Result := Value3 + #13#10 + #13#10 + Value4;
  930. end
  931. else
  932. begin
  933. Result := Value3;
  934. end;
  935. end
  936. else
  937. begin
  938. Result := Value4;
  939. end;
  940. end;
  941.  
  942. // Import awards
  943. procedure ImportAwards;
  944. var
  945. PageText, FullValue, Block, Value, Row: string;
  946. Year, Result, Award, Category: string;
  947. begin
  948. sleep(50);
  949. Value := MovieUrl;
  950. PageText := ConvertToASCII(GetPage(Value+'/awards'));
  951. PageText := TextBetween(PageText, '<table style=', '</table>');
  952. FullValue := '';
  953. while PageText <> '' do
  954. begin
  955. Block := TextBetween(PageText, '<big>', '<big>');
  956. if Block = '' then
  957. begin
  958. Block := PageText;
  959. PageText := '';
  960. end
  961. else
  962. begin
  963. Block := '<big>' + Block;
  964. PageText := '<big>' + RemainingText;
  965. end;
  966. Value := TextBetween(Block, '<big>', '</big>');
  967. Block := RemainingText;
  968. HTMLRemoveTags(Value);
  969. HTMLDecode(Value);
  970. FullValue := FullValue + #13#10 + '- ' + Value;
  971. Year := '';
  972. Result := '';
  973. repeat
  974. Award := '';
  975. Category := '';
  976. Row := TextBetween(Block, '<tr>', '</tr>');
  977. Block := RemainingText;
  978. if (Pos('<th>Year</th><th>Result</th><th>Award</th><th>Category/Recipient(s)</th>', Row) = 0)
  979. and (Pos('<td colspan="4">&nbsp;</td>', Row) = 0) then
  980. begin
  981. if Pos('<a href="/Sections/Awards', Row) > 0 then
  982. begin
  983. Year := TextBetween(Row, '<a href="/Sections/Awards', '</a>');
  984. Row := RemainingText;
  985. Year := FullTrim(TextAfter(Year, '>'));
  986. end;
  987. if Pos('valign="middle"><b>', Row) > 0 then
  988. begin
  989. Result := TextBetween(Row, 'valign="middle"><b>', '</b></td>');
  990. HTMLDecode(Result);
  991. Row := RemainingText;
  992. end;
  993. if Pos('valign="middle">', Row) > 0 then
  994. begin
  995. Award := TextBetween(Row, 'valign="middle">', '</td>');
  996. HTMLDecode(Award);
  997. Row := RemainingText;
  998. end;
  999. if Award <> '' then
  1000. FullValue := FullValue + #13#10 + ' ' + Year + ' ' + Result + ' "' + Award + '"';
  1001. Category := TextBetween(Row, '<td valign="top">' + #13#10, '<br>');
  1002. if Pos('<a href="/name', Category) > 0 then
  1003. begin
  1004. RemainingText := Category;
  1005. Category := '';
  1006. end;
  1007. HTMLDecode(Category);
  1008. Category := FullTrim(Category);
  1009. Row := StringReplace(StringReplace(RemainingText, #13#10, ''), '<br>', ', ');
  1010. HTMLRemoveTags(Row);
  1011. HTMLDecode(Row);
  1012. Row := FullTrim(Row);
  1013. Row := StringReplace(Row, ' ', '');
  1014. Row := StringReplace(Row, ' ,', ',');
  1015. if Row = ',' then
  1016. Row := '';
  1017. if (Row <> '') or (Category <> '') then
  1018. begin
  1019. FullValue := FullValue + #13#10 + ' ' + Category;
  1020. if Row <> '' then
  1021. begin
  1022. while StrGet(Row, Length(Row)) = ',' do
  1023. begin
  1024. Delete(Row, Length(Row), 1);
  1025. Row := FullTrim(Row);
  1026. end;
  1027. if Category = '' then
  1028. FullValue := FullValue + Row
  1029. else
  1030. FullValue := FullValue + ': ' + Row;
  1031. end;
  1032. end;
  1033. end;
  1034. until Pos('</tr>', Block) = 0;
  1035. end;
  1036. if FullValue <> '' then
  1037. case GetOption('Awards') of
  1038. 1:
  1039. begin
  1040. if GetField(fieldDescription) <> '' then
  1041. Value := GetField(fieldDescription) + #13#10 + #13#10 + 'AWARDS: ' + FullValue
  1042. else
  1043. Value := 'AWARDS: ' + FullValue;
  1044. SetField(fieldDescription, Value);
  1045. end;
  1046. 2:
  1047. begin
  1048. if GetField(fieldComments) <> '' then
  1049. Value := GetField(fieldComments) + #13#10 + #13#10 + 'AWARDS: ' + FullValue
  1050. else
  1051. Value := 'AWARDS: ' + FullValue;
  1052. SetField(fieldComments, Value);
  1053. end;
  1054. end;
  1055. end;
  1056.  
  1057. // ***** beginning of the program *****
  1058.  
  1059. begin
  1060. // Check StringUtils1 version and update if < version 7
  1061. if StringUtils1_Version < 7 then
  1062. begin
  1063. if ShowWarning('Old version of file "Stringutils1.pas" detected: v'+IntToStr(StringUtils1_Version)+#13#10+'The script requires at least version 7.'+#13#10+'Download and install latest version now ?') = True then
  1064. begin
  1065. UpdateFile := TStringList.Create;
  1066. UpdateFile.Text := GetPage('http://update.antp.be/amc/scripts/StringUtils1.pas');
  1067. UpdateFile.SaveToFile(dirScripts + 'StringUtils1.pas');
  1068. UpdateFile.Free;
  1069. ShowInformation('StringUtils1 has been updated. Please restart IMDB script now. Thank you.');
  1070. Exit;
  1071. end
  1072. else
  1073. begin
  1074. ShowInformation('You can download latest version of "StringUtils1.pas" using script "update scripts" or via http://update.antp.be/amc/scripts');
  1075. Exit;
  1076. end;
  1077. end;
  1078. // Check for current AMC version
  1079. if CheckVersion(3,5,0) then
  1080. begin
  1081. MovieName := '';
  1082. if GetOption('BatchMode') = 2 then
  1083. begin
  1084. MovieName := GetField(fieldURL);
  1085. if Pos('imdb.com', MovieName) = 0 then
  1086. MovieName := '';
  1087. end;
  1088. if MovieName = '' then
  1089. MovieName := GetField(fieldOriginalTitle);
  1090. if MovieName = '' then
  1091. MovieName := GetField(fieldTranslatedTitle);
  1092. if GetOption('BatchMode') = 0 then
  1093. begin
  1094. if not Input('IMDB Import', 'Enter the title or the IMDB URL of the movie:', MovieName) then
  1095. Exit;
  1096. end
  1097. else
  1098. Sleep(500);
  1099. if MovieName <> '' then
  1100. begin
  1101. if Pos('imdb.com', MovieName) > 0 then
  1102. AnalyzeResultsPage(MovieName)
  1103. else
  1104. begin
  1105. MovieName := StringReplace(MovieName, '&', 'and');
  1106. if GetOption('GoogleSearch') = 1 then
  1107. AnalyzeGooglesResultsPage('http://www.google.com/search?num=30&q=site:www.imdb.com/title/+' + UrlEncode(MovieName) + '+/maindetails')
  1108. else
  1109. if GetOption('GoogleSearch') = 2 then
  1110. AnalyzeGooglesResultsPage('http://www.google.com/search?num=30&q=site:www.imdb.com/title/+%22' + UrlEncode(MovieName) + '%22+/maindetails')
  1111. else
  1112. begin
  1113. if (GetOption('BatchMode') > 0) or (GetOption('PopularSearches') = 1) then
  1114. AnalyzeResultsPage(PopularTitleSearchURL + UrlEncode(MovieName))
  1115. else
  1116. AnalyzeResultsPage(FullTitleSearchURL + UrlEncode(MovieName));
  1117. end;
  1118. end;
  1119. end;
  1120. end
  1121. else
  1122. ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  1123. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement