[BETA] IMDB Grabber

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Anti-Spam Guide
rambo9
Registered User
Posts: 34
Joined: Wed Jan 13, 2010 4:40 am

[BETA] IMDB Grabber

Post by rambo9 »

This is a simple mod which gets info from a given imdb link, either tv show or movie.

on viewtopic.php

find

Code: Select all

<?php
after add

Code: Select all


function get_parse($text) {
    $text = preg_replace("/<!-- m --><a class=\"postlink\" href=\"http:\/\/www\.imdb\.com\/title\/[a-zA-Z0-9]*\/\">/",
            "", $text);
    $text = preg_replace("/<\/a><!-- m -->/", "", $text);

    $imdb_regex = "/http:\/\/www\.imdb\.com\/title\/[a-zA-Z0-9]+\//";
    preg_match($imdb_regex, $text, $matches);
    for ($i = 0; isset($matches[$i]); $i++){
        $url = $matches[$i];
    }

//get the page content
    $imdb_content = get_data($url);

//parse for product name
    $name = get_match('/<title>(.*)<\/title>/isU', $imdb_content);
    $director = strip_tags(get_match('/<h5[^>]*>Director:<\/h5>(.*)<\/div>/isU', $imdb_content));
    $plot = get_match('/<h5[^>]*>Plot:<\/h5>(.*)<\/div>/isU', $imdb_content);
    $release_date = get_match('/<h5[^>]*>Release Date:<\/h5>(.*)<\/div>/isU', $imdb_content);
    $mpaa = get_match('/<a href="\/mpaa">MPAA<\/a>:<\/h5>(.*)<\/div>/isU', $imdb_content);
    $run_time = get_match('/Runtime:<\/h5>(.*)<\/div>/isU', $imdb_content);
    $image_link = get_match("#<link rel=\"image_src\" href=\"(.*)\">#Ui", $imdb_content);

//build content
    $content .= "<div style='display:block;background-color:#FFF;border:1px solid black;padding:5px;'>";
    $content .= "<table><tr><td align=\"center\">" . $name . "<br>";
    $content .= "<img src=" . $image_link . "></img></td>";
    $content .= "<td>" . $director . "<br>";
    $content .= substr($plot, 0, strpos($plot, '<a')) . "</div><br>";
    $content .= substr($release_date, 0, strpos($release_date, '<a')) . "</div><br>";
    $content .= $mpaa . "<br>";
    $content .= $run_time . "</div><br>";
    $content .= $url . "<br></td></tr></table></div>";

    return preg_replace("/http:\/\/www\.imdb\.com\/title\/[a-zA-Z0-9]+\//", $content, $text,1);
}

//gets the match content
function get_match($regex, $content) {
    preg_match($regex, $content, $matches);
    return $matches[1];
}

//gets the data from a URL
function get_data($url) {
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}


find

Code: Select all

		'MESSAGE'			=> $message,
after add

Code: Select all

		'MESSAGE'			=> get_parse($message),
looks like this:

Image
Image
Image


and their is one imdb per post, it can be on code or just as text.
Last edited by rambo9 on Sat Sep 11, 2010 1:50 am, edited 1 time in total.
User avatar
darkonia
Registered User
Posts: 1901
Joined: Tue May 13, 2008 1:10 pm
Location: Munich, Germany

Re: [BETA] IMDB Grabber

Post by darkonia »

why you make it so complicated and make not only a bbcode?
MMOG-Heaven - Das Gaming Portal
Community bedeutet Gleichgesinnte finden - MMOG-Heaven ist Deine Community! Von Spielern für Spieler bietet Dir dieses Portal genau das, was ein Spieler braucht. Bleibe ständig informiert, finde die neuesten MMORPGs, oder suche die frischesten News aus der Welt des Online Gamings - dieses und vieles mehr erwartet Dich auf MMOG-Heaven.
rambo9
Registered User
Posts: 34
Joined: Wed Jan 13, 2010 4:40 am

Re: [BETA] IMDB Grabber

Post by rambo9 »

