Author Topic: Update IMDB ratings from ratings.list.gz  (Read 7115 times)

0 Members and 1 Guest are viewing this topic.

Offline Sone

  • Member
  • *
  • Posts: 1
    • View Profile
Update IMDB ratings from ratings.list.gz
« on: August 14, 2012, 11:21:00 am »
Hello there,
I just wrote a little script + program. The script loads 127.0.0.1/year/otitle and the program provides the info from a downloaded extracted ratings.list (see http://www.imdb.com/interfaces).

The problem: I want to overwrite the ratings imported by the original IMDB import plugin. I've made GetRatingName return "IMDB" but this just makes another row "IMDB Bewertung" show up (though without a colon!). Is there a way to do that with a script?

Script:
Code: [Select]
const
 //Script types
 stMovies = 0;
 stPeople = 1;
 stPoster = 2;
 
 //Script modes
 smSearch   = 0;
 smNormal   = 1;
 smCast     = 2;
 smReview   = 3;
 smCredits  = 4;
 smPoster   = 5;
 smFinished = 6;
 
 //Parse results
 prError     = 0;
 prFinished  = 1;
 prList      = 2;
 prListImage = 3;
 prDownload  = 4;
 
 //Download methods
 dmGET  = 0;
 dmPOST = 1;
 
 //Prefix modes
 pmNone   = 0;
 pmEnd    = 1;
 pmBegin  = 2;
 pmRemove = 3;
 
 //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;
 
 //Credits types
 ctActors    = 0;
 ctDirectors = 1;
 ctWriters   = 2;
 ctComposers = 3;
 ctProducers = 4;
 
 //Script data   
 SCRIPT_VERSION = '0.0.0.1';
 SCRIPT_NAME    = 'IMDB batch [EN]';
 SCRIPT_DESC    = '[EN] Read ratings.list from IMDB.com/interfaces';
 SCRIPT_LANG    = $09; //English
 SCRIPT_TYPE    = stMovies;
 
 BASE_URL    = 'http://127.0.0.1';
 RATING_NAME = 'IMDB';
 
 CODE_PAGE   = 65001;
 
 START_SERVER = False;
 USE_MSGBOX = False;

var
busy : Byte;

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 GetBaseURL : AnsiString;
begin
Result := BASE_URL;
end;

function GetScriptLang : Cardinal;
begin
Result := SCRIPT_LANG;
end;

function GetScriptType : Byte;
begin
Result := SCRIPT_TYPE;
end;

function GetCurrentMode : Byte;
begin
Result := busy;
end;

function GetRatingName : String;
begin
Result := RATING_NAME;
end;

function GetCodePage : Cardinal;
begin
Result := CODE_PAGE;
end;

function GetDownloadURL : AnsiString;
begin
if START_SERVER then FileExecute(GetAppPath()+'Scripts\socket80.exe', '');
Result := 'http://127.0.0.1/' + GetFieldValue(5) + '/' + GetFieldValue(3);
end;

function ParsePage(HTML : String; URL : AnsiString) : Cardinal;
begin
busy := 1;

if Copy(HTML, 1, 1) = 'x' then begin
Result := prError;
if USE_MSGBOX = True then
ShowMessage('  '+GetFieldValue(3) + ' (' + GetFieldValue(5) + ')' + ': '+Copy(HTML, 2, Length(HTML) -1), 'Error')
else
LogMessage('  '+GetFieldValue(3) + ' (' + GetFieldValue(5) + ')' + ': '+Copy(HTML, 2, Length(HTML) -1));
busy := 0;
Exit;
end;

LogMessage('Rating:' + FloatToStr(StrToFloat(Trim(HTML))));
AddFieldValue(mfRating, FloatToStr(StrToFloat(Trim(HTML))));

Result := prFinished;
busy := 0;
end;

begin
busy := 0;
end.

PS: If you want to use it, you have to change the encoding of ratings.list to UTF-8 without BOM.

[attachment deleted by admin]
« Last Edit: October 22, 2012, 02:14:51 pm by Sone »

 

anything