English > Scripts and Templates
AllMovie.com (movies)
rick.ca:
I'm modifying the script to handle additional data elements for custom fields. That's coming along quite nicely, but I need a little help. As a measure of my profound coding-lameness, I'm unable to introduce a simple variable to add two data elements together.
I would like to combine MPAA (e.g., "R") and MPAA Reasons (e.g., "language and sexual references") into the same way it's expressed on IMDb (e.g., "Rated R for language and sexual references.")
So MPAA is retrieved with...
--- Code: --- //MPAA
EndPos := PosFrom('style="width: 86px;', HTML, EndPos); //if no countries found set EndPos to the right position
curPos := PosFrom('">', HTML, EndPos) + 2;
EndPos := PosFrom('</td>', HTML, curPos);
AddFieldValue(mfMPAA, Copy(HTML, curPos, EndPos - curPos));
--- End code ---
...and I'm adding MPAA reasons to a custom field with...
--- Code: --- //MPAA Reasons
AddCustomFieldValueByName('MPAA', HTMLValues(HTML,
'<span>MPAA Reasons</span>', '</table>',
'<li>', '</li>',
', ', EndPos));
--- End code ---
How can I modify this to combine the two and put the result into mfMPAA?
I realize this is a trivial thing—there are very few cases where the data won't already have come from IMDb—but I'll be able to use the same technique for other things.
nostra:
There is already a variable for tremporary data declared: TmpStr
You need to do following:
--- Code: ---//MPAA
EndPos := PosFrom('style="width: 86px;', HTML, EndPos); //if no countries found set EndPos to the right position
curPos := PosFrom('">', HTML, EndPos) + 2;
EndPos := PosFrom('</td>', HTML, curPos);
TmpStr := Copy(HTML, curPos, EndPos - curPos);
--- End code ---
and then
--- Code: ---//MPAA Reasons
AddCustomFieldValueByName('MPAA', TmpStr + ' ' + HTMLValues(HTML,
'<span>MPAA Reasons</span>', '</table>',
'<li>', '</li>',
', ', EndPos));
--- End code ---
I have added a space like this ' ', so that it looks better.
P.S. I have not tested this code
rick.ca:
Thanks! It turned out to be a little more complicated, but I figured it out...
I forgot to mention TmpStr is used between the two parts (in the Box Office section). Eventually, I figured out how to declare and use TmpStr2. Then, because I wanted it to be "Rated X for... .", it had to be conditional on a rating existing. So I'm using global variables and conditional statements—wow. ::)
Is a date function available? I would like to be able to save the current date in a custom Date updated field.
Now that I'm running out of new things to add, I'm eyeing the Similar Works section (under Plot Synopsis). Is it possible to grab that list and add the movies to PVD's Connections (as a separate section, I suppose)—or is that beyond the scope of a script?
--- Quote ---P.S. I have not tested this code
--- End quote ---
That's okay. You can test the script when it's finished. ;D
Two Wire:
--- Quote ---
--- End quote ---
Attached:
-Current version of the script [0.1.0.3]
--- Quote ---
--- End quote ---
Where is this attachment? No can find. Help.
Thanks
tantrum829:
Ok I am a little lost. I downloaded the new script but it wont replace the old one. I drag and drop it to the same place where the old one is and i assume it should
ask me if I want to overwrite the old file but it doesnt. The icon is different. It has a .txt icon instead of the .pvd
How do i change it.
Thanks
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version