Jump to content

Tag Imdb


Administrador
 Share

Recommended Posts

editei um pouco o codigo para deixar de ser só para o IPB e ser mais geral só para tentar ajudar ai o ppl que o quer meter num blog, espero que o jamesp0tter não se importe.

all credits go to jamesp0tter (nice code :) )

index.php:

<HEAD>
<style type="text/css">
body
{
	color: #222;
	font-family: Verdana, Tahoma, Arial, Trebuchet MS, Sans-Serif, Georgia, Courier, Times New Roman, Serif;
	font-size: 11px;
	line-height: 135%;
}

.imdbtop{
	background: #E4EAF2 url(http://www.fastnewsforum.org/style_images/nouwel-us/css_img_imdb.gif) no-repeat right;
	border: 1px dotted #000;
	border-bottom: 0;
	border-left: 4px solid #8394B2;
	color: #000;
	font-weight: bold;
	font-size: 10px;
	margin: 8px auto 0 auto;
	padding: 3px;
} 
.quotemain
{
	background: #FAFCFE;
	border: 1px dotted #000;
	border-left: 4px solid #8394B2;
	color: #465584;
	padding: 4px;
	margin: 0 auto 8px auto;
}

</style>


<HEAD>
<BODY>
<?
	//exemplo
	echo regex_parse_imdb("http://www.imdb.com/title/tt0369441/");
	
    /*-------------------------------------------------------------------------*/
    // regex_parse_imdb: cria a caixinha do imdb
	//
	// function coded by jamesp0tter
    /*-------------------------------------------------------------------------*/
	
    $imdb_count = 0;    
    function regex_parse_imdb($texto="")
    {
        global $imdb_count;
        
        // supostamente nao deve acontecer, maaaaas...
        if ($texto == "") return;

        //numero de tags [imdb] processadas para este post
        $imdb_count++;
        
        //se superior ao nº permitido, terminar
        if ($imdb_count > 1) return;

        /* eleminar tudo o qe nao seja numeros do argumento (http://www.imdb.com/title/tt0326905/, mdb.com/title/tt0326905/, http://www.imdb.com/title/tt0326905/www.imdb.com/, etc --> 0326905)   */   
        $idfilme = preg_replace('/[^0-9]/i',"\\1",$texto);
        
        if (strlen($idfilme) != 7) { $this->error = 'imdb_nao7'; return; }

        // get css styles
        //$imdb_style = $this->wrap_style('imdb');
      
        // url imdb
        $imdb_url = "http://imdb.com/title/tt".$idfilme."/";
      
        // grab html
        $imdb = @fopen($imdb_url, "r");
        if ($imdb == FALSE) { $this->error = 'imdb_invalido'; return; }
        while (!feof($imdb))
            $imdb_raw .= fgets($imdb, 4096);
        fclose($imdb);
            
        // e agora separar a informaçao
            
        // capa
            //  preg_match ( "'<img border=\"0\" alt=\"cover\" src=\"(.*?)\"'" , $imdb_raw , $capa );                
            //$capa = $capa[1];
        // titulo do filme
              preg_match ( "'<h1><strong class=\"title\">(.*?)</strong></h1>'" , $imdb_raw , $titulo );            
            $titulo = strip_tags($titulo[1]);
        // genero
              preg_match ( "'Genre:</b>\\n(.*?)(\(more\)|\\n)'" , $imdb_raw , $genero );            
            $genero = @strip_tags($genero[1]);
        // slogan
              preg_match ( "'Tagline:</b> (.*?)( <a href|\\n)'" , $imdb_raw , $slogan );            
            $slogan = @$slogan[1];
        // resumo
              preg_match ( "'Plot (Outline|Summary):</b> (.*?)( <a href=|\\n)'" , $imdb_raw , $resumo );        
            $resumo = @$resumo[2];
        // duraçao
              preg_match ( "'Runtime:</b>\\n(.*?)\\n<br>'" , $imdb_raw , $duracao );        
            $duracao = @$duracao[1];
        // votaçao, nº d votos, e estrelas
              preg_match ( "'User Rating:(.*?)\\n\\n(.*?)\\n(.*?)\\n<b>(.*?)/10</b> \((.*?) votes\)\\n'" , $imdb_raw , $votacao );                    
            $votos = @$votacao[5];
            $votacao = @$votacao[4];
            $estrelas = 4 + $votacao * 9 + log10($votacao);
            $estrelas = '<span style="font-size: 16px; background: url(\'http://www.fastnewsforum.org/style_images/1/imdb_rate_full.gif\')"><img src="http://www.fastnewsforum.org/style_images/1/tp.gif" width="'.($estrelas - 1).'" height="16"></span><span style="font-size: 16px; background: url(\'http://www.fastnewsforum.org/style_images/1/imdb_rate_none.gif\') right"><img src="http://www.fastnewsforum.org/style_images/1/tp.gif" width="'.(101 - $estrelas).'" height="16"></span>';
        // top250
              preg_match ( "'top 250: (.*?)</a>'" , $imdb_raw , $top );        
            $top = @strip_tags($top[0]);
        // premios
              preg_match ( "'Awards:</b> \\n(.*?)\\n<a href's" , $imdb_raw , $premios );        
            $premios = @str_replace("\n"," ",$premios[1]);            

        // $imdb_final vai ser o codigo html final da caixa IMDB
        $imdb_final = "<div class='imdbTop'><tr><td>IMDB</tr></td></div>\n";
        $imdb_final .= "<div class='quotemain'><table border='0'><tr><td><table border='0'><tr><td style='font-size: 10pt; color: #465584; line-height:125%;'>\n";
        $imdb_final .= "<b><span style='font-size:11pt;line-height:100%'>» <u>".$titulo."</u></span></b><br><br>";      
        if ($genero <> "") $imdb_final .= "<b>Género</b>: $genero<br>\n";
        if ($slogan <> "") $imdb_final .= "<b>Slogan</b>: $slogan<br>\n";
        if ($resumo <> "") $imdb_final .= "<b>Resumo</b>: $resumo<br>\n";
        if ($votos <> "") $imdb_final .= "<b>Votação</b>: $votacao/10 $estrelas ($votos votos) <b>$top</b><br>\n";
        if ($duracao <> "") $imdb_final .= "<b>Duração</b>: $duracao<br>\n";
        if ($premios <> "") $imdb_final .= "<b>Prémios</b>: $premios<br>\n";
        $imdb_final .= "<br><b>IMDB</b>: <a href='".$imdb_url."'target = '_blank' >".$imdb_url."</a></span></td></tr></table></td></tr></table></div>\n";
      
        //e finalmente mandar todo o html processado para o post
        return "<!--ImdbBegin".$idfilme."-->\n".$imdb_style['START'].$imdb_final.$imdb_style['END']."\n<!--ImdbEnd".$idfilme."-->\n";
      
    }    
?> 
</BODY>
Link to comment
Share on other sites

edit #999: depois de algums testes parece que não gosta do numero do smallville lol, com o 0279600 dá esse erro marado mas com 0279601 funciona :S

edit #1000: tive a ver o source da página e o problema é que com a página do smallville ele não inicializa a tabela nem mete o título do filme nem nada. ara alem disso no filme 0279601 o a duração aparece 2 vezes e a primeira aparece no fim do resumo weird :X

<!--ImdbBegin0279601-->

<div class='imdbtop'>IMDB</div>

<div class='quotemain'>

<table border='0'>

<tr>

  <td>

  <table border='0'>

    <tr>

    <td style='font-size: 10pt; color: #465584; line-height:125%;'>

      <b>

      <span style='font-size:11pt;line-height:100%'>»

      <u>  "Smehotvorci" (1989) (mini)

      </u></span></b><br><br><b>Género</b>: Comedy / Documentary<br>

      <b>Votação</b>: Credited <span style="font-size: 16px; background: url('style_images/1/imdb_rate_full.gif')"><img src="style_images/1/tp.gif" width="-INF" height="16"></span><span style="font-size: 16px; background: url('style_images/1/imdb_rate_none.gif') right"><img src="style_images/1/tp.gif" width="INF" height="16">

      </span> cast:  Mija Aleksic .... Himself (interviewed)Branka Veselinovic .... Herself (interviewed)Zika Milenkovic .... Himself (interviewed)Radmila Savicevic .... Herself (interviewed)Slavko Simic .... Himself (interviewed)Radivoje 'Lola' Djukic .... Himself (interviewed)Olivera Markovic .... Herself (interviewed) rest of cast listed alphabetically: Dragutin Dobricanin ....  (archive footage)Dragan Lukic-Omoljac ....  (archive footage)Milan Panic ....  (archive footage)Mihajlo-Bata Paskaljevic ....  (archive footage)Miodrag 'Ckalja' Petrovic ....  (archive footage)Miodrag 'Mladja' Veselinovic ....  (archive footage)&nbsp;&nbsp; <b>57 min (6 episodes)</b><br>

      <b>Duração</b>: 57 min (6 episodes)<br><br>

      <b>IMDB</b>: <a href='http://imdb.com/title/tt0279601/' target='_blank'>http://imdb.com/title/tt0279601/</a></span>

    </td>

    </tr>

  </table>

  </td>

