2008-08-28 00:00:23 +06:00
on unlockfile(encryptedFile, MobiDeDRMPath, encryptionKey)
set encryptedFilePath to POSIX path of file encryptedFile
tell application "Finder" to <20>
set parent_folder to (container of file encryptedFile) as text
tell application "Finder" to set fileName to (name of file encryptedFile) as text
set unlockedFilePath to POSIX path of file (parent_folder & "Unlocked_" & fileName)
set shellcommand to "python \"" & MobiDeDRMPath & "\" \"" & encryptedFilePath & "\" \"" & unlockedFilePath & "\" '" & encryptionKey & "'"
try
--with timeout of 5 seconds
-- display dialog "About to Unlock " & fileName buttons {"Unlock"} default button 1 giving up after 1
--end timeout
end try
set result to do shell script shellcommand
try
if (offset of "Error" in result) > 0 then
with timeout of 5 seconds
display dialog "Can't unlock file " & fileName & ".
" & result buttons ("OK") default button 1 giving up after 5
end timeout
end if
end try
end unlockfile
on unlockfolder(encryptedFolder, MobiDeDRMPath, encryptionKey)
2009-03-01 16:30:42 +06:00
tell application "Finder" to set encryptedFileList to (every file in folder encryptedFolder) whose (name extension is "prc") or (name extension is "mobi") or (name extension is "azw")
2008-08-28 00:00:23 +06:00
tell application "Finder" to set encryptedFolderList to (every folder in folder encryptedFolder)
repeat with this_item in encryptedFileList
unlockfile(this_item as text, MobiDeDRMPath, encryptionKey)
end repeat
repeat with this_item in encryptedFolderList
unlockfolder(this_item as text, MobiDeDRMPath, encryptionKey)
end repeat
end unlockfolder
on run
set MobiDeDRMPath to POSIX path of file ((path to me as text) & "Contents:Resources:MobiDeDRM.py")
set encryptedFolder to choose folder with prompt "Please choose the folder of encrypted Mobipocket files."
2009-03-01 16:30:42 +06:00
set encryptionKey to (display dialog "Enter Mobipocket key for encrypted Mobipocket files." default answer "X12QIL1M3D" buttons {"Cancel", "OK"} default button 2)
2008-08-28 00:00:23 +06:00
set encryptionKey to text returned of encryptionKey
unlockfolder(encryptedFolder, MobiDeDRMPath, encryptionKey)
end run
on open some_items
set MobiDeDRMPath to POSIX path of file ((path to me as text) & "Contents:Resources:MobiDeDRM.py")
2009-03-01 16:30:42 +06:00
set encryptionKey to (display dialog "Enter Mobipocket key for encrypted Mobipocket files." default answer "X12QIL1M3D" buttons {"Cancel", "OK"} default button 2)
2008-08-28 00:00:23 +06:00
set encryptionKey to text returned of encryptionKey
repeat with this_item in some_items
if (folder of (info for this_item) is true) then
unlockfolder(this_item as text, MobiDeDRMPath, encryptionKey)
else
tell application "Finder" to set item_extension to name extension of file this_item
2009-03-01 16:30:42 +06:00
if item_extension is "prc" or item_extension is "mobi" or item_extension is "azw" then
2008-08-28 00:00:23 +06:00
unlockfile(this_item as text, MobiDeDRMPath, encryptionKey)
end if
end if
end repeat
end open