If you're Canadian and concerned about your online rights, go visit Online Rights Canada. It's an organization created by the EFF and Canadian Internet Policy and Public Interest Clinic to "promotes the public's interest in technology and information policy".
And while your at it, also visit Micheal Geist blog, Micheal is a law professor at University of Ottawa and very active in promoting and defending our rights (or the ones we should have) regarding technology, copyrights and information policies.
12.09.2005
12.07.2005
Fixing iTunes 6 library with Ruby
Like many people, when I upgraded iTunes to V6, I had problem with my iTunes library. For some reason, in the upgrade process iTunes lost the location of many mp3 files in its library.
I was unable to use the fix proposed by Apple as I do not immediately found out about the problem. I added stuff to my library and would loose all me new playlists and ratings if I followed it. Also, I was not able to find a version of my library dated at the time of the upgrade.
I have something like 1200 songs in my library, more than 200 of them lost the location of the actual mp3 file. Clicking around to try to find them within iTunes would have take me days.... And bored me to death.
So I wanted to add all these files back to my library while keeping their rating (I did not care much for the last play time and play count).
I've started to play with Ruby a few weeks ago. I use it to test web application using Watir. I thought that fixing my iTunes library with a small Ruby script would be a fun thing to try.
So I did... I wrote a small Ruby script that would connect to iTunes using the Win32 OLE interface. The script is fairly simple, it check each tracks in the library and if it's location is an empty string, it try to find the music file (mp3 or m4a), add it back to the library and set it's rating to the same rating as the current track.
Note that I could not just set the Location property of the track as this property is read only using the iTunes OLE interface.
A few minutes later, all the music files that matched to a song name were added back to my library with the proper rating. I did have to get rid of the duplicates entries in my library. But at least iTunes allows one to easily show duplicate songs. It was just a matter of selecting songs with the (i) icon, right-clicking and pressing clear.
I also wrote another Ruby script that would scan my music folder and add music file that were not already present in my library. This was necessary as my first script missed some files. I lost my rating for these files but there was'nt that many of those.
So here are the Ruby script, customize them to your liking (like the music base folder) and use them to fix your own library. But do so at your OWN RISK. I do not garantee that they will work for you!
Script 1 :
Script 2 :
I was unable to use the fix proposed by Apple as I do not immediately found out about the problem. I added stuff to my library and would loose all me new playlists and ratings if I followed it. Also, I was not able to find a version of my library dated at the time of the upgrade.
I have something like 1200 songs in my library, more than 200 of them lost the location of the actual mp3 file. Clicking around to try to find them within iTunes would have take me days.... And bored me to death.
So I wanted to add all these files back to my library while keeping their rating (I did not care much for the last play time and play count).
I've started to play with Ruby a few weeks ago. I use it to test web application using Watir. I thought that fixing my iTunes library with a small Ruby script would be a fun thing to try.
So I did... I wrote a small Ruby script that would connect to iTunes using the Win32 OLE interface. The script is fairly simple, it check each tracks in the library and if it's location is an empty string, it try to find the music file (mp3 or m4a), add it back to the library and set it's rating to the same rating as the current track.
Note that I could not just set the Location property of the track as this property is read only using the iTunes OLE interface.
A few minutes later, all the music files that matched to a song name were added back to my library with the proper rating. I did have to get rid of the duplicates entries in my library. But at least iTunes allows one to easily show duplicate songs. It was just a matter of selecting songs with the (i) icon, right-clicking and pressing clear.
I also wrote another Ruby script that would scan my music folder and add music file that were not already present in my library. This was necessary as my first script missed some files. I lost my rating for these files but there was'nt that many of those.
So here are the Ruby script, customize them to your liking (like the music base folder) and use them to fix your own library. But do so at your OWN RISK. I do not garantee that they will work for you!
Script 1 :
require 'win32ole'
iTunes= WIN32OLE.new('iTunes.Application')
tracks= iTunes.LibraryPlaylist.Tracks
totalTracks= 0;
tracks.each {|t|
totalTracks+= 1
if t.Location == ''
puts t.Name
name= t.Name
Dir.glob(File.join("D:\\My Music", "**", "*#{name}*.{mp3,m4a,MP3}")) {|l|
puts "Adding #{l} to iTunes"
status= iTunes.LibraryPlaylist.addFile(l)
while (status.InProgress) do
sleep(0.5)
end
status.Tracks.each {|track|
track.rating= t.rating
}
}
end
}
puts totalTracks
iTunes= WIN32OLE.new('iTunes.Application')
tracks= iTunes.LibraryPlaylist.Tracks
totalTracks= 0;
tracks.each {|t|
totalTracks+= 1
if t.Location == ''
puts t.Name
name= t.Name
Dir.glob(File.join("D:\\My Music", "**", "*#{name}*.{mp3,m4a,MP3}")) {|l|
puts "Adding #{l} to iTunes"
status= iTunes.LibraryPlaylist.addFile(l)
while (status.InProgress) do
sleep(0.5)
end
status.Tracks.each {|track|
track.rating= t.rating
}
}
end
}
puts totalTracks
Script 2 :
require 'win32ole'
iTunes= WIN32OLE.new('iTunes.Application')
tracks= iTunes.LibraryPlaylist.Tracks
totalTracks= 0
Dir.glob(File.join("D:\\My Music", "**", "*.{mp3,m4a,MP3}")) {|l|
found= false
tracks.each {|t|
if t.Location.rindex(File.basename(l)) then
found= true
break
end
}
if (!found) then
totalTracks+= 1
puts "Adding #{l} to iTunes"
status= iTunes.LibraryPlaylist.addFile(l)
while (status.InProgress) do
sleep(0.5)
end
end
}
puts totalTracks
Have fun!iTunes= WIN32OLE.new('iTunes.Application')
tracks= iTunes.LibraryPlaylist.Tracks
totalTracks= 0
Dir.glob(File.join("D:\\My Music", "**", "*.{mp3,m4a,MP3}")) {|l|
found= false
tracks.each {|t|
if t.Location.rindex(File.basename(l)) then
found= true
break
end
}
if (!found) then
totalTracks+= 1
puts "Adding #{l} to iTunes"
status= iTunes.LibraryPlaylist.addFile(l)
while (status.InProgress) do
sleep(0.5)
end
end
}
puts totalTracks
12.06.2005
RE: Benevolent Worms
Bruce Schneier wrote about Benevolent Worms.
While I mostly agree that Benevolent Worms are not necessarely a good idea. I don't think they are as bad as Bruce says.
The main problem of benovelent worms in Bruce opinion is that they act without the user knowledge and consent. While this may be true, this is just a design issue. Upon arriving on a computer, the worm can always ask permission to the use to install itself and activate. It's true that the initial "infection" is without consent, but it is mostly like Automated Update were an update is automatically downloaded and the software ask for the user consent to install and activate it.
Computer viruses and worms spread a bit like their biological counterpart (the mecanism is different, but the spreading model is close enough). So I beleive it's fair enough to create counter measure mechanism that mimics more or less the biological system.
With that idea in mind, benevolent worms are not necessarly a bad thing. It would make sense that when a threat is detected a system create defenses and spread them accross it's system. We can see a computer network as a system and the computers within it as it's cells. A benevolent worm could easily do that. When new cells are added to the system, the benevolent worm would migrate to them to make sure they have the proper self-defense machanism.
Now, for the benevolent worm to be of no danger, it should stay within well defined boundaries. It should never "infect" another network without that network consent. It should also be easily removable or upgradable.
The problem right now, is that the actual benefit that a benevolent worm can provide (automated threat defense) is not much better that managed automatic update. And it comes with it's load of potential problems : bugs, uncontrolled spreading, vulnerabilities within the worm, etc. The fact that we need to limit the potential spreading of the worm to external network makes it less effective. For true effectiveness, the worm should be allowed to spread across networks and to patch system (at least temporarely) without the user consent. Then how would a system react to an infection of a "good" agent? How can a system can make sure that the payload of a worm is for it's own benefit? It simply can't.
Benevolent worm sounds good... They also sound bad! I believe researcher should continue to invistigate the implication of this idea. Maybe, sometime in the future, we will find out that they are the only mechanism to defend a complex network against threat. Then maybe not...
Subscribe to:
Posts (Atom)