• Resolved Film Complet En Francais

    (@film-complet-en-francais)


    This code takes imdb movie id from custom field and uses it to print runtime.

    $imdbid = get_post_meta(get_the_ID(),'imdb-id',true);
    $connector_movie = get_imdb_connector_movie($imdbid);
    $minutes = $connector_movie["runtime"];
    $minutes  = preg_replace("'[^0-9]'", "", $minutes);
    $new_time = date("G:i:00", mktime(0, $minutes));
    echo "Runtime: " . $new_time;

    This code works great, but when I choose an option to store movie cache in WordPress MySQL database it stops working and gives this message:
    The movie tt2978462 could not be found. Please check your spelling.
    What could be the problem?

    BTW, thanks for an option not to cache posters!:)

    https://www.ads-software.com/plugins/imdb-connector/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    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.

    Plugin Author thaikolja

    (@thaikolja)

    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).

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    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?

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    I understand the changes made, but my lack of understanding of PHP gives me trouble implementing it:/

    Plugin Author thaikolja

    (@thaikolja)

    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 )

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    Now it’s working perfectly, thank you!:)

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    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?

    Plugin Author thaikolja

    (@thaikolja)

    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

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘IMDB ID’ is closed to new replies.