1395 USBMass1 for a network shares ... on an Apple Mac

Any ideas about how to improve MediaMonkey? Let us know!

Moderator: Gurus

1395 USBMass1 for a network shares ... on an Apple Mac

Postby markstuartwalker » Sat Jun 25, 2011 4:16 am

I would like to use this plugin to write to a network share i.e. a drive letter mapped to a shared folder on another machine. This allows me to export a subset of my tracks and playlists to another laptop. In my case it's an Apple Mac.

This may seem to be an abomination of the original plugin design scope but the analogy is very close - they both present a drive letter to MM.

There are a few things which don't work logically
* The Device Name doesn't get applied when it is changed.
* Scanning behaviour when the drive letter isn't mapped causes huge timeouts. It would be better interpretted as 'device not attached'.
* Find Device and Device Label are illogical

Could these be fixed?
Windows 7 SP1 x64 / Ubuntu 11.10 / Lion 10.7.3 / iOS 5.1 / iTunes 10.6.0
iTunes plugin (d_itunes & itunes4) viewtopic.php?f=2&t=45713
Running MM under Mac OS X with Wine viewtopic.php?f=4&t=58507
markstuartwalker
 
Posts: 868
Joined: Fri Jul 10, 2009 8:10 am

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby nohitter151 » Sat Jun 25, 2011 8:48 am

markstuartwalker wrote:
There are a few things which don't work logically
* The Device Name doesn't get applied when it is changed.

Have you tried on the latest builds? Because it was just fixed:
http://www.ventismedia.com/mantis/view.php?id=7999

markstuartwalker wrote:* Find Device and Device Label are illogical

Could these be fixed?

Can you explain how? What do you mean?
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?
nohitter151
 
Posts: 21459
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby markstuartwalker » Sun Jun 26, 2011 6:37 am

I was on 1395. I'll try later.

Find Device clearly can't work for a network share as it looks for USB devices ... and there is none for a network share.

Device label is also USB oriented. For a network share it could take the volume name or the share name.
Windows 7 SP1 x64 / Ubuntu 11.10 / Lion 10.7.3 / iOS 5.1 / iTunes 10.6.0
iTunes plugin (d_itunes & itunes4) viewtopic.php?f=2&t=45713
Running MM under Mac OS X with Wine viewtopic.php?f=4&t=58507
markstuartwalker
 
Posts: 868
Joined: Fri Jul 10, 2009 8:10 am

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby nohitter151 » Sun Jun 26, 2011 8:25 am

markstuartwalker wrote:Find Device clearly can't work for a network share as it looks for USB devices ... and there is none for a network share.

Device label is also USB oriented. For a network share it could take the volume name or the share name.

Ok? But what's your point? The USB mass is clearly not only for network shares, it can also be used for USB.
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?
nohitter151
 
Posts: 21459
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby markstuartwalker » Sun Jun 26, 2011 12:13 pm

nohitter151 wrote:
markstuartwalker wrote:Find Device clearly can't work for a network share as it looks for USB devices ... and there is none for a network share.

Device label is also USB oriented. For a network share it could take the volume name or the share name.

Ok? But what's your point? The USB mass is clearly not only for network shares, it can also be used for USB.


I'd like a device driver for network shares!
Windows 7 SP1 x64 / Ubuntu 11.10 / Lion 10.7.3 / iOS 5.1 / iTunes 10.6.0
iTunes plugin (d_itunes & itunes4) viewtopic.php?f=2&t=45713
Running MM under Mac OS X with Wine viewtopic.php?f=4&t=58507
markstuartwalker
 
Posts: 868
Joined: Fri Jul 10, 2009 8:10 am

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby Lowlander » Sun Jun 26, 2011 12:56 pm

You can use USBMass on a mapped network share.
Lowlander
 
Posts: 31724
Joined: Sat Sep 06, 2003 5:53 pm

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby markstuartwalker » Mon Jun 27, 2011 3:32 am

Yes, I know. But there are anomalies due to it being designed for USB. I was hoping that some of these might be addressed.
Windows 7 SP1 x64 / Ubuntu 11.10 / Lion 10.7.3 / iOS 5.1 / iTunes 10.6.0
iTunes plugin (d_itunes & itunes4) viewtopic.php?f=2&t=45713
Running MM under Mac OS X with Wine viewtopic.php?f=4&t=58507
markstuartwalker
 
Posts: 868
Joined: Fri Jul 10, 2009 8:10 am

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby rusty » Mon Jun 27, 2011 4:20 pm

Hi,

Not really an abomination--I kind of like the idea. It's something that we've even thrown around in the past (to kind of munge the Virtual CD and Sync functionality, since virtual CD is really just a reverse sync).

