Author Topic: AllRovi movie script  (Read 120982 times)

0 Members and 13 Guests are viewing this topic.

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #20 on: July 12, 2011, 01:13:25 pm »
Happens now, the rating here...

Try this...

Code: [Select]
//Rovi Rating
 TmpStr := Trim(HTMLValues(HTML,
'<dt>rovi rating</dt>',  '</dd>',
'<li class="star ', '"></li>',
', ', EndPos));

 L := Length(TmpStr);
 H := LastPos('half', TmpStr);
 if H = 0 then
R := (L + 2)/3
 else
R := (L + 2)/3 - 1;

 AddCustomFieldValueByName('Rovi rating', IntToStr(R));
 LogMessage('Rovi rating: ' + IntToStr(R));

Be sure to define L, H and R as integers (I just added them to the preceding 'var' statement). This converts 1 to 5 stars to a number from 1 to 10 for storing in a custom Rating field named "Rovi rating." I suppose we should add the option to save it in [orating] as well.

This works for 95% of movies. Unfortunately, I have no idea why it doesn't for the other 5%. They all have ratings, and I can't see any difference in the source. Some examples...

Age of Gold (1930)
Aileen Wuornos: The Selling of a Serial Killer (1992)
All That Heaven Allows (1955)
Along Came a Spider (2001)
Asthenic Syndrome (1989)
Atalante (1934)

Please have a look and see if you can figure it out. Or maybe just confirm that the error rate is really as low as it seems to be—and then we just won't tell anyone about it. ;)

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #21 on: July 12, 2011, 04:52:28 pm »
Happens now, the rating here...

Try this...

Code: [Select]
//Rovi Rating
 TmpStr := Trim(HTMLValues(HTML,
'<dt>rovi rating</dt>',  '</dd>',
'<li class="star ', '"></li>',
', ', EndPos));

 L := Length(TmpStr);
 H := LastPos('half', TmpStr);
 if H = 0 then
R := (L + 2)/3
 else
R := (L + 2)/3 - 1;

 AddCustomFieldValueByName('Rovi rating', IntToStr(R));
 LogMessage('Rovi rating: ' + IntToStr(R));

Be sure to define L, H and R as integers (I just added them to the preceding 'var' statement). This converts 1 to 5 stars to a number from 1 to 10 for storing in a custom Rating field named "Rovi rating." I suppose we should add the option to save it in [orating] as well.

This works for 95% of movies. Unfortunately, I have no idea why it doesn't for the other 5%. They all have ratings, and I can't see any difference in the source. Some examples...

Age of Gold (1930)
Aileen Wuornos: The Selling of a Serial Killer (1992)
All That Heaven Allows (1955)
Along Came a Spider (2001)
Asthenic Syndrome (1989)
Atalante (1934)

Please have a look and see if you can figure it out. Or maybe just confirm that the error rate is really as low as it seems to be—and then we just won't tell anyone about it. ;)

Certainly not at my work.

I added a DVD Releases namely,work does not transfer data, Awards I did not and will not even add, unless of course it would Nostra added, because this is my last version, except for some adjustments of course.

Notice:
Adding in the first post new AllRovi Script Version 0.1.0.5
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: AllRovi movie script
« Reply #22 on: July 12, 2011, 07:40:00 pm »
Quote
Awards I did not and will not even add,

Even in the old script AllMovie Awards were not there

Code: [Select]
//Rovi Rating
 TmpStr := Trim(HTMLValues(HTML,
'<dt>rovi rating</dt>',  '</dd>',
'<li class="star ', '"></li>',
', ', EndPos));

 AddCustomFieldValueByName('Rovi rating', TmpStr );

This code is for me better info display data in the previous code, but I could not find anything, because I always had a log file reported error, which I could not figure out what was written.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #23 on: July 12, 2011, 08:09:12 pm »
Certainly not at my work.

I don't understand. Your code is incomplete. The result has to be a numeric which can saved in a Rating (i.e., "stars") field. My code works perfectly except for a small portion of movies.

Quote
This code is for me better info display data in the previous code, but I could not find anything, because I always had a log file reported error, which I could not figure out what was written.

That's fine for your own debugging, but it shouldn't be in the final script.

Quote
Awards I did not and will not even add

I don't care. I probably won't use Awards or Releases. I only suggested they be added because I thought you would want them, and assumed the coding might be similar to that used for Cast & Crew.



I'll test your DVD Releases change, add my Rovi rating section, and post a new version later today.

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #24 on: July 12, 2011, 08:30:07 pm »
Quote
I'll test your DVD Releases change, add my Rovi rating section, and post a new version later today.

I'll wait for your new version and then I will tomorrow or some day later helped, in my strength and knowledge to solve the problem by Rating.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline minolotus

  • User
  • ***
  • Posts: 69
    • View Profile
Re: AllRovi movie script
« Reply #25 on: July 12, 2011, 09:08:12 pm »
I trying to test yours script but I think I get lost in with all these codes  :o. I have downloaded the version 0.1.0.5 from Ivek's first post and a version from rick.ca (0.1.0.4). My question is if I have to add custom items to the database? I have added a characteristic memo field and that works. But I am not sure if I need more items to test the full possible range of your scripts.

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #26 on: July 12, 2011, 09:46:06 pm »
Code: [Select]
(*
//Poster
 curPos := PosFrom('<img class="cover-art" src="', HTML, EndPos);
 if curPos > 0 then begin
  curPos := curPos + Length('<img class="cover-art" src="');
  EndPos := PosFrom('?Partner=allrovi.com', HTML, curPos);
 
  ExtraLinks[smPoster] := Copy(HTML, curPos, EndPos - curPos);
  if Pos('noimage', ExtraLinks[smPoster]) > 0 then
   ExtraLinks[smPoster] := '';
 end;*)

Rick.ca ,I think I've found what part of the problem - Poster.
Now marked like this poster and do test it, then it should work.See also source code for the poster, and you'll see different endings and will need to change this part of the code
Code: [Select]
EndPos := PosFrom('?Partner=allrovi.com', HTML, curPos);
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #27 on: July 12, 2011, 11:03:52 pm »
I added a DVD Releases namely,work does not transfer data...

I seem to be having trouble understanding your English. I thought this meant "DVD Releases does not work," but I did not understand why you would post the script if that were the case. Now I see it indeed does not work. I'll leave the changes in the script, as they seem to do no harm. I assume you intend to fix it. Sorry, I have no idea why it doesn't work.

Quote
I think I've found what part of the problem - Poster.

I don't understand. The Poster code seems to work fine. I've never seen it fail to get a poster.
Or do you mean it somehow prevents DVD Releases from working? Disabling Poster (I assume that's what enclosing the code in "(*...*)" does) does not change anything for me—still no DVD Releases data.


[Edit] Now I get it. Sorry for being dense. Poster was interfering with my Rovi rating. But I can't figure out how to make them both work... ::)
« Last Edit: July 13, 2011, 01:51:57 am by rick.ca »

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #28 on: July 13, 2011, 04:00:41 am »

I think I've found what part of the problem - Poster. Now marked like this poster and do test it, then it should work. See also source code for the poster, and you'll see different endings and will need to change this part of the code
Code: [Select]
EndPos := PosFrom('?Partner=allrovi.com', HTML, curPos);

Yes, it took me a very long time to understand, but this was the problem. Hopefully, both Poster and Rovi rating will now always normally work. For reasons I still don't understand, if there is no image then the Rating code will fail. :(

It will only get the poster if it's a JPG, but I haven't seen any other types. And they're all poor quality anyway—so I can't imagine why anyone would care.

As for DVD Releases, you're welcome to finish that or not. I've added the alternative option of adding a link (to the Releases page) to the standard Features field. As I recall discussing in the past, I believe this is better solution anyway. The list of links is not very informative, so an interested user is going to go to the website anyway.

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #29 on: July 13, 2011, 04:08:44 am »
I added a DVD Releases namely,work does not transfer data...

I seem to be having trouble understanding your English. I thought this meant "DVD Releases does not work," but I did not understand why you would post the script if that were the case. Now I see it indeed does not work. I'll leave the changes in the script, as they seem to do no harm. I assume you intend to fix it. Sorry, I have no idea why it doesn't work.

Quote
I think I've found what part of the problem - Poster.

I don't understand. The Poster code seems to work fine. I've never seen it fail to get a poster.
Or do you mean it somehow prevents DVD Releases from working? Disabling Poster (I assume that's what enclosing the code in "(*...*)" does) does not change anything for me—still no DVD Releases data.


[Edit] Now I get it. Sorry for being dense. Poster was interfering with my Rovi rating. But I can't figure out how to make them both work... ::)

I apologize for my clumsy explanation of Releases (DVD Releases), I will see if anything can be changed, otherwise I'll have a procedure for Releases (DVD Releases) removed from the script.
For the poster will also be figuring out how and what.
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: AllRovi movie script
« Reply #30 on: July 13, 2011, 04:19:56 am »
Quote
As for DVD Releases, you're welcome to finish that or not. I've added the alternative option of adding a link (to the Releases page) to the standard Features field. As I recall discussing in the past, I believe this is better solution anyway. The list of links is not very informative, so an interested user is going to go to the website anyway.

Even just a link connection is fine so I
Quote
procedure for Releases (DVD Releases) removed from the script
and such then I will add later gave in first post
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #31 on: July 13, 2011, 04:50:55 am »
Quote
and such then I will add later gave in first post

I will upload my version shortly. Please make your modifications to it—so I don't have to redo mine.

I was just thinking the script might be a tiny bit faster if it didn't have to download and parse Releases. Maybe the solution to whatever is going wrong with the poster routine is to put it into a separate procedure. It looks like the scripting engine was designed to be used that way—as suggested by the smPoster "script mode." If you can do that, and add a GET_POSTER option, the script would be faster for those of use who don't need posters.

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #32 on: July 13, 2011, 05:34:47 am »
The problem is finding movies where there are at least two films with the same titles find a movie which was first written:
 What I think is so beautiful example Along Came a Spider .
Your movie with this title, Looking for which was built in 2001, However, it is found as the first from year 1970. If, however, such as manually added the correct URL is okay
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: AllRovi movie script
« Reply #33 on: July 13, 2011, 07:22:11 am »
The problem is finding movies where there are at least two films with the same titles find a movie which was first written:
 What I think is so beautiful example Along Came a Spider .
Your movie with this title, Looking for which was built in 2001, However, it is found as the first from year 1970. If, however, such as manually added the correct URL is okay

Try this code ...

Code: [Select]
procedure ParseSearchResults(HTML : String);
var
 curPos, EndPos : Integer;
 Title, Year, URL : String;
begin
 curPos := Pos('<div id="main" class="search-results movies">', HTML);
 if curPos < 1 then
  Exit;
 
 LogMessage('Parsing search results...'); 

  curPos := PosFrom('<a href="http://www.allrovi.com/movies/', HTML, curPos);
 while curPos > 0 do begin
  EndPos := PosFrom('" class="title">', HTML, curPos);
  URL := Copy(HTML, curPos + 31, EndPos - curPos - 31);
 
  URL := BASE_URL + URL;
  curPos := PosFrom('" class="title">', HTML, curPos);
  EndPos := PosFrom('</a>', HTML, curPos);
  Title := Copy(HTML, curPos+16, EndPos - curPos-16);
  EndPos := PosFrom('</dd>', HTML, curPos);
  Year:= ''
 
  AddSearchResult(Title, '', Year, URL, '');

  curPos := PosFrom('" href="/movies/', HTML, curPos);
 end;


 curPos := Pos('<div class="results">', HTML);
 if curPos < 1 then
  Exit;
 
curPos := PosFrom('<a href="http://www.allrovi.com/movies/', HTML, curPos);
 while curPos > 0 do begin
  EndPos := PosFrom('">', HTML, curPos);
  URL := Copy(HTML, curPos + 31, EndPos - curPos - 31);
 
   URL := BASE_URL + URL;

  curPos := PosFrom('">', HTML, curPos);
  EndPos := PosFrom('</a>', HTML, curPos);
  Title := Copy(HTML, curPos+2, EndPos - curPos-2);
  EndPos := PosFrom('</td>', HTML, curPos);
  Year:= ''
 
  AddSearchResult(Title, '', Year, URL, '');

   curPos := PosFrom('" href="/movies/', HTML, curPos);
 end;
end;
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #34 on: July 13, 2011, 08:11:24 am »
Quote
Try this code ...

I just posted version 6, so I'll let you add this to version 7. If it improves the handling of ambiguous titles, that would be great. As I've been testing (generally updating movies already in my database), I've noticed it can make a bad selection from the search results. My old AllMovie+ script did that too, so I thought this might be something we have to live with. It would, of course, be much better if it asked if there were more than one movie in the search results.

Another thing I was wondering... For existing movies previously updated with Allmovies, would it be possible to get the saved Allmovie URL and convert it to a Rovi URL? If so, then a search and this sort of error could be avoided. 8)

There are a few things you should be aware of in version 6...

  • I removed the DVD Releases code. It was a bit entangled with my addition of the link for the Features field.

  • I changed some custom field names in an effort to standardize them. I think it will be easier on everyone if we all try to use the same names. There's probably some additional changes required. Generally, we should use exactly the same name as the source, unless that conflicts with an existing standard field. Yes, a custom field can have the same name, but it invites confusion. So, for example, use "Cast," not "Actors." ;)

  • I've updated the attachment to the top post, but I'll attach it here as well—in case it's ever needed for historical reference.

I'm going to be busy with other things for the rest of the week, but I'll look forward to your updates.

[attachment deleted by admin]

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #35 on: July 13, 2011, 11:04:21 am »
Quote
Another thing I was wondering... For existing movies previously updated with Allmovies, would it be possible to get the saved Allmovie URL and convert it to a Rovi URL? If so, then a search and this sort of error could be avoided.

I do not know if I have understood this, but I now update 8 Mile (2002), url in the url field has remained, while in the field will be overwritten by custom, add pictures.

[attachment deleted by admin]
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: AllRovi movie script
« Reply #36 on: July 13, 2011, 12:30:46 pm »
Quote
I just posted version 6, so I'll let you add this to version 7. If it improves the handling of ambiguous titles, that would be great. As I've been testing (generally updating movies already in my database), I've noticed it can make a bad selection from the search results. My old AllMovie+ script did that too, so I thought this might be something we have to live with. It would, of course, be much better if it asked if there were more than one movie in the search results.

More than one (with at least two similar or same title unless there where only one) movie in the search results.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: AllRovi movie script
« Reply #37 on: July 13, 2011, 01:07:10 pm »
Quote
I do not know if I have understood this...

No, that's not what I mean. Using your example, your 8 Mile record now has the AllRovi URL recorded: http://www.allrovi.com/movies/movie/8-mile-v261159. If you run the script again, the function GetDownloadURL will retrieve that from the record and use it to access the page directly—no search will be done. It's able to select that URL from the URL field—which may contain many URL's—because we've provided the BASE_URL: http://www.allrovi.com.

I don't understand the logic of the script, but there must be a way use this function like this:


Just to be clear, the only thing different here is step 2. And I don't think the script has much to do with step 4—the main application downloads the page (whatever it is) and ParsePage handles it. For the same reason, I have difficulty seeing a point at which step 2 might be inserted. Unless this is straightforward, it's probably not worth the bother. But I think it would be very helpful generally if we understood how things like this work. :-\

BTW, the Scripting Manual has some interesting tidbits hidden in it—like this one:

"If you download poster in a movie information script or a photo in a person information script then make sure URL to an image is passed after all other pages are retrieved!"—found at the end of the GetDownloadURL example.

No wonder I was having such a problem with the Poster messing up the Rating! I did try to move it to the end, but for some reason it then didn't work. Maybe you could give that a try.

Quote
More than one (with at least two similar or same title unless there where only one) movie in the search results.

As long as it doesn't stop and ask when one title is exact but another is "similar."

It's still not clear to me what this is about. If this code presents the search results, what is doing now? Automatically using the first hit, unless it's not similar enough to the search term? Come to think of it, when the dialog appears, it's most often just to confirm one found movie. Seldom, if ever, am I presented with a list to choose from. Anyway—no need to explain. I'll figure it out after you've added it to the script.

Offline Ivek23

  • Global Moderator
  • *****
  • Posts: 2713
    • View Profile
Re: AllRovi movie script
« Reply #38 on: July 13, 2011, 04:23:43 pm »
I trying to test yours script but I think I get lost in with all these codes  :o. I have downloaded the version 0.1.0.5 from Ivek's first post and a version from rick.ca (0.1.0.4). My question is if I have to add custom items to the database? I have added a characteristic memo field and that works. But I am not sure if I need more items to test the full possible range of your scripts.

Sorry for the delay with the response that for those custom fields, what you use and the start script as follows
Code: [Select]
AddCustomFieldValueByName(' ... );for others this
Code: [Select]
AddFieldValue(mf... ); custom fields do not need.
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: AllRovi movie script
« Reply #39 on: July 13, 2011, 04:34:10 pm »
Quote
No wonder I was having such a problem with the Poster messing up the Rating! I did try to move it to the end, but for some reason it then didn't work. Maybe you could give that a try.

I modified the Poster and procedures ParseSearchResults
That's all there.

Notice:
Adding in the first post new AllRovi Script Version 0.1.0.7
Quote
I do not know if I have understood this...

No, that's not what I mean. Using your example, your 8 Mile record now has the AllRovi URL recorded: http://www.allrovi.com/movies/movie/8-mile-v261159. If you run the script again, the function GetDownloadURL will retrieve that from the record and use it to access the page directly—no search will be done. It's able to select that URL from the URL field—which may contain many URL's—because we've provided the BASE_URL: http://www.allrovi.com.

I don't understand the logic of the script, but there must be a way use this function like this:


Just to be clear, the only thing different here is step 2. And I don't think the script has much to do with step 4—the main application downloads the page (whatever it is) and ParsePage handles it. For the same reason, I have difficulty seeing a point at which step 2 might be inserted. Unless this is straightforward, it's probably not worth the bother. But I think it would be very helpful generally if we understood how things like this work. :-\

BTW, the Scripting Manual has some interesting tidbits hidden in it—like this one:

"If you download poster in a movie information script or a photo in a person information script then make sure URL to an image is passed after all other pages are retrieved!"—found at the end of the GetDownloadURL example.


I do this later to see how and what.
Would be generally the script or more for you.
Ivek23
Win 10 64bit (32bit)   PVD v0.9.9.21, PVD v1.0.2.7, PVD v1.0.2.7 + MOD


 

anything