~ubuntu-branches/ubuntu/quantal/ipod-sharp/quantal

« back to all changes in this revision

Viewing changes to tools/PodTool.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-13 12:36:39 UTC
  • mfrom: (1.1.4 upstream) (6.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20061113123639-cynm2axegef1etff
* New upstream release
* debian/patches/01_fix-playcounts.patch:
  + Dropped, merged upstream
* debian/control:
  + Build depend on mono-gmcs, libmono-sharpzip2.84-cil, libmono2.0-cil,
    libglib2.0-dev and libipoddevice >= 0.5.0
  + Bumped Standards-Version to 3.7.2
  + Add ${misc:Depends} to Depends
  + Let libipodui-cil depend on libipod-cil
* debian/libipod-cil.install:
  + Add ipod-sharp-firmware.dll
* debian/patches/01_dllmap.patch:
  + Add dllmap to libgobject-2.0.so.0 

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    public class PodTool {
8
8
 
9
9
        private static void Usage () {
10
 
            Console.WriteLine ("ipod-tool [--dump-songs, --dump-playlists, --clear] <mount_point> ");
 
10
            Console.WriteLine ("ipod-tool [--dump-tracks, --dump-playlists, --clear] <mount_point> ");
11
11
        }
12
12
 
13
 
        private static string GetSongPath (string dest, Song song) {
14
 
            string artist = song.Artist;
 
13
        private static string GetTrackPath (string dest, Track track) {
 
14
            string artist = track.Artist;
15
15
 
16
16
            if (artist == null || artist == String.Empty)
17
17
                artist = "Unknown";
18
18
 
19
 
            string album = song.Album;
 
19
            string album = track.Album;
20
20
            
21
21
            if (album == null || album == String.Empty)
22
22
                album = "Unknown";
23
23
 
24
 
            string title = song.Title;
 
24
            string title = track.Title;
25
25
            if (title == null || title == String.Empty)
26
26
                title = "Unknown";
27
27
 
28
 
            string ext = Path.GetExtension (song.FileName);
 
28
            string ext = Path.GetExtension (track.FileName);
29
29
            
30
30
            int index = 0;
31
31
            string path = null;
53
53
            }
54
54
 
55
55
            Device device = new Device (args[1]);
56
 
            SongDatabase db = device.SongDatabase;
 
56
            TrackDatabase db = device.TrackDatabase;
57
57
 
58
58
            switch (args[0]) {
59
59
            case "--dump-files":
64
64
                
65
65
                string dest = args[2];
66
66
                int count = 1;
67
 
                int total = db.Songs.Length;
 
67
                int total = db.Tracks.Count;
68
68
                
69
 
                foreach (Song song in db.Songs) {
70
 
                    string path = GetSongPath (dest, song);
71
 
                    Console.WriteLine ("Copying ({0} of {1}): {2}", count++, total, song);
 
69
                foreach (Track track in db.Tracks) {
 
70
                    string path = GetTrackPath (dest, track);
 
71
                    Console.WriteLine ("Copying ({0} of {1}): {2}", count++, total, track);
72
72
 
73
73
                    string dir = Path.GetDirectoryName (path);
74
74
                    if (!Directory.Exists (dir))
75
75
                        Directory.CreateDirectory (dir);
76
76
                    
77
 
                    File.Copy (song.FileName, path);
 
77
                    File.Copy (track.FileName, path);
78
78
                }
79
79
                break;
80
 
            case "--dump-songs":
81
 
                foreach (Song song in db.Songs) {
82
 
                    Console.WriteLine (song);
 
80
            case "--dump-tracks":
 
81
                foreach (Track track in db.Tracks) {
 
82
                    Console.WriteLine (track);
83
83
                }
84
84
                break;
85
85
            case "--dump-playlists":
86
86
                foreach (Playlist playlist in db.Playlists) {
87
87
                    Console.WriteLine ("Playlist: " + playlist.Name);
88
 
                    foreach (Song song in playlist.Songs) {
89
 
                        Console.WriteLine ("\t" + song);
 
88
                    foreach (Track track in playlist.Tracks) {
 
89
                        Console.WriteLine ("\t" + track);
90
90
                    }
91
91
                }
92
92
                break;
93
 
            case "--add-song":
 
93
            case "--add-track":
94
94
                {
95
 
                    Song song = db.CreateSong ();
96
 
                    song.Artist = "WOO WOO";
97
 
                    song.Album = "WOO WOO";
98
 
                    song.Title = "WOO WOO";
99
 
                    song.Duration = new TimeSpan(333 * TimeSpan.TicksPerMillisecond);
100
 
                    song.FileName = "/tmp/foobar.mp3";
 
95
                    Track track = db.CreateTrack ();
 
96
                    track.Artist = "WOO WOO";
 
97
                    track.Album = "WOO WOO";
 
98
                    track.Title = "WOO WOO";
 
99
                    track.Duration = new TimeSpan(333 * TimeSpan.TicksPerMillisecond);
 
100
                    track.FileName = "/tmp/foobar.mp3";
101
101
                }
102
102
                break;
103
 
            case "--remove-song":
 
103
            case "--remove-track":
104
104
                int id = Int32.Parse (args[2]);
105
 
                foreach (Song song in db.Songs) {
106
 
                    if (song.Id == id)
107
 
                        db.RemoveSong (song);
 
105
                foreach (Track track in db.Tracks) {
 
106
                    if (track.Id == id)
 
107
                        db.RemoveTrack (track);
108
108
                }
109
109
                break;
110
110
            case "--clear":
111
 
                foreach (Song song in db.Songs) {
112
 
                    db.RemoveSong (song);
 
111
                foreach (Track track in db.Tracks) {
 
112
                    db.RemoveTrack (track);
 
113
                }
 
114
                break;
 
115
            case "--playcounts":
 
116
                foreach (Track track in db.Tracks) {
 
117
                    Console.WriteLine ("{0}: total {1}, latest {2}", track.Title,
 
118
                                       track.PlayCount, track.LatestPlayCount);
113
119
                }
114
120
                break;
115
121
            default: