Get assets of certain type from Content Library
Greetings!
I try to fetch all Expressions of Genesis 3 from the Content Library.
I use the DzContentMgr to try to locate those expression packages, but it seems like I'm operating on the file level, whereas I'd like to operate on the "Content Library" level, since things there are not mapped 1:1 to directories, at least for the cloud content.
Two and a half questions:
1. I assume cloud content can be encrypted, there is no way for me to process the raw files then? If so, I will need to ignore cloud content completely, unfortunately.
1b. Can I detect if something is encrypted? I then could at least provide functionality for the unencrypted content.
2. How do I find products within the Genesis 3 Female Expressions folder? From the content library, not filesystem.
I have this right now:
var contentManager = App.getContentMgr();
var folderExpressionNative = contentManager.findFile("data/DAZ 3D/Genesis 3/Female/Morphs/", DzContentMgr.NativeDirs);
This kind of works, but it is not what I'm looking for. It will return me all the morphs, and I have no way (that I know of) to tell which ones are expressions.
It'd be easier if I could navigate on the Content Library level, where those products are mapped to a known directory structure.
Any idea how I can do that? :)
Thank you very much!
-mork
Edit 1:
As for question 2, I made a little bit of progess - I think.
I use this example here to fetch the Products from the AssetMgr:
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/metadata/list_products/start
Now I need to filter them by Expressions. I try this right now using
oProduct.getCategories();
but this works for the very first item only, everything else throws an error like
dzpostgresqlobjectdatabase.cpp(37): db fetch error: No results fetching tblCategories with id: 2198
I try to bite myself through it, but any help is much appreciated. :)
Comments
To whom it may concern, here is a brute force approach.
It takes about 7 seconds for a product library with 29 items. I expect it to take a couple of minutes on a full blown product library, at least. That is way too long for such a simple task. A simple DB query should return the same in a couple of miliseconds.
But that's all I got so far. The problem with it all is not coding it, problem is to understand how it all connects together first, find out about undocumented features and find out the DAZ way to do things. I'm progressing slowly but steadily. Be afraid, be very afraid. :-D
Edit:
It's actual 38 products, the 29 is the amount of folders returned by oProductsTop.getNumChildContainers()
I'll update the script with some other fixes and improvements at a later time.
For some odd reason, oAssetMgr.getProducts() only returns me the products of 2 content library paths, where I have three:
1. Daz Connect Data (works)
2. DAZ Studio Formats
a) myuser/Documents/DAZ 3D/Studio/My Library/ (works)
b) Public/Documents/My DAZ 3D Library/ ( does not work )
Any idea? I already restarted Studio, I can see the content in the Content library, but the asset manager does not know about it for some odd reason?
Edit:
It does search that path, but for some reason it insist that the product is not installed. I installed it via DIM (as I do most of the time), I also re-installed it, restarted database, restarted DAZ, but it insists that the product is not installed. But it is, or, should I say, it should be.
Edit2:
Not sure what happened, but I reimported the content database and it fixed it. Hopefuly this was only a hickup, no clue what I can do if that happens to someone else.