English > Feature Suggestions

Suggestion for Ivek23

<< < (13/16) > >>

Ivek23:
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: ---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;
--- End code ---

I hope that will help.

afrocuban:
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!

afrocuban:
Ok, I got it!

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


--- Code: ---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);
--- End code ---

Once again, thanks a lot, Ivek!

Ivek23:

--- Quote from: 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!
--- End quote ---

Glad to have found the right solution.


--- Quote from: 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: ---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);
--- End code ---

Once again, thanks a lot, Ivek!
--- End quote ---

Thanks, I'm glad that I can help you find the right solution and that the script works properly.

afrocuban:
Ivek, you're the best!  :)

And if someone wants only title without a year, then this:

--- Code: ---EndPos := PosFrom('</span></h1>', HTML, curPos)-6;
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version