Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using iTunesLib;
- using System.Xml.Linq;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- using TagLib;
- using ITLRU;
- namespace BackupLib
- {
- class Program
- {
- static void Main(string[] args)
- {
- // iTunes classes
- iTunesAppClass itunes = new iTunesAppClass();
- IITLibraryPlaylist mainLibrary = itunes.LibraryPlaylist;
- IITTrackCollection ittracks = mainLibrary.Tracks;
- List<string> files = new List<string>();
- string[] extensions = { "*.mp3", "*.mp4", "*.m4a", "*.m4v", "*.m4p", "*.m4b", "*.flac"};
- string filepath = "G:\\iTunes Media";
- foreach (string extension in extensions)
- {
- files.AddRange(Directory.GetFiles(filepath, extension, SearchOption.AllDirectories));
- }
- XDocument doc = new XDocument
- (
- new XElement("Songs",
- files.Select(file =>
- new XElement("Song",
- (new XElement("Title", (TagLib.File.Create(file).Tag.Title))),
- (new XElement("Path", (file))),
- (new XElement("Artist", (TagLib.File.Create(file).Tag.Performers)))
- ))));
- doc.Save("D:\\files.xml");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment