tankcr

Untitled

Apr 18th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using iTunesLib;
  3. using System.Xml.Linq;
  4. using System.IO;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using TagLib;
  8. using ITLRU;
  9.  
  10. namespace BackupLib
  11. {
  12.     class Program
  13.     {
  14.       static void Main(string[] args)
  15.         {
  16.             // iTunes classes
  17.             iTunesAppClass itunes = new iTunesAppClass();
  18.             IITLibraryPlaylist mainLibrary = itunes.LibraryPlaylist;
  19.             IITTrackCollection ittracks = mainLibrary.Tracks;
  20.            
  21.                      
  22.             List<string> files = new List<string>();
  23.             string[] extensions = { "*.mp3", "*.mp4", "*.m4a", "*.m4v", "*.m4p", "*.m4b", "*.flac"};
  24.             string filepath = "G:\\iTunes Media";
  25.             foreach (string extension in extensions)
  26.             {
  27.                 files.AddRange(Directory.GetFiles(filepath, extension, SearchOption.AllDirectories));
  28.             }
  29.             XDocument doc = new XDocument
  30.                 (
  31.                 new XElement("Songs",
  32.                  files.Select(file =>
  33.                     new XElement("Song",
  34.                    (new XElement("Title", (TagLib.File.Create(file).Tag.Title))),
  35.                    (new XElement("Path", (file))),
  36.                    (new XElement("Artist", (TagLib.File.Create(file).Tag.Performers)))
  37.                    ))));
  38.                 doc.Save("D:\\files.xml");      
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment