#!/bin/sh

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

FILE="${1}"
HEIGHT="${2}"

case "$1" in
	#*.png|*.jpg|*.jpeg|*.gif|*.webp)viu -w 100 -s "$1";;
	*.png|*.jpg|*.jpeg|*.gif|*.webp)
		catimg -w 100 "${FILE}";;
	*.tar*) 
		tar tf "$1";;
	*.zip) 
		unzip -l "$1";;
	*.rar) 
		unrar l "$1";;
	*.7z) 
		7z l "$1";;
	*.pdf) 
		pdftotext "$1" -;;
        *.mp4|*.avi|*.mkv|*.webm|*.mpg)
		TMPFILE=$(mktemp)
		ffmpegthumbnailer -i "${FILE}" -o "${TMPFILE}" -s 0 
		catimg -w 100 "${TMPFILE}";;
        	#mediainfo ${FILE};;
        *.cbz|*.cbr|*.epub)
		TMPFILE=$(mktemp)
		comicthumb.py "${FILE}" "${TMPFILE}" 512 > /dev/null 2>&1
		echo $TMPFILE
		catimg -w 100 "${TMPFILE}";;
	*) 
		bat --color=always --theme=base16 "$1";;
esac

IFS=$SAVEIFS
