Personal Video Database

English => Feature Suggestions => Topic started by: deazo on November 12, 2012, 07:20:07 pm

Title: Suggestion for Ivek23
Post by: deazo on November 12, 2012, 07:20:07 pm

 Hi all,

 I'm sorry for putting this on you Ivek23 but I have been dying for seeing a Rotten tomatoes ratings import for PVD.
 I cannot help to notice that you were able to fix the IMDB script so that it could take the IMDB ratings....
 Would you be able to do the same for RT ratings?

 I do not care about any other info coming from RT, only their ratings.

 I don't know if this can help you, but there is a Chrome extension that brings RT ratings into the IMDB page.
https://chrome.google.com/webstore/detail/imdbrt/dhmlipoakdghhhemjmefopbcdcobiphp (https://chrome.google.com/webstore/detail/imdbrt/dhmlipoakdghhhemjmefopbcdcobiphp)
 If you install the extension, then go into your chrome extension manager you get access to the script (background html) it uses.

 I wonder if that script could not help you (or anyone here) to "transcript" it for PVD.

 I hope I am making sense, and I know this has been requested a while ago, but RT ratings are soooo much better than IMDB's that I constantly check them out on the IMDB page using the extension.

 It is perfectly OK for you to tell me to bugger off and delete that request  :)

 Thank you for your efforts (past and future).

 D.



 
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 12, 2012, 08:06:33 pm
No, I do not mind. I need a bit more time for a little more detailed look into this. It is also true, it will be a bit less time to the end of this week. When I know more, I will messages.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 14, 2012, 08:27:38 pm
I took a look at that, what you ask, but as far as I see, it will not work.
I use Firefox and there is a similar Greasemonkey script
(IMDB_-_add_Rottentomatoes_info)
  shows the same as Chrome extension.

I'll explain for example Casablanca (1942) movie:

