Organized Asset Export Script to put resources in image/ media/ and js/ folders

Hi @jonathan, I’m having some issues with the script and my Python skills are a bit lacking.

I’ve got mp4 files in my project which I do not initiate on the stage, but load only via js using:

myVideo.setAttribute('src', "${resourcesFolderName}/video_02.mp4");

which works fine in editor, browser preview and building, using standard folder export. But if I use this script (OrganizedAssets), the mp4’s are correctly moved to /media folder but the hype generated script is looking for it at the root, rather than /media.

From the hype_generated_script.js:
hype_video.setAttribute('src', \"./video_01.mp4\");

Is it that the OrganizedAssets doesn’t understand / update references if they’re referenced only in a script, not loaded onto stage?

I can easily get around it (adding /media to the media url for instance) but this breaks it in editor & preview (unless I use ‘Preview Using Export Script:’ option).

I’m thinking that when I train colleagues on how to use Hype, the smoother sailing, the better :blush:

The problem is that ${resourcesFolderName} is a simple text replacement and isn’t really smart enough to see that the reset of the code is referencing a video and to adjust like that.

In this case you will want to use add the media/ manually and then use the preview using export script option.

(side note: I’m surprised it works in the editor environment since it is being dynamically added anyways?)

Hello Jonathan,

First of all, thank you for the script. I use it to create web banners using Advanced Export and the official CDN

Each time I export, I have to edit the default_hype_generated_script.js file by replacing all occurrences of "js/HYPE-“ with “HYPE-"

If I don't do this, the CDN doesn't work and I get an error (Bad request)

Can I edit the .py file so that I don't have to make this correction to the HYPE-generated .js file?

I don't know Python at all.

Thanks for your help,

Maher,

Yes, you can fix the export script so it will work with the CDN setting.

  1. In Hype's Export Preferences, select OrganizedAssets.hype-export.py and click Show in Finder to reveal the file.

  2. Open it in a text editor, and locate these two lines

         	elif (int(args.url_type) == HypeURLType.HypeJS):
         		url_info['url'] = "js/" + args.replace_url
    
  3. Comment them out so they are not run by putting the # character in front:

    # 		elif (int(args.url_type) == HypeURLType.HypeJS):
    # 			url_info['url'] = "js/" + args.replace_url
    
  4. Save and close the file

  5. Go back to Hype and try exporting again

Thank you very much, Jonathan,

It works, but the script does not create a js folder anymore. That's OK, I work around it by editing the index.html file. It's a lot less work for me.

Thanks again for your time.

Doing the comment out for me does work but also does create a js folder for any other js.

Screenshot 2021-04-13 at 10.45.13

What are you seeing ?.

If you are not seeing any folders then you may have a syntax error in the .py

Here is the standard export script with the change above.

--- UPDATED The script to account for the hype_generated_script.js file.

OrganizedAssetsCDNRtime.hype-export.py 2.zip (2.4 KB)

Hello Jonathan,

I have downloaded the script, installed it in the right place. I have exported a banner I am working on at the moment, but there is still no js folder generated. I have included a video so you can see for yourself.

It's not so bad, editing the html file will fix it.

However, I would like to know what is wrong.

Thanks Jonathan,

Maher

(Attachment CDN.mp4 is missing)

Your video is not showing..?

Also did you try the script I put above ?

Yes, I used the script you sent me.

Here is another link for the video :

https://mahers.d.pr/3hnzut

Oh I see, The hype_generated_script.js is not being included in a js folder.

Let me have a look at that.

Ok fixed that. Probably could write it better but it works.

I changed the original lines.

elif (int(args.url_type) == HypeURLType.HypeJS):
     		url_info['url'] = "js/" + args.replace_url

to

 elif args.replace_url.lower().endswith(('hype_generated_script.js')):
             url_info['url'] = "js/" + args.replace_url

I have replace the script I put above ( incase someone only gets that far in the thread )
So download that again.

1 Like

Hi, I use the export asset script regularly and it stopped working for me today!

I am on Mac OS 12.3. Is it possible they removed python or ???

This has instructions on how to get Export Scripts working again (It has to do with the removal of Python in Mac OS 12.3)

1 Like

Thank you so much for the fast response. This fix worked for me! :slight_smile:

2 Likes

I had an issue with an export script as well. I had to remove it and reload it. After that it worked for me again. Hope it helps for you.

1 Like

To clarify these instructions:

  1. Choose the Hype > Preferences… menu item
  2. Click the Exporting Preference pane
  3. Click Show Export Scripts Folder in Finder
  4. Throw the com.tumult.Hype4 folder in the Trash (this will remove all export scripts)
  5. Re-download the latest Organized Asset Export script and install it
    :arrow_right: OrganizedAssets.pkg

If that doesn't solve it for you, let me know and there are some logs I'd like to collect to see what the problem might be.

Maybe Node.js could replace Python eventually? Would that be an option?

1 Like

My issue with export scripts is resolved.

Apologies, I realized I was running Hype 4.1.7 on the machine I was using - after updating all was fine.

Okay, glad you figured it out!

Sorry about the delay - I had to investigate why we didn't originally get your emails/reports (it was from an overzealous configuration option in our spam filter).

Theoretically I do think this is the best solution, but there's practical hurdles.

You could use export scripts with node.js right now if you wanted to; the interface is via command line arguments. Python was chosen for all of Tumult's and the initial examples because it is a pretty clear language and was shipped on the system by default. Node unfortunately isn't, and I don't really like having to build/ship runtimes with our apps :frowning: (Whisk has Java).

Export scripts use the macOS Application Script feature as a way to escape the security sandbox so you can do arbitrary things. It turns out most export scripts don't need this ability at all. Further, JavaScript would be the best language to use to interact with the Hype UI, and could be run the Hype editor WebView even. So there might be some middle ground we can do that either gives appropriate instructions to get node, or provide a minimal amount of functionality found in node for the types of things common in export scripts.

3 Likes