topical media & game development

talk show tell print

mashup-delicious-10-jukebox-index.php / php



  <?php
  
  //base filetype tag feed url
  define('BASE_MP3_FEED_URL','http://del.icio.us/rss/tag/system:filetype:mp3');
  
  //bring in magpie goodness
  require_once('lib/rss_fetch.inc');
  
  //set cache directory
  define('MAGPIE_CACHE_DIR', 'cache');
  
  //get rid of error Notices because magpie produces some
  error_reporting(E_ERROR | E_WARNING | E_PARSE);
  
  if (isset(_POST['fetchpls'])) {
      //add any tags
      if (isset(_POST['tag']))
          feed_url = BASE_MP3_FEED_URL."+"._POST['tag'];
      else
          feed_url = BASE_MP3_FEED_URL;
      //grab the feed
      rss = fetch_rss(feed_url);
      //setup headers
      header("Content-type: audio/mpegurl");
      header('Content-Disposition: attachment; filename="jukebox.pls"');
      //output pls
      echo "[playlist]\n";
      i = 1;
      foreach (rss->items as item) {
          echo "File".i."=".item['link']."\n";
          echo "Title".i."=".item['title']."\n";
          i++;
      }
      echo "NumberOfEntries=".sizeof(rss->items)."\n";
      echo "Version=2\n";
      //die to stop further execution
      die();
  }
  ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <title>A del.icio.us Jukebox!</title>
      <style type="text/css">
      body
      {
          margin: 1em;
          font-family: Helvetica, Arial, Sans-Serif;
      }
      </style>
  </head>
  <body>
  <form method="post">
  Export a music playlist live from 
  <a href="http://del.icio.us/tag/system:filetype:mp3">del.icio.us</a>.
  <br />
  <br />
  Enter in a tag to narrow it down (optional), or just hit "Get Playlist"
  <br />
  <br /> 
  Tag: <input type="text" name="tag" 
      value="<?php if (isset(_GET['tag'])) echo _GET['tag']; ?>" />
  <br />
  <br />
  <input type="hidden" name="fetchpls" value="true" />
  <input type="submit" value="Get Playlist" />
  </form>
  
  </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.