Advertisement
scriptz-team

[PHP] Get TVShow Banner from TheTVDB -> Upload to imgur

Apr 24th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. /* _____ _____ _ _____ _____ _____ _____ _____ _____
  3. ___| | __ |_| _ |_ _|___ ___|_ _| __| _ | |
  4. |_ -| --| -| | __| | | |- _|___| | | | __| | | | |
  5. |___|_____|__|__|_|__| |_| |___| |_| |_____|__|__|_|_|_|
  6. |s C R i P T z - T E A M . i N F O|----------------------------
  7.  
  8. Get TVShow Banner from TheTVDB -> Upload to imgur
  9.  
  10. RESULT:
  11. IMGUR iMAGE LiNK
  12. */
  13.  
  14. define("TV_SHOW", "house");
  15. define("UPLOAD_URL", "http://imgur.com/upload?url=");
  16. define("IMG_REGEX", "/http:\/\/i.imgur.com\/[a-z0-9A-Z.]+/");
  17.  
  18. function GET_($url)
  19. {
  20. $ch = curl_init();
  21. curl_setopt($ch, CURLOPT_URL, $url);
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  23. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  24. $source_code = curl_exec($ch);
  25. curl_close($ch);
  26. return $source_code;
  27. }
  28.  
  29. function TV_SHOW_BANNER($title)
  30. {
  31. $url = "http://thetvdb.com/api/GetSeries.php?seriesname=" . urlencode(str_replace(".", " ", $title));
  32. $page = GET_($url);
  33. if (preg_match("/graphical\/[a-z0-9A-Z.\-]+/", $page, $match)) {
  34. $pic = $match[0];
  35. $img = GET_(UPLOAD_URL . "http://cache.thetvdb.com/banners/$pic");
  36. preg_match(IMG_REGEX, $img, $match);
  37. $imageUrl = $match[0];
  38. return $imageUrl;
  39. }
  40.  
  41. }
  42. echo TV_SHOW_BANNER(TV_SHOW);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement