English > Scripts and Templates
AllRovi movie script
Ivek23:
--- Quote ---
* Review: I couldn't figure out how to do this, simply because I don't know how to go to another page (i.e., in this case, MoveURL + '/review'). It must be simple, but I'm stumped.
--- End quote ---
--- Quote ---We'll see if we can do something in this for the Review.
--- End quote ---
Here are the codes for the Review which must be:
--- Code: ---function RemoveTagsEx(AText : String) : String;
var
B, E : Integer;
begin
Result := AText;
B := PosFrom('<', Result, 1);
E := PosFrom('>', Result, B);
while (B > 0) AND (B < E) do begin
Delete(Result, B, E - B + 1);
B := Pos('<', Result);
E := Pos('>', Result);
end;
end;
procedure ParseReview(HTML : String);
var
curPos, EndPos : Integer;
TmpStr, TmpStr1, TmpStr2, TmpStr3, TmpStr4, TmpStr5 : String;
begin
curPos := Pos('<div class="tab-title">', HTML);
if curPos < 1 then
Exit;
LogMessage('Pasrsing review...');
//Review
curPos := PosFrom('<span>', HTML, curPos);
endPos := PosFrom('</span>', HTML, curPos);
TmpStr5 := TextBetween(HTML, '<span>', '</span>', True, curPos);
curPos := PosFrom('<span>by', HTML, curPos);
endPos := PosFrom('</span>', HTML, curPos);
TmpStr3 := TextBetween(HTML, '<span>', '</span>', True, curPos);
curPos := PosFrom('<strong>', HTML, curPos);
endPos := PosFrom('</strong>', HTML, curPos);
TmpStr4 := TextBetween(HTML, '<strong>', '</strong>', True, curPos);
curPos := PosFrom('<p>', HTML, curPos);
endPos := PosFrom('</p>', HTML, curPos);
TmpStr := Copy(HTML, curPos, EndPos - curPos);
TmpStr1 := StringReplace(TmpStr, ' -- ', '—', True, True, False);
TmpStr2 := StringReplace(TmpStr1, ' --- ', '—', True, True, False);
TmpStr := StringReplace(TmpStr2, '--', '—', True, True, False);
TmpStr1 := StringReplace(TmpStr, #13#13#13#13, #13#10#13#10, True, True, False);
TmpStr2 := RemoveTagsEx(TmpStr1);
AddCustomFieldValueByName('Review', TmpStr5 + ' ' + TmpStr4 + #13 + TmpStr4 + ' ' + TmpStr3 + #13 + TmpStr2);
end;
procedure ParseMovie(MovieURL : String; HTML : String);
--- End code ---
--- Code: ---//Get URL
EndPos := Pos('" class="title">', HTML);
if EndPos > 0 then begin
curPos := PrevPos('<div class="details"><a href="', HTML, EndPos);
AddFieldValue(mfURL, Copy(HTML, curPos + 21, EndPos - curPos - 21));
end else
AddFieldValue(mfURL, MovieURL);
AddCustomFieldValueByName('Url', '<link url="' + MovieURL + '">' + MovieURL + '</link>');
//Get Review URL
if GET_REVIEW then begin
EndPos := Pos('"><span>review</span>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smReview] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
end;
--- End code ---
--- Code: ---if Pos('Search Results for', HTML) > 0 then begin
ParseSearchResults(HTML);
Result := prList;
Exit;
end else
if Pos('- Cast, Reviews, Summary, and Awards - AllRovi</title>', HTML) > 0 then
ParseMovie(URL, HTML)
else
if Pos('- Review - AllRovi</title>', HTML) > 0 then
ParseReview(HTML);
--- End code ---
Notice:
Adding in the first post new AllRovi Script Version 0.1.0.3
Ivek23:
--- Quote ---
* Cast & Crew: I don't know what you or others might want. I get my people data from IMDb and don't want Rovi data messing that up. So my preference is that the names are captured as Rovi links along with the Role, and the whole thing be saved together in a memo field. That provides a convenient secondary source of credits, along with links to additional people information at the Rovi site.
--- End quote ---
I managed to find a solution and the code for Cast & Crew, but will wait for tomorrow, this is further tested and know for sure that it worked, so please wait for maybe a day or two.
rick.ca:
Thanks very much for your work on this, Ivek. I'm happy I've my Reviews back. :D
I wasn't expecting you to incorporate all my changes, having assumed we would need to maintain our separate versions. I now see that should not be necessary. Where you've used a custom field for something I don't use, I can just ignore it. Where you've used a standard field I get from elsewhere, I can turn it off in my Overwrite fields settings. The only real conflicts are where we treat the actual data differently (e.g., Description). In the attached version, I've added a RICK_CA := True option and then separated my modifications using if RICK_CA then... So unless you plan to do something very unusual, I'm confident we can share the same script. We can use the same technique to add options other users might want.
Having said that, it's still a PITA when we're both making changes at the same time—as we are today. I'm hoping you won't mind once again incorporating my changes. Or if you prefer, I'll merge the two after you've finished with your Cast & Crew addition. That should be easy if that's all you've changed since version 3.
My changes, not including minor editing:
* Alternate formatting for Description and Review.
* Minor changes to Title and Year and their use in LogMessages; removed unnecessary LogMessages.
* Optional Run time destined for numeric field (removes " min.").
* Changed Produced by so it will work if there's a Released by or not.
* Changed Themes so it's added to mfCategory if the GET_THEMES option is set, and always added to the a custom field named "Category" (not to be confused with the standard field of the same name).
[attachment deleted by admin]
rick.ca:
--- Quote from: minolotus on July 10, 2011, 12:24:16 pm ---Ivec23 and rick.ca, thank you very much for your excellent work.
--- End quote ---
You're welcome. Thanks to Ivek's perseverance, we're making good progress.
--- Quote ---...So, this would not work very proper and hence I don't think that it is worth to spend time and adjust the scipt as proposed above.
--- End quote ---
Yes, it's almost impossible to figure out what they're doing with "Characteristics," which, of course, is a big part of the problem. Not only does it not work as a "mashup," they're not doing whatever they're doing with any discernible consistency. Attached is my effort to figure it out. I can see some patterns, but my conclusion is there is very good reason why it's useless. More disturbingly, it appears they may be dropping some data elements (Moods and Keywords) entirely. If that's the case, I have little hope any of this data will be restored to it's previous form. :(
--- Quote ---Possible Low-tech solution: If this could not be done within a script, maybe it is possible to build a second script for the reviews only and put both scripts together with a batch file?
--- End quote ---
Low-tech is a well-used tool in my kit, but it seems Ivek has figured it out. Even when I look at what he did, I don't understand why it works. :-[
[attachment deleted by admin]
Ivek23:
For Cast & Crew
Copy the below procedure ParseReview
--- Code: ---//Parse Cast
//Modified 09/24/2010 to save entire Cast tab to custom memo field, as well as individual actors.
procedure ParseCast(HTML : String);
var
curPos, EndPos : Integer;
TmpStr, TmpStr1 : String;
Name, Role, URL : String;
begin
curPos := Pos('<div class="description-box">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</table>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 2;
EndPos := PosFrom('</td>', HTML, curPos);
Role := Trim(Copy(HTML, curPos +4, EndPos - curPos -4));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', '', URL, ctActors);
if TmpStr <> '' then
TmpStr := TmpStr + #13;
if URL <> '' then
TmpStr := TmpStr + '<link url="' + URL + '">';
TmpStr := TmpStr + Name;
if Role <> '' then
TmpStr := TmpStr + ' - ' + Role;
if URL <> '' then
TmpStr := TmpStr + '</link>';
if curPos > 0 then
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Cast', TmpStr); // If you do not exist then the change to:
AddCustomFieldValueByName('Actors', TmpStr);
curPos := Pos('<div class="profession-box">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</dl>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := 'http://www.allrovi.com/name/' + Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 2;
EndPos := PosFrom('</dd>', HTML, curPos);
Role := Trim(Copy(HTML, curPos +4, EndPos - curPos -4));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', Role, URL, ctProducers);
if TmpStr <> '' then
TmpStr := TmpStr + #13;
if URL <> '' then
TmpStr := TmpStr + '<link url="' + URL + '">';
TmpStr := TmpStr + Name;
if Role <> '' then
TmpStr := TmpStr + ' - ' + Role;
if URL <> '' then
TmpStr := TmpStr + '</link>';
if curPos > 0 then
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Production', TmpStr);
end;
--- End code ---
Notice:
--- Code: ---AddMoviePerson(Name, '', Role, URL, ctProducers);
--- End code ---
This is only a test there to see how information is transferred
--- Code: ---[s]GET_CAST = True;[/s]
--- End code ---
--- Code: ---//Get Cast URL
[s]if GET_CAST then begin[/s]
EndPos := Pos('"><span>cast & crew</span></a>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smCast] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
[s]end; [/s]
--- End code ---
Notice:
Strikethrough may be necessary
--- Code: ---ParseReview(HTML)
else
if Pos('- Cast and Crew - AllRovi</title>', HTML) > 0 then
ParseCast(HTML):
--- End code ---
This is now testing that might find a solution to the Role there because I leave this <td> and this <dd>, but I can not find solution how to remove this.
Notice:
If, however, it might be something, here are the necessary code:
--- Code: ---procedure ParseCredits(HTML : String);
var
curPos, EndPos : Integer;
TmpStr, TmpStr1 : String;
Name, Role, URL : String;
begin
curPos := Pos('<div class="profession-box">', HTML);
if curPos < 1 then
Exit;
TmpStr := '';
EndPos := curPos;
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos);
while (curPos > 0) AND (curPos < PosFrom('</dl>', HTML, EndPos)) do begin
EndPos := PosFrom('">', HTML, curPos);
URL := 'http://www.allrovi.com/name/' + Copy(HTML, curPos, EndPos - curPos);
curPos := EndPos + 2;
EndPos := PosFrom('</a>', HTML, curPos);
Name := Copy(HTML, curPos, EndPos - curPos);
curPos := PosFrom('>', HTML, EndPos);
if curPos > 0 then begin
curPos := curPos + 2;
EndPos := PosFrom('</dd>', HTML, curPos);
Role := Trim(Copy(HTML, curPos, EndPos - curPos));
end else begin
Role := '';
curPos := EndPos;
end;
AddMoviePerson(Name, '', Role, URL, ctProducers);
if TmpStr <> '' then
TmpStr := TmpStr + #13;
if URL <> '' then
TmpStr := TmpStr + '<link url="' + URL + '">';
TmpStr := TmpStr + Name;
if Role <> '' then
TmpStr := TmpStr + ' - ' + Role;
if URL <> '' then
TmpStr := TmpStr + '</link>';
if curPos > 0 then
curPos := PosFrom('http://www.allrovi.com/name/', HTML, curPos)
else
Exit;
end;
AddCustomFieldValueByName('Production', TmpStr);
end;
--- End code ---
--- Code: ---//Get Review URL
if GET_REVIEW then begin
EndPos := Pos('"><span>review</span>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smReview] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
end;
//Get Cast URL
if GET_CAST then begin
EndPos := Pos('"><span>cast & crew</span></a>', HTML);
if EndPos > 0 then begin
curPos := PrevPos('href="/movies', HTML, EndPos);
ExtraLinks[smCast] := BASE_URL + Copy(HTML, curPos + 6, EndPos - curPos - 6);
end;
end;
--- End code ---
--- Code: ---ParseReview(HTML)
else
if Pos('- Cast and Crew - AllRovi</title>', HTML) > 0 then
ParseCast(HTML)
else
if Pos('- Cast and Crew - AllRovi</title>', HTML) > 0 then
ParseCredits(HTML);
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version