Skip to main content

AssetDatabase in ShortGPT

The AssetDatabase in ShortGPT is a powerful tool that allows you to manage both local and remote assets. This guide will provide you with examples of how to use the AssetDatabase.

Importing AssetDatabase and AssetType

from shortGPT.config.asset_db import AssetDatabase, AssetType

Adding Assets

You can add both remote and local assets to the AssetDatabase.

Adding Remote Assets

AssetDatabase.add_remote_asset("minecraft background cube", AssetType.BACKGROUND_VIDEO, "")
AssetDatabase.add_remote_asset('chill music', AssetType.BACKGROUND_MUSIC, "")

Adding Local Assets

AssetDatabase.add_local_asset('my_music', AssetType.AUDIO, "./my_music.wav")

Asset Types

The AssetType enum is used to specify the type of asset being added to the AssetDatabase. The available asset types are:


Getting Asset Information

You can retrieve information about an asset using the following methods:

Get Asset Duration

This method returns the duration in seconds of a video or audio asset. If the asset is neither video nor audio, it returns None.

AssetDatabase.get_asset_duration('minecraft background cube')

This method returns a source URL, or the path of the resource. If the asset is a YouTube video or audio, it uses yt-dlp to extract a download URL or a direct video/audio link.

AssetDatabase.get_asset_link('minecraft background cube')

Synchronizing Local Assets

The sync_local_assets method synchronizes the database with local assets found in the /public folder. If it doesn't find one, it doesn't do anything.


Removing Assets

You can remove an asset from the database by providing its name to the remove_asset method.


Getting Database State

You can get the state of the asset database as a pandas dataframe using the get_df method.


This method returns a dataframe that includes the name, type, link, source, and timestamp of each asset in the database.