View Single Post
Old 03-03-2008   #8 (permalink)
Boomer


 
 

Re: deleting files that meet specific criteria

On Feb 29, 8:57*am, Boomer <marion...@xxxxxx> wrote:
Quote:

> On Feb 25, 9:21*pm, Jeff <jeff.hill...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > On Feb 25, 5:46 pm, Jeff <jeff.hill...@xxxxxx> wrote:
>
Quote:
Quote:

> > >Boomer,
>
Quote:
Quote:

> > > I found an SDK that might help you with what you want to do:
>
Quote:
Quote:

> > > Windows Media Format 11 SDKhttp://msdn2.microsoft.com/en-us/library/aa387410(VS.85).aspx
>
Quote:
Quote:

> > > This SDK lets you query all kinds of DRM information for a file, and
> > > the SDK comes with a whole bunch of useful sample code. *It doesn't
> > > look like any of it is easily accessible from .NET (no TLBs or COM
> > > servers), so you may have to write a small Win32 console application
> > > to query what you want, and then call it from your PowerShell script.
>
Quote:
Quote:

> > > I hope this helps.
>
Quote:
Quote:

> > > Jeff
>
Quote:
Quote:

> > > Jeff wrote:
> > > > On Feb 25, 1:00 pm,Boomer<Boo...@xxxxxx> wrote:
> > > > > Hi all,
>
Quote:
Quote:

> > > > > My intent is use PS to search through my digital music library andremove
> > > > > all DRM files for which I no longer have rights.
>
Quote:
Quote:

> > > > > I used to subscribe to the URGE music store, and have a bunch of files
> > > > > tagged with "protected content" under the License Property Set. *This
> > > > > "license" tab can be viewed as a tab along side the general, the security,
> > > > > and the summary tabs, *if one clicks on the file's property.
>
Quote:
Quote:

> > > > > For the life of me, I cannot find anything that describes how to show/list
> > > > > the presence of the "license" tab. *TypeName: System.IO.FileInfo... I can
> > > > > retreive info about the file with the memberType Property ... *Nothing out of
> > > > > the ordinary is listed for memberType when I enter the following command on a
> > > > > file in question:
>
Quote:
Quote:

> > > > > > gci | gm
>
Quote:
Quote:

> > > > > I figured it would the easiest to do it in PS, but it didn't turn out to be
> > > > > such a good *assumption.
>
Quote:
Quote:

> > > > > Your assistance is greatly appreciated.
>
Quote:
Quote:

> > > >Boomer,
>
Quote:
Quote:

> > > > I looked around at what was available through Windows Media player,
> > > > and the best I could come up with is this little script that tells you
> > > > if a file has DRM protection or not:
>
Quote:
Quote:

> > > > # Get-Protected.ps1
> > > > param( [string] $wmaFile )
>
Quote:
Quote:

> > > > if ( Test-Path $wmaFile )
> > > > {
> > > > * * $wmplayer = New-Object -ComObject "WMPlayer.OCX"
>
Quote:
Quote:

> > > > * * $media = $wmplayer.newMedia( $wmaFile )
>
Quote:
Quote:

> > > > * * [bool]::Parse( $media.getItemInfo( "Is_Protected" ) )
> > > > }
> > > > # Get-Protected.ps1
>
Quote:
Quote:

> > > > If you want much more information that that, it looks like you might
> > > > need to get a license from Microsoft for a DRM SDK of some kind:
> > > >http://msdn2.microsoft.com/en-us/win.../bb190309.aspx
>
Quote:
Quote:

> > > > These licenses are necessary if you are creating an application to
> > > > manage licenses or something like that, so it seems like they
> > > > shouldn't be necessary if all you want to do is query the
> > > > information. *If you do find anything, please post back here; I would
> > > > certainly be interested.
>
Quote:
Quote:

> > > > Jeff
>
Quote:

> >Boomer,
>
Quote:

> > In case this is the route you decide to take, here is a small console
> > application that determines if playback is allowed for a DRM-protected
> > file:
>
Quote:

