English > Scripts and Templates

Script: TheMovieDB [ES] (Easy API Script)

<< < (7/11) > >>

Ivek23:
Very good job, works great, but miss the release date, because it missing in the transfer of information.

It may help this one piece of code to release date:

--- Code: ---procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, curPos1, endPos : Integer;
Date, Released, Wpage, Wpage1, TmpStr, TmpStr0, TmpStr1, TmpStr2, TmpStr3 : 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];

Date := StringReplace(Date, '01.', '1.', True, True, False);
Date := StringReplace(Date, '02.', '2.', True, True, False);
Date := StringReplace(Date, '03.', '3.', True, True, False);
Date := StringReplace(Date, '04.', '4.', True, True, False);
Date := StringReplace(Date, '05.', '5.', True, True, False);
Date := StringReplace(Date, '06.', '6.', True, True, False);
Date := StringReplace(Date, '07.', '7.', True, True, False);
Date := StringReplace(Date, '08.', '8.', True, True, False);
Date := StringReplace(Date, '09.', '9.', True, True, False);

AddCustomFieldValueByName('TheMovieDB Updated', Date);  // Simple
// AddCustomFieldValueByName('TheMovieDB Updated', DateToStr(CurrentDateTime));  // Simple
// AddCustomFieldValueByName('TheMovieDB Updated', DateToStr(CurrentDateTime) + ' at ' + TimeToStr(CurrentDateTime));  // Verbose
//  AddCustomFieldValueByName('TheMovieDB Updated', DateToStr(CurrentDateTime) + + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION); // Annoying
//AddCustomFieldValueByName('TheMovieDB Updated1', Date + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION); // Annoying
AddCustomFieldValueByName('TheMovieDB Updated1', Date + ' at ' + TimeToStr(CurrentDateTime) + ' • ' + RATING_NAME + ' ' + SCRIPT_VERSION); // Annoying
  end else
    LogMessage('date not found');

//~Released~
curPos := PosFrom('"release_date":"', HTML, EndPos);
 if curPos > 0 then begin
  curPos := PosFrom('"release_date":"', HTML, EndPos);
endPos := PosFrom('","revenue"', HTML, curPos);
 Released :=  TextBetween(HTML, '"release_date":"', '","revenue"', True, curPos);
    //Released := StringReplace(Released, '01', '1', True, True, False);
//Released := StringReplace(Released, '02', '2', True, True, False);
//Released := StringReplace(Released, '03', '3', True, True, False);
//Released := StringReplace(Released, '04', '4', True, True, False);
//Released := StringReplace(Released, '05', '5', True, True, False);
//Released := StringReplace(Released, '06', '6', True, True, False);
//Released := StringReplace(Released, '07', '7', True, True, False);
//Released := StringReplace(Released, '08', '8', True, True, False);
//Released := StringReplace(Released, '09', '9', True, True, False);
  if Released <> '' then
  begin
    ExplodeString(Released, DateParts, '-');
    Released := DateParts[2] +'.'+ DateParts[1] +'.'+ DateParts[0];
    LogMessage('rdate: '+ Released);
AddFieldValueXML('rdate', Released);
AddCustomFieldValueByName('Release info', Released);
  end else
    LogMessage('rdate not found');
  end;

end;
--- End code ---

Ivek23:
If you change this

--- Code: ---  //LANG_API_STR         = '&language=es';                                  //WEB_SPECIFIC
  LANG_API_STR       = '&language=en';                                  //WEB_SPECIFIC
  //LANG_API_STR       = '&language=fr';                                  //WEB_SPECIFIC
--- End code ---
and with that part of the code

--- Code: ---      //Get ~url~
      curPos:=Pos('"homepage":"","id":',HTML)+Length('"homepage":"","id":');    //WEB_SPECIFIC
      endPos:=PosFrom(',',HTML,curPos);                                         //WEB_SPECIFIC
      ItemValue:=Copy(HTML,curPos,endPos - curPos);                                 
      if (0=Pos('null',ItemValue)) then begin                                   //WEB_SPECIFIC. But it's impossible not 'homepage'.
         ItemValue:=StringReplace(ItemValue,'"','',True,True,False);
         ItemValue:=BASE_URL_TRUE+Copy(HTML,curPos,endPos - curPos);
         AddFieldValueXML('url',ItemValue);
         LogMessage('      Get result url:'+ItemValue+'||');
      end;
--- End code ---
occur under certain movie to wrong url address
--- Code: ---http://www.themoviedb.org/movie/ckdrop_path":"/17zArExB7ztm6fjUXZwQWgGMC9f.jpg"
--- End code ---

VVV_Easy_Programing:
CHANGE LOG (21/12/2014):
            V 0.2.0.1   VVV: Adjust search list Posters width.
                                    Add a comprobation translated LANG_API_STR overview (Description) (User Option TRASLATED_OVERVIEW)
                                    Add the first ~rdate~ Release Date (Ivek23 proposition)
Attached the new versión

(If some movie fails, please send me the title, the bad information and the search language. Thank you.)
(Edito: New version down)

VVV_Easy_Programing:
CHANGE LOG (25/12/2014):
            V 0.2.0.2   VVV: Fixed bug (search URL) with movies with stored IMDB URL.
                                    Fixed bug with URL get (Ivek23 detected)
Attached the new versión.

Merry Christmas!

(Edito: New version down)

Ivek23:

--- Quote from: VVV_Easy_Programing on December 25, 2014, 12:14:34 pm ---CHANGE LOG (25/12/2014):
            V 0.2.0.2   VVV: Fixed bug (search URL) with movies with stored IMDB URL.
                                    Fixed bug with URL get (Ivek23 detected)
Attached the new versión.
--- End quote ---

Thanks.


--- Quote from: VVV_Easy_Programing on December 25, 2014, 12:14:34 pm ---Merry Christmas!
--- End quote ---

Same to you.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version