Advertisement
Guest User

NHL Streams

a guest
Nov 8th, 2013
2,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>NHL Streams</title>
  6. </head>
  7. <body>
  8. <?php
  9.     $sked = file_get_contents( 'http://live.nhl.com/GameData/SeasonSchedule-20132014.json' );
  10.     $sked_json = json_decode( $sked );
  11.     $todays_date = date( 'Ymd', time() );
  12.     $output = '<ul>';
  13.     foreach ( $sked_json as $game ) {
  14.         $date = $game->est;
  15.         $game_date = date( 'Ymd', strtotime( $date ) );
  16.         if( $game_date != $todays_date ) {
  17.             continue;
  18.         }
  19.  
  20.         $game_id = substr( $game->id, -4 );
  21.  
  22.         $streams = file_get_contents( 'http://smb.cdnak.neulion.com/fs/nhl/mobile/feed_new/data/streams/2013/ipad/02_'.$game_id.'.json' );
  23.         $streams_json = json_decode( $streams );
  24.         $output .= '<li>';
  25.             $output .= $game->a . ' @ ' . $game->h . ' - ' . date( 'g:i a', strtotime( $game->est) ) . ' EST';
  26.             $output .= '<ul>';
  27.                 if( !isset( $streams_json->gameStreams->ipad->away->live ) ) {
  28.                     $output .= '<li>No streams available yet. Check back soon</li>';
  29.                 } else {
  30.                 $stream_a = $streams_json->gameStreams->ipad->away->live->bitrate0;
  31.                 $stream_h = $streams_json->gameStreams->ipad->home->live->bitrate0;
  32.                 $output .= '<li>' . $game->a;
  33.                     $output .= '<ul>';
  34.                         $output .= '<li>' . $stream_a . '</li>';
  35.                         $output .= '<li>' . preg_replace( '/ipad/i', '4500', $stream_a ) . '</li>';
  36.                         $output .= '<li>' . preg_replace( '/ipad/i', '3000', $stream_a ) . '</li>';
  37.                         $output .= '<li>' . preg_replace( '/ipad/i', '1600', $stream_a ) . '</li>';
  38.                     $output .= '</ul>';
  39.                 $output .= '</li>';
  40.                 $output .= '<li>' . $game->h;
  41.                     $output .= '<ul>';
  42.                         $output .= '<li>' . $stream_h . '</li>';
  43.                         $output .= '<li>' . preg_replace( '/ipad/i', '4500', $stream_h ) . '</li>';
  44.                         $output .= '<li>' . preg_replace( '/ipad/i', '3000', $stream_h ) . '</li>';
  45.                         $output .= '<li>' . preg_replace( '/ipad/i', '1600', $stream_h ) . '</li>';
  46.                     $output .= '</ul>';
  47.                 $output .= '</li>';
  48.                 }
  49.             $output .= '</ul>';
  50.         $output .= '</li>';
  51.     }
  52.     $output .= '</ul>';
  53.  
  54.     echo $output;
  55. ?>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement