PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/services/services/lyrics/leoslyrics.php

https://github.com/jinzora/jinzora3
PHP | 92 lines | 49 code | 9 blank | 34 comment | 5 complexity | 5f83a14953f18421baa802dc62ee04d1 MD5 | raw file
  1. <?php if (!defined(JZ_SECURE_ACCESS)) die ('Security breach detected.');
  2. /**
  3. * - JINZORA | Web-based Media Streamer -
  4. *
  5. * Jinzora is a Web-based media streamer, primarily desgined to stream MP3s
  6. * (but can be used for any media file that can stream from HTTP).
  7. * Jinzora can be integrated into a CMS site, run as a standalone application,
  8. * or integrated into any PHP website. It is released under the GNU GPL.
  9. *
  10. * - Resources -
  11. * - Jinzora Author: Ross Carlson <ross@jasbone.com>
  12. * - Web: http://www.jinzora.org
  13. * - Documentation: http://www.jinzora.org/docs
  14. * - Support: http://www.jinzora.org/forum
  15. * - Downloads: http://www.jinzora.org/downloads
  16. * - License: GNU GPL <http://www.gnu.org/copyleft/gpl.html>
  17. *
  18. * - Contributors -
  19. * Please see http://www.jinzora.org/team.html
  20. *
  21. * - Code Purpose -
  22. * - This is the leo's lyrics service.
  23. *
  24. * @since 01.14.05
  25. * @author Ross Carlson <ross@jinzora.org>
  26. * @author Ben Dodson <ben@jinzora.org>
  27. */
  28. $jzSERVICE_INFO = array();
  29. $jzSERVICE_INFO['name'] = "Leo's Lyrics";
  30. $jzSERVICE_INFO['url'] = "http://www.leoslyrics.com";
  31. define('SERVICE_LYRICS_leoslyrics','true');
  32. /*
  33. * Gets the lyrics via Leo's Lyrics
  34. *
  35. * @author Ross Carlson
  36. * @version 1/15/05
  37. * @since 1/15/05
  38. * @param $track a jzMediaTrack
  39. **/
  40. function SERVICE_GETLYRICS_leoslyrics($track) {
  41. global $include_path;
  42. include_once($include_path. "lib/snoopy.class.php");
  43. $meta = $track->getMeta();
  44. $artist = $meta['artist'];
  45. $name = $meta['title'];
  46. // Let's up the max execution time here
  47. ini_set('max_execution_time','60000');
  48. // Now let's see if we can get close...
  49. $snoopy = new Snoopy;
  50. $snoopy->fetch("http://api.leoslyrics.com/api_search.php?auth=Jinzora&artist=". urlencode($artist). '&songtitle='. urlencode($name). '&search=true');
  51. $contents = $snoopy->results;
  52. unset($snoopy);
  53. // Now let's see if we got an exact match
  54. if (stristr($contents,'exactMatch="true"')
  55. or (strstr($contents,'SUCCESS')
  56. and (stristr($contents,$artist) and stristr($contents,$name)))
  57. ){
  58. $lyrics = "";
  59. // Ok, now let's get the ID number
  60. $song_hid = substr($contents,strpos($contents,"hid=")+5,50);
  61. $song_hid = substr($song_hid,0,strpos($song_hid,'"'));
  62. // Now that we've got the HID let's get the lyrics
  63. // Now let's see if we get back the lyrics from leo's lyrics...
  64. $snoopy = new Snoopy;
  65. $snoopy->fetch("http://api.leoslyrics.com/api_lyrics.php?auth=Jinzora&hid=". urlencode($song_hid). '&file= NULL');
  66. $lyrics = $snoopy->results;
  67. unset($snoopy);
  68. // Now let's make sure that was successful
  69. if (stristr($lyrics,"SUCCESS")){
  70. // Now let's clean them up
  71. $lyrics = substr($lyrics,strpos($lyrics,"<text>")+6,999999);
  72. $lyrics = stripslashes(substr($lyrics,0,strpos($lyrics,"</text>")));
  73. }
  74. }
  75. if ($lyrics == "") {
  76. return false;
  77. }
  78. return $lyrics;
  79. }
  80. ?>