Skip to content

Using python templates to customize post

datawhores edited this page Aug 29, 2023 · 15 revisions

Basics

The template system is powered by cheetah. The goal is to convert the input into standard bbcode, and provide dynamic outputs at the simplest placeholders and up to pure python

To take full advantage of the cheetah system one should read the documentation

https://cheetahtemplate.org/users_guide

Filling in information

A basic use of template is provided via what is called a searchlist

empuploader will generate values based on the files submit, and the additionally it will take information like the description entered by the user

The searchlist then allows for these values to be replaced dynamically in the template

${desc}

Would be an example of a placeholder that will be replaced by the user description

Built-in Placeholders

General

title
cover
desc
screens
torrent
input

** static image dictionary

static image dictionary reads files recursevely from

--args input

The user can then access these images by using the filename without extension

Media info

audio_{key} values

video_{key} values

Keys for mediainfo

Video:

  • 'track_type': 'Video',
  • 'track_id': '2', '
  • format': 'AVC',
  • 'format_info': 'Advanced Video Codec',
  • 'format_profile': '[email protected]',
  • 'format_settings': 'CABAC / 2 Ref Frames',
  • 'format_settings__cabac': 'Yes',
  • 'format_settings__reframes': '2 frames',
  • 'format_settings__gop': 'M=2, N=30',
  • 'codec_id': 'avc1',
  • 'codec_id_info': 'Advanced Video Coding',
  • 'duration': '10 min 14 s',
  • 'bit_rate_mode': 'Variable',
  • 'bit_rate': '12.0 Mb/s',
  • 'maximum_bit_rate': '768 kb/s', *'width': '1 280 pixels',
  • 'height': '720 pixels',
  • 'display_aspect_ratio': '16:9',
  • 'frame_rate_mode': 'Constant',
  • 'frame_rate': '29.970 (30000/1001) FPS',
  • 'original_frame_rate': '25.000 FPS',
  • 'color_space': 'YUV',
  • 'chroma_subsampling': '4:2:0',
  • 'bit_depth': '8 bits',
  • 'scan_type': 'Progressive',
  • 'bits__pixel_frame': '0.434',
  • 'stream_size': '879 MiB (98%)',
  • 'title': 'Core Media Video',
  • 'encoded_date': 'UTC 2014-12-22 16:00:54',
  • 'tagged_date': 'UTC 2014-12-22 16:04:44',
  • 'color_range': 'Limited', *'color_primaries': 'BT.709',
  • 'transfer_characteristics': 'BT.709',
  • 'matrix_coefficients': 'BT.709',
  • 'other_duration': 614514,
  • 'other_width': 1280,
  • 'other_height': 720

Audio

  • 'tack_type': 'Audio',
  • 'track_id': '1',
  • 'format': 'AAC',
  • 'format_info': 'Advanced Audio Codec',
  • 'format_profile': 'LC',
  • 'codec_id': 'mp4a-40-2',
  • 'duration': '10 min 14 s',
  • 'source_duration': '10 min 14 s',
  • 'bit_rate_mode': 'Constant',
  • 'bit_rate': '256 kb/s',
  • 'channel_s': '2 channels',
  • 'channel_positions': 'Front: L R',
  • 'sampling_rate': '48.0 kHz',
  • 'frame_rate': '46.875 FPS (1024 SPF)',
  • 'compression_mode': 'Lossy',
  • 'stream_size': '19.0 MiB (2%)',
  • 'source_stream_size': '19.0 MiB (2%)',
  • title': 'Core Media Audio',
  • 'language': 'English',
  • 'encoded_date': 'UTC 2014-12-22 16:00:54',
  • 'tagged_date': 'UTC 2014-12-22 16:04:44'

Reset current template or post string

Just delete the template string from yaml file