HubL function to get video URL based on video id

We store the video library in the HubDB table. One of the column types is a video. Linked videos are stored in the file manager. When we loop the rows and we want to show videos, we only get video id. There is no HubL function to get videos’ public URLs so there is no way to create custom video players, nor get URLs directly from HubDB.

The only way is to use Vidyard’s video player:

{% video_player "embed_player" player_id='8787878787878' %}

Please make it possible to retrieve video URLs with HubL or public url available directly from HubDB, so we can store videos in HubSpot, not on Youtube.:folded_hands:

Otherwise, we would also benefit if the HubDB video/file field could also return the public HubSpot file path. I know that path exists and all uploaded HubSpot files can be found from path like this https://f.hubspotusercontent40.net/hubfs/**PORTAL-ID**/Demo-Test.mp4

I was having this issue trying to set a background video in a custom Hero module on a dynamic page template.

In the database I set a video background column with the property of VIDEO.

This gives a file ID number but like above I could not get the File URL from this ID. After some investigating and paying attention to various IDs and File IDs I found that the database ID I was getting was +1 from the video file ID. So I thought this may be workable. My code below allowed me to access the File ID URL from the database ID. I have tested it on 3 different videos and so far it works. Now I just have to get the custom thumbnail for the poster!

{% if dynamic_page_hubdb_row && dynamic_page_hubdb_row.hero_background_choice['name'] == 'Video' %} {% set videoID = dynamic_page_hubdb_row.hero_background_video %} {% set videoID = videoID|int - 1 %} {% set file = file_by_id( videoID ) %} {% set backgroundOptions = '{"loop": {{ module.background.loop }}, "source":{"mp4":" {{ file.url }}" ...etc..hero video stuff...etc..{% endif %}

@JohnLaprairie apparently that’s not always the case. I’ve been working on a video playlist module for a while now, using the id-minus-1-hack, which worked fine on my test portal(s), but once I rolled it out to the live page everything broke. In my case the ids between the HubDB and FileManager had seemingly random differences, not just -1 (one of my colleague assumes that’s the case probably because the videos that are used in the HubDB have been uploaded way in advance via the FileManager, not the HubDB directly).

My playlist module didn’t use the file_by_id function, because it was mostly rendered via javascript, and so far I used the filemanager-api (with the minus-1-id). My current new workaround is using the following url instead

https://api-eu1.hubapi.com/video/v1/public/${videoID}?portalId=${portalID}

which is used by the video_player and uses the videoID received from the HubDB.

But as long as Hubspot has no good official solution, this module will likely break again in the future.

Hello ATBLonzepthaus,
Thank you for the update.
I was hoping it worked for at least one other person or at least set them
on the path of successfully getting it to work for them.
I found this worked, in PHP, for my purpose for most of the videos: {% set
file = file_by_id( videoID - 1 ) %}
but for one video, I had to use {% set file = file_by_id( videoID - 5 ) %}
So I did a check if file returned a value or not, and if not, go - 2, then
- 3, - 4 , - 5 until it found the video. If file returned a value that was
not the video url it would then throw an error and I replaced the video and
video player with a static image.
Still not the best solution but like you said, something that works until
it doesn’t. I didn’t want to post this bit as it becomes even more of a
hack than a solution.