iTunesUpdates.cs :  » Development » iTuner » iTunerTests » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » iTuner 
iTuner » iTunerTests » iTunesUpdates.cs
//************************************************************************************************
// Copyright  2010 Steven M. Cohn. All Rights Reserved.
//
//************************************************************************************************

namespace iTunerTests{
  using System;
  using Microsoft.VisualStudio.TestTools.UnitTesting;
  using iTunesLib;
  using iTuner;

  
  /// <summary>
  /// These are not unit tests specifically but rather utility scripts for altering
  /// large quantities of songs in my library...
  /// </summary>

  [TestClass]
  public class ManualUpdates : TestBase
  {

    //[TestMethod]
    //public void UpgradeTest ()
    //{
    //    UpgradeHelper helper = new UpgradeHelper();
    //    helper.CheckReleases();
    //}


    /// <summary>
    /// All songs in the "Top 500 Rock" album had a title of the form
    /// "track - artist - title", such as "003 - Derek and the Dominos - Layla"
    /// and Artist set to "Various".  So this is not a unit test but rather as
    /// small utility to parse those names and populate the Arist, Name, and TrackNumber
    /// fields accordingly.
    /// </summary>

    [Ignore]
    [TestMethod]
    public void RenameTop500 ()
    {
      iTunesAppClass itunes = new iTunesAppClass();
      IITLibraryPlaylist playlist = itunes.LibraryPlaylist;
      IITTrackCollection tracks = playlist.Tracks;

      foreach (IITTrack track in tracks)
      {
        if ((track != null) &&
          (track.Album != null) &&
          track.Album.Equals("Top 500 Rock"))
        {
          // 003 - Derek and the Dominos - Layla
          string[] parts = track.Name.Split('-');
          if (parts.Length == 3)
          {
            Console.WriteLine("... " + track.Name);

            int trackNumber = Int32.Parse(parts[0].Trim());
            string artist = parts[1].Trim();
            string name = parts[2].Trim();

            track.Comment = track.Name;

            if (trackNumber > 0)
              track.TrackNumber = trackNumber;

            if (!String.IsNullOrEmpty(artist))
              track.Artist = artist;

            if (!String.IsNullOrEmpty(name))
              track.Name = name;
          }
        }
      }
    }



    /// <summary>
    /// </summary>

    [Ignore]
    [TestMethod]
    public void RenameX ()
    {
      iTunesAppClass itunes = new iTunesAppClass();
      IITLibraryPlaylist playlist = itunes.LibraryPlaylist;
      IITTrackCollection tracks = playlist.Tracks;

      foreach (IITTrack track in tracks)
      {
        if ((track != null) &&
          (track.Album != null) &&
          track.Album.Equals("Sheer Heart Attack") &&
          track.Artist.Equals("Queen"))
        {
          // 07 - Lenny Kravitz - Mr. Cab Driver (1989)
          string[] parts = track.Name.Split('-');
          if (parts.Length == 2)
          {
              Console.WriteLine("... " + track.Name);

              int trackNumber = Int32.Parse(parts[0].Trim());
              string name = parts[1].Trim();

              track.Comment = track.Name;

              if (trackNumber > 0)
                  track.TrackNumber = trackNumber;

              if (!String.IsNullOrEmpty(name))
                  track.Name = name;
          }

          //int index = track.Name.IndexOf('(');
          //if (index > 0)
          //{
          //    track.Name = track.Name.Substring(0, index - 1).Trim();
          //}
        }
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.