In any case, I'm copying this to the wishlist for future consideration.

-Rusty
rusty
 
Posts: 5293
Joined: Tue Apr 29, 2003 3:39 am
Location: Montreal, Canada

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby markstuartwalker » Mon Jul 04, 2011 5:06 am

Thanks very much. :-)

I have now got an applescript that will take the playlist and music files from this exported network share and import them into iTunes on my Mac.

For this to work the Device Configuration must be set to
* Library Playlists
* Destination directory = \
* Force Relative Paths
* Use Unicode
* Use Linux Folder Separator

Code: Select all
(*
*)


on readFile(unixPath)
   set foo to (open for access (POSIX file unixPath))
   set txt to (read foo for (get eof foo))
   close access foo
   return txt
end readFile

tell application "Finder"
   activate
   
   set playlistFolder to choose folder with prompt "Please choose the folder containing the Playlists"
   set playlistFiles to name of every file of folder playlistFolder
   set playlistcount to count of files in folder playlistFolder
   --display dialog playlistcount
   
end tell
--
--
tell application "iTunes"
   activate
   
   set root to playlistFolder as string
   
   repeat with i from 1 to the playlistcount
      
      -- the filename
      set theFile to item i of playlistFiles
      --if type of theFile is file then
      set theSuffix to text ((offset of "." in theFile) + 1) thru -1 of theFile
      --display dialog theSuffix
      
      if theSuffix = "m3u" then
         
         tell application "iTunes"
            
            -- build the playlist name            
            set theName to text 1 thru ((offset of "." in theFile) - 1) of theFile
            display dialog "Playlist to import " & theName giving up after 10
            
            -- find or create the playlist in iTunes
            try
               set new_playlist to (some playlist whose name is theName)
            on error errmesg number errn
               --display dialog errmesg & return & return & "error number: " & ¬
               (errn as text)
               log "Create " & theName
               set new_playlist to (make new user playlist with properties {name:theName})
            end try
            
         end tell
         
         -- read the file contents
         set thePlaylist to {root & theFile} as alias
         my readFile(POSIX path of thePlaylist)
         set thecontents to result
         set thelines to every paragraph of thecontents
         
         my checkLInes(thelines)
         set thePathCount to result
         
         -- loop through the lines
         tell application "iTunes"
            set i to 1
            
            -- Get the list of tracks
            set theTracks to (get a reference to every track of new_playlist)
            set k to count of items of theTracks
            --display dialog k
            --display dialog thePathCount
            
            if not k = thePathCount then
               repeat with j from 1 to the count of thelines
                  
                  set thetrack to (item j of thelines) as string
                  if not thetrack = "" then
                     
                     set thetrack to POSIX path of (root) & thetrack
                     
                     repeat while (i ≤ k)
                        -- Find the path on this track
                        set theLocation to (location of (item i of theTracks)) as text
                        set theLocation to POSIX path of theLocation
                        --log i & k
                        --log thetrack & " " & theLocation
                        
                        -- compare the new and old location
                        if not theLocation = thetrack then
                           -- remove the offending track
                           log "delete " & i & theLocation
                           delete item i of theTracks
                           set k to k - 1
                        else
                           exit repeat
                        end if
                     end repeat
                     
                     if not (i ≤ k) then
                        try
                           set thetrack to POSIX file thetrack as string
                           
                           log "Add " & thetrack
                           --display dialog "Add " & thetrack
                           add thetrack to new_playlist
                        end try
                     end if
                     set i to i + 1
                  end if
               end repeat
            end if
         end tell
      end if
   end repeat
   
   
end tell

on checkLInes(thelines)
   
   set k to 0
   repeat with j from 1 to the count of thelines
      set thetrack to (item j of thelines) as string
      if not thetrack = "" then
         set k to k + 1
      end if
      
   end repeat
   
   return k
   
end checkLInes



While we're on the subject of wishlisting it would be good to be able to trigger scripts before or after synchronisation too.
Windows 7 SP1 x64 / Ubuntu 11.10 / Lion 10.7.3 / iOS 5.1 / iTunes 10.6.0
iTunes plugin (d_itunes & itunes4) viewtopic.php?f=2&t=45713
Running MM under Mac OS X with Wine viewtopic.php?f=4&t=58507
markstuartwalker
 
Posts: 868
Joined: Fri Jul 10, 2009 8:10 am

Re: 1395 USBMass1 for a network shares ... on an Apple Mac

Postby markstuartwalker » Wed Jul 06, 2011 10:49 am

Updated script

Code: Select all
(*
*)


on readFile(unixPath)
   set foo to (open for access (POSIX file unixPath))
   set txt to (read foo for (get eof foo))
   close access foo
   return txt
end readFile

-- Where all the playlists are
set playlistFolder to choose folder with prompt "Please choose the folder containing the Playlists"
set playlistFiles to my getPlaylistNames(playlistFolder)


--
--
--set root to playlistFolder as string
set addCount to 0

set playlistcount to count of playlistFiles
repeat with i from 1 to the playlistcount
   
   -- the filename
   set theFile to item i of playlistFiles
   
   -- build the playlist name
   set theName to my nameOf(POSIX path of theFile)
   display dialog "Playlist to import " & theName giving up after 1
   
   -- find or create the playlist in iTunes
   tell application "iTunes"
      try
         set new_playlist to (some playlist whose name is theName)
      on error errmesg number errn
         --display dialog errmesg & return & return & "error number: " & ¬
         (errn as text)
         log "Create " & theName
         set new_playlist to (make new user playlist with properties {name:theName})
      end try
      
   end tell
   
   -- read the file contents
   set thecontents to my readFile(POSIX path of theFile)
   set thelines to every paragraph of thecontents
   
   set thePathCount to my checkLInes(thelines)
   
   -- loop through the lines
   tell application "iTunes"
      set i to 1
      
      -- Get the list of tracks
      set theTracks to (get a reference to every track of new_playlist)
      set k to count of items of theTracks
      --display dialog k
      --display dialog thePathCount
      
      if not k = thePathCount then
         repeat with j from 1 to the count of thelines
            
            set thetrack to (item j of thelines) as string
            if not thetrack = "" then
               
               set thetrack to POSIX path of (playlistFolder) & thetrack
               
               repeat while (i ≤ k)
                  -- Find the path on this track
                  set theLocation to (location of (item i of theTracks)) as text
                  set theLocation to POSIX path of theLocation
                  --log i & k
                  --log thetrack & " " & theLocation
                  
                  -- compare the new and old location
                  if not theLocation = thetrack then
                     -- remove the offending track
                     log "delete " & i & theLocation
                     delete item i of theTracks
                     set k to k - 1
                  else
                     exit repeat
                  end if
               end repeat
               
               if not (i ≤ k) then
                  try
                     set thetrack to POSIX file thetrack as string
                     
                     log "Add " & thetrack
                     --display dialog "Add " & thetrack
                     add thetrack to new_playlist
                     set addCount to addCount + 1
                  end try
               end if
               set i to i + 1
            end if
         end repeat
      end if
   end tell
end repeat

display dialog "Complete. Added=" & addCount


on checkLInes(thelines)
   
   set k to 0
   repeat with j from 1 to the count of thelines
      set thetrack to (item j of thelines) as string
      if not thetrack = "" then
         --set j to j - 1
         set k to k + 1
      end if
      
   end repeat
   --set k to count of thelines
   
   return k
   
end checkLInes

on extOf(theFile)
   set theSuffix to text ((offset of "." in theFile) + 1) thru -1 of theFile
   return theSuffix
end extOf

on nameOf(thePath)
   set n to (offset of "/" in (reverse of characters of thePath) as string) - 1
   set theFile to text ((length of (thePath)) - n + 1) thru -1 of thePath
   set theName to text 1 thru ((offset of "." in theFile) - 1) of theFile
   return theName
end nameOf

on getPlaylistNames(playlistFolder)
   tell application "Finder"
      activate
      set playlistFiles to name of every file of folder playlistFolder
   end tell
   
   set root to playlistFolder as string
   
   set thePlaylistAliasList to {}
   set playlistcount to count of playlistFiles
   log playlistcount
   repeat with i from 1 to the playlistcount
      
      -- the filename
      set theFile to item i of playlistFiles
      --if type of theFile is file then
      
      set theSuffix to my extOf(POSIX path of theFile)
      --display dialog "Suffix " & theSuffix
      
      if theSuffix = "m3u" then
         
         set thePlaylist to {root & theFile} as alias
         
         copy thePlaylist to the end of thePlaylistAliasList
         
      end if
   end repeat
   return thePlaylistAliasList
end getPlaylistNames
Windows 7 SP1 x64 / Ubuntu 11.10 / Lion 10.7.3 / iOS 5.1 / iTunes 10.6.0
iTunes plugin (d_itunes & itunes4) viewtopic.php?f=2&t=45713
Running MM under Mac OS X with Wine viewtopic.php?f=4&t=58507
markstuartwalker
 
Posts: 868
Joined: Fri Jul 10, 2009 8:10 am


Return to Wishlist (mmw)

Who is online

Users browsing this forum: No registered users and 10 guests