So one as another extension in Casablanca (1942) movie (http://www.imdb.com/title/tt0034583/) for IMDB,  leaves no piece of code in the source code page, that this could be used for example, Imdb Movie script.

It is possible (maybe, we'll see) it would be well done RT script for Casablanca (1942) movie (http://www.rottentomatoes.com/m/1003707-casablanca/) on RT (and other movies).

I wonder which part of the rating you are interested in:
first, second or both of the percentages, or anything else.


Maybe will then simple RT script written to the end of the week.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 17, 2012, 07:02:12 pm
Maybe will then simple RT script written to the end of the week.

With a little effort I managed do simple RT script .

For unregistered users:
Rottentomatoes.psf



Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.0.0
DATE: 17/11/2012

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

///Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
smCredits = 4;
smDVDReleases = 5;
smBiography = 6;
smGenreindex = 7;
smAwards = 8;
smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
pfComment    = 9;
pfBookmark    = 10;
pfPid        = 11;
pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.0.0';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);

//~Rating~ or ~RT Rating~
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, 'Average Rating: <span>', '/10</span>', True, curPos);
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<ul id="movie_results_ul" class="results_ul" ', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a href="/m/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('<a id="more_movies" href="#results_movies_tab">More Movies...</a>', HTML, endPos)) do begin
endPos := PosFrom('"  class=', HTML, curPos);
URL := 'http://www.rottentomatoes.com/'+Trim(Copy(HTML, curPos+9, endPos - curPos-9));

curPos := PosFrom('"  class="" >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  class="" >', '</a>', True, curPos);

curPos := PosFrom('</a>', HTML, curPos);
endPos := PosFrom('</span></h3>', HTML, curPos);
Year := TextBetween(HTML, '</a>', '</span></h3>', True, curPos);

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.

Rottentomatoes script is attached.

[attachment deleted by admin]
Title: Re: Suggestion for Ivek23
Post by: deazo on November 19, 2012, 01:08:20 am

 OMG YOU DID IT!!!
 Sorry I did not check the forum for a while I was not expecting you to do it.
 Thank you soooooo much Ivek23 this will help me a lot choose the right movie to watch.
 
Quote
I wonder which part of the rating you are interested in:
first, second or both of the percentages, or anything else
I was interested by the first % which is the tomatometer.

 I managed to get the "average rating" in a custom field called "RT rating" in my movie page (please see attached image), but what I was after was having it displayed just like the allmovie and imdb ratings are displayed.
 Do you know if this is possible?

 Thank you thak you thank you again
 

[attachment deleted by admin]
Title: Re: Suggestion for Ivek23
Post by: deazo on November 19, 2012, 01:15:22 am

 Actually, I think there is a maximum of 3 rating fields, right?
 
 If so then I would like to remove al the ratings I had added using the allmovie scripts, is this possible?
 This way the field would be blank and would get filled by the RT rating, right?
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 19, 2012, 09:53:14 am
OMG YOU DID IT!!!
 Sorry I did not check the forum for a while I was not expecting you to do it.

There is no problem.

Thank you soooooo much Ivek23 this will help me a lot choose the right movie to watch.
.
.
.
 Thank you thak you thank you again

Welcome.

Quote
I wonder which part of the rating you are interested in:
first, second or both of the percentages, or anything else
I was interested by the first % which is the tomatometer.

This is what I put for rating in the script.

I managed to get the "average rating" in a custom field called "RT rating" in my movie page (please see attached image), but what I was after was having it displayed just like the allmovie and imdb ratings are displayed.
 Do you know if this is possible?

As far as I understood from the attached image, is used skin pvd_classic_movie. In pvd_classic_movie skin is RT raring custom field visible as is seen in the attached picture.
Of course this can be done, in skin can be added skin is RT raring custom field, but beware, therefore, all other custom fields will disappeared.

How this is done, you can see in my skins in the Scripts and Templates (http://www.videodb.info/forum_en/index.php/board,9.40.html)  or  My current skin for Ivek23 (http://www.videodb.info/forum_en/index.php/topic,2249.msg11886.html#msg11886)  you can add more details about the skin in several pictures, as well as a detailed list of custom fields (I think you have 10 custom fields), and I'll do you skin by RT rating, such as you desire, if you can not you know how to edit the skin according to your taste.


 Actually, I think there is a maximum of 3 rating fields, right?
 
 If so then I would like to remove al the ratings I had added using the allmovie scripts, is this possible?
 This way the field would be blank and would get filled by the RT rating, right

Yes, true, but I recommend that you do not do this (or do that), because you lose some information, which will not be possible to reimburse, but it is better to rearrange the skin, as has been mentioned before.
Option in the skin, however, is that can be blocked IMDb rating, as shown in the code below:
Code: [Select]
          </row>

          <!--
  <row>
   <column width="120" halign="right">
    <fieldlabel field="imdbrating" width="118" wordwrap="true" halign="right"/>
   </column>
   <column>
<imdbrating/>
   </column>
  </row>
          -->

          <row>
However IMDb rating will no longer be visible.
Title: Re: Suggestion for Ivek23
Post by: deazo on November 20, 2012, 09:14:33 am


   
Quote
This is what I put for rating in the script.
 
   Are you sure? The rating I am getting is the "average rating", not the "Tomatometer" (in %).

  Thank you for your skin, but I do not want to use it because I want all information to be visible in one page (home theatre), and not in tabs.

 
Quote
Yes, true, but I recommend that you do not do this (or do that), because you lose some information, which will not be possible to reimburse, but it is better to rearrange the skin, as has been mentioned before.
Option in the skin, however, is that can be blocked IMDb rating, as shown in the code below:

 I don't care about the allmovie/alrovi rating really. And I do not mind loosing it. Also I do not want to loose my other custom fields and I would like to keep the imdb rating.
 So my question is: How can I remove all Allmovie/alRovi ratings from my database?

 Thank you again, I have been wanting this plugin for almost 3 years!


 
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 20, 2012, 01:10:07 pm
Quote
This is what I put for rating in the script.
 
Are you sure? The rating I am getting is the "average rating", not the "Tomatometer" (in %).

However, it is a small problem, which I will explain later, because I need a little time for a little more detailed insight into the problem.

Thank you for your skin, but I do not want to use it because I want all information to be visible in one page (home theatre), and not in tabs.

Of course, to edit, to make everything visible on one side only. Put this under your skin (home theatre) attached to your post, I edited it so that everything will be on one side.

I don't care about the allmovie/alrovi rating really. And I do not mind loosing it. Also I do not want to loose my other custom fields and I would like to keep the imdb rating.
 So my question is: How can I remove all Allmovie/alRovi ratings from my database?

A simple way to solve this:
the RT script settings only confirm box for an additional rating, then the simply overwrite allmovie / alrovi rating (see image to Tools> Preferences> Plugins).

[attachment deleted by admin]
Title: Re: Suggestion for Ivek23
Post by: deazo on November 20, 2012, 01:20:34 pm

 
Quote
A simple way to solve this:
the RT script settings only confirm box for an additional rating, then the simply overwrite allmovie / alrovi rating (see image to Tools> Preferences> Plugins).

 Of course! I should have known, thank you.

 By the way, you do not need to spend more time on the Tomatometer, I am happy with the RT rating, this is really great thank you!!
Title: Re: Suggestion for Ivek23
Post by: deazo on November 28, 2012, 09:56:22 am
 Hi Ivek23,

 I am updating hundreds of movies with the RT script, but for some reason, it does not find some of the movies and does not even suggest titles.
 I attach screenshots for example.
 I think (i am not sure) in the case of this Lars Von Trier movie, (and probably for many others) it is looking for the original title (Forbrydelsens element), where is should look for the AkA (the element of crime).
 So maybe the scrip has to be changed so that it also looks for the aka's?

 I also wonder if it is struggling with special characters (titles like "Fortapàsc" or "Frontière(s)".

 So I would say it works at 75% of cases.
 Thank you for the help

 D

[attachment deleted by admin]
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 28, 2012, 07:44:07 pm
I am updating hundreds of movies with the RT script, but for some reason, it does not find some of the movies and does not even suggest titles.

I've been able to find the error, repair it,
Quote
this part of code
Code: [Select]
curPos := PosFrom('<a href="/m/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('<a id="more_movies" href="#results_movies_tab">More Movies...</a>', HTML, endPos)) do begin
endPos := PosFrom('"  class=', HTML, curPos);
replace this part of code
Code: [Select]
curPos := PosFrom('<a href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('"  class=', HTML, curPos);
not I have not added Rottentomatoes (1) script , because I tested the search results on about 300 movies.
There is a small cosmetic problem, namely to the first five results (one until five hits - depending on how many are on the All Search Results page) these results again repeat with all the other results in Movies Search Results page (see attached images).
I personally use this Rottentomatoes (1) script only if the basic Rottentomatoes script, if it does not display the correct search movie titles for your search movie or if it does not display all search movie titles for your search movie, including it is also correct title for your search movie.

Script will be added in the next post.


[attachment deleted by admin]
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 28, 2012, 08:40:42 pm
I think (i am not sure) in the case of this Lars Von Trier movie, (and probably for many others) it is looking for the original title (Forbrydelsens element), where is should look for the AkA (the element of crime).
 So maybe the scrip has to be changed so that it also looks for the aka's?

No, it is not necessary, is corrected, note is written above.

I also wonder if it is struggling with special characters (titles like "Fortapàsc" or "Frontière(s)".

The problem is solved in a simple way:

1. )
This is the url address
http://www.rottentomatoes.com/search/?search=Fronti%E8re&sitesearch=rt
for Web search in PVD (see attached picture).

Quote
Example:
This is the search url address for Frontière:
http://www.rottentomatoes.com/search/?search=Fronti%E8re&sitesearch=rt
For Web search in PVD:
Title: 
Rotten Tomatoes
URL:   
http://www.rottentomatoes.com/search/?search=Fronti%E8re&sitesearch=rt
Instead of this  " =Fronti%E8re&sitesearch=rt "  insert this "=%s&sitesearch=rt "

2. )
Do the first backup database so that you can do restore database to its original state.  Add an entry in databaso instead title "Frontière" this title "Frontiere" and RottenTomatoes script you will certainly find a movie title (see attached picture). So obtained url address for this movie,  copy to the url field "Frontière" movie, but first do is restore database before copying copied url.

Good luck in this work to you.

Rottentomatoes (1) script is attached.


[attachment deleted by admin]
Title: Re: Suggestion for Ivek23
Post by: deazo on November 29, 2012, 01:11:10 am

 Hi Ivek23,

 I am really not sure I understand what you mean, so let me know if I understood:

 This is a summary of what I think you are telling me:
 I should basically search the movie on the Rottentomatoes website, then copy the URL and paste it in the URL field, before running the script.
 This is what you mean, right?

 This is actually the workaround I have been already using for movies that are not found by the script. My issue is that it takes a lot of time to do this one movie at a time, and I was hoping that there was a problem in the script that you could fix.

 But I think you have not changed the script, am I right?
 Please let me know and I will carry on using the URL's one by one.

 Thanks again

 
 
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 29, 2012, 09:00:59 am
Thanks again

Welcome.

I am really not sure I understand what you mean, so let me know if I understood:

 This is a summary of what I think you are telling me:
 I should basically search the movie on the Rottentomatoes website, then copy the URL and paste it in the URL field, before running the script.
 This is what you mean, right?

Yes, it is true. It is only in the event  Rottentomatoes script or  Rottentomatoes (1) script does not find results.

This is actually the workaround I have been already using for movies that are not found by the script. My issue is that it takes a lot of time to do this one movie at a time, and I was hoping that there was a problem in the script that you could fix.

I apologize for the long workflow. It is also a problem in the script, which I can not solve.

But I think you have not changed the script, am I right?
 Please let me know and I will carry on using the URL's one by one.

Rottentomatoes script was not nothing changed.

Rottentomatoes (1) script has been modified to better search results. The problem with search results it is in writing addresses instance in movies such as "Frontière". The problem I have tried to fix, but try to solve the problem were unfortunately unsuccessful. For that matter, have to do so as already mentioned
Quote
Please let me know and I will carry on using the URL's one by one.
unfortunately, and so sorry that I was unable to solve.
Title: Re: Suggestion for Ivek23
Post by: deazo on November 29, 2012, 10:35:35 am

 Please do not apologize, you already did a lot for me, I have now hundreds of very useful RT ratings!
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 29, 2012, 12:06:02 pm
Please do not apologize, you already did a lot for me, I have now hundreds of very useful RT ratings!
Welcome, nice to hear, thank you for the errors found. I'm glad that you are now satisfied user of this script.

BTW:
Repaired Imdb Movie Script and Imdb Movie(1) Script is attached here. (http://www.videodb.info/forum_en/index.php/topic,3248.msg15966.html#msg15966)
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on February 03, 2013, 06:04:13 pm
Preparing Imdb Movie Script and Imdb Movie(1) Script with additional information, which data are Imdb plugin is not transferred.

I wonder what additional information is added to the script, so you can write your suggestions here for additional information, which should be added to the script.

Then I'll see how and what I can do and which of the proposals the can be added to the script.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 29, 2013, 12:53:34 pm
Quote
P.S.:
Please add Director of Photography for imdb-plugin! ;)

Not yet, because PVD does not support this field. The only option is a custom field and Imdb plugin to add the option to download the data in the custom field.
Another option would be to IMDB script and data in a custom field. Easy IMDB script is here (Imdb Movie Script for rating ...). (http://www.videodb.info/forum_en/index.php/topic,3282.0.html)

Another option would be to IMDB script and data in a custom field. Easy IMDB script is here (Imdb Movie Script for rating ...). (http://www.videodb.info/forum_en/index.php/topic,3282.0.html)

This option has not yet been added to Imdb script. Can I do a little more thorough look at Imdb source code page and see what I can do. Then I can also tell you at what time then it would be also feasible.

It can also write in this thread:  Suggestion for Ivek23 (http://www.videodb.info/forum_en/index.php/topic,3252.msg16452.html#msg16452)

I hope that by the middle of October will also be done.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on August 25, 2013, 12:59:24 pm
I fixed it procedure ParseSearchResults to re-presentation of search results.

Rottentomatoes script
v 0.1.0.1

Rottentomatoes(1) script
v 0.1.0.1




Rottentomatoes script and Rottentomatoes(1) script is attached.
Title: Re: Suggestion for Ivek23
Post by: deazo on August 30, 2013, 07:34:51 am

 Thanks A LOT Ivek23 for this update.
 I use this script regularly.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on August 30, 2013, 03:26:41 pm

 Thanks A LOT Ivek23 for this update.
 I use this script regularly.

Welcome and thanks.
Title: Re: Suggestion for Ivek23
Post by: sunspot on September 05, 2013, 05:13:23 pm
Please also accept my thanks! :-)
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on September 05, 2013, 05:59:05 pm
Please also accept my thanks!

Welcome and accepted.
Title: Re: Suggestion for Ivek23
Post by: Legin76 on January 31, 2014, 10:19:00 pm
Hi.. This is a great script. Thankyou.

I may have found bug however.

If it is not sure which is the correct movie and brings up the list to select. It adds the rating correctly, but then creates a new listing for the movie with the name and its date exactly as it is on Rotten Tomatos,  but no other content. So for example with Blade the second listing has the title "Blade (1998)" but has no date in the date field.

Also would it be possibe to also add the Audiance rating from RT as I often go by an average of the two.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on February 01, 2014, 08:27:56 am
Welcome on the forum, Legin76.

In which Rottentomatoes script version of this is happening and which version of PVD program is being used. Then it will be easier to answer.

Also a screenshot would be welcome to see what actually happens.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on February 09, 2014, 10:58:10 am
Question:

How to could be two different ratings for a one movie be combined into one movie rating or how to get to the average rating for one movie from for two different movie ratings.

Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 04, 2014, 03:18:26 pm
Also would it be possibe to also add the Audiance rating from RT as I often go by an average of the two.

Audiance rating

It is possible, but there is a small problem that can be seen only one rating in PVD database:
Tomatometer rating or Audiance rating.

Recommendation or advice:

First of all, Tomatometer rating info you download with Rottentomatoes script. (http://www.videodb.info/forum_en/index.php/topic,3252.msg17168.html#msg17168) If Tomatometer rating not stand it now, but whoever wants you Audiance rating may be transferred to Rottentomatoes (a) script. If it was not yet the transfer, then they use Rottentomatoes (a1) script for Audiance rating, this script will Audiance rating surely passed if, of course, is added to the movies web sites.


One warning:

Rottentomatoes (a) or Rottentomatoes (a1) script will overwrite Tomatometer rating information.


Rottentomatoes (a) script
v 0.1.0.5.a

Rottentomatoes (a1) script
v 0.1.0.5.a




Rottentomatoes (a) script and Rottentomatoes (a1) script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 04, 2014, 03:28:05 pm
For unregistered users:

Rottentomatoes script
v 0.1.0.1

Rottentomatoes.psf

Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.0.1
DATE: 25/08/2013

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

///Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
smCredits = 4;
smDVDReleases = 5;
smBiography = 6;
smGenreindex = 7;
smAwards = 8;
smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
pfComment    = 9;
pfBookmark    = 10;
pfPid        = 11;
pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.0.1';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);

//~Rating~ or ~RT Rating~
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, 'Average Rating: <span>', '/10</span>', True, curPos);
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<ul id="movie_results_ul" class="results_ul" ', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('<a id="more_movies" href="#results_movies_tab">More Movies...</a>', HTML, endPos)) do begin
endPos := PosFrom('"  class=', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+23, endPos - curPos-23));

curPos := PosFrom('"  class="" >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  class="" >', '</a>', True, curPos);

curPos := PosFrom('<span class="movie_year">', HTML, curPos);
endPos := PosFrom('</span></h3>', HTML, curPos);
Year := TextBetween(HTML, '<span class="movie_year">', '</span></h3>', True, curPos);

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 04, 2014, 03:28:54 pm
For unregistered users:

Rottentomatoes(1) script
v 0.1.0.1

Rottentomatoes(1).psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script 1
AUTHOR: Ivek23
VERSION: 0.1.0.1
DATE: 25/08/2013

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

///Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
smCredits = 4;
smDVDReleases = 5;
smBiography = 6;
smGenreindex = 7;
smAwards = 8;
smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
pfComment    = 9;
pfBookmark    = 10;
pfPid        = 11;
pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.0.1';
SCRIPT_NAME = 'Rottentomatoes Script1';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com1';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);

//~Rating~ or ~RT Rating~
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, 'Average Rating: <span>', '/10</span>', True, curPos);
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<ul id="movie_results_ul" class="results_ul" ', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('"  class=', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+23, endPos - curPos-23));

curPos := PosFrom('"  class="" >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  class="" >', '</a>', True, curPos);

curPos := PosFrom('</a>', HTML, curPos);
endPos := PosFrom('</span></h3>', HTML, curPos);
Year := TextBetween(HTML, '</a>', '</span></h3>', True, curPos);

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 04, 2014, 03:29:32 pm
For unregistered users:

Rottentomatoes (a) script
v 0.1.0.5.a

Rottentomatoes (a).psf


Code: [Select]
(*
SCRIPT INFO:

Following until 'SCRIPT BEGINS HERE...' is documentation.
Please see 'USER OPTIONS' in the body of the script.

---------------------------------------------

SCRIPT: Rottentomatoes (a) Script
AUTHOR: Ivek23
VERSION: 0.1.0.5.a
DATE: 04/03/2014

---------------------------------------------

TYPES AND FUNCTIONS
Additional types and functions that can be used in scripts:

Types
TWIDEARRAY : array of String

Field functions
procedure AddSearchResult(Title1, Title2, Year, URL, PreviewURL : String)
procedure AddFieldValue(AField: Integer; AValue : String)
procedure AddMoviePerson(Name, TransName, Role, URL : String; AType : Byte)
procedure AddPersonMovie(Title, OrigTitle, Role, Year, URL : String; AType : Byte)
procedure AddAward(Event, Award, Category, Recipient, Year: String; const Won : Boolean)
procedure AddAwardEx(Event, Award, Category, RecipientVal1, RecipientVal2, Year : String; const Won : Boolean);
procedure AddConnection(Title, OrigTitle, Category, URL, Year: String)
procedure AddEpisode(Title, OrigTitle, Description, URL, Year, Season, Episode : String)

String functions
function Pos(Substr : String; Str: String): Integer
function PosFrom(const SubStr, Str : String; FromIndex : Integer) : Integer
function LastPos(const SubStr, Str : String) : Integer
function PrevPos(const SubStr, Str : String; APos : Integer) : Integer
function RemoveTags(AText : String; doLineBreaks : Boolean) : String
function ExplodeString(AText : String; var Items : TWideArray; Delimiters : String) : Integer
function Copy(S: String; Index, Count: Integer): String
procedure Delete(var S: String; Index, Count: Integer)
procedure Insert(Source: String; var Dest: String; Index: Integer)
function Length(S: String): Integer
function Trim(S: String): String
function CompareText(S1, S2: String): Integer
function CompareStr(S1, S2: String): Integer
function UpperCase(S: String): String
function LowerCase(S: String): String
function AnsiString(S, OldPattern, NewPattern: String; All : Boolean; IgnoreCase : Boolean; WholeWord: Boolean): String
function StrToInt(const S: String): Integer
function IntToStr(const Value: Integer): String
function StrToFloat(const S: String): Extended
function FloatToStr(const Value: Extended): String
function CurrentDateTime : Extended
function DateToStr(Value : Extended) : String
function TimeToStr(Value : Extended) : String
function HTMLValues(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function HTMLValues2(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function TextBetween(const HTML : String; ABegin, AEnd : String; doLineBreaks : Boolean; var Pos : Integer) : String
function HTMLToText(const HTML : String) : String

  procedure ShowMessage(const Msg, Head : String)
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

///Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
smCredits = 4;
smDVDReleases = 5;
smBiography = 6;
smGenreindex = 7;
smAwards = 8;
smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
pfComment    = 9;
pfBookmark    = 10;
pfPid        = 11;
pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.0.5.a';
SCRIPT_NAME = 'Rottentomatoes(a) Script';
SCRIPT_DESC = '[EN] Get Movie Information(a) from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//User Options
GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
    GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
fullinfo, fullinfo1, fullinfo2 : String;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;


procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
Date, Title, URL, Month, TmpStr, TmpStr0, TmpStr1, TmpStr2, TmpStr3, TmpStr4, TmpStr5, TmpStr6: String;
DateParts : TWideArray;
begin

//Date ~Updated~ (choose simple or verbose version)
Date := DateToStr(CurrentDateTime);
if Date <> '' then
  begin
    ExplodeString(Date, DateParts, '-');
Date := DateParts[2] +'.'+ DateParts[1] +'.'+ DateParts[0];
AddCustomFieldValueByName('RTUpdated', Date + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION); // Annoying
  end else
    LogMessage('date not found');


//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);


//~Rating~ or ~RT Rating~
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, 'Average Rating: <span>', '/10</span>', True, curPos);
// //TmpStr := StringReplace(TmpStr, ',', '', True, True, False);
 if TmpStr = '0' then
TmpStr := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
    AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
//end;
end else
//~Rating~
curPos := PosFrom('<span class="meter popcorn numeric ">', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
curPos := PosFrom('Average Rating: ', HTML, curPos);
endPos := PosFrom('/5', HTML, curPos);
    TmpStr1 :=  FloatToStr((StrToFloat(Copy(HTML, curPos + 16, endPos - curPos - 16)) * 2));
 if TmpStr1 = '0' then
TmpStr1 := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr1);
    AddCustomFieldValueByName('RT Rating', TmpStr1);
 if TmpStr1 = '' then
TmpStr1 := 'rating unknown';
 end;
  EndPos := curPos;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<ul id="movie_results_ul" class="results_ul" ', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

EndPos := PosFrom('<span class="movieposter">', HTML, EndPos);
curPos := PosFrom('<img src="', HTML, EndPos);
endPos := PosFrom('" width="', HTML, curPos);
Preview := Copy(HTML, curPos+10, EndPos - curPos-10);
curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('<a id="more_movies" href="#results_movies_tab">More Movies...</a>', HTML, endPos)) do begin
endPos := PosFrom('"  class=', HTML, curPos);
URL := 'http://www.rottentomatoes.com/'+Trim(Copy(HTML, curPos+23, endPos - curPos-23));
curPos := PosFrom('"  class="" >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  class="" >', '</a>', True, curPos);
curPos := PosFrom('<span class="movie_year">', HTML, curPos);
endPos := PosFrom('</span></h3>', HTML, curPos);
Year := RemoveTags(TextBetween(HTML, '<span class="movie_year">', '</span></h3>', True, curPos), false);
AddSearchResult(Title+' '+Year, '', '', URL, Preview);
EndPos := PosFrom('<span class="movieposter">', HTML, EndPos);
curPos := PosFrom('<img src="', HTML, EndPos);
endPos := PosFrom('" width="', HTML, curPos);
Preview := Copy(HTML, curPos+10, EndPos - curPos-10);
curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
 end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.

Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 04, 2014, 03:30:32 pm
For unregistered users:

Rottentomatoes (a1) script
v 0.1.0.5.a

Rottentomatoes (a1).psf


Code: [Select]
(*
SCRIPT INFO:

Following until 'SCRIPT BEGINS HERE...' is documentation.
Please see 'USER OPTIONS' in the body of the script.

---------------------------------------------

SCRIPT: Rottentomatoes (a1) Script
AUTHOR: Ivek23
VERSION: 0.1.0.5.a1
DATE: 04/03/2014

---------------------------------------------

TYPES AND FUNCTIONS
Additional types and functions that can be used in scripts:

Types
TWIDEARRAY : array of String

Field functions
procedure AddSearchResult(Title1, Title2, Year, URL, PreviewURL : String)
procedure AddFieldValue(AField: Integer; AValue : String)
procedure AddMoviePerson(Name, TransName, Role, URL : String; AType : Byte)
procedure AddPersonMovie(Title, OrigTitle, Role, Year, URL : String; AType : Byte)
procedure AddAward(Event, Award, Category, Recipient, Year: String; const Won : Boolean)
procedure AddAwardEx(Event, Award, Category, RecipientVal1, RecipientVal2, Year : String; const Won : Boolean);
procedure AddConnection(Title, OrigTitle, Category, URL, Year: String)
procedure AddEpisode(Title, OrigTitle, Description, URL, Year, Season, Episode : String)

String functions
function Pos(Substr : String; Str: String): Integer
function PosFrom(const SubStr, Str : String; FromIndex : Integer) : Integer
function LastPos(const SubStr, Str : String) : Integer
function PrevPos(const SubStr, Str : String; APos : Integer) : Integer
function RemoveTags(AText : String; doLineBreaks : Boolean) : String
function ExplodeString(AText : String; var Items : TWideArray; Delimiters : String) : Integer
function Copy(S: String; Index, Count: Integer): String
procedure Delete(var S: String; Index, Count: Integer)
procedure Insert(Source: String; var Dest: String; Index: Integer)
function Length(S: String): Integer
function Trim(S: String): String
function CompareText(S1, S2: String): Integer
function CompareStr(S1, S2: String): Integer
function UpperCase(S: String): String
function LowerCase(S: String): String
function AnsiString(S, OldPattern, NewPattern: String; All : Boolean; IgnoreCase : Boolean; WholeWord: Boolean): String
function StrToInt(const S: String): Integer
function IntToStr(const Value: Integer): String
function StrToFloat(const S: String): Extended
function FloatToStr(const Value: Extended): String
function CurrentDateTime : Extended
function DateToStr(Value : Extended) : String
function TimeToStr(Value : Extended) : String
function HTMLValues(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function HTMLValues2(const HTML : String; ABegin, AEnd, ItemBegin, ItemEnd : String; ValDelim : String; var Pos : Integer) : String
function TextBetween(const HTML : String; ABegin, AEnd : String; doLineBreaks : Boolean; var Pos : Integer) : String
function HTMLToText(const HTML : String) : String

  procedure ShowMessage(const Msg, Head : String)
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

///Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
smCredits = 4;
smDVDReleases = 5;
smBiography = 6;
smGenreindex = 7;
smAwards = 8;
smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
pfComment    = 9;
pfBookmark    = 10;
pfPid        = 11;
pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.0.5.a1';
SCRIPT_NAME = 'Rottentomatoes(a1) Script';
SCRIPT_DESC = '[EN] Get Movie Information(a1) from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//User Options
GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
    GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
fullinfo, fullinfo1, fullinfo2 : String;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;


procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
Date, Title, URL, Month, TmpStr, TmpStr0, TmpStr1, TmpStr2, TmpStr3, TmpStr4, TmpStr5, TmpStr6: String;
DateParts : TWideArray;
begin

//Date ~Updated~ (choose simple or verbose version)
Date := DateToStr(CurrentDateTime);
if Date <> '' then
  begin
    ExplodeString(Date, DateParts, '-');
Date := DateParts[2] +'.'+ DateParts[1] +'.'+ DateParts[0];
AddCustomFieldValueByName('RTUpdated', Date + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION); // Annoying
  end else
    LogMessage('date not found');


//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);


//~Rating~ or ~RT Rating~
//curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
//if curPos > 0 then begin
// EndPos := curPos;
// TmpStr :=  TextBetween(HTML, 'Average Rating: <span>', '/10</span>', True, curPos);
// //TmpStr := StringReplace(TmpStr, ',', '', True, True, False);
// if TmpStr = '0' then
// TmpStr := '';
//    AddCustomFieldValueByName('RT Rating', TmpStr);
//if TmpStr = '' then
// TmpStr := 'rating unknown';
//end;
//~Rating~
//If Pos('audience', HTML) > 0 then begin
//If Pos('<span class="meter popcorn numeric ">', HTML) > 0 then begin
curPos := PosFrom('<span class="meter popcorn numeric ">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
    curPos := PosFrom('Average Rating: ', HTML, curPos);
endPos := PosFrom('/5', HTML, curPos);
    TmpStr3 :=  StringReplace(FloatToStr((StrToFloat(Copy(HTML, curPos + 16, endPos - curPos - 16)) * 2)), '/5', '', True, True, False);
 if TmpStr3 = '0' then
TmpStr3 := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr3);
    AddCustomFieldValueByName('RT Rating', TmpStr3);
 if TmpStr3 = '' then
TmpStr3 := 'rating unknown';
//  end;
 end;
end else
//~Rating~
//If Pos('audience', HTML) > 0 then begin
//If Pos('<span class="meter spilled numeric ">', HTML) > 0 then begin
curPos := PosFrom('<span class="meter spilled numeric ">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
    curPos := PosFrom('Average Rating: ', HTML, curPos);
endPos := PosFrom('/5', HTML, curPos);
    TmpStr4 :=  StringReplace(FloatToStr((StrToFloat(Copy(HTML, curPos + 16, endPos - curPos - 16)) * 2)), '/5', '', True, True, False);
 if TmpStr4 = '0' then
TmpStr4 := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr4);
    AddCustomFieldValueByName('RT Rating', TmpStr4);
 if TmpStr4 = '' then
TmpStr4 := 'rating unknown';
//  end;
 end;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<ul id="movie_results_ul" class="results_ul" ', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

EndPos := PosFrom('<span class="movieposter">', HTML, EndPos);
curPos := PosFrom('<img src="', HTML, EndPos);
endPos := PosFrom('" width="', HTML, curPos);
Preview := Copy(HTML, curPos+10, EndPos - curPos-10);
curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('<a id="more_movies" href="#results_movies_tab">More Movies...</a>', HTML, endPos)) do begin
endPos := PosFrom('"  class=', HTML, curPos);
URL := 'http://www.rottentomatoes.com/'+Trim(Copy(HTML, curPos+23, endPos - curPos-23));
curPos := PosFrom('"  class="" >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  class="" >', '</a>', True, curPos);
curPos := PosFrom('<span class="movie_year">', HTML, curPos);
endPos := PosFrom('</span></h3>', HTML, curPos);
Year := RemoveTags(TextBetween(HTML, '<span class="movie_year">', '</span></h3>', True, curPos), false);
AddSearchResult(Title+' '+Year, '', '', URL, Preview);
EndPos := PosFrom('<span class="movieposter">', HTML, EndPos);
curPos := PosFrom('<img src="', HTML, EndPos);
endPos := PosFrom('" width="', HTML, curPos);
Preview := Copy(HTML, curPos+10, EndPos - curPos-10);
curPos := PosFrom('<a target="_top" href="/m/', HTML, curPos);
 end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on March 30, 2014, 02:10:18 pm
Preparing Imdb Movie Script and Imdb Movie(1) Script with additional information, which data are Imdb plugin is not transferred.

I wonder what additional information is added to the script, so you can write your suggestions here for additional information, which should be added to the script.

Then I'll see how and what I can do and which of the proposals the can be added to the script.

Solutions, comprehensive information and more scripts now in Imdb Movie Script for Additional Information (http://www.videodb.info/forum_en/index.php/topic,3382.msg17085.html#msg17085) topic described.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on July 27, 2014, 02:12:59 pm
I fixed it procedure ParseSearchResults to re-presentation of search results.

Rottentomatoes script
v 0.1.0.6


The source code for the search results on Rottentomatoes web pages there have been some changes, which is now very important influence in modifying and correcting the Rottentomatoes script.

This problem is removed, no more present.
There is a small cosmetic problem, namely to the first five results (one until five hits - depending on how many are on the All Search Results page) these results again repeat with all the other results in Movies Search Results page
Now this is no longer a cosmetic fault.

Rottentomatoes(1) script is no longer necessary because now it's all in one script.



Rottentomatoes script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on July 27, 2014, 02:13:35 pm
For unregistered users:

Rottentomatoes script
v 0.1.0.6

Rottentomatoes.psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.0.6
DATE: 27/07/2014

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

//Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
//smCredits = 4;
//smDVDReleases = 5;
//smBiography = 6;
//smGenreindex = 7;
//smAwards = 8;
//smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
//pfComment    = 9;
//pfBookmark    = 10;
//pfPid        = 11;
//pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.0.6';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);

//~Rating~ or ~RT Rating~
curPos := PosFrom('<p class="critic_stats">', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, 'Average Rating: <span>', '/10</span>', True, curPos);
 if TmpStr = '0' then
TmpStr := '';
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
// curPos := Pos('<ul id="movie_results_ul" class="results_ul" ', HTML);
curPos := Pos('<div id="results_movies_tab" class="ui-tabs-hide">', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a target="_top" data-pageheader="" href="/m/', HTML, curPos);
//while (curPos > 0) AND (curPos < PosFrom('<a id="more_movies" href="#results_movies_tab">More Movies...</a>', HTML, endPos)) do begin
while curPos > 0 do begin
endPos := PosFrom('"  class=', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+42, endPos - curPos-42));

curPos := PosFrom('"  class="" >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  class="" >', '</a>', True, curPos);

curPos := PosFrom('</a>', HTML, curPos);
endPos := PosFrom('</span></h3>', HTML, curPos);
Year := TextBetween(HTML, '</a>', '</span></h3>', True, curPos);

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a target="_top" data-pageheader="" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on July 27, 2014, 03:16:36 pm
Also would it be possibe to also add the Audiance rating from RT as I often go by an average of the two.

Audiance rating

It is possible, but there is a small problem that can be seen only one rating in PVD database:
Tomatometer rating or Audiance rating.

Recommendation or advice:

First of all, Tomatometer rating info you download with Rottentomatoes script. (http://www.videodb.info/forum_en/index.php/topic,3252.msg17168.html#msg17168) If Tomatometer rating not stand it now, but whoever wants you Audiance rating may be transferred to Rottentomatoes (a) script. If it was not yet the transfer, then they use Rottentomatoes (a1) script for Audiance rating, this script will Audiance rating surely passed if, of course, is added to the movies web sites.


One warning:

Rottentomatoes (a) or Rottentomatoes (a1) script will overwrite Tomatometer rating information.


Rottentomatoes (a) script
v 0.1.0.5.a

Rottentomatoes (a1) script
v 0.1.0.5.a


These Rottentomatoes scripts still work as before.
Title: Re: Suggestion for Ivek23
Post by: deazo on August 06, 2014, 01:28:44 am
Thanks a lot Ivek, working GREAT!
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on August 06, 2014, 04:40:26 am
Thanks a lot Ivek, working GREAT!

Welcome and thank you for feedback.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 04, 2014, 11:53:14 am
Rottentomatoes script
v 0.1.1.0


Due to changes in the source code on Rottentomatoes pages, it was necessary that I again had to fix "process ParseSearchResults" to restore the functioning of the search results. The good side of these changes is, that it will now transfer rating data using only one Rottentomatoes script. Up to now, for the transmission of rating data were in many cases required two or even three script that was made a successful transfer of data for TOMATOMETER rating or AUDIENCE SCORE rating. Now for the transmission of data over rating requires only one script namely Rottentomatoes script, because I added code for TOMATOMETER rating and AUDIENCE SCORE rating.
In addition, Average Rating for All Critics,  the yet added Average Rating for Top Critics and Average Rating for Audience Score.


Custom field:

RT data:                                           custom field:
---------------                                       -------------------

Rating for All Critics                                     RT Rating      
Rating for Top Critics                                   RT Top Rating
Rating for Audience Score                           RT Audience Rating



Notice:

Rottentomatoes (a) script
v 0.1.0.5.a

Rottentomatoes (a1) script
v 0.1.0.5.a (http://www.videodb.info/forum_en/index.php/topic,3252.msg18338.html#msg18338)
is no longer necessary because now it's all in one script.




Rottentomatoes script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 04, 2014, 12:12:35 pm
In Average Rating for All Critics also features such possibility in the code

Code: [Select]
//  ~Rating for All Critics~
//~Average Rating~ or ~RT Rating~ for All Critics
.
.
.
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;

it is possible to do this
Code: [Select]
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 04, 2014, 12:14:02 pm
For unregistered users:

Rottentomatoes script
v 0.1.1.0

Rottentomatoes.psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.1.0
DATE: 04/10/2014

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

//Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
//smCredits = 4;
//smDVDReleases = 5;
//smBiography = 6;
//smGenreindex = 7;
//smAwards = 8;
//smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
//pfComment    = 9;
//pfBookmark    = 10;
//pfPid        = 11;
//pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.1.0';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//User Options
// GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
// GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr, TmpStr1, TmpStr2 : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);


//  ~TOMATOMETER~

//  ~Rating for All Critics~
//~Average Rating~ or ~RT Rating~ for All Critics
curPos := PosFrom('<div id="all-critics-numbers" class="tab-pane active"', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, 'Average Rating: ', '/10</div>', True, curPos);
 if TmpStr = '0' then
TmpStr := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;

//  ~Rating for Top Critics~
//~Average Rating~ or ~RT Top Rating~ for Top Critics
curPos := PosFrom('<div id="top-critics-numbers" class="tab-pane">', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr1 :=  TextBetween(HTML, 'Average Rating: ', '/10</div>', True, curPos);
 if TmpStr1 = '0' then
TmpStr1 := '';
    AddCustomFieldValueByName('RT Top Rating', TmpStr1);
 if TmpStr1 = '' then
TmpStr1 := 'rating unknown';
  EndPos := curPos;
end;
 
 
//  ~AUDIENCE SCORE~ 

//~Audience: Average Rating~ or ~RT Audience Rating~ for Audience Score
curPos := PosFrom('<h3 style="padding:10px">AUDIENCE SCORE', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
curPos := PosFrom('<div class="audience-info" style="padding-bottom:10px">', HTML, EndPos);
if curPos > 0 then begin
    curPos := PosFrom('Average Rating: ', HTML, curPos);
endPos := PosFrom('/5', HTML, curPos);
    TmpStr2 :=  StringReplace(FloatToStr((StrToFloat(Copy(HTML, curPos + 16, endPos - curPos - 16)) * 2)), '/5', '', True, True, False);
 if TmpStr2 = '0' then
TmpStr2 := '';
    AddCustomFieldValueByName('RT Audience Rating', TmpStr2);
 if TmpStr2 = '' then
TmpStr2 := 'rating unknown';
  end;
  EndPos := curPos;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<div id="results_movies_tab" class="ui-tabs-hide">', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('"  >', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+71, endPos - curPos-71));

curPos := PosFrom('"  >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  >', '</a>', True, curPos); 

curPos := PosFrom('</a>', HTML, curPos);
endPos := PosFrom('</span></div>', HTML, curPos);
Year := TextBetween(HTML, '</a>', '</span></div>', True, curPos);

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: deazo on October 05, 2014, 09:38:45 am
Again Ivek: THANKS A LOT for the hard work!
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 05, 2014, 09:55:17 am
Again Ivek: THANKS A LOT for the hard work!

deazo, thanks.
Title: Re: Suggestion for Ivek23
Post by: deazo on October 09, 2014, 10:13:13 am

 Hi Ivek,

 For some reason the new script does not grab the rating anymore.
 I have even tried with the previous script and ratings are not taken either.
 Would you know what the problem is by any chance?

Thanks
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 10, 2014, 11:37:02 am

 Hi Ivek,

 For some reason the new script does not grab the rating anymore.
 I have even tried with the previous script and ratings are not taken either.
 Would you know what the problem is by any chance?

Thanks

Yeah, I noticed that the rating does not work anymore.
Reason: again the changes in the source code on rottentomatoes pages.



Rottentomatoes script
v 0.1.1.4


I fixed the rating code that now the problem is solved.
I hope that will not change in the source code on rottentomatoes pages in the near future - at least for some time not.

Rottentomatoes script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 10, 2014, 11:37:35 am
For unregistered users:

Rottentomatoes script
v 0.1.1.4

Rottentomatoes.psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.1.4
DATE: 10/10/2014

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

//Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
//smCredits = 4;
//smDVDReleases = 5;
//smBiography = 6;
//smGenreindex = 7;
//smAwards = 8;
//smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
//pfComment    = 9;
//pfBookmark    = 10;
//pfPid        = 11;
//pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.1.4';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//User Options
// GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
// GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr, TmpStr1, TmpStr2 : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);


//  ~TOMATOMETER~

//  ~Rating for All Critics~
//~Average Rating~ or ~RT Rating~ for All Critics
curPos := PosFrom('<div id="all-critics-numbers" class="tab-pane active"', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, '<span class="subtle">Average Rating: </span>', '/10', True, curPos);
 if TmpStr = '0' then
TmpStr := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;

//  ~Rating for Top Critics~
//~Average Rating~ or ~RT Top Rating~ for Top Critics
curPos := PosFrom('<div id="top-critics-numbers" class="tab-pane', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr1 :=  TextBetween(HTML, '<span class="subtle">Average Rating: </span>', '/10', True, curPos);
 if TmpStr1 = '0' then
TmpStr1 := '';
    AddCustomFieldValueByName('RT Top Rating', TmpStr1);
 if TmpStr1 = '' then
TmpStr1 := 'rating unknown';
  EndPos := curPos;
end;
 
 
//  ~AUDIENCE SCORE~ 

//~Audience: Average Rating~ or ~RT Audience Rating~ for Audience Score
//curPos := PosFrom('<div class="audience-info">', HTML, EndPos);
curPos := Pos('<div class="audience-info">', HTML);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr2 :=  FloatToStr(StrToFloat(TextBetween(HTML, '<span class="subtle">Average Rating:</span>', '/5', True, curPos)) * 2);
 if TmpStr2 = '0' then
TmpStr2 := '';
    AddCustomFieldValueByName('RT Audience Rating', TmpStr2);
 if TmpStr2 = '' then
TmpStr2 := 'rating unknown';
  EndPos := curPos;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<div id="results_movies_tab" class="ui-tabs-hide">', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('"  >', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+71, endPos - curPos-71));

curPos := PosFrom('"  >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  >', '</a>', True, curPos); 

curPos := PosFrom('</a>', HTML, curPos);
endPos := PosFrom('</span></div>', HTML, curPos);
Year := TextBetween(HTML, '</a>', '</span></div>', True, curPos);

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: deazo on October 10, 2014, 01:20:36 pm

 Works perfectly.
 Thanks again!
  ;D ;D ;D ;D ;D
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 10, 2014, 03:19:39 pm

 Works perfectly.
 Thanks again!
  ;D ;D ;D ;D ;D

Thank you, we'll see how long it will work because they are so far were daily changes in the source code on rottentomatoes pages.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 01, 2014, 07:08:18 pm
Again, it was corrected procedure ParseSearchResults for the re-presentation of search results.

Rottentomatoes script
v 0.1.1.5

Rottentomatoes script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 01, 2014, 07:09:31 pm
For unregistered users:

Rottentomatoes script
v 0.1.1.5

Rottentomatoes.psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.1.5
DATE: 1/11/2014

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

//Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
//smCredits = 4;
//smDVDReleases = 5;
//smBiography = 6;
//smGenreindex = 7;
//smAwards = 8;
//smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
//pfComment    = 9;
//pfBookmark    = 10;
//pfPid        = 11;
//pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.1.5';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
CODE_PAGE = 65001; //Use 0 for Autodetect

//User Options
// GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
// GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr, TmpStr1, TmpStr2 : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('"canonical" href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 18, endPos - curPos - 18));
end else
AddFieldValue(mfURL, MovieURL);


//  ~TOMATOMETER~

//  ~Rating for All Critics~
//~Average Rating~ or ~RT Rating~ for All Critics
curPos := PosFrom('<div id="all-critics-numbers" class="tab-pane active"', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, '<span class="subtle">Average Rating: </span>', '/10', True, curPos);
 if TmpStr = '0' then
TmpStr := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;

//  ~Rating for Top Critics~
//~Average Rating~ or ~RT Top Rating~ for Top Critics
curPos := PosFrom('<div id="top-critics-numbers" class="tab-pane', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr1 :=  TextBetween(HTML, '<span class="subtle">Average Rating: </span>', '/10', True, curPos);
 if TmpStr1 = '0' then
TmpStr1 := '';
    AddCustomFieldValueByName('RT Top Rating', TmpStr1);
 if TmpStr1 = '' then
TmpStr1 := 'rating unknown';
  EndPos := curPos;
end;
 
 
//  ~AUDIENCE SCORE~ 

//~Audience: Average Rating~ or ~RT Audience Rating~ for Audience Score
//curPos := PosFrom('<div class="audience-info">', HTML, EndPos);
curPos := Pos('<div class="audience-info">', HTML);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr2 :=  FloatToStr(StrToFloat(TextBetween(HTML, '<span class="subtle">Average Rating:</span>', '/5', True, curPos)) * 2);
 if TmpStr2 = '0' then
TmpStr2 := '';
    AddCustomFieldValueByName('RT Audience Rating', TmpStr2);
 if TmpStr2 = '' then
TmpStr2 := 'rating unknown';
  EndPos := curPos;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<div id="results_movies_tab" class="ui-tabs-hide">', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('"  >', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+71, endPos - curPos-71));

curPos := PosFrom('"  >', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '"  >', '</a>', True, curPos); 

curPos := PosFrom('<span class="movie_year">', HTML, curPos);
endPos := PosFrom('</span></div>', HTML, curPos);
Year := TextBetween(HTML, '<span class="movie_year">', '</span></div>', True, curPos);

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: deazo on November 09, 2014, 01:10:54 am

 THANKS again!
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 09, 2014, 06:32:51 am

 THANKS again!

Welcome.
Title: Re: Suggestion for Ivek23
Post by: deazo on April 28, 2015, 08:14:54 am

 Hi Ivek,
I think the script is broken (RT has probably changed again...)
I cannot get ratings and also the script will download a bunch of codes in the URL field...
Let us know if you can take a look when you have time please?
No rush.
Thank you in advance.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on April 28, 2015, 10:38:07 am

 Hi Ivek,
I think the script is broken (RT has probably changed again...)
I cannot get ratings and also the script will download a bunch of codes in the URL field...
Let us know if you can take a look when you have time please?
No rush.
Thank you in advance.

Thank you for your feedback, deazo.

I'll see what the problem is, when I have more time. Certainly, this will be when I updated and added new movie titles in my movie database. Then will AllMovie.com_new script, which is also currently does not work, it will also
then updated.
Title: Re: Suggestion for Ivek23
Post by: deazo on April 28, 2015, 08:03:50 pm

 Ok thanks take your time.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on May 23, 2015, 07:14:48 pm
Again, it was corrected procedure ParseSearchResults for the re-presentation of search results. I also fixed all rating information transmission.

Rottentomatoes script
v 0.1.1.6

Rottentomatoes script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on May 23, 2015, 07:16:31 pm
For unregistered users:

Rottentomatoes script
v 0.1.1.6

Rottentomatoes.psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.1.6
DATE: 23/05/2015

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

//Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
//smCredits = 4;
//smDVDReleases = 5;
//smBiography = 6;
//smGenreindex = 7;
//smAwards = 8;
//smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
//pfComment    = 9;
//pfBookmark    = 10;
//pfPid        = 11;
//pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.1.6';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
//SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s';
CODE_PAGE = 65001; //Use 0 for Autodetect

//User Options
// GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
// GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr, TmpStr1, TmpStr2 : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" rel="canonical" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('</title> <link href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, endPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);


//  ~TOMATOMETER~

//  ~Rating for All Critics~
//~Average Rating~ or ~RT Rating~ for All Critics
curPos := PosFrom('<div id="all-critics-numbers" class="tab-pane active"', HTML, EndPos);
//curPos := PosFrom('<<meta itemprop="name" content="All Critic Tomatometer"/>', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, '<span class="subtle superPageFontColor">Average Rating: </span>', '/10 </div>', True, curPos);
 if TmpStr = '0' then
TmpStr := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;

//  ~Rating for Top Critics~
//~Average Rating~ or ~RT Top Rating~ for Top Critics
curPos := PosFrom('<div id="top-critics-numbers" class="tab-pane', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr1 :=  TextBetween(HTML, '<span class="subtle superPageFontColor">Average Rating: </span>', '/10 </div>', True, curPos);
 if TmpStr1 = '0' then
TmpStr1 := '';
    AddCustomFieldValueByName('RT Top Rating', TmpStr1);
 if TmpStr1 = '' then
TmpStr1 := 'rating unknown';
  EndPos := curPos;
end;
 
 
//  ~AUDIENCE SCORE~ 

//~Audience: Average Rating~ or ~RT Audience Rating~ for Audience Score
//curPos := PosFrom('<div class="audience-info">', HTML, EndPos);
curPos := Pos('<div class="audience-score meter">', HTML);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr2 :=  FloatToStr(StrToFloat(TextBetween(HTML, '<div> <span class="subtle superPageFontColor">Average Rating:</span>', '/5 </div>', True, curPos)) * 2);
 if TmpStr2 = '0' then
TmpStr2 := '';
    AddCustomFieldValueByName('RT Audience Rating', TmpStr2);
 if TmpStr2 = '' then
TmpStr2 := 'rating unknown';
  EndPos := curPos;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<div id="results_movies_tab" class="ui-tabs-hide">', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('">', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+71, endPos - curPos-71));

curPos := PosFrom('">', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '">', '</a>', True, curPos); 

curPos := PosFrom('<span class="movie_year">', HTML, curPos);
endPos := PosFrom('</span></div>', HTML, curPos);
Year := TextBetween(HTML, '<span class="movie_year">', '</span></div>', True, curPos);

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a class="unstyled articleLink" target="_top" data-pageheader="" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: deazo on May 26, 2015, 11:22:49 pm
NICE ONE
Thank you Ivek it works perfectly!
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on May 27, 2015, 05:22:48 am
NICE ONE
Thank you Ivek it works perfectly!

Welcome.
Title: Re: Suggestion for Ivek23
Post by: afrocuban on October 26, 2015, 11:29:36 pm
Hello Ivek,

Is it possible with this script to import Title to a Custom Field also named "Title"? What piece of code it would be? Thanks in advance.

I have already added this piece of code
AddCustomFieldValueByName('Rottentomatoes.com', '<link url="' + MovieURL + '">Rottentomatoes.com</link>');
:
Code: [Select]
//Get ~mfURL~ or ~RT Url~
endPos := Pos('" rel="canonical" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('</title> <link href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, endPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);
AddCustomFieldValueByName('Rottentomatoes.com', '<link url="' + MovieURL + '">Rottentomatoes.com</link>');
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 27, 2015, 07:15:25 am
Of course it is possible, very simply, is the same as the URL in the box to custom, only a different part of the code.

Here is the piece of code in the script:

Code: [Select]
procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
Date, Title, URL, Month, Month1, Months, TmpStr, TmpStr0, TmpStr1, TmpStr2  : String;
DateParts : TWideArray;
begin

//Date ~Updated~ (choose simple or verbose version)
Date := DateToStr(CurrentDateTime);
if Date <> '' then
  begin
    ExplodeString(Date, DateParts, '-');
Date := DateParts[2] +'.'+ DateParts[1] +'.'+ DateParts[0];
AddCustomFieldValueByName('RTUpdated', Date + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + RATING_NAME + ' ' + SCRIPT_VERSION); // Annoying
  end else
    LogMessage('date not found');


//Get ~mfURL~ or ~RT Url~
endPos := Pos('" rel="canonical" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('</title> <link href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, endPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);
AddCustomFieldValueByName('Rottentomatoes.com', '<link url="' + MovieURL + '">Rottentomatoes.com</link>');

////// ---- ~Movie~ ---- //////

//~Title~
curPos := Pos('" itemprop="name"> ', HTML) + Length('" itemprop="name"> ');
EndPos := PosFrom('</span></h1>', HTML, curPos);
    TmpStr := RemoveTags(Trim(Copy(HTML, curPos, endPos - curPos)), false);
TmpStr := StringReplace(TmpStr, '                 ', ' ', True, True, False);
if TmpStr <> '' then
AddCustomFieldValueByName('RT Title','<link url="' + MovieURL + '">' + TmpStr + '</link>';

end;

I hope that will help.
Title: Re: Suggestion for Ivek23
Post by: afrocuban on October 27, 2015, 03:47:19 pm
Thanks Ivek, for the quick response.

Whe I paste this code, PVD doesn't recognize the script. The part about "Updated" is ok, but, the part about "Title" isn't. When I delete only part of code about "Title" (////// ---- ~Movie~ ---- //////

//~Title~...), and leave the rest as you wrote ("Updated").

PVD recognize the script.

Thanks a lot!
Title: Re: Suggestion for Ivek23
Post by: afrocuban on October 27, 2015, 04:28:56 pm
Ok, I got it!

One (right) bracket missing, and one sufficient "end". This was what I asked for

Code: [Select]
procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
Date, Title, URL, Month, Month1, Months, TmpStr, TmpStr0, TmpStr1,

TmpStr2  : String;
DateParts : TWideArray;
begin

//Date ~Updated~ (choose simple or verbose version)
Date := DateToStr(CurrentDateTime);
if Date <> '' then
  begin
    ExplodeString(Date, DateParts, '-');
Date := DateParts[2] +'.'+ DateParts[1] +'.'+ DateParts[0];
AddCustomFieldValueByName('RTUpdated', Date + ' at ' + TimeToStr

(CurrentDateTime) + ' • ' + RATING_NAME + ' ' + SCRIPT_VERSION); //

Annoying
  end else
    LogMessage('date not found');


//Get ~mfURL~ or ~RT Url~
endPos := Pos('" rel="canonical" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('</title> <link href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, endPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);
AddCustomFieldValueByName('Rottentomatoes.com', '<link url="' + MovieURL +

'">Rottentomatoes.com</link>');


////// ---- ~Movie~ ---- //////

//~Title~
curPos := Pos('" itemprop="name"> ', HTML) + Length('" itemprop="name"> ');
EndPos := PosFrom('</span></h1>', HTML, curPos);
    TmpStr := RemoveTags(Trim(Copy(HTML, curPos, endPos - curPos)), false);
TmpStr := StringReplace(TmpStr, '                 ', ' ', True, True, False);
if TmpStr <> '' then
AddCustomFieldValueByName('Title',TmpStr);

Once again, thanks a lot, Ivek!
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 27, 2015, 05:51:12 pm
Thanks Ivek, for the quick response.

Whe I paste this code, PVD doesn't recognize the script. The part about "Updated" is ok, but, the part about "Title" isn't. When I delete only part of code about "Title" (////// ---- ~Movie~ ---- //////

//~Title~...), and leave the rest as you wrote ("Updated").

PVD recognize the script.

Thanks a lot!

Glad to have found the right solution.

Ok, I got it!

One (right) bracket missing, and one sufficient "end". This was what I asked for

Code: [Select]
procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
Date, Title, URL, Month, Month1, Months, TmpStr, TmpStr0, TmpStr1,

TmpStr2  : String;
DateParts : TWideArray;
begin

//Date ~Updated~ (choose simple or verbose version)
Date := DateToStr(CurrentDateTime);
if Date <> '' then
  begin
    ExplodeString(Date, DateParts, '-');
Date := DateParts[2] +'.'+ DateParts[1] +'.'+ DateParts[0];
AddCustomFieldValueByName('RTUpdated', Date + ' at ' + TimeToStr

(CurrentDateTime) + ' • ' + RATING_NAME + ' ' + SCRIPT_VERSION); //

Annoying
  end else
    LogMessage('date not found');


//Get ~mfURL~ or ~RT Url~
endPos := Pos('" rel="canonical" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('</title> <link href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, endPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);
AddCustomFieldValueByName('Rottentomatoes.com', '<link url="' + MovieURL +

'">Rottentomatoes.com</link>');


////// ---- ~Movie~ ---- //////

//~Title~
curPos := Pos('" itemprop="name"> ', HTML) + Length('" itemprop="name"> ');
EndPos := PosFrom('</span></h1>', HTML, curPos);
    TmpStr := RemoveTags(Trim(Copy(HTML, curPos, endPos - curPos)), false);
TmpStr := StringReplace(TmpStr, '                 ', ' ', True, True, False);
if TmpStr <> '' then
AddCustomFieldValueByName('Title',TmpStr);

Once again, thanks a lot, Ivek!

Thanks, I'm glad that I can help you find the right solution and that the script works properly.
Title: Re: Suggestion for Ivek23
Post by: afrocuban on October 27, 2015, 08:04:23 pm
Ivek, you're the best!  :)

And if someone wants only title without a year, then this:
Code: [Select]
EndPos := PosFrom('</span></h1>', HTML, curPos)-6;
Title: Re: Suggestion for Ivek23
Post by: afrocuban on October 28, 2015, 06:51:05 pm
Hello Ivek,
What I see now, the script searches by url if there's any, and if there's no url then by: 1. Title and if there's no title, or script cannot find in on RT, it searches by 2. origtitle

One more possible use of it arrised. Is it possible to set this script to search for a movie details by this order: 1. Custom title; 2. Title; 3. origtitle.

So, if theres no Custom title, it would search by Title, and if there's no results by these 2, to search by origtitle?

Thanks in advance! :)

Title: Re: Suggestion for Ivek23
Post by: Ivek23 on October 29, 2015, 09:09:39 am
Hello Ivek,
What I see now, the script searches by url if there's any, and if there's no url then by: 1. Title and if there's no title, or script cannot find in on RT, it searches by 2. origtitle

One more possible use of it arrised. Is it possible to set this script to search for a movie details by this order: 1. Custom title; 2. Title; 3. origtitle.

So, if theres no Custom title, it would search by Title, and if there's no results by these 2, to search by origtitle?

Thanks in advance! :)

Unfortunately, but here I can not help, maybe someone other users can do to help you, which may have some user experience in relation to your request.

Maybe you can help this Rottentomatoes_simple_Bing_Search script.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on January 31, 2016, 11:19:47 am
Again, it was corrected procedure ParseSearchResults for the re-presentation of search results.

Rottentomatoes script
v 0.1.1.7

Rottentomatoes script is attached.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on January 31, 2016, 11:29:18 am
For unregistered users:

To download the scripts can link found in Rottentomatoes Links (http://www.videodb.info/forum_en/index.php/topic,4036.msg19459.html#msg19459) topic.

Rottentomatoes script
v 0.1.1.7

Rottentomatoes.psf


Code: [Select]
(*
SCRIPT INFO:

---------------------------------------------

SCRIPT: Rottentomatoes Script
AUTHOR: Ivek23
VERSION: 0.1.1.7
DATE: 31/01/2016

---------------------------------------------
*)

//SCRIPT BEGINS HERE...

//Some useful constants

const

//Script types
stMovies = 0;
stPeople = 1;
stPoster = 2;

//Script modes
smSearch = 0;
smNormal = 1;
smCast = 2;
smReview = 3;
//smCredits = 4;
//smDVDReleases = 5;
//smBiography = 6;
//smGenreindex = 7;
//smAwards = 8;
//smMiscellaneous = 9;
smPoster = 10;
smFinished = 11;

//Parse results
prError = 0;
prFinished = 1;
prList = 2;
prListImage = 3;
prDownload = 4;

//Prefix modes
pmNone = 0;
pmEnd = 1;
pmBegin = 2;
pmRemove = 3;

//Download methods
dmGET = 0;
dmPOST = 1;

//Movie fields
mfURL = 0;
mfTitle = 1;
mfOrigTitle = 2;
mfAka = 3;
mfYear = 4;
mfGenre = 5;
mfCategory = 6;
mfCountry = 7;
mfStudio = 8;
mfMPAA = 9;
mfRating = 10;
mfTags = 11;
mfTagline = 12;
mfDescription = 13;
mfDuration = 14;
mfFeatures = 15;

//People fields
    pfURL        = 0;
pfName        = 1;
pfTransName  = 2;
pfAltNames    = 3;
pfBirthday    = 4;
pfBirthplace = 5;
pfGenre      = 6;
pfBio        = 7;
pfDeathDate  = 8; 
//pfComment    = 9;
//pfBookmark    = 10;
//pfPid        = 11;
//pfCareer      = 12;

//Credits types
ctActors = 0;
ctDirectors = 1;
ctWriters = 2;
ctComposers = 3;
ctProducers = 4;

//Script data
SCRIPT_VERSION = '0.1.1.7';
SCRIPT_NAME = 'Rottentomatoes Script';
SCRIPT_DESC = '[EN] Get Movie Information about from Rottentomatoes.com';
SCRIPT_LANG = $09; //English
SCRIPT_TYPE = stMovies;

BASE_URL = 'http://www.rottentomatoes.com';
RATING_NAME = 'Rottentomatoes';
//SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s&sitesearch=rt';
SEARCH_STR = 'http://www.rottentomatoes.com/search/?search=%s';
CODE_PAGE = 28591; //Use 0 for Autodetect
//CODE_PAGE = 65001; //Use 0 for Autodetect
//CODE_PAGE = 0; //Use 0 for Autodetect

//User Options
// GET_THEMES = True; //Set to False to ensure ~mfCategory~ not added even if 'Overwrite fields' setting allows
// GET_POSTER  = False; //Set to False or True
GET_RATING = True; //Set to False to ensure ~mfRating~ not set even if 'Overwrite setting' fields setting allows

//Global variables
var
ELI : Integer;
Mode : Byte;
ExtraLinks : array [smCast..smPoster] of String;

//Functions
function GetScriptVersion : String;
begin
Result := SCRIPT_VERSION;
end;

function GetScriptName : String;
begin
Result :=  SCRIPT_NAME;
end;

function GetScriptDesc : String;
begin
Result := SCRIPT_DESC;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetScriptLang: Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetDownloadURL : AnsiString;
begin
if (Mode = smSearch) then
Result := SEARCH_STR
else
Result := ExtraLinks[Mode];
end;

function GetDownloadMethod : Byte;
begin
Result := dmGET;
end;

function GetPrefixMode : Byte;
begin
Result := pmBegin;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := Mode;
end;

procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, endPos : Integer;
TmpStr, TmpStr1, TmpStr2 : String;
begin

//Get ~mfURL~ or ~RT Url~
endPos := Pos('" rel="canonical" itemprop="url"/>', HTML);
if endPos > 0 then begin
curPos := PrevPos('</title> <link href="', HTML, endPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, endPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);


//  ~TOMATOMETER~

//  ~Rating for All Critics~
//~Average Rating~ or ~RT Rating~ for All Critics
curPos := PosFrom('<div id="all-critics-numbers" class="tab-pane active"', HTML, EndPos);
//curPos := PosFrom('<<meta itemprop="name" content="All Critic Tomatometer"/>', HTML, EndPos);
if curPos > 0 then begin
EndPos := curPos;
TmpStr :=  TextBetween(HTML, '<span class="subtle superPageFontColor">Average Rating: </span>', '/10 </div>', True, curPos);
 if TmpStr = '0' then
TmpStr := '';
if GET_RATING then
AddFieldValue(mfRating, TmpStr);
AddCustomFieldValueByName('RT Rating', TmpStr);
 if TmpStr = '' then
TmpStr := 'rating unknown';
end;

//  ~Rating for Top Critics~
//~Average Rating~ or ~RT Top Rating~ for Top Critics
curPos := PosFrom('<div id="top-critics-numbers" class="tab-pane', HTML, EndPos);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr1 :=  TextBetween(HTML, '<span class="subtle superPageFontColor">Average Rating: </span>', '/10 </div>', True, curPos);
 if TmpStr1 = '0' then
TmpStr1 := '';
    AddCustomFieldValueByName('RT Top Rating', TmpStr1);
 if TmpStr1 = '' then
TmpStr1 := 'rating unknown';
  EndPos := curPos;
end;
 
 
//  ~AUDIENCE SCORE~ 

//~Audience: Average Rating~ or ~RT Audience Rating~ for Audience Score
//curPos := PosFrom('<div class="audience-info">', HTML, EndPos);
curPos := Pos('<div class="audience-score meter">', HTML);
if curPos > 0 then begin
// EndPos := curPos;
TmpStr2 :=  FloatToStr(StrToFloat(TextBetween(HTML, '<div> <span class="subtle superPageFontColor">Average Rating:</span>', '/5 </div>', True, curPos)) * 2);
 if TmpStr2 = '0' then
TmpStr2 := '';
    AddCustomFieldValueByName('RT Audience Rating', TmpStr2);
 if TmpStr2 = '' then
TmpStr2 := 'rating unknown';
  EndPos := curPos;
end;
 
end;


procedure ParseSearchResults(HTML : String);
var
curPos, endPos : Integer;
Title, Year, URL, Preview : String;
begin
curPos := Pos('<div id="results_movies_tab" class="ui-tabs-hide">', HTML);
if curPos < 1 then
Exit;

LogMessage('Parsing search results...');

curPos  := PosFrom('<img src="', HTML, curPos)+10;
endPos  := PosFrom('" width=', HTML, curPos);
Preview := Trim(Copy(HTML, curPos, endPos - curPos));

curPos := PosFrom('<a class="unstyled articleLink" href="/m/', HTML, curPos);
while curPos > 0 do begin
endPos := PosFrom('">', HTML, curPos);
URL := 'http://www.rottentomatoes.com'+Trim(Copy(HTML, curPos+38, endPos - curPos-38));

curPos := PosFrom('">', HTML, curPos);
endPos := PosFrom('</a>', HTML, curPos);
Title := TextBetween(HTML, '">', '</a>', True, curPos); 

curPos := PosFrom('<span class="movie_year">', HTML, curPos);
endPos := PosFrom('</span> </div>', HTML, curPos);
Year := TextBetween(HTML, '<span class="movie_year">', '</span> </div>', True, curPos);

AddSearchResult(Title+' '+Year, '', '', URL, '');

curPos := PosFrom('<a class="unstyled articleLink" href="/m/', HTML, curPos);
  end;
end;

function NextMode(curMode : Integer) : Integer;
var
I : Integer;
begin
Result := smFinished;
if curMode < Low(ExtraLinks) - 1 then
curMode := Low(ExtraLinks) - 1;

for I := curMode + 1 to High(ExtraLinks) do
if ExtraLinks[I] <> '' then begin
Result := I;
Break;
end;
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
HTML := HTMLToText(HTML);
HTML := StringReplace (HTML, 'http://rottentomatoes.com', 'http://www.rottentomatoes.com', True, True, False);

if Pos('Search Results - Rotten Tomatoes', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;

end else
 if Pos(' - Rotten Tomatoes</title>', HTML) > 0 then
    ParseMovie(URL, HTML);

Mode := NextMode(Mode);
if Mode <> smFinished then
Result := prDownload
else
Result := prFinished;
end;

begin
Mode := smSearch;
for ELI := Low(ExtraLinks) to High(ExtraLinks) do
ExtraLinks[ELI] := '';
end.
Title: Re: Suggestion for Ivek23
Post by: afrocuban on June 10, 2016, 07:13:12 pm
Well, https case with Rottent Tomatoes, as well. :(
Title: Re: Suggestion for Ivek23
Post by: deazo on July 01, 2016, 11:08:19 pm

 Yup.
 Not working anymore :(
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on July 02, 2016, 05:46:44 am
Yup.
 Not working anymore :(

It is true, another web page, which is switching to a secure https:// connection.

Unfortunately Rotten Tomatoes script does not work anymore and now we can not fix.

We'll see if in the future a problem with the secure https:// link in a PVD program solved (if Nostra solved this problem with a new version of the program) or we will have to say goodbye to him, unfortunately, all our users for PVD program.
Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 05, 2016, 12:12:40 pm
Even for the Rotten Tomatoes script is promising news, because the script with a few corrections and curl program will again be fully operational.
Title: Re: Suggestion for Ivek23
Post by: afrocuban on November 11, 2016, 03:36:18 pm

Perhaps other people can help us trying the script.

Well, guys, thank you so much for your effort to keep this fabulous piece of software - PVD, alive!

I'm for sure willing to try curl solution(s) for https, but please do make it easier for us, non-programming guys:

1. Ivek, please rename this topic to: Rotten Tomatoes Script and make it sticky to "Scripts and Templates" child board. This script doesn't have it's topic, and I (as well as others, I guess) always have a problem to find latest info about the script.

2. Please compile and "clean" your correspondence with VVV_Easy_Programing, and put clear instructions here/there (when you transfer the topic to proper childboard) what to do with curl, while attaching the latest script in OP's message (first one in the topic).

3. Optionally, make a sticky topic for curl, how to install it, where and how, in order to prepare us for further implementation with https.

4. Not an option - PVD dies. It HAS TO survive, :D


Thank you once again, both of you!

Title: Re: Suggestion for Ivek23
Post by: Ivek23 on November 12, 2016, 10:24:34 am

Perhaps other people can help us trying the script.

Well, guys, thank you so much for your effort to keep this fabulous piece of software - PVD, alive!

Thanks.

1. Ivek, please rename this topic to: Rotten Tomatoes Script and make it sticky to "Scripts and Templates" child board. This script doesn't have it's topic, and I (as well as others, I guess) always have a problem to find latest info about the script.

No, it will not be renaming this theme, but the new RottenTomatoes Script topic in  Scripts and Templates  (http://www.videodb.info/forum_en/index.php/board,9.0.html) board. However, there will also set out data which have now been mentioned here.

Please compile and "clean" your correspondence with VVV_Easy_Programing, and put clear instructions here/there (when you transfer the topic to proper childboard) what to do with curl, while attaching the latest script in OP's message (first one in the topic).

Of course, because I'm already thinking about what has now been said

3. Optionally, make a sticky topic for curl, how to install it, where and how, in order to prepare us for further implementation with https.

Instructions for use curl program will also be there, and a new topic on the curl program.


4. Not an option - PVD dies. It HAS TO survive, :D


Thank you once again, both of you!

Yeah, indeed it is.

Welcome.
Title: Re: Suggestion for Ivek23
Post by: afrocuban on November 12, 2016, 04:04:55 pm
Thank you, Ivek. I can't wait to see it there!

Cheers