9Jan/090
Getting music from iTunes to your G1
I wanted to export all my music from iTunes to my G1, but I wanted to maintain the folder structure like this:
Artist\Album\TrackName.mp3
Couldn’t find anything on Google so here’s some C# code to get it done. Remember to add a reference to iTunesLib (Add Reference / COM).
1: private static class ITunesExporter{
2: public static void Export(string playlistName, string path) {
3: iTunesAppClass iTunes = new iTunesAppClass();
4:
5: foreach (IITPlaylist playlist in iTunes.LibrarySource.Playlists) {
6: if (playlist.Name == playlistName) {
7: foreach (IITTrack track in playlist.Tracks) {
8: if (track.Kind == ITTrackKind.ITTrackKindFile) {
9: IITFileOrCDTrack file = (IITFileOrCDTrack)track;
10: string extension = Path.GetExtension(file.Location);
11: string newPath = ITunesExporter.createValidFileName(path, file.Artist, file.Album, file.Name, extension);
12: string newDirectoryName = Path.GetDirectoryName(newPath);
13: Directory.CreateDirectory(newDirectoryName);
14:
15: if (File.Exists(newPath) == false) {
16: File.Copy(file.Location, newPath);
17: }
18: }
19: }
20: }
21: }
22: }
23: private static string createValidFileName(string exportPath, string artist, string album, string track, string extension) {
24: artist = ITunesExporter.removeInvalidFileNameCharacters(artist);
25: album = ITunesExporter.removeInvalidFileNameCharacters(album);
26: track = ITunesExporter.removeInvalidFileNameCharacters(track);
27:
28: string filePath = exportPath;
29: filePath = Path.Combine(filePath, artist);
30: filePath = Path.Combine(filePath, album);
31: filePath = Path.Combine(filePath, track);
32: filePath = Path.ChangeExtension(filePath, extension);
33: return filePath;
34: }
35: private static string removeInvalidFileNameCharacters(string str) {
36: char[] chars = Path.GetInvalidFileNameChars();
37: foreach (char c in chars) {
38: str = str.Replace(c.ToString(), null);
39: }
40: return str;
41: }
42: }
You can use the code like this:
1: ITunesExporter.Export("Phone", @"D:\Music");
”Phone” is the playlist name and “D:\Music” is the path that the files will be exported to.
If anyone want’s to recode it to use the iTunes XML file please post the code! (I am to lazy).
7Aug/072
Cellphone Radar Crap
It isn't really a scam, because they don't actually say it is a cell phone radar, but it doesn't do the shit you would expect it to do.
EDIT: Forgot to mention, the file you download is a stupid little animated GIF!
