Code I provided doesn’t seem to work with v0.3, now it just prints 0:00:00 instead of actual movie runtime. Reverted to v0.2 and it works as it used to.
Thanks for your comment.
A few things have changed in 0.3 as I’ve mentioned in the change note. It was necessary and will be a lot easier to use in the long run.
You didn’t mention how you put the data into the post meta field. Actually there’s not even a need to use post meta fields since the information is either stored on your server or in your database (if you activated caching).
When using database caching, the selected movie details will be downloaded and put into a get_option() called “imdb_connector_cache”. When you call the movie details the next time, it’ll first look through the database and only download the information if they haven’t been saved yet.
So instead of using post meta, you could just use the regular get_imdb_connector_movie_detail($movie_title, $detail). Note that the structure of the returned array has changed a little bit, especially the “runtime” value. It’s now an array containing “minutes”, “hours” and “timestamp” (see the documentation).
I’m writing imdb id into post custom field manually when publishing a post, so the custom field is called imdb-id and the value is tt2978462. The reason I want to use imdb id instead of movie title is that my movie titles are in foreign language, which omdbapi doesn’t support if I’m right?
How would you change the code I provided to work with v0.3 so it prints runtime correctly instead of zeros?
I understand the changes made, but my lack of understanding of PHP gives me trouble implementing it:/
No, it was my fault. I used a wrong variable at a crucial position in the code. I’ve just fixed it and updated the plugin. Please download the newest version and try again.
print_r(get_imdb_connector_movie_detail("tt2978462", "runtime"));
gives me:
Array ( [timestamp] => 1412966859 [minutes] => 107 [hours] => 1:47 )
Now it’s working perfectly, thank you!:)
BTW, let’s say I have thousands of movies on my website, which is the better way to store cache? As files or in database?
Good question… I really don’t know. Both have advantages and disadvantages. But I know too little about that to tell you something reliable here :p