Advertisement
niammuddin

acak_sc_dan_yt

Jul 27th, 2017
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <style type="text/css">
  2. .box{padding:10px;border-bottom:1px solid #ddd}
  3. .tumb{float:left;margin-right:10px;width:55px;height:55px}
  4. .right{height:55px}
  5. .title_box{font-weight:bold}
  6. .title_box a{color:#555;text-decoration:none}
  7. @media all and (max-width: 600px) {.tumb {display:none;}}
  8. </style>
  9.  
  10.  
  11. <?php
  12. $s = 'aku jatuh cinta';
  13. // Functions
  14. function car($ss){
  15. $ss = trim(preg_replace(array('`"`', '`[^a-z0-9]+`'),  array('', '-'), strtolower($ss)), '-');
  16. return $ss;
  17. }
  18. function limit_words($string, $word_limit){
  19. $words = explode(" ",$string);
  20. return implode(" ",array_splice($words,0,$word_limit));}
  21. $api1 = '257519e63d94a91f7a6d0ab40684a6a7';
  22. $json1 = file_get_contents('http://api.soundcloud.com/tracks.json?client_id='.$api1.'&q='.urlencode(limit_words($s,5)).'&limit=15&offset=1');
  23. $out1  = json_decode($json1,true);
  24. $api2 = 'AIzaSyAuRwtR62BoOeW1rgwwPjJJOopiR3zq9BI';
  25. $json2  = file_get_contents('https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=15&q='.urlencode(limit_words($s,5)).'&type=video&key='.$api2.'');
  26. $out2 = json_decode($json2,true);
  27. $output1 = array();
  28. $output2 = array();
  29. //output
  30. foreach ($out1 as $sc){
  31. $output1[] = '<div class="box">
  32. <div class="tumb"><img src="https://lh5.ggpht.com/bgW-nCeeAMdoXdWhMXUOMGEmhZn9-nAjPXjikdxfFWzalnN6p5VLqYuVMMhj_lAll3k=w55"/></div>
  33. <div class="right"><span class="title_box">'.$sc['title'].'</span><br/>
  34. <span><small>source: soundcloud</small> | <a rel="nofollow" target="_blank" href="https://waitingfor.download/server1/'.$sc['id'].'/'.car($sc['title']).'.html">Download</a></span></div>
  35. </div>';
  36. }
  37. foreach ($out2['items'] as $yt){
  38. $output2[] = '<div class="box">
  39. <div class="tumb"><img src="https://lh5.ggpht.com/bgW-nCeeAMdoXdWhMXUOMGEmhZn9-nAjPXjikdxfFWzalnN6p5VLqYuVMMhj_lAll3k=w55"/></div>
  40. <div class="right"><span class="title_box">'.$yt['snippet']['title'].'</span><br/>
  41. <span><small>source: youtube</small> | <a rel="nofollow" target="_blank" href="https://waitingfor.download/server2/'.$yt['id']['videoId'].'/'.car($yt['snippet']['title']).'.html">Download</a></span></div>
  42. </div>';
  43. }
  44.      $output = array_map( null, $output1, $output2);
  45.         if ( !empty($output) ) {
  46.         foreach ( $output as $lines ) {
  47.                   $lines = array_filter( $lines );
  48.                   if (!empty($lines)) {
  49.                   foreach ( $lines as $line ) {
  50.                        echo $line;
  51.                   }
  52.         }
  53.         }
  54.         }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement