From a9de8db967ce3c8d7063301bf3a806a1b1597503 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Sat, 14 Jan 2012 10:23:43 +1100 Subject: [PATCH] Version 1.7 * Useful error for empty libraries * Added File menu with "Sync", "Preview", "Close" options * If a playlist disappears then don't try to sync it (previously crashed) --- English.lproj/NotiPod.xib | 681 +++++++++++++++++++++++++++++++------- Info.plist | 4 +- libnotipod.py | 2 + notipod_cli.py | 2 +- notipod_gui.py | 22 +- 5 files changed, 582 insertions(+), 129 deletions(-) diff --git a/English.lproj/NotiPod.xib b/English.lproj/NotiPod.xib index db670b5..edbf8b2 100644 --- a/English.lproj/NotiPod.xib +++ b/English.lproj/NotiPod.xib @@ -1,30 +1,28 @@ - + 1050 - 10H574 - 677 - 1038.35 + 10K549 + 851 + 1038.36 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 851 + YES - - - + + + YES - com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin - YES - - YES - - - YES - + PluginDependencyRecalculationVersion + YES @@ -158,6 +156,135 @@ _NSAppleMenu + + + File + + 2147483647 + + + submenuAction: + + File + + YES + + + Synchronise! + S + 1048576 + 2147483647 + + + + + + Preview + P + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + + + + Edit + + 2147483647 + + + submenuAction: + + Edit + + YES + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Delete + + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + Help @@ -194,7 +321,7 @@ NotiPod NSWindow - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} {381, 527} @@ -213,7 +340,7 @@ Step 1 - Select a playlist: LucidaGrande - 1.300000e+01 + 13 1044 @@ -223,7 +350,7 @@ controlColor 3 - MC42NjY2NjY2ODY1AA + MC42NjY2NjY2NjY3AA @@ -390,16 +517,16 @@ YES icon - 4.000000e+01 - 1.600000e+01 - 1.000000e+03 + 40 + 16 + 1000 - 75628032 - 0 + 75628096 + 2048 LucidaGrande - 1.100000e+01 + 11 3100 @@ -429,12 +556,12 @@ selected - 2.000000e+01 - 1.000000e+01 - 3.402823e+38 + 20 + 10 + 3.4028229999999999e+38 - 75628032 - 0 + 75628096 + 2048 @@ -474,12 +601,12 @@ playlist - 2.580000e+02 - 1.000000e+01 - 3.402823e+38 + 258 + 10 + 3.4028229999999999e+38 - 75628032 - 0 + 75628096 + 2048 @@ -504,8 +631,8 @@ - 3.000000e+00 - 2.000000e+00 + 3 + 2 6 @@ -516,8 +643,10 @@ MC41AA - 1.700000e+01 + 17 46137344 + + 4 15 0 @@ -539,7 +668,7 @@ _doScroller: - 9.970502e-01 + 0.9970502 @@ -549,7 +678,7 @@ 1 _doScroller: - 9.969512e-01 + 0.99695120000000004 {{32, 142}, {329, 340}} @@ -567,7 +696,7 @@ {{0, 0}, {1024, 746}} {381, 549} - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} NotiPodController @@ -580,7 +709,7 @@ Window NSWindow - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} 256 @@ -593,8 +722,8 @@ {{18, 42}, {306, 20}} 16394 - 2.000000e+01 - 1.000000e+02 + 20 + 100 @@ -636,7 +765,7 @@ {342, 100} {{0, 0}, {1024, 746}} - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} PlaylistModel @@ -648,10 +777,11 @@ 15 2 {{196, -30}, {637, 540}} - 603979776 + 1677721600 Preview NSWindow + {1.79769e+308, 1.79769e+308} 256 @@ -691,7 +821,7 @@ YES LucidaGrande - 1.000000e+01 + 10 2843 @@ -699,100 +829,100 @@ YES - 0.000000e+00 + 0.0 - 5.600000e+01 + 56 - 1.120000e+02 + 112 - 1.680000e+02 + 168 - 2.240000e+02 + 224 - 2.800000e+02 + 280 - 3.360000e+02 + 336 - 3.920000e+02 + 392 - 4.480000e+02 + 448 - 5.040000e+02 + 504 - 5.600000e+02 + 560 - 6.160000e+02 + 616 - 6.720000e+02 + 672 - 7.280000e+02 + 728 - 7.840000e+02 + 784 - 8.400000e+02 + 840 - 8.960000e+02 + 896 - 9.520000e+02 + 952 - 1.008000e+03 + 1008 - 1.064000e+03 + 1064 - 1.120000e+03 + 1120 - 1.176000e+03 + 1176 - 1.232000e+03 + 1232 - 1.288000e+03 + 1288 - 1.344000e+03 + 1344 - 1.400000e+03 + 1400 - 1.456000e+03 + 1456 - 1.512000e+03 + 1512 - 1.568000e+03 + 1568 - 1.624000e+03 + 1624 - 1.680000e+03 + 1680 - 1.736000e+03 + 1736 @@ -809,7 +939,7 @@ YES LucidaGrande-Bold - 1.000000e+01 + 10 16 @@ -866,7 +996,7 @@ - 5.800000e+02 + 580 1 @@ -911,7 +1041,7 @@ 1 MCAwIDEAA - + @@ -940,7 +1070,7 @@ _doScroller: - 9.415205e-01 + 0.94152049999999998 @@ -950,8 +1080,8 @@ 1 _doScroller: - 1.000000e+00 - 9.456522e-01 + 1 + 0.94565220000000005 {{20, 20}, {597, 506}} @@ -967,7 +1097,7 @@ {{0, 0}, {1280, 778}} - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} @@ -1149,13 +1279,55 @@ 539 + + + copy: + + + + 586 + + + + selectAll: + + + + 587 + + + + performClose: + + + + 605 + + + + performClick: + + + + 608 + + + + performClick: + + + + 609 + YES 0 - + + YES + @@ -1163,7 +1335,7 @@ -2 - RmlsZSdzIE93bmVyA + File's Owner -1 @@ -1184,6 +1356,8 @@ YES + + MainMenu @@ -1616,14 +1790,112 @@ + + 540 + + + YES + + + + + + 541 + + + YES + + + + + + + + + + + + + 548 + + + + + 549 + + + + + 551 + + + + + 552 + + + + + 553 + + + + + 554 + + + + + 555 + + + + + 556 + + + + + 588 + + + YES + + + + + + 589 + + + YES + + + + + + + + 597 + + + + + 606 + + + + + 607 + + + YES YES - -1.IBPluginDependency - -2.IBPluginDependency -3.IBPluginDependency 103.IBPluginDependency 103.ImportedFromIB2 @@ -1658,6 +1930,7 @@ 29.WindowOrigin 29.editorWindowContentRectSynchronizationRect 371.IBEditorWindowLastContentRect + 371.IBPluginDependency 371.IBWindowTemplateEditedContentRect 371.NSWindowTemplate.visibleAtLaunch 371.editorWindowContentRectSynchronizationRect @@ -1675,8 +1948,8 @@ 413.IBPluginDependency 413.editorWindowContentRectSynchronizationRect 414.IBPluginDependency - 425.IBPluginDependency 428.IBEditorWindowLastContentRect + 428.IBPluginDependency 428.IBWindowTemplateEditedContentRect 428.NSWindowTemplate.visibleAtLaunch 428.editorWindowContentRectSynchronizationRect @@ -1690,9 +1963,7 @@ 469.IBPluginDependency 470.IBPluginDependency 472.IBPluginDependency - 477.IBPluginDependency 485.IBPluginDependency - 490.IBPluginDependency 509.IBPluginDependency 510.IBPluginDependency 514.IBPluginDependency @@ -1712,6 +1983,17 @@ 535.IBPluginDependency 536.IBPluginDependency 537.IBPluginDependency + 540.IBPluginDependency + 541.IBEditorWindowLastContentRect + 541.IBPluginDependency + 548.IBPluginDependency + 549.IBPluginDependency + 551.IBPluginDependency + 552.IBPluginDependency + 553.IBPluginDependency + 554.IBPluginDependency + 555.IBPluginDependency + 556.IBPluginDependency 56.IBPluginDependency 56.ImportedFromIB2 57.IBPluginDependency @@ -1719,47 +2001,56 @@ 57.editorWindowContentRectSynchronizationRect 58.IBPluginDependency 58.ImportedFromIB2 + 588.IBPluginDependency + 588.ImportedFromIB2 + 589.IBEditorWindowLastContentRect + 589.IBPluginDependency + 589.ImportedFromIB2 + 589.editorWindowContentRectSynchronizationRect + 597.IBPluginDependency + 597.ImportedFromIB2 + 606.IBPluginDependency + 607.IBPluginDependency YES com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilderKit - com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin - - {{87, 691}, {163, 23}} + + {{460, 691}, {160, 23}} com.apple.InterfaceBuilder.CocoaPlugin - + {{98, 681}, {163, 23}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{436, 809}, {64, 6}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - - {{0, 714}, {148, 20}} + + {{327, 750}, {234, 20}} com.apple.InterfaceBuilder.CocoaPlugin - + {74, 862} {{529, 476}, {148, 20}} - {{249, 160}, {381, 527}} - {{249, 160}, {381, 527}} - + {{329, 160}, {381, 527}} + com.apple.InterfaceBuilder.CocoaPlugin + {{329, 160}, {381, 527}} + {{505, 213}, {252, 190}} {381, 527} @@ -1775,8 +2066,8 @@ com.apple.InterfaceBuilder.CocoaPlugin {{89, 581}, {211, 33}} com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin {{82, 548}, {342, 100}} + com.apple.InterfaceBuilder.CocoaPlugin {{82, 548}, {342, 100}} {{196, 436}, {204, 74}} @@ -1801,24 +2092,43 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{329, 122}, {637, 540}} + com.apple.InterfaceBuilder.CocoaPlugin + {{329, 122}, {637, 540}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{158, 122}, {637, 540}} com.apple.InterfaceBuilder.CocoaPlugin - {{158, 122}, {637, 540}} - com.apple.InterfaceBuilder.CocoaPlugin + {{456, 597}, {151, 153}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + {{23, 551}, {192, 153}} com.apple.InterfaceBuilder.CocoaPlugin - + + com.apple.InterfaceBuilder.CocoaPlugin + + {{414, 687}, {177, 63}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{323, 672}, {199, 203}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -1837,7 +2147,7 @@ - 539 + 609 @@ -1849,6 +2159,13 @@ doSelectFolder: id + + doSelectFolder: + + doSelectFolder: + id + + YES @@ -1862,6 +2179,25 @@ id + + YES + + YES + folderPopup + window + + + YES + + folderPopup + id + + + window + id + + + IBProjectSource notipod_gui.py @@ -1885,6 +2221,30 @@ id + + YES + + YES + doCancel: + doPreview: + doSync: + + + YES + + doCancel: + id + + + doPreview: + id + + + doSync: + id + + + YES @@ -1910,6 +2270,55 @@ id + + YES + + YES + folderModel + loadingIndicator + loadingLabel + loadingSheet + playlistModel + previewText + previewWindow + window + + + YES + + folderModel + id + + + loadingIndicator + id + + + loadingLabel + id + + + loadingSheet + id + + + playlistModel + id + + + previewText + id + + + previewWindow + id + + + window + id + + + @@ -1927,12 +2336,44 @@ outlineView id + + outlineView + + outlineView + id + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES ../notipod.xcodeproj 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + NSSwitch + + + YES + {9, 8} + {7, 2} + {15, 15} + + diff --git a/Info.plist b/Info.plist index d5ca792..d3b1369 100644 --- a/Info.plist +++ b/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.6 + 1.7 CFBundleSignature ???? CFBundleVersion - 1.6 + 1.7 NSMainNibFile NotiPod NSPrincipalClass diff --git a/libnotipod.py b/libnotipod.py index 3e30e4d..76b7fb0 100644 --- a/libnotipod.py +++ b/libnotipod.py @@ -44,6 +44,8 @@ class ITunesLibrary(NSObject): filename = os.path.expanduser(filename) yield "Reading library..." plist = read_plist(os.path.expanduser(filename)) + if plist is None: + raise Exception("Could not find music library: " + filename) self.folder = self.loc2name(plist["Music Folder"]) pl_tracks = plist["Tracks"] pl_lookup = {} diff --git a/notipod_cli.py b/notipod_cli.py index b21bfec..0d7c44e 100755 --- a/notipod_cli.py +++ b/notipod_cli.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -VERSION = "1.6" +VERSION = "1.7" import logging import optparse diff --git a/notipod_gui.py b/notipod_gui.py index 5a0d329..85d2f15 100644 --- a/notipod_gui.py +++ b/notipod_gui.py @@ -4,6 +4,8 @@ import logging import os +import sys +import traceback import objc from Foundation import * @@ -167,6 +169,7 @@ class NotiPodController(NSObject): self.loadingLabel.setStringValue_, msg, True) except Exception, e: NSRunAlertPanel("Error!", str(e), "Ok", None, None) + traceback.print_exc() finish = fail self.performSelectorOnMainThread_withObject_waitUntilDone_( self.stopGenerator, finish, True) @@ -188,11 +191,15 @@ class NotiPodController(NSObject): yield "Calculating changes..." folder = self.folders()[0] - playlists = [self.library.get_playlist_pid(pid) for pid in self.playlists()] + if not os.path.isdir(folder.encode("utf-8")): + NSRunAlertPanel("Error!", "Destination " + folder + " does not exist, try mounting it first?", "Ok", None, None) + return all_tracks = [] - for playlist in playlists: - all_tracks.extend(playlist.tracks) + for playlist_id in self.playlists(): + playlist = self.library.get_playlist_pid(playlist_id) + if playlist is not None: + all_tracks.extend(playlist.tracks) gen = libnotipod.sync( dry_run=True, @@ -217,14 +224,17 @@ class NotiPodController(NSObject): @objc.IBAction def doSync_(self, sender): folder = self.folders()[0] - playlists = [self.library.get_playlist_pid(pid) for pid in self.playlists()] - if not os.path.isdir(folder.encode("utf-8")): NSRunAlertPanel("Error!", "Destination " + folder + " does not exist, try mounting it first?", "Ok", None, None) return all_tracks = [] - for playlist in playlists: + for playlist_id in self.playlists(): + playlist = self.library.get_playlist_pid(playlist_id) + if playlist is None: + print "Forgetting unknown playlist:", playlist_id + self.setPlaylist_selected_(playlist_id, False) + continue all_tracks.extend(playlist.tracks) libnotipod.export_m3u(dry_run=False, dest=folder, path_prefix="", playlist_name=playlist.name, files=playlist.tracks) -- 2.39.2