Author Topic: Suggestion for Ivek23  (Read 78138 times)

0 Members and 1 Guest are viewing this topic.

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #60 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.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #61 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!

Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #62 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!

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #63 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.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #64 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;

Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #65 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! :)

« Last Edit: October 28, 2015, 07:10:06 pm by afrocuban »

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #66 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.
« Last Edit: October 29, 2015, 09:31:09 am by Ivek23 »
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #67 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.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #68 on: January 31, 2016, 11:29:18 am »
For unregistered users:

To download the scripts can link found in Rottentomatoes Links 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.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #69 on: June 10, 2016, 07:13:12 pm »
Well, https case with Rottent Tomatoes, as well. :(

Offline deazo

  • Older Power User
  • *****
  • Posts: 283
    • View Profile
Re: Suggestion for Ivek23
« Reply #70 on: July 01, 2016, 11:08:19 pm »

 Yup.
 Not working anymore :(

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #71 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.
« Last Edit: July 02, 2016, 07:40:23 am by Ivek23 »
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #72 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.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #73 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!


Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: Suggestion for Ivek23
« Reply #74 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 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.
« Last Edit: June 27, 2017, 07:49:53 pm by Ivek23 »
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline afrocuban

  • Moderator
  • *****
  • Posts: 475
    • View Profile
Re: Suggestion for Ivek23
« Reply #75 on: November 12, 2016, 04:04:55 pm »
Thank you, Ivek. I can't wait to see it there!

Cheers

 

anything