I need to use cURL to grab data from imdb. i am not aware of a bbcode that can do that. if their is, let me know.
User avatar
Sshadow
Registered User
Posts: 302
Joined: Thu Aug 20, 2009 3:54 pm
Name: Chris C.

Re: [BETA] IMDB Grabber

Post by Sshadow »

This is a great idea. This is far from complicated as well. thank you very much for sharing :)
Chris/Admin
User avatar
darkonia
Registered User
Posts: 1901
Joined: Tue May 13, 2008 1:10 pm
Location: Munich, Germany

Re: [BETA] IMDB Grabber

Post by darkonia »

can i use this with all imdb websites, i mean also the german site or else?
MMOG-Heaven - Das Gaming Portal
Community bedeutet Gleichgesinnte finden - MMOG-Heaven ist Deine Community! Von Spielern für Spieler bietet Dir dieses Portal genau das, was ein Spieler braucht. Bleibe ständig informiert, finde die neuesten MMORPGs, oder suche die frischesten News aus der Welt des Online Gamings - dieses und vieles mehr erwartet Dich auf MMOG-Heaven.
User avatar
Eragon
Registered User
Posts: 218
Joined: Tue Oct 07, 2008 1:57 pm

Re: [BETA] IMDB Grabber

Post by Eragon »

very nice but .. how to BBCode style
User avatar
Mess
Registered User
Posts: 985
Joined: Wed Jul 01, 2009 6:37 am
Name: Kim

Re: [BETA] IMDB Grabber

Post by Mess »

There is a topic on startrek guide with something similar, only for bbcodes. It has not be completed yet though. :)
http://startrekguide.com/community/view ... =40&t=9824

Hopefully this can help. :)
Keep up the good work.
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: [BETA] IMDB Grabber

Post by imkingdavid »

Hello,

I see that you've posted your modification's contents in your first post of this topic. Please instead offer your modification as a MODX package download (uploading your modification's MODX package to a server and giving a direct link, with no registration restrictions), rather than posting the modification's contents in your post, as you have done. For more information, view the links on the Modifications page.

Thank you for your cooperation,
The phpBB Modifications Team
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
darkonia
Registered User
Posts: 1901
Joined: Tue May 13, 2008 1:10 pm
Location: Munich, Germany

Re: [BETA] IMDB Grabber

Post by darkonia »

in this form the code is pure buggy, soory nothin show...
MMOG-Heaven - Das Gaming Portal
Community bedeutet Gleichgesinnte finden - MMOG-Heaven ist Deine Community! Von Spielern für Spieler bietet Dir dieses Portal genau das, was ein Spieler braucht. Bleibe ständig informiert, finde die neuesten MMORPGs, oder suche die frischesten News aus der Welt des Online Gamings - dieses und vieles mehr erwartet Dich auf MMOG-Heaven.
clight77
Registered User
Posts: 907
Joined: Sun May 11, 2003 11:09 pm

Re: [BETA] IMDB Grabber

Post by clight77 »

Nice idea for phpbb3 but it does not get anything other than the IMDB title name.
I Follow Up On My Posts.
So Should Everybody...
User avatar
Dragosvr92
Registered User
Posts: 1470
Joined: Sat Sep 12, 2009 7:27 am
Location: Romania
Name: Dragos Valentin Rădulescu

Re: [BETA] IMDB Grabber

Post by Dragosvr92 »

clight77 wrote:Nice idea for phpbb3 but it does not get anything other than the IMDB title name.
Thats because the mod is 4 years old and imdb has changed their website layout. The mod can no longer extract the right data.
Formerly known as TheKiller
3.0| Avatar on Memberlist 1.0.3
Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve

Re: [BETA] IMDB Grabber

Post by Pony99CA »

My IMDB BBCode no longer works, either. Apparently IMDB doesn't allow using IFRAME to display content now. At least they still give you a link to the content.

It's not a big deal for me -- I only wrote it as a proof of concept to show that a BBCode could display IMDB data -- but it may affect others.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

Return to “[3.0.x] MODs in Development”