> > #include <atlbase.h>
> > #include <TCHAR.H>
> > #include "wmsdk.h"
>
Quote:

> > int _tmain( int argc, wchar_t *argv[] )
> > {
> > * * if ( SUCCEEDED( CoInitialize( NULL ) ) )
> > * * {
> > * * * * int nCount = MultiByteToWideChar(
> > * * * * * * CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, NULL, 0 );
>
Quote:

> > * * * * wchar_t *pwszFileName = new wchar_t[ nCount ];
>
Quote:

> > * * * * MultiByteToWideChar(
> > * * * * * * CP_ACP, 0, (LPCSTR)argv[ 1 ], -1, pwszFileName, nCount );
>
Quote:

> > * * * * // check to see if the file is protected with DRM
> > * * * * BOOL bProtected;
>
Quote:

> > * * * * HRESULT hr = WMIsContentProtected(
> > * * * * * * pwszFileName, &bProtected );
>
Quote:

> > * * * * if ( SUCCEEDED( hr ) )
> > * * * * {
> > * * * * * * // if the file isn't protected with DRM,
> > * * * * * * // we don't need to continue
> > * * * * * * if ( !bProtected )
> > * * * * * * {
> > * * * * * * * * wprintf( L"Playback Allowed: True\n" );
> > * * * * * * }
> > * * * * * * else
> > * * * * * * {
> > * * * * * * * * // create a meta data editor
> > * * * * * * * * CComPtr<IWMMetadataEditor> spEditor;
> > * * * * * * * * hr = WMCreateEditor( &spEditor );
>
Quote:

> > * * * * * * * * // open the media file
> > * * * * * * * * if ( SUCCEEDED( hr ) )
> > * * * * * * * * {
> > * * * * * * * * * * hr = spEditor->Open( pwszFileName );
> > * * * * * * * * }
>
Quote:

> > * * * * * * * * // QI for the DRM editor
> > * * * * * * * * CComQIPtr<IWMDRMEditor> spDRMEditor( spEditor );
> > * * * * * * * * WMT_ATTR_DATATYPE wmtAttribute;
> > * * * * * * * * BYTE playbackAllowed[ 4 ];
> > * * * * * * * * WORD wLength;
>
Quote:

> > * * * * * * * * if ( SUCCEEDED( hr ) && spDRMEditor )
> > * * * * * * * * {
> > * * * * * * * * * * // get the 'playback allowed' property value
> > * * * * * * * * * * hr = spDRMEditor->GetDRMProperty(
> > * * * * * * * * * * * * g_wszWMDRM_ActionAllowed_Playback,
> > * * * * * * * * * * * * &wmtAttribute, playbackAllowed,
> > * * * * * * * * * * * * &wLength );
>
Quote:

> > * * * * * * * * * * if ( SUCCEEDED( hr ) )
> > * * * * * * * * * * {
> > * * * * * * * * * * * * wprintf( L"Playback Allowed: %s\n",
> > * * * * * * * * * * * * * * ( (BOOL)*playbackAllowed ? L"True"
> > * * * * * * * * * * * * * * * * * * * * * * * * * * *: L"False" ) );
> > * * * * * * * * * * }
> > * * * * * * * * }
> > * * * * * * }
> > * * * * }
>
Quote:

> > * * * * CoUninitialize();
> > * * }
>
Quote:

> > * * return 0;
>
Quote:

> > }
>
Quote:

> > This should be enough to determine if you want to keep a file or not.
>
Quote:

> > Good luck.
>
Quote:

> > Jeff- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> Thanks a bunch all ... I have a coulle of options here with your
> help. *I'll give all of them a try and let you all know how it turns
> out.- Hide quoted text -
>
> - Show quoted text -
I found a way to remove those DRM files without programming (no fun,
but faster) ... Click on Library Tab > Music > In the navigation pane
right-click library and check/choose Show More Views > Online Stores

Obviously at this point it is querying and providing exactly what I
needed.

Thanks for all of your help.

-Boomer
My System SpecsSystem Spec