</tr>

</table>

</div>

<!--ImdbEnd0279601-->

<!--ImdbBegin0279600-->

<div class='imdbtop'>IMDB</div>

<div class='quotemain'>

  <table border='0'>

  <tr>

 

    ********FALTA AQUI A INICIAÇÃO DA TABELA******

   

    <b>Género</b>: Drama / Sci-Fi / Action / Adventure / Fantasy / Thriller <br>

    <b>Slogan</b>: Every superhero has a beginning... <br>

    <b>Resumo</b>: A young Clark Kent struggles to find his place in the world as he learns to harness his alien powers for good and deals with the typical troubles of teenage life in Smallvile.  <br>

    <b>Duração</b>: 60 min (including commercials)<br><b>Prémios</b>: Won Emmy.  Another 9 wins &amp; 55 nominations<br><br>

    <b>IMDB</b>: <a href='http://imdb.com/title/tt0279600/' target='_blank'>http://imdb.com/title/tt0279600/</a></span></td></tr>

    </table>

    </td>

  </tr>

  </table>

</div>

<!--ImdbEnd0279600-->

Edited by txunk
Link to comment
Share on other sites

LOL

podes dormir descansado qe a ideia nao foi roubada de ninguem ... original ou nao, nao sei se + alguem nao se tera' lembrado, ms "roubada" n foi de ctz ;)

Tava eu mto contente a acabar de recuperar o cd2 do great raid e a descompacta.lo qd m lembrei de ir ver o resumo do movie no imdb.nfo, e ent fez.se luz: qe tal uma tag imdb, qd um poster anunciava um post ou qeria fzr referencia a um filme qq, bastava por , e era criado automaticament uma coisinha do tipo:

(etc)
Link to comment
Share on other sites

gostaria de saber se o user juveleoes sabe usar acentos ou nao conhece esta "técnica"?

:P

o juveleoes escreve no forum com um computador que nao foi comprado em Portugal e por isso o teclado nao possoteclar com acentos. Posso por teclado portugues mas eu sou um pouco preguicoso para tentar decorar aonde estao certos caracteres e bla bla bla ...

:- "

Link to comment
Share on other sites

  • 1 month later...

teste assim dáfixe :P :fnf: [imdb ]

IMDB
» Firewall (2006)

Género(s): Action / Crime / Drama / Thriller

Slogan: Everything He loves Is About To Be Used Against Him.

Resumo: A security specialist is forced into robbing the bank that he's protecting, as a bid to pay off his family's ransom.

Votação: 6.1/10 tp.giftp.gif (564 votos)

Duração: 105 min

Actores (primeiros 5): Alan Arkin, Jimmy Bennett, Paul Bettany, Beverley Breuer, Nikolaj Coster-Waldau

IMDB: http://imdb.com/title/tt0408345/

Edited by {zzz}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.