Guest User

Untitled

a guest
Aug 11th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.68 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) 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 & Year
  256. if CanSetField(fieldOriginalTitle) or CanSetField(fieldYear) 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. if CanSetField(fieldOriginalTitle) then
  271. if ValueAlt <> '' then
  272. SetField(fieldOriginalTitle, ValueAlt)
  273. else
  274. SetField(fieldOriginalTitle, Value2);
  275. if Pos('/', Value) > 0 then
  276. Value2 := TextBefore(Value, '/', '')
  277. else
  278. Value2 := TextBefore(Value, ')', '');
  279. if CanSetField(fieldYear) then
  280. SetField(fieldYear, Value2);
  281. end;
  282. // Picture
  283. if CanSetPicture then
  284. begin
  285. case GetOption('ImageKind') of
  286. 2: if not ImportSmallPicture(PageText) then
  287. ImportPictureNotAvailable(PageText);
  288. 3: if not ImportLargePicture(PageText) then
  289. if not ImportSmallPicture(PageText) then
  290. ImportPictureNotAvailable(PageText);
  291. 4: if not ImportMerchandisingPicture then
  292. if not ImportDvdDetailsPicture then
  293. ImportSmallPicture(PageText);
  294. 5: if not ImportDvdDetailsPicture then
  295. if not ImportMerchandisingPicture then
  296. ImportSmallPicture(PageText);
  297. else
  298. ImportSmallPicture(PageText);
  299. end;
  300. end;
  301. // Director
  302. if CanSetField(fieldDirector) then
  303. begin
  304. Value := TextBetween(PageText, '<h5>Director:', '</div>');
  305. if Value = '' then
  306. Value := TextBetween(PageText, '<h5>Director', '</div>');
  307. if Pos(':<', Value) > 0 then
  308. Value := '<' + TextAfter(Value, ':<');
  309. if Pos('<p>', Value) > 0 then
  310. Value := TextBetween(Value, '<p>', '</p>');
  311. Value := StringReplace(Value, '<br/>', ',');
  312. HTMLRemoveTags(Value);
  313. HTMLDecode(Value);
  314. Value := StringReplace(Value, ', more', '');
  315. Value := StringReplace(Value, ', (more)', '');
  316. Value := StringReplace(Value, ' ', '');
  317. Value := StringReplace(Value, #13, '');
  318. Value := StringReplace(Value, #10, '');
  319. Value := StringReplace(Value, #9, '');
  320. Value := StringReplace(Value, ',', ', ');
  321. if Copy(Value, Length(Value) - 1, 2) = ', ' then
  322. Value := Copy(Value, 0, Length(Value) - 2);
  323. SetField(fieldDirector, Value);
  324. end;
  325. // Actors
  326. if CanSetField(fieldActors) then
  327. begin
  328. Value := FullTrim(TextBetween(PageText, '<table class="cast">', '</table>'));
  329. if Value <> '' then
  330. begin
  331. FullValue := '';
  332. Count := 0;
  333. case GetOption('ActorsLayout') of
  334. 0, 1:
  335. while Pos('<tr', Value) > 0 do
  336. begin
  337. Value2 := TextBetween(Value, '<tr', '</tr>');
  338. Value := RemainingText;
  339. if Pos('rest of cast', Value2) > 0 then
  340. Continue;
  341. if FullValue <> '' then
  342. FullValue := FullValue + #13#10;
  343. TextBefore(Value2, '</td>', '');
  344. Value2 := FullTrim(TextBetween(Value2, '<td class="nm">', '</td>'));
  345. HTMLRemoveTags(Value2);
  346. if Value2 <> '' then
  347. begin
  348. FullValue := FullValue + Value2;
  349. Count := Count + 1;
  350. end;
  351. // ###
  352. if (Count = 15) and (GetOption('AllActors') = 0) then
  353. Break;
  354. // ###
  355. if (Count = 10) and (GetOption('AllActors') = 2) then
  356. Break;
  357. end;
  358. 2, 3:
  359. while Pos('<tr', Value) > 0 do
  360. begin
  361. Value2 := TextBetween(Value, '<tr', '</tr>');
  362. Value := RemainingText;
  363. if Pos('rest of cast', Value2) > 0 then
  364. Continue;
  365. if FullValue <> '' then
  366. FullValue := FullValue + #13#10;
  367. TextBefore(Value2, '</td>', '');
  368. Value2 := FullTrim(TextBetween(Value2, '<td class="nm">', '</td>'));
  369. HTMLRemoveTags(Value2);
  370. if Value2 <> '' then
  371. begin
  372. FullValue := FullValue + Value2;
  373. Value2 := FullTrim(TextBetween(RemainingText, '"char">', '</td>'));
  374. if Value2 <> '' then
  375. FullValue := FullValue + ' (as ' + Value2 + ')';
  376. Count := Count + 1;
  377. // ###
  378. if (Count = 15) and (GetOption('AllActors') = 0) then
  379. Break;
  380. // ###
  381. if (Count = 10) and (GetOption('AllActors') = 2) then
  382. Break;
  383. end;
  384. end;
  385. 4:
  386. begin
  387. FullValue := Value;
  388. FullValue := StringReplace(FullValue, ' <tr><td align="center" colspan="4"><small>rest of cast listed alphabetically:</small></td></tr>', '');
  389. FullValue := StringReplace(FullValue, '> <', '><');
  390. FullValue := StringReplace(FullValue, '</tr>', #13#10);
  391. end;
  392. end;
  393. HTMLRemoveTags(FullValue);
  394. HTMLDecode(FullValue);
  395. case GetOption('ActorsLayout') of
  396. 0, 2:
  397. FullValue := StringReplace(FullValue, #13#10, ', ');
  398. end;
  399. SetField(fieldActors, FullValue);
  400. end;
  401. end;
  402. //Country
  403. if CanSetField(fieldCountry) then
  404. begin
  405. SetField(fieldCountry, ImportList(PageText, GetOption('MultipleValuesCountry'), '/country/'));
  406. end;
  407. //Category
  408. if CanSetField(fieldCategory) then
  409. begin
  410. SetField(fieldCategory, ImportList(PageText, GetOption('MultipleValuesCategory'), '/Genres/'));
  411. end;
  412. // Language
  413. if CanSetField(fieldLanguages) then
  414. begin
  415. SetField(fieldLanguages, ImportList(PageText, GetOption('MultipleValuesLanguages'), '/language/'));
  416. end;
  417. // Audio Format
  418. if CanSetField(fieldAudioFormat) then
  419. begin
  420. SetField(fieldAudioFormat, ImportList(PageText, GetOption('MultipleValuesAudioFormat'), '/search/title?sound_mixes='));
  421. end;
  422. // Aspect Ratio
  423. begin
  424. Value := '';
  425. Value := TextBetween(PageText, '<h5>Aspect Ratio:</h5>', '</div>');
  426. if Pos('<p>', Value) > 0 then
  427. Value := TextBetween(Value, '<p>', '</p>');
  428. if Pos('<a ', Value) > 0 then
  429. Value := TextBefore(Value, '<a ', '');
  430. HTMLRemoveTags(Value);
  431. HTMLDecode(Value);
  432. Value := FullTrim(Value);
  433. Value := StringReplace(Value, ', more', '');
  434. Value := StringReplace(Value, ', (more)', '');
  435. Value := StringReplace(Value, ' more', '');
  436. if (CanSetField(fieldVideoFormat)) and (GetOption('AspectRatio') = 1) then
  437. SetField(fieldVideoFormat, Value);
  438. if (CanSetField(fieldResolution)) and (GetOption('AspectRatio') = 2) then
  439. SetField(fieldResolution, Value);
  440. end;
  441. // Description
  442. if CanSetField(fieldDescription) then
  443. begin
  444. Value := TextBetween(PageText, '<h5>Plot:</h5>', '</div>');
  445. if Value = '' then
  446. Value := TextBetween(PageText, '<h5>Plot Summary:</h5>', '</div>');
  447. if Pos('<p>', Value) > 0 then
  448. Value := TextBetween(Value, '<p>', '</p>');
  449. Value := StringReplace(Value, '<div class="info-content">', '');
  450. Value := StringReplace(Value, Textbetween(Value, '| <a class="tn15more inline" href="synopsis">', '</a>'), '');
  451. Value := StringReplace(Value, Textbetween(Value, '<a class="tn15more inline" href="synopsis">', '</a>'), '');
  452. Value := StringReplace(Value, '| <a class="tn15more inline" href="synopsis"></a>', '');
  453. Value := StringReplace(Value, '<a class="tn15more inline" href="synopsis"></a>', '');
  454. Value := StringReplace(Value, '&raquo;', '');
  455. if (Value = #13#10 + #13#10) or (Value = #13#10) then
  456. Value := '';
  457. if (GetOption('DescriptionSelection') = 0) and (Pos('<a class="tn15more inline"', Value) > 0) then
  458. Value := TextAfter(Value, #13#10);
  459. if Value <> '' then
  460. SetField(fieldDescription, ImportSummary(Value));
  461. end;
  462. // Length
  463. if CanSetField(fieldLength) then
  464. begin
  465. Value := TextBetween(PageText, '<h5>Runtime:</h5>', '</div>');
  466. if Pos('<p>', Value) > 0 then
  467. Value := TextBetween(Value, '<p>', '</p>');
  468. Value := TextBefore(Value, ' min', '');
  469. HTMLRemoveTags(Value);
  470. Value := FullTrim(Value);
  471. if Value <> '' then
  472. begin
  473. if Pos(':', Value) > 0 then
  474. SetField(fieldLength, TextAfter(Value, ':'))
  475. else
  476. SetField(fieldLength, Value);
  477. end;
  478. end;
  479. // Writer (Producer Field)
  480. if CanSetField(fieldProducer) then
  481. begin
  482. if GetOption('Producer') = 1 then
  483. begin
  484. Value := TextBetween(PageText, 'Produced by</a></h5>', '</table>');
  485. FullValue := '';
  486. Value2 := TextBetween(Value, '<a href="/name/', '</a>');
  487. while Value2 <> '' do
  488. begin
  489. Value := RemainingText;
  490. Value2 := TextAfter(Value2, '">');
  491. if FullValue <> '' then
  492. FullValue := FullValue + ', ';
  493. FullValue := FullValue + Value2;
  494. Value2 := TextBetween(Value, '<a href="/name/', '</a>');
  495. end;
  496. HTMLDecode(FullValue);
  497. SetField(fieldProducer, FullValue);
  498. end
  499. else
  500. begin
  501. Value := TextBetween(PageText, '<h5>Writer', '</div>');
  502. if Pos(':<', Value) > 0 then
  503. Value := '<' + TextAfter(Value, ':<');
  504. if Pos('<p>', Value) > 0 then
  505. Value := TextBetween(Value, '<p>', '</p>');
  506. Value := StringReplace(Value, '<br/>', ',');
  507. Value := StringReplace(Value, '>more<', '><');
  508. HTMLRemoveTags(Value);
  509. HTMLDecode(Value);
  510. if Value <> '' then
  511. begin
  512. Value := StringReplace(Value, '..., more', '');
  513. Value := StringReplace(Value, ', more', '');
  514. Value := StringReplace(Value, '...', '');
  515. Value := StringReplace(Value, ' &', '');
  516. Value := StringReplace(Value, ' ', '');
  517. Value := StringReplace(Value, #13, '');
  518. Value := StringReplace(Value, #10, '');
  519. Value := StringReplace(Value, #9, '');
  520. Value := StringReplace(Value, ',', ', ');
  521. Value := FullTrim(StringReplace(Value, ' and, ', ', '));
  522. if Value <> '' then
  523. while StrGet(Value, Length(Value)) = ',' do
  524. begin
  525. Delete(Value, Length(Value), 1);
  526. Value := FullTrim(Value);
  527. end;
  528. SetField(fieldProducer, Value);
  529. end;
  530. end;
  531. end;
  532. // AKA Name
  533. if CanSetField(fieldTranslatedTitle) then
  534. begin
  535. Value := TextBetween(PageText, '<h5>Also Known As:</h5>', '</div></div>');
  536. if Value <> '' then
  537. begin
  538. Value := StringReplace(Value, 'See more', '');
  539. Value := StringReplace(Value, '&raquo;', '');
  540. Value := FullTrim(StringReplace(Value, '<br>', ', '));
  541. HTMLRemoveTags(Value);
  542. HTMLDecode(Value);
  543. Value := FullTrim(Value);
  544. if Value <> '' then
  545. if StrGet(Value, Length(Value)) = ',' then
  546. Delete(Value, Length(Value), 1);
  547. SetField(fieldTranslatedTitle, Value)
  548. end;
  549. end;
  550. // Comments
  551. if CanSetField(fieldComments) then
  552. begin
  553. if (GetOption('CommentType') = 1) then
  554. begin
  555. Value := TextAfter(PageText,'/rg/title-nav-item/usercomments/');
  556. if (Value <> '') or (Pos('href="usercomments" class="link"', PageText) > 0) then
  557. begin
  558. Value2 := '';
  559. FullValue := ConvertToASCII(GetPage(MovieURL+'/usercomments'));
  560. FullValue := TextAfter(FullValue, 'review useful:</small><br>');
  561. while FullValue <> '' do
  562. begin
  563. Value := TextBetween(FullValue, '<b>', '<div');
  564. Value2 := Value2 + #13#10 + #13#10 + TextBefore(Value, '</b>', '');
  565. Value := RemainingText;
  566. Value2 := Value2 + #13#10 + 'Date: ' + TextBetween(Value, '<small>', '</small>');
  567. Value := RemainingText;
  568. Value := 'Author: ' + TextBetween(Value, 'comments">', '<br>');
  569. HtmlRemoveTags(Value);
  570. Value2 := Value2 + #13#10 + Value;
  571. Value := RemainingText;
  572. Value := TextBetween(Value, '<p>' + #13#10, #13#10 + '</p>');
  573. Value := StringReplace(Value, #13#10, ' ');
  574. Value := StringReplace(Value, '<br><br>', #13#10);
  575. Value := StringReplace(Value, '<br>', #13#10);
  576. HtmlDecode(Value);
  577. Value2 := Value2 + #13#10 + #13#10 + FullTrim(Value);
  578. FullValue := TextAfter(FullValue, 'review useful:</small><br>');
  579. end;
  580. HTMLRemoveTags(Value2);
  581. HTMLDecode(Value2);
  582. SetField(fieldComments, 'USER COMMENTS:' + Value2 + #13#10);
  583. end;
  584. end
  585. else
  586. if (GetOption('CommentType') = 0) then
  587. begin
  588. Value := TextAfter(PageText, '/comments">');
  589. if Value <> '' then
  590. begin
  591. Value := TextBetween(Value, '<p>', '</p>');
  592. Value := StringReplace(Value, #13#10, ' ');
  593. Value := StringReplace(Value, '<br>', #13#10);
  594. HTMLRemoveTags(Value);
  595. HTMLDecode(Value);
  596. Value := FullTrim(Value);
  597. while Pos(' ', Value) > 0 do
  598. Value := StringReplace(Value, ' ', ' ');
  599. while Pos(#13#10, Value) = 1 do
  600. Delete(Value, 1, 2);
  601. SetField(fieldComments, Value + #13#10);
  602. end;
  603. end
  604. else
  605. if (GetOption('CommentType') = 2) then
  606. SetField(fieldComments, '');
  607. end;
  608. // TagLine
  609. if GetOption('GetTagline') > 0 then
  610. begin
  611. Value := TextBetween(PageText, '<h5>Tagline:</h5>', '</div>');
  612. if Pos('<p>', Value) > 0 then
  613. Value := TextBetween(Value, '<p>', '</p>');
  614. if Pos('<a', Value) > 0 then
  615. Value := TextBefore(Value, '<a', '');
  616. Value := TextAfter(Value, #13#10);
  617. HTMLRemoveTags(Value);
  618. HTMLDecode(Value);
  619. Value := FullTrim(Value);
  620. if Value <> '' then
  621. begin
  622. if StrGet(Value, 1) <> '"' then
  623. Value := '"' + Value + '"';
  624. case GetOption('GetTagline') of
  625. 1:
  626. begin
  627. if GetField(fieldDescription) <> '' then
  628. Value := Value + #13#10 + #13#10 + GetField(fieldDescription);
  629. SetField(fieldDescription, Value);
  630. end;
  631. 2:
  632. begin
  633. if GetField(fieldComments) <> '' then
  634. Value := Value + #13#10 + #13#10 + GetField(fieldComments);
  635. SetField(fieldComments, Value);
  636. end;
  637. end;
  638. end;
  639. end;
  640. // Trivia
  641. if GetOption('Trivia') > 0 then
  642. begin
  643. sleep(50);
  644. Value := MovieUrl;
  645. FullValue := ConvertToASCII(GetPage(Value+'/trivia'));
  646. case GetOption('Trivia') of
  647. 1,2:
  648. Value := TextBetween(FullValue, '<div class="sodatext">', '</div>');
  649. 3,4:
  650. Value := TextBetween(FullValue, '<div class="list">', '<div id="sidebar">');
  651. end;
  652. if Value <> '' then
  653. begin
  654. Value := StringReplace(Value, #13#10, '');
  655. while Pos(' ', Value) > 0 do
  656. Value := StringReplace(Value, ' ', '');
  657. while Pos('<span class="linksoda">', Value) > 0 do
  658. begin
  659. Value := StringReplace(Value, TextBetween(Value, '<span class="linksoda">', '</div>'), '');
  660. Value := StringReplace(Value, '<span class="linksoda"></div>', '');
  661. end;
  662. Value := StringReplace(Value, 'Link this trivia', '');
  663. Value := StringReplace(Value, '<div class="sodatext">', #13#10 + '- ');
  664. HTMLRemoveTags(Value);
  665. HTMLDecode(Value);
  666. case GetOption('Trivia') of
  667. 1,3:
  668. begin
  669. if GetField(fieldDescription) <> '' then
  670. Value := GetField(fieldDescription) + #13#10 + #13#10 + 'IMDB TRIVIA: ' + Value
  671. else
  672. Value := 'IMDB TRIVIA: ' + Value;
  673. SetField(fieldDescription, Value);
  674. end;
  675. 2,4:
  676. begin
  677. if GetField(fieldComments) <> '' then
  678. Value := GetField(fieldComments) + #13#10 + #13#10 + 'IMDB TRIVIA: ' + Value
  679. else
  680. Value := 'IMDB TRIVIA: ' + Value;
  681. SetField(fieldComments, Value);
  682. end;
  683. end;
  684. end;
  685. end;
  686. // Awards
  687. if (GetOption('Awards') > 0) then
  688. begin
  689. ImportAwards();
  690. end;
  691. // Rating
  692. if CanSetField(fieldRating) then
  693. begin
  694. // (Remove the "//" of the next two lines beginning with "Value" and add "//" to the following two lines beginning with Value
  695. // if you would like to import arithmetic ratings instead of IMDB's user ratings)
  696. // Value := ConvertToASCII(GetPage(MovieURL + '/ratings'));
  697. // Value := TextBetween(Value, 'Arithmetic mean = ', '. ');
  698. Value := TextBetween(PageText, '<h5>User Rating:</h5>', '</b>');
  699. Value := TextBetween(Value, '<b>', '/');
  700. if Value <> '' then
  701. SetField(fieldRating, Value);
  702. end;
  703. if GetOption('UserRatings') > 0 then
  704. begin
  705. Value := TextBetween(PageText, '<a href="ratings" class="tn15more">', '</a>');
  706. if Value <> '' then
  707. Value := 'User Rating: ' + GetField(fieldRating) + ' out of 10 (with ' + Value + ')';
  708. if (GetOption('UserRatings') = 1) and (Value <> '') and (CanSetField(fieldMediaType)) then
  709. SetField(fieldMediaType, Value);
  710. if (GetOption('UserRatings') = 2) and (Value <> '') then
  711. SetField(fieldComments, GetField(fieldComments) + #13#10 + #13#10 + Value);
  712. end;
  713. // Classification
  714. if GetOption('Classification') > 0 then
  715. begin
  716. if UserCountry = '' then
  717. 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')
  718. else
  719. begin
  720. Value := TextBetween(PageText, '<a href="/search/title?certificates=', '</div>');
  721. Value := TextBetween(Value, UserCountry + ':', '</a>'); if Value <> '' then
  722. begin
  723. if GetOption('Classification') = 1 then
  724. SetField(fieldMediaType, Value)
  725. else
  726. SetField(fieldComments, GetField(fieldComments) + #13#10 + #13#10 + 'Classification: ' + Value);
  727. end;
  728. end;
  729. end;
  730. // MPAA rating
  731. if (GetOption('MPAA') > 0) then
  732. begin
  733. Value := FullTrim(TextBetween(PageText, '<h5><a href="/mpaa">MPAA</a>:</h5>', '</div>'));
  734. if Pos('<p>', Value) > 0 then
  735. Value := TextBetween(Value, '<p>', '</p>');
  736. HTMLRemoveTags(Value);
  737. Value := FullTrim(Value);
  738. // Value := TextAfter(Value, #13#10);
  739. if Value <> '' then
  740. begin
  741. if GetOption('MPAA') = 1 then
  742. SetField(fieldMediaType, TextBetween(Value, 'Rated ', ' '))
  743. else
  744. SetField(fieldComments, GetField(fieldComments) + #13#10 + #13#10 + Value);
  745. end;
  746. end;
  747. end;
  748.  
  749. // ***** Imports lists like Genre, Country, etc. depending of the selected option *****
  750.  
  751. function ImportList(PageText: string; MultipleValues: Integer; StartTag: string): string;
  752. var
  753. Value, Value2: string;
  754. begin
  755. if MultipleValues = 0 then
  756. begin
  757. Value := TextBetween(PageText, StartTag, '</a>');
  758. Value2 := TextAfter(Value, '">');
  759. end
  760. else
  761. begin
  762. Value := TextBetween(PageText, StartTag, '</div>');
  763. Value2 := TextBefore(Value, '<a class="tn15more inline"', '');
  764. if Value2 = '' then
  765. Value2 := Value;
  766. Value2 := TextAfter(Value2, '">');
  767. HTMLRemoveTags(Value2);
  768. if MultipleValues = 1 then
  769. Value2 := StringReplace(Value2, ' | ', ', ');
  770. if MultipleValues = 2 then
  771. Value2 := StringReplace(Value2, ' | ', ' / ');
  772. if MultipleValues = 3 then
  773. Value2 := '';
  774. end;
  775. Value2 := StringReplace(Value2, #13#10, '');
  776. Value2 := StringReplace(Value2, ' , ', ', ');
  777. HTMLDecode(Value2);
  778. Result := FullTrim(Value2);
  779. end;
  780.  
  781. // ***** functions to import the different pictures kinds, depending of the option selected by user *****
  782.  
  783. //Import small picture from IMDB movie main page
  784. function ImportSmallPicture(PageText: string): Boolean;
  785. var
  786. Value: string;
  787. begin
  788. Result := False;
  789. Value := TextBetween(PageText, '<div class="photo">', '</div>');
  790. if (Value <> '') and (Pos('"Poster Not Submitted"', Value) = 0) then
  791. begin
  792. Value := TextBetween(Value, 'src="', '"');
  793. if Value <> '' then
  794. begin
  795. GetPicture(Value);
  796. Result := True;
  797. end;
  798. end;
  799. end;
  800.  
  801. //Import large image from link on IMDB movie main page
  802. function ImportLargePicture(PageText: string): Boolean;
  803. var
  804. Value: string;
  805. begin
  806. Result := False;
  807. Value := TextBetween(PageText, '<div class="photo">', '</div>');
  808. if (Value <> '') and (Pos('"Poster Not Submitted"', Value) = 0) and (Pos('<a name="poster" href="/rg/action-box-title/primary-photo', Value) > 0) then
  809. begin
  810. Value := TextBetween(Value, 'href="/rg/action-box-title/primary-photo', '"');
  811. if Value <> '' then
  812. begin
  813. Value := 'http://www.imdb.com' + Value;
  814. Value := GetPage(Value);
  815. Value := TextBetween(Value, '<div class="primary">', '</div>');
  816. if (Value <> '') and (Pos(' src="', Value) > 0) then
  817. begin
  818. Value := TextBetween(Value, ' src="', '"');
  819. GetPicture(Value);
  820. Result := True;
  821. end;
  822. end;
  823. end;
  824. end;
  825.  
  826. //Image not available, import "No Poster Available" icon
  827. function ImportPictureNotAvailable(PageText: string): Boolean;
  828. var
  829. Value: string;
  830. begin
  831. Result := False;
  832. Value := TextBetween(PageText, '<div class="photo">', '</div>');
  833. if (Value <> '') and (Pos('"Poster Not Submitted"', Value) > 0) then
  834. begin
  835. Value := TextBetween(Value, 'src="', '"');
  836. if Value <> '' then
  837. begin
  838. GetPicture(Value);
  839. Result := True;
  840. end;
  841. end;
  842. end;
  843.  
  844. //Image from DVD Details Page
  845. function ImportDvdDetailsPicture: Boolean;
  846. var
  847. Value, PageText: string;
  848. begin
  849. Result := False;
  850. PageText := ConvertToASCII(GetPage(MovieUrl+'/dvd'));
  851. Value := TextBefore(PageText, '.jpg alt="', '<table class="dvd_section" cellpadding="10"><tr>');
  852. if Value <> '' then
  853. begin
  854. Value := TextBetween(Value, '<a href="', '">');
  855. if Value <> '' then
  856. Result := ImportFromAmazonRedirect('http://www.imdb.com' + Value);
  857. end;
  858. end;
  859.  
  860. //Image from Merchandising Links (/sales) Page
  861. function ImportMerchandisingPicture: Boolean;
  862. var
  863. Value, PageText: string;
  864. begin
  865. Result := False;
  866. PageText := ConvertToASCII(GetPage(MovieUrl+'/sales'));
  867. Value := TextBefore(PageText, '.jpg" width=', '<td class=w_rowtable_colcover><a href="');
  868. if Value <> '' then
  869. begin
  870. Value := TextBefore(Value, '"><img', '');
  871. if Value <> '' then
  872. Result := ImportFromAmazonRedirect('http://www.imdb.com' + Value);
  873. end;
  874. end;
  875.  
  876. function ImportFromAmazonRedirect(Url: string): Boolean;
  877. var
  878. Value, PageText: string;
  879. begin
  880. Result := False;
  881. PageText := ConvertToASCII(GetPage(Url));
  882. Value := TextBetween(PageText, '<td id="prodImageCell"', '" id="prodImage"');
  883. // Value := StringReplace(TextAfter(Value, ' src="'), '_AA240', '');
  884. Value := StringReplace(Value, TextBetween(Value, '_AA', '_'), '');
  885. Value := StringReplace(TextAfter(Value, ' src="'), '_AA', '');
  886. if Value <> '' then
  887. begin
  888. GetPicture(Value);
  889. Result := True;
  890. end;
  891. end;
  892.  
  893. // ***** Gets summaries for the movie, based on the plot outline given in parameter (that contains the URL to more summaries) *****
  894.  
  895. function ImportSummary(PlotText: string): string;
  896. var
  897. Address, Value, Value2, Value3, Value4, PageText, Longest: string;
  898. begin
  899. Address := TextBetween(PlotText, '<a class="tn15more inline" href="', '" ');
  900. if (Address = '') or (GetOption('DescriptionSelection') = 0) or (GetOption('DescriptionSelection') = 3) then
  901. begin
  902. Value3 := FullTrim(TextBefore(PlotText, '<a class="tn15more inline"', ''));
  903. if Value3 = '' then
  904. Value3 := FullTrim(PlotText);
  905. HTMLRemoveTags(Value3);
  906. HTMLDecode(Value3);
  907. end;
  908. if (Address <> '') and (GetOption('DescriptionSelection') > 0) then
  909. begin
  910. PageText := ConvertToASCII(GetPage('http://www.imdb.com' + Address));
  911. PickListClear;
  912. Longest := '';
  913. Value := TextBetween(PageText, '<p class="plotpar">', '</p>');
  914. PageText := RemainingText;
  915. while Value <> '' do
  916. begin
  917. Value := TextBefore(Value, '<i>', '');
  918. Value := FullTrim(StringReplace(Value, #13#10, ' '));
  919. Value := StringReplace(Value, '<br>', #13#10);
  920. HTMLRemoveTags(Value);
  921. HTMLDecode(Value);
  922. while Pos(' ', Value) > 0 do
  923. Value := StringReplace(Value, ' ', ' ');
  924. if Length(Value) > Length(Longest) then
  925. Longest := Value;
  926. PickListAdd(FullTrim(Value));
  927. Value := TextBetween(PageText, '<p class="plotpar">', '</p>');
  928. PageText := RemainingText;
  929. end;
  930. if (GetOption('BatchMode') > 0) or (GetOption('DescriptionSelection') = 2) then
  931. Value4 := Longest
  932. else
  933. begin
  934. if not PickListExec('Select a description for "' + GetField(fieldOriginalTitle) + '"', Value4) then
  935. Value4 := '';
  936. end;
  937. end;
  938. if Value3 <> '' then
  939. begin
  940. if Value4 <> '' then
  941. begin
  942. Result := Value3 + #13#10 + #13#10 + Value4;
  943. end
  944. else
  945. begin
  946. Result := Value3;
  947. end;
  948. end
  949. else
  950. begin
  951. Result := Value4;
  952. end;
  953. end;
  954.  
  955. // Import awards
  956. procedure ImportAwards;
  957. var
  958. PageText, FullValue, Block, Value, Row: string;
  959. Year, Result, Award, Category: string;
  960. begin
  961. sleep(50);
  962. Value := MovieUrl;
  963. PageText := ConvertToASCII(GetPage(Value+'/awards'));
  964. PageText := TextBetween(PageText, '<table style=', '</table>');
  965. FullValue := '';
  966. while PageText <> '' do
  967. begin
  968. Block := TextBetween(PageText, '<big>', '<big>');
  969. if Block = '' then
  970. begin
  971. Block := PageText;
  972. PageText := '';
  973. end
  974. else
  975. begin
  976. Block := '<big>' + Block;
  977. PageText := '<big>' + RemainingText;
  978. end;
  979. Value := TextBetween(Block, '<big>', '</big>');
  980. Block := RemainingText;
  981. HTMLRemoveTags(Value);
  982. HTMLDecode(Value);
  983. FullValue := FullValue + #13#10 + '- ' + Value;
  984. Year := '';
  985. Result := '';
  986. repeat
  987. Award := '';
  988. Category := '';
  989. Row := TextBetween(Block, '<tr>', '</tr>');
  990. Block := RemainingText;
  991. if (Pos('<th>Year</th><th>Result</th><th>Award</th><th>Category/Recipient(s)</th>', Row) = 0)
  992. and (Pos('<td colspan="4">&nbsp;</td>', Row) = 0) then
  993. begin
  994. if Pos('<a href="/Sections/Awards', Row) > 0 then
  995. begin
  996. Year := TextBetween(Row, '<a href="/Sections/Awards', '</a>');
  997. Row := RemainingText;
  998. Year := FullTrim(TextAfter(Year, '>'));
  999. end;
  1000. if Pos('valign="middle"><b>', Row) > 0 then
  1001. begin
  1002. Result := TextBetween(Row, 'valign="middle"><b>', '</b></td>');
  1003. HTMLDecode(Result);
  1004. Row := RemainingText;
  1005. end;
  1006. if Pos('valign="middle">', Row) > 0 then
  1007. begin
  1008. Award := TextBetween(Row, 'valign="middle">', '</td>');
  1009. HTMLDecode(Award);
  1010. Row := RemainingText;
  1011. end;
  1012. if Award <> '' then
  1013. FullValue := FullValue + #13#10 + ' ' + Year + ' ' + Result + ' "' + Award + '"';
  1014. Category := TextBetween(Row, '<td valign="top">' + #13#10, '<br>');
  1015. if Pos('<a href="/name', Category) > 0 then
  1016. begin
  1017. RemainingText := Category;
  1018. Category := '';
  1019. end;
  1020. HTMLDecode(Category);
  1021. Category := FullTrim(Category);
  1022. Row := StringReplace(StringReplace(RemainingText, #13#10, ''), '<br>', ', ');
  1023. HTMLRemoveTags(Row);
  1024. HTMLDecode(Row);
  1025. Row := FullTrim(Row);
  1026. Row := StringReplace(Row, ' ', '');
  1027. Row := StringReplace(Row, ' ,', ',');
  1028. if Row = ',' then
  1029. Row := '';
  1030. if (Row <> '') or (Category <> '') then
  1031. begin
  1032. FullValue := FullValue + #13#10 + ' ' + Category;
  1033. if Row <> '' then
  1034. begin
  1035. while StrGet(Row, Length(Row)) = ',' do
  1036. begin
  1037. Delete(Row, Length(Row), 1);
  1038. Row := FullTrim(Row);
  1039. end;
  1040. if Category = '' then
  1041. FullValue := FullValue + Row
  1042. else
  1043. FullValue := FullValue + ': ' + Row;
  1044. end;
  1045. end;
  1046. end;
  1047. until Pos('</tr>', Block) = 0;
  1048. end;
  1049. if FullValue <> '' then
  1050. case GetOption('Awards') of
  1051. 1:
  1052. begin
  1053. if GetField(fieldDescription) <> '' then
  1054. Value := GetField(fieldDescription) + #13#10 + #13#10 + 'AWARDS: ' + FullValue
  1055. else
  1056. Value := 'AWARDS: ' + FullValue;
  1057. SetField(fieldDescription, Value);
  1058. end;
  1059. 2:
  1060. begin
  1061. if GetField(fieldComments) <> '' then
  1062. Value := GetField(fieldComments) + #13#10 + #13#10 + 'AWARDS: ' + FullValue
  1063. else
  1064. Value := 'AWARDS: ' + FullValue;
  1065. SetField(fieldComments, Value);
  1066. end;
  1067. end;
  1068. end;
  1069.  
  1070. // ***** beginning of the program *****
  1071.  
  1072. begin
  1073. // Check StringUtils1 version and update if < version 7
  1074. if StringUtils1_Version < 7 then
  1075. begin
  1076. 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
  1077. begin
  1078. UpdateFile := TStringList.Create;
  1079. UpdateFile.Text := GetPage('http://update.antp.be/amc/scripts/StringUtils1.pas');
  1080. UpdateFile.SaveToFile(dirScripts + 'StringUtils1.pas');
  1081. UpdateFile.Free;
  1082. ShowInformation('StringUtils1 has been updated. Please restart IMDB script now. Thank you.');
  1083. Exit;
  1084. end
  1085. else
  1086. begin
  1087. ShowInformation('You can download latest version of "StringUtils1.pas" using script "update scripts" or via http://update.antp.be/amc/scripts');
  1088. Exit;
  1089. end;
  1090. end;
  1091. // Check for current AMC version
  1092. if CheckVersion(3,5,0) then
  1093. begin
  1094. MovieName := '';
  1095. if GetOption('BatchMode') = 2 then
  1096. begin
  1097. MovieName := GetField(fieldURL);
  1098. if Pos('imdb.com', MovieName) = 0 then
  1099. MovieName := '';
  1100. end;
  1101. if MovieName = '' then
  1102. MovieName := GetField(fieldOriginalTitle);
  1103. if MovieName = '' then
  1104. MovieName := GetField(fieldTranslatedTitle);
  1105. if GetOption('BatchMode') = 0 then
  1106. begin
  1107. if not Input('IMDB Import', 'Enter the title or the IMDB URL of the movie:', MovieName) then
  1108. Exit;
  1109. end
  1110. else
  1111. Sleep(500);
  1112. if MovieName <> '' then
  1113. begin
  1114. if Pos('imdb.com', MovieName) > 0 then
  1115. AnalyzeResultsPage(MovieName)
  1116. else
  1117. begin
  1118. MovieName := StringReplace(MovieName, '&', 'and');
  1119. if GetOption('GoogleSearch') = 1 then
  1120. AnalyzeGooglesResultsPage('http://www.google.com/search?num=30&q=site:www.imdb.com/title/+' + UrlEncode(MovieName) + '+/maindetails')
  1121. else
  1122. if GetOption('GoogleSearch') = 2 then
  1123. AnalyzeGooglesResultsPage('http://www.google.com/search?num=30&q=site:www.imdb.com/title/+%22' + UrlEncode(MovieName) + '%22+/maindetails')
  1124. else
  1125. begin
  1126. if (GetOption('BatchMode') > 0) or (GetOption('PopularSearches') = 1) then
  1127. AnalyzeResultsPage(PopularTitleSearchURL + UrlEncode(MovieName))
  1128. else
  1129. AnalyzeResultsPage(FullTitleSearchURL + UrlEncode(MovieName));
  1130. end;
  1131. end;
  1132. end;
  1133. end
  1134. else
  1135. ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  1136. end.
Advertisement
Add Comment
Please, Sign In to add comment