///////////////////////////////////////////////////////////////// // // // Manglepod by Dailysonic // // available at http://www.manglepod.com // // // // Copyright 2006 Dailysonic LLC // // // ///////////////////////////////////////////////////////////////// This code is released under the GNU GPL: http://www.gnu.org/copyleft/gpl.html Manglepod is a suite of php tools to aid in the production of dynamic podcasts. stitchit v0.1 ============= stitchit is a small collection of tools for stitching together individual mp3 files into a single file on the fly. They are used to create audio files dynamically -- allowing you to automatically create content as you need it. It consists of three functions... id3strip(), id3tag(), and mp3stitch(): [see the examples in the 'EXAMPLES' directory for usage instructions] id3strip() - Removes id3 tags from mp3 files. This is necessary before you can splice the files together (for better performance, your mp3 files should have their id3 tags removed before uploading them to the server -- in which case, you won't need id3strip). id3tag() - Creates an id3 tag for your stitched mp3 files. mp3stitch() - Stitches multiple mp3s into a single mp3 file and delivers it directly to the user. You provide the function with an array containing the names of all the individual mp3 files and an optional id3 tag created by id3tag(), and it'll return a single mp3 file. mp3stitch() does not save the resulting file, but rather delivers it to the browser as an output stream. Requesting a script utilizing mp3stitch() is equivalent to requesting a static file, as far as the requester is concerned. NOTE: At this time only mp3 files are supported, and the audio sample size for each file (e.g. 8-bit, 16-bit) must be the same, otherwise the functions will not work properly. The software has been designed to be speedy (it has to splice these files together on the fly with minimal delay); as such it does not convert files to the proper format nor does it even check to make sure the files are valid. Those tasks are your responsibility, and should be done prior to using any mp3 files (there are plenty of really neat third-party scripts that do this. My personal favorite is getid3, which you can find at http://getid3.sourceforge.net/). Each file may contain different bitrates (e.g. 96 kbit/s, 112 kbit/s), but not all mp3 players will handle the particular Variable Bit Rate (VBR) files that are produced by this script. Proceed at your own risk when using variable bitrates. Note #2: mp3stitch() needs to send the proper HTTP headers in order to initiate the file download. Because of this, you cannot print anything to the screen or flush the output buffer before using mp3stitch(). If you do, it won't be able to send the headers (as the headers must always be the first thing sent). If you encounter any problems, please email me at: isaac@dailysonic.com rssLube v0.1 ============ rssLube addresses the pesky, and sometimes dangerous, spike in traffic that occurs when an RSS file with audio or video enclosures is updated. Since many RSS readers query the RSS feed frequently, there tends to be a short-lived but significant upsurge in the number of enclosure files downloaded shortly after new items are added to the feed. These simultaneous downloads can slow file access to a crawl or even bring down smaller servers. rssLube attempts to alleviate this problem by intelligently distributing the traffic over a longer period of time, thus decreasing the extent of the traffic spike. It accomplishes this by introducing the updated RSS feed in a controlled manner. Instead of delivering the latest feed in response to 100% of requests, it delivers it to only a fraction of users -- the rest receive a cached version of the old feed. The software essentially flips a coin to decide whether or not to give the requesting user the newest feed or the old one (although, the probability isn't necessarily 50% as in a true coin toss). To users receiving the old feed, it will appear as if the feed has not been updated yet. Presumably only users receiving the latest feed will download the new enclosed files, thus reducing traffic proportionally. Any user who does not receive the latest feed the first time around will get it eventually. The net effect of the 'lube is that RSS updates are introduced gradually and as painlessly as possible. After a sufficient length of time, rssLube will return to delivering the latest file to all users. To use the 'lube, you need to create a php file (for example 'rss.php', although it can be named anything) that contains the following code: [see the example in the 'EXAMPLES' directory] You'll need to specify the location of your rss xml file ($rssfile), the probability that any given user will receive the very latest RSS feed ($probability), the length of time during which some users will receive the old feed ($duration)... after this duration, all users will receive the latest feed until the cache is updated again. And finally, you'll need to specify a password which will allow you to update the cached feed and turn caching on and off ($my_password). You'll also need to put the rsslube.php script in the same directory, and make sure that you set the proper write permissions on that directory (PHP will need to be able to create a couple cache files). Using rssLube means that your RSS feed is now being generated dynamically. As such, you will need to publish your feed using this new file's address (for example, you would give people 'http://www.mypodcast.com/rss.php'). When you want to update your RSS feed, make changes to the xml file ('rss.xml' in the example above), and then tell rssLube to update the cache by visiting the following url: http://www.mypodcast.com/rss.php?password=ilovepasswords&cache=new Make sure that you change the password in the url ('ilovepasswords') to whatever password you have set in the php file. To temporarily disable caching (so that all users will receive the very latest rss feed), visit the following url: http://www.mypodcast.com/rss.php?password=ilovepasswords&cache=off To turn it back on, visit: http://www.mypodcast.com/rss.php?password=ilovepasswords&cache=on To get the current status of rssLube (such as whether caching is on/off, whether the new feed version is currently being delivered, and when the last update occured), visit: http://www.mypodcast.com/rss.php?password=ilovepasswords&cache=status Remember to change the password. And that's it! Enjoy! If you encounter any problems, please email me at: isaac@dailysonic.com musicplug v0.1 ============== musicplug provides links to online music stores for specific artists or albums. Currently, it creates links for the following stores: amazon, barnes & noble, bleep, cdbaby, cduniverse, ebay, emusic, gemm, insound, itunes, napster, and rhapsody. The link urls lead to the various stores' album and artist search pages, where a search is performed for the given artist and/or album. Since most of these stores do not provide an API or other means of validating searches, the links produced by musicplug are not guaranteed to return useful results. musicplug consists of three functions... music_links(), amazon(), and music_links_asin(): music_links() - Takes an artist name and/or album title as inputs, and produces an array of music store link urls and other information. For example: Among other things, the information for each store consists of three link urls... one for an artist search, one for an album search, and one for the store's main website. The output of music_links() can be accessed as follows: NOTE: To use the store icon images, you'll have to download them from http://www.dailysonic.com/manglepod/musicplug_icons.zip In total, this function produces links for ten different online stores: 'amazon' - Amazon.com 'barnesandnoble' - Barnes & Noble 'bleep' - Bleep.com 'cdbaby' - CDBaby.com 'cduniverse' - CDUniverse.com 'ebay' - Ebay.com 'emusic' - eMusic.com 'gemm' - Gemm.com 'insound' - Insound.com 'itunes' - The iTunes Music Store 'napster' - Napter.com 'rhapsody' Rhapsody.com NOTE: I may periodically add or remove stores to this list. And since I have no control over how any of these stores format their search queries, some of the links produced by this function may suddenly stop working. I'll try to keep on top of any changes made, but if you notice that a link no longer seems valid please shoot an email to isaac@dailysonic.com and let me know. amazon() - Takes an Amazon ASIN number for an album, and retrieves information about that album. For example: NOTE: This function requires an Amazon Web Services Key ID. To apply for one, visit http://aws.amazon.com/ If this function is provided with an invalid ASIN or AWS Key, it will spit out an error on $return['error']. music_links_asin() - Same as music_links(), except it takes an ASIN number as an input instead of artist name and album title. For example: NOTE: This function requires an Amazon Web Services Key ID. To apply for one, visit http://aws.amazon.com/ If this function is provided with an invalid ASIN or AWS Key, it will spit out an error on $return['error']. If you encounter any problems, please email me at: isaac@dailysonic.com