Miscellaneous Code
  Home arrow Miscellaneous Code arrow iTunes2
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS CODE

iTunes2
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-06-15

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    iTunes2 is a Library.export viewer for the popular iTunes (version 2) music player created by Apple computers. It reads the entire file into an array and then cycles through each line of the file to extract wanted information.

    Support is included to convert time (in seconds) to a more readable format (minutes:seconds), as well as export file size, genere, bit and sample rates, and track numbers. Optional headers/footers can be set by un-commenting the appropriate lines.


    By : RobertDX

    <?php
    // Name: iTunes 2
    // Author: Robert Baird
    /* Description:
    iTunes2 is a Library.export viewer for the popular iTunes (version 2)
    music player created by Apple computers. It reads the entire file into
    an array and then cycles through each line of the file to extract
    wanted information. It take awhile to execute on slower systems or
    with large music libraries.

    The script is designed to work with the playlist being grouped by
    "Artists", although it will work otherwise, just not as intended.

    Support is included to convert time (in seconds) to a more readable
    format (minutes:seconds), as well as export file size, genere, bit and
    sample rates, and track numbers. Optional headers/footers can be set by
    un-commenting the appropriate lines.

    Trademarked names such as Apple computers and iTunes are held by Apple
    Computers, code is copyrighted by Robert Baird.
    */

    // set the location of your exported library
    $filepath = "/home/user/Library.export";

    // set the URI of the script on your server
    $scripturl = "http://domain.host/itunes2.php";

    // include an optional header file if you wish
    // include("/home/user/public_html/include/header.php.inc");

    // read the file into an array named $readfile
    $readfile = file($filepath);

    // *** working backwards, if the user has selected both
    // an artist and a song, display the info for that song

    if ($song && $artist) {

    // start a for loop the cycles through the entire file line by line
    for ($k=1; $k<=count($readfile)-1; $k++) {

    // split each line into a sepearte array $fields
    $fields = split("\t",$readfile[$k]);

    // when we get to the line that matches the song we want this
    // if loop trips and displays the song info
    if (($artist == $fields[1]) && ($song == $fields[0])) {

    // time conversion, seconds -> minutes:seconds
    // I couldn't find any easier ways to do this
    $minutes = floor(($fields[5] / 60));
    $seconds = round(($fields[5] - ($minutes * 60)), 0);
    if (strlen($seconds) == 1) { $seconds = "0". $seconds; }

    // format the filesize value from bytes -> kb
    $size = round(($fields[4]/1024),2);


    // expore the data, this is all customizable
    print("
    Song - $fields[0]<br>
    Artist - $fields[1]<br>
    Album - $fields[2]<br>
    Genre - $fields[3]<br>
    Size - $size K<br>
    Time - $minutes:$seconds<br>
    Track - $fields[6]/$fields[7]<br>
    Date - $fields[9]<br>
    Date Added - $fields[10]<br>
    Bit Rate - $fields[11]<br>
    Sample Rate - $fields[12]<br>
    Volume Adjustment - $fields[13]<br>
    Kind - $fields[14]<br>
    Comments - $fields[15]<br>
    "); }

    }

    }

    // *** continueing to work backwards, if no song has been selected, but
    // but an artist has, display all songs by that particular artist

    elseif ($artist) {

    // start a for loop the cycles through the entire file line by line
    for ($k=1; $k<=count($readfile)-1; $k++) {

    // split each line into a sepearte array $fields
    $fields = split("\t",$readfile[$k]);

    // when we find a line that matches the artist we want this if conditional
    // trips and prints out a link to the song's info
    if ($artist == $fields[1]) {

    print("<a href=\"$scripturl?artist=$fields[1]&song=$fields[0]\">$fields[0]<br>");
    }

    }

    }

    // *** continueing to work backwards, if no song has been selected, and
    // and no artist has been selected, we need to print out a list of artists

    else {

    // the $last variable is used within the next for loop, basically, we look at
    // each line in file and group them together. the first song in the list is
    // displayed because it does not match "101668871488" (probably)
    $last = "101668871488";

    // start a for loop the cycles through the entire file line by line
    for ($k=1; $k<=count($readfile)-1; $k++) {

    // split each line into a sepearte array $fields
    $fields = split("\t",$readfile[$k]);

    // print out the artists name with a link to all of their songs
    if ($last != $fields[1]) {
    print("<a href=\"$scripturl?artist=$fields[1]\">$fields[1]</a><br>"); }

    // this is the trick, at the end of the for loop, we reset $last to this
    // particular artist. any of the next songs that have the name of $last
    // will be skipped until we get to a new artist
    $last = $fields[1];

    }

    }

    // include an optional footer file if you wish
    // include("/home/user/public_html/include/footer.inc.php");

    ?>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Miscellaneous Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer.
    FREE! Go There Now!


    NEW! Build Web services with transport-level security using Rational Application Developer V7, Part 1: Build Web services and Web services clients

    Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services.
    FREE! Go There Now!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP.
    FREE! Go There Now!


    NEW! Evaluate Rational Host Access Transformation Services (HATS) Toolkit V7.1

    Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications.
    FREE! Go There Now!


    NEW! IBM Rational ClearCase Innovator's Series

    Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase.
    FREE! Go There Now!


    NEW! Rational Talks to You: Grady Booch on Architecture

    Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered!
    FREE! Go There Now!


    NEW! Test terminal-based applications with Rational Functional Tester

    Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily.
    FREE! Go There Now!


    NEW! The role of integrated requirements management in software delivery

    This paper is about the critical role that a discipline called integrated require­ments management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrat­ing, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Performance Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads.
    FREE! Go There Now!


    NEW! Webcast: Accelerating Software Innovation with System z

    Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    MISCELLANEOUS CODE ARTICLES

    - A Web App Based on a Model for the CodeIgnit...
    - Completing a Model for the CodeIgniter PHP F...
    - Validating Input Data with the CodeIgniter P...
    - Deleting Database Records with the CodeIgnit...
    - Inserting Database Records with a CodeIgnite...
    - Fetching Database Rows with a Model for the ...
    - Model Data and Validation Rules for a Generi...
    - Building a Generic Model for the CodeIgniter...
    - upload image to database sql
    - Random Password Generator
    - BCroot, get the root of a number with BC fun...
    - Find pi in a high precision
    - [PHP5] FORMCHECKER : data validation
    - SPL and ITERATOR : examples
    - Xml with Rss Feeds





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek