English > Feature Suggestions
Suggestion for Ivek23
			Ivek23:
			
			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.
		
			Ivek23:
			
			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.
		
			Ivek23:
			
			
--- Quote from: Legin76 on January 31, 2014, 10:19:00 pm ---Also would it be possibe to also add the Audiance rating from RT as I often go by an average of the two.
--- End quote ---
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. 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.
		
			Ivek23:
			
			For unregistered users:
Rottentomatoes script
v 0.1.0.1
Rottentomatoes.psf
--- Code:  ---(*	
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.
--- End code ---
		
			Ivek23:
			
			For unregistered users:
Rottentomatoes(1) script
v 0.1.0.1
Rottentomatoes(1).psf
--- Code:  ---(*	
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.
--- End code ---
		
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version