Find Protected 1.0 [MM2+3]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Find Protected 1.0 [MM2+3]

Post by trixmoto »

This script, as requested here, runs through the entire library finding tracks which are protected with DRM. Like a few of my scripts, there is a report to run which populates the node in the background, then you can click on the node to few the results.

The installers are available to download from my website, as always! :)

Code: Select all

'
' MediaMonkey Script
'
' NAME: FindProtected 1.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 29/11/2007
'
' INSTALL: Copy to Scripts\Auto directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately'          
'
' [FindProtected]
' FileName=Auto\FindProtected.vbs
' ProcName=FindProtected
' Order=10
' DisplayName=Find Protected
' Description=Populates Find Protected node
' Language=VBScript
' ScriptType=1
'

Option Explicit

Sub onStartUp
  'create node and add to tree
  Dim node : Set node = SDB.Objects("FindProtectedNode")
  If node Is Nothing Then
    Dim tree : Set tree = SDB.MainTree
    Set node = tree.CreateNode
    node.Caption = "Find Protected"
    node.IconIndex = 32
    node.UseScript = Script.ScriptPath
    node.OnFillTracksFunct = "ShowProtected"
    node.SortCriteria = 2
    tree.AddNode tree.Node_FilestoEdit,node,3
    Set SDB.Objects("FindProtectedNode") = node
  End If
End Sub

Sub ShowProtected(node)
  'check for list
  Dim list : Set list = SDB.Objects("FindProtectedList")
  If list Is Nothing Then
    'warn node not yet populated
    Call SDB.MessageBox("FindProtected: You need to select 'File|Create Reports|Find Protected' from the menu before this node will be populated.",mtInformation,Array(mbOk))
  Else
    'add list to main window
    Dim trax : Set trax = SDB.MainTracksWindow
    Dim i : i = 0
    For i = 0 To list.Count-1
      Call trax.AddTrack(list.Item(i))
      SDB.ProcessMessages
    Next
    'finish off
    trax.FinishAdding
  End If
End Sub

Sub FindProtected
  'reset list
  Set SDB.Objects("FindProtectedList") = Nothing
  Dim list : Set list = SDB.NewSongList
  Dim fso : Set fso = SDB.Tools.FileSystem
  
  'create progress bar
  Dim prog : Set prog = SDB.Progress
  prog.Value = 0
  Dim iter : Set iter = SDB.Database.OpenSQL("SELECT Count(1) AS SongCount FROM Songs")
  prog.MaxValue = iter.ValueByName("SongCount")
  prog.Text = "FindProtected: Initialising..."
  
  'get protected column
  Dim app : Set app = CreateObject("Shell.Application")  
  Dim fol : Set fol = app.Namespace(SDB.ApplicationPath)
  Dim i : i = 0
  For i = 0 To 34
    If fol.GetDetailsOf(fol.Items,i) = "Protected" Then
      Exit For
    End If
  Next
  If i = 35 Then
    Call SDB.MessageBox("FindProtected: Cannot find protected column!",mtError,Array(mbOk))
    Exit Sub
  End If      

  'loop through tracks
  Set fol = Nothing
  Dim loc : loc = ""
  Set iter = SDB.Database.QuerySongs("")
  Do While Not iter.EOF
    'update progress bar
    prog.Increase
    prog.Text = "FindProtected: Checking track "&prog.Value&"/"&prog.MaxValue&" (found: "&list.Count&")..."
    SDB.ProcessMessages
    
    'check details
    Dim pat : pat = iter.Item.Path
    Dim pos : pos = InStrRev(pat,"\")
    If Not (loc = Left(pat,pos-1)) Then
      loc = Left(pat,pos-1)
      Set fol = app.Namespace(loc)
    End If
    If Not (fol Is Nothing) Then
      Dim fil : Set fil = fol.ParseName(Mid(pat,pos+1))
      If Not (fil Is Nothing) Then
        If fol.GetDetailsOf(fil,i) = "Yes" Then
          list.Add(iter.Item)
        End If    
      End If
    End If
    
    'check next track
    If prog.Terminate Then 
      Exit Sub
    Else
      iter.Next
    End If
  Loop
  
  'finish off
  Set SDB.Objects("FindProtectedList") = list
  If list.Count = 0 Then
    Call SDB.MessageBox("FindProtected: You have no protected files!",mtInformation,Array(mbOk))
    Exit Sub
  End If
  
  'show results
  i = SDB.MessageBox("FindProtected: Do you want to see the "&list.Count&" results now?",mtConfirmation,Array(mbYes,mbNo))
  If i = mrYes Then
    Dim tree : Set tree = SDB.MainTree
    Dim node : Set node = SDB.Objects("FindProtectedNode")
    tree.CurrentNode = tree.Node_Library
    tree.Node_Library.Expanded = True
    tree.CurrentNode = tree.Node_FilestoEdit
    tree.Node_FilestoEdit.Expanded = True
    tree.CurrentNode = node
  End If
End Sub

Sub Install()
  Dim inip : inip = SDB.ApplicationPath&"Scripts\Scripts.ini"
  Dim inif : Set inif = SDB.Tools.IniFileByPath(inip)
  If Not (inif Is Nothing) Then
    inif.StringValue("FindProtected","Filename") = "FindProtected.vbs"
    inif.StringValue("FindProtected","Procname") = "FindProtected"
    inif.StringValue("FindProtected","Order") = "10"
    inif.StringValue("FindProtected","DisplayName") = "Find Protected"
    inif.StringValue("FindProtected","Description") = "Populates Find Protected node"
    inif.StringValue("FindProtected","Language") = "VBScript"
    inif.StringValue("FindProtected","ScriptType") = "1"
    SDB.RefreshScriptItems
  End If
  Call onStartUp()
End Sub
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Guest

Post by Guest »

Hi,
Great Idea and thanks for a script.
I have an issue: after installing and clicking on create report option I am getting error message: FindProtected: Cannot find protected column!
It this meant I dont have protected mp3's or theres an error with the script?

Best regards,
Piotr
Guest

Post by Guest »

Just want to add I have Vista 64 and it seems other scripts have also problem with working properly. Its something with admin rights or something in vista64.
I am running mediamonkey as an admin.
best regards,
Piotr
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Strange, I've tested this on Vista and it worked for me. It means that it cannot work out where in the file the protected header is. I've seen it be different values on different operating systems, but I've not seen it not there. Although maybe it could be a language thing - is your Vista using a language other than english?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
gapcnet
Posts: 3
Joined: Mon Nov 26, 2007 6:15 pm
Contact:

Post by gapcnet »

A really DUMB question .... I used your auto-installer. Now how do I make us if it?

Duuhhh

:oops:
Guy Austrian
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

File > Create Report > Find Sync Dups
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Killjoy12
Posts: 100
Joined: Mon Jun 11, 2007 11:33 pm
Contact:

Post by Killjoy12 »

I love this script, but it only works for me the first time after install.


The installation script does not put it in the Scripts\Auto folder. Could this be the issue I am seeing?

Thanks
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Yes, you are right, sorry! I have rebuilt the installer so if you download it again it should work. :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Killjoy12
Posts: 100
Joined: Mon Jun 11, 2007 11:33 pm
Contact:

Post by Killjoy12 »

Awesome! Thanks
martialartsguy
Posts: 282
Joined: Mon Apr 03, 2006 9:11 am
Location: Denver, CO
Contact:

Weird Error

Post by martialartsguy »

Getting the following error after downloading and running:

Image
MM 4.1.28.1905
MMA 1.3.7.0906

MM Gold since 2006
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Does the file exist where the message says it should? If no then the installation must have failed, if yes then something (maybe an anti virus program) must be blocking the script from running.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
martialartsguy
Posts: 282
Joined: Mon Apr 03, 2006 9:11 am
Location: Denver, CO
Contact:

Post by martialartsguy »

Trix-

Looks like the installation failed. I moved the file to the proper place and all is well.
MM 4.1.28.1905
MMA 1.3.7.0906

MM Gold since 2006
Guest

Post by Guest »

also got the "FindProtected: Cannot find protected column!" problem...
but i work with a german version of winxp on my pc
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

In this case you might need to change line 77 which is...

Code: Select all

If fol.GetDetailsOf(fol.Items,i) = "Protected" Then
I'm not sure what this column would be called in German, but translating it should fix the problem.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
nabuhonodozor
Posts: 5
Joined: Fri Mar 07, 2008 3:28 am
Location: warsaw, poland
Contact:

Post by nabuhonodozor »

Hi Trix, first of all thanks for great contributions!
As for find protected - I also have same error.
Changing line 77 didnt solve it. Ive change it to actually reflect a nod-name , an autoinstaller created during installation. New node is: Library/Files to Edit/Find Protected. So Ive change line 77 of vbs script from "Protected" to "Find Protected" but issue persists.
I have polish vista64 and english MM runs with administrator rights.
Best regards,
Piotr
Post Reply