Commit 7130723e authored by Booloki's avatar Booloki

Merge branch 'topic/shellchecking' into 'master'

Add Global bash lint (Shellcheck)

See merge request !1
parents b9a10023 f1df88aa
Pipeline #54 passed with stage
in 17 seconds
stages:
- lint
- build
- test
- deb-deploy
## Stage "lint": bash shellchecking
lint:
stage: lint
image: koalaman/shellcheck-alpine:stable
before_script:
- apk update
- apk add findutils bash
script:
- ./shellcheck_all.sh
## Stage "package" for Ubuntu 18.04 LTS Bionic packaging
build:deb-package:
stage: build
......
This diff is collapsed.
#!/bin/bash
## check functions
checkandsource_wazzuf_conf () {
if [ ! -f ${CONF_FILE} ]; then
echo -ne "\n *************************************\n"
echo -ne " ${CONF_FILE} configuration file not found !\n"
echo -ne " Copying an example: please fill some informations in it !\n"
mkdir -p ${CONF_PATH_BASE}
cp -v ${CONF_FILE_EXAMPLE} ${CONF_FILE}
echo -ne " Exiting...\n"
echo -ne " *************************************\n"
exit 1
else
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG Sourcing ${CONF_FILE}..."; fi
source ${CONF_FILE}
fi
if [ ! -f "${CONF_FILE}" ]; then
echo -ne "\n *************************************\n"
echo -ne " ${CONF_FILE} configuration file not found !\n"
echo -ne " Copying an example: please fill some informations in it !\n"
mkdir -p "${CONF_PATH_BASE}"
cp -v "${CONF_FILE_EXAMPLE}" "${CONF_FILE}"
echo -ne " Exiting...\n"
echo -ne " *************************************\n"
exit 1
else
if [[ "${DEBUG}" == 1 ]]; then echo "DEBUG Sourcing ${CONF_FILE}..."; fi
# shellcheck source=conf/wazzuf-ripper.conf
source "${CONF_FILE}"
fi
}
checkandsource_wazzuf_files () {
for WFILE in ${WAZZUF_FILES}
do
if [ ! -f ${WFILE} ]; then
echo -ne "\n *************************************\n"
echo -ne " ${WFILE} file not found ! Exiting...\n"
echo -ne " *************************************\n"
exit 1
else
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG Sourcing ${WFILE}..."; fi
source ${WFILE}
fi
done
for WFILE in ${WAZZUF_FILES}; do
if [ ! -f "${WFILE}" ]; then
echo -ne "\n *************************************\n"
echo -ne " ${WFILE} file not found ! Exiting...\n"
echo -ne " *************************************\n"
exit 1
else
if [[ "${DEBUG}" == "1" ]]; then echo "DEBUG Sourcing ${WFILE}..."; fi
# shellcheck source=/dev/null
source "${WFILE}"
fi
done
}
# Check if user is not a super-user (root)
check_user () {
if [[ ${EUID} -eq 0 ]]; then
echo " ########################"
echo " # Do not run as root ! #"
echo " ########################"
exit 1
if [[ "${EUID}" -eq 0 ]]; then
echo " ########################"
echo " # Do not run as root ! #"
echo " ########################"
exit 1
fi
}
# check if value is an integer
# need NUMBER_TO_CHECK
# MESSAGE
# WAZZUF_UI
# MESSAGE
# WAZZUF_UI
#
# return nothing
check_integer () {
if echo ${NUMBER_TO_CHECK} | egrep -vq '^[0-9]+$'; then
if [[ ${WAZZUF_UI} == "GUI" ]]; then
zenity --error --title "${ZEN_TITLE}" \
--text "${MESSAGE} is not an integer ! Exiting."
else
echo -ne " Error ! ${MESSAGE} is not an integer ! Exiting.\n"
fi
exit 1
fi
if echo "${NUMBER_TO_CHECK}" | grep -vEq '^[0-9]+$'; then
if [[ "${WAZZUF_UI}" == "GUI" ]]; then
zenity --error --title "${ZEN_TITLE}" \
--text "${MESSAGE} is not an integer ! Exiting."
else
echo -ne " Error ! ${MESSAGE} is not an integer ! Exiting.\n"
fi
exit 1
fi
}
# check if missing softwares
check_omdb () {
if [ ! -x /usr/bin/omdbtool ]; then
SOFT_NAME="omdb-cli"
soft_to_install_exit
fi
if [ ! -x /usr/bin/omdbtool ]; then
SOFT_NAME="omdb-cli"
soft_to_install_exit
fi
}
check_nice () {
if [ ! -x "/usr/bin/nice" ]; then
SOFT_NAME="nice (coreutils)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/nice ]; then
SOFT_NAME="nice (coreutils)"
soft_to_install_exit
fi
}
check_ionice () {
if [ ! -x "/usr/bin/ionice" ]; then
SOFT_NAME="ionice (util-linux)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/ionice ]; then
SOFT_NAME="ionice (util-linux)"
soft_to_install_exit
fi
}
check_ogmtools () {
if [ ! -x "/usr/bin/dvdxchap" ]; then
SOFT_NAME="dvdxchap (ogmtools)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/dvdxchap ]; then
SOFT_NAME="dvdxchap (ogmtools)"
soft_to_install_exit
fi
}
check_bdchapters () {
if [ ! -x "/usr/bin/bdchapters" ]; then
SOFT_NAME="bdchapters"
soft_to_install_exit
fi
if [ ! -x /usr/bin/bdchapters ]; then
SOFT_NAME="bdchapters"
soft_to_install_exit
fi
}
check_lsdvd () {
if [ ! -x "/usr/bin/lsdvd" ]; then
SOFT_NAME="lsdvd"
soft_to_install_exit
fi
if [ ! -x /usr/bin/lsdvd ]; then
SOFT_NAME="lsdvd"
soft_to_install_exit
fi
}
check_mediainfo () {
if [ ! -x "/usr/bin/mediainfo" ]; then
SOFT_NAME="mediainfo"
soft_to_install_exit
fi
if [ ! -x /usr/bin/mediainfo ]; then
SOFT_NAME="mediainfo"
soft_to_install_exit
fi
}
check_avconv () {
if [ ! -x "/usr/bin/avconv" ]; then
SOFT_NAME="avconv (libav-tools)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/avconv ]; then
SOFT_NAME="avconv (libav-tools)"
soft_to_install_exit
fi
}
check_ffmpeg () {
if [ ! -x "/usr/bin/ffmpeg" ]; then
SOFT_NAME="ffmpeg"
soft_to_install_exit
fi
if [ ! -x /usr/bin/ffmpeg ]; then
SOFT_NAME="ffmpeg"
soft_to_install_exit
fi
}
check_7z () {
if [ ! -x "/usr/bin/7z" ]; then
SOFT_NAME="7z (p7zip-full)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/7z ]; then
SOFT_NAME="7z (p7zip-full)"
soft_to_install_exit
fi
}
check_genisoimage () {
if [ ! -x "/usr/bin/genisoimage" ]; then
SOFT_NAME="genisoimage"
soft_to_install_exit
fi
if [ ! -x /usr/bin/genisoimage ]; then
SOFT_NAME="genisoimage"
soft_to_install_exit
fi
}
check_mplayer () {
if [ ! -x "/usr/bin/mplayer" ]; then
SOFT_NAME="mplayer"
soft_to_install_exit
fi
if [ ! -x /usr/bin/mplayer ]; then
SOFT_NAME="mplayer"
soft_to_install_exit
fi
}
check_mencoder () {
if [ ! -x "/usr/bin/mencoder" ]; then
SOFT_NAME="mencoder"
soft_to_install_exit
fi
if [ ! -x /usr/bin/mencoder ]; then
SOFT_NAME="mencoder"
soft_to_install_exit
fi
}
check_cvlc () {
if [ ! -x "/usr/bin/cvlc" ]; then
SOFT_NAME="cvlc (vlc)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/cvlc ]; then
SOFT_NAME="cvlc (vlc)"
soft_to_install_exit
fi
}
check_oggenc () {
if [ ! -x "/usr/bin/oggenc" ]; then
SOFT_NAME="oggenc (vorbis-tools)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/oggenc ]; then
SOFT_NAME="oggenc (vorbis-tools)"
soft_to_install_exit
fi
}
check_lame () {
if [ ! -x "/usr/bin/lame" ]; then
SOFT_NAME="lame"
soft_to_install_exit
fi
if [ ! -x /usr/bin/lame ]; then
SOFT_NAME="lame"
soft_to_install_exit
fi
}
check_opusenc () {
if [ ! -x "/usr/bin/opusenc" ]; then
SOFT_NAME="opusenc (opus-tools)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/opusenc ]; then
SOFT_NAME="opusenc (opus-tools)"
soft_to_install_exit
fi
}
check_imagemagick () {
if [ ! -x "/usr/bin/convert" ]; then
SOFT_NAME="convert (imagemagick)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/convert ]; then
SOFT_NAME="convert (imagemagick)"
soft_to_install_exit
fi
}
check_mkvmerge () {
if [ ! -x "/usr/bin/mkvmerge" ]; then
SOFT_NAME="mkvmerge (mkvtoolnix)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/mkvmerge ]; then
SOFT_NAME="mkvmerge (mkvtoolnix)"
soft_to_install_exit
fi
}
check_tsmuxer () {
if [ ! -x "/usr/bin/tsmuxer" ]; then
SOFT_NAME="tsmuxer (CLI)"
soft_to_install_exit
fi
if [ ! -x /usr/bin/tsmuxer ]; then
SOFT_NAME="tsmuxer (CLI)"
soft_to_install_exit
fi
}
check_ccextractor () {
if [ ! -x "/usr/bin/ccextractor" ]; then
SOFT_NAME="ccextractor"
soft_to_install_exit
fi
if [ ! -x /usr/bin/ccextractor ]; then
SOFT_NAME="ccextractor"
soft_to_install_exit
fi
}
check_wget () {
if [ ! -x "/usr/bin/wget" ]; then
SOFT_NAME="wget"
soft_to_install_exit
fi
if [ ! -x /usr/bin/wget ]; then
SOFT_NAME="wget"
soft_to_install_exit
fi
}
check_md5sum () {
if [ ! -x "/usr/bin/md5sum" ]; then
SOFT_NAME="md5sum"
soft_to_install_exit
fi
if [ ! -x /usr/bin/md5sum ]; then
SOFT_NAME="md5sum"
soft_to_install_exit
fi
}
check_udisksctl () {
if [ ! -x "/usr/bin/udisksctl" ]; then
SOFT_NAME="udisksctl"
soft_to_install_exit
fi
if [ ! -x /usr/bin/udisksctl ]; then
SOFT_NAME="udisksctl"
soft_to_install_exit
fi
}
This diff is collapsed.
#!/bin/bash
## Cover art management functions
# convert imput image file in supported format (jpeg and png only) + thumbnail
# need SOURCE_DIRECTORY
# COVER
# COVER_FORMAT
# COVER_HEIGHT
# COVER_WIDTH
# need SOURCE_DIRECTORY
# COVER
# COVER_FORMAT
# COVER_HEIGHT
# COVER_WIDTH
# return MERGE_COVER
cover_art_convert () {
COVER_SOURCE_PATH="${SOURCE_DIRECTORY}/${COVER}"
# detect size type (landscape, portrait or square)
if [[ ${COVER_HEIGHT} -gt ${COVER_WIDTH} ]]; then
# portrait
if [[ ${COVER_WIDTH} -gt 600 || ${COVER_HEIGHT} -gt 800 ]]; then
COVER_FORMAT="jpeg"
COVER_OUTPUT_SIMPLE="cover.jpg"
COVER_DIMENSION_SIMPLE="600x800"
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x160"
else
COVER_OUTPUT_SIMPLE="cover.${COVER_FORMAT}"
COVER_DIMENSION_SIMPLE=""
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x160"
fi
elif [[ ${COVER_HEIGHT} -eq ${COVER_WIDTH} ]]; then
# square
if [[ ${COVER_WIDTH} -gt 600 ]]; then
COVER_FORMAT="jpeg"
COVER_OUTPUT_SIMPLE="cover.jpg"
COVER_DIMENSION_SIMPLE="600x600"
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x120"
else
COVER_OUTPUT_SIMPLE="cover.${COVER_FORMAT}"
COVER_DIMENSION_SIMPLE=""
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x120"
fi
else
# landscape
if [[ ${COVER_WIDTH} -gt 960 || ${COVER_HEIGHT} -gt 600 ]]; then
COVER_FORMAT="jpeg"
COVER_OUTPUT_SIMPLE="cover_land.jpg"
COVER_DIMENSION_SIMPLE="960x600"
COVER_OUTPUT_THUMB="small_cover_land.jpg"
COVER_DIMENSION_THUMB="192x120"
else
COVER_OUTPUT_SIMPLE="cover_land.${COVER_FORMAT}"
COVER_DIMENSION_SIMPLE=""
COVER_OUTPUT_THUMB="small_cover_land.jpg"
COVER_DIMENSION_THUMB="192x120"
fi
fi
COVER_SOURCE_PATH="${SOURCE_DIRECTORY}/${COVER}"
# detect size type (landscape, portrait or square)
if [[ "${COVER_HEIGHT}" -gt "${COVER_WIDTH}" ]]; then
# portrait
if [[ "${COVER_WIDTH}" -gt 600 || "${COVER_HEIGHT}" -gt 800 ]]; then
COVER_FORMAT="jpeg"
COVER_OUTPUT_SIMPLE="cover.jpg"
COVER_DIMENSION_SIMPLE="600x800"
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x160"
else
COVER_OUTPUT_SIMPLE="cover.${COVER_FORMAT}"
COVER_DIMENSION_SIMPLE=""
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x160"
fi
elif [[ "${COVER_HEIGHT}" -eq "${COVER_WIDTH}" ]]; then
# square
if [[ "${COVER_WIDTH}" -gt 600 ]]; then
COVER_FORMAT="jpeg"
COVER_OUTPUT_SIMPLE="cover.jpg"
COVER_DIMENSION_SIMPLE="600x600"
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x120"
else
COVER_OUTPUT_SIMPLE="cover.${COVER_FORMAT}"
COVER_DIMENSION_SIMPLE=""
COVER_OUTPUT_THUMB="small_cover.jpg"
COVER_DIMENSION_THUMB="120x120"
fi
else
# landscape
if [[ "${COVER_WIDTH}" -gt 960 || "${COVER_HEIGHT}" -gt 600 ]]; then
COVER_FORMAT="jpeg"
COVER_OUTPUT_SIMPLE="cover_land.jpg"
COVER_DIMENSION_SIMPLE="960x600"
COVER_OUTPUT_THUMB="small_cover_land.jpg"
COVER_DIMENSION_THUMB="192x120"
else
COVER_OUTPUT_SIMPLE="cover_land.${COVER_FORMAT}"
COVER_DIMENSION_SIMPLE=""
COVER_OUTPUT_THUMB="small_cover_land.jpg"
COVER_DIMENSION_THUMB="192x120"
fi
fi
if [[ $DEBUG == "1" ]]; then
echo "DEBUG COVER_FORMAT ${COVER_FORMAT}"
echo "DEBUG COVER_OUTPUT_SIMPLE ${COVER_OUTPUT_SIMPLE}"
echo "DEBUG COVER_DIMENSION_SIMPLE ${COVER_DIMENSION_SIMPLE}"
echo "DEBUG COVER_OUTPUT_THUMB ${COVER_OUTPUT_THUMB}"
echo "DEBUG COVER_DIMENSION_THUMB ${COVER_DIMENSION_THUMB}"
fi
if [[ "${DEBUG}" == "1" ]]; then
echo "DEBUG COVER_FORMAT ${COVER_FORMAT}"
echo "DEBUG COVER_OUTPUT_SIMPLE ${COVER_OUTPUT_SIMPLE}"
echo "DEBUG COVER_DIMENSION_SIMPLE ${COVER_DIMENSION_SIMPLE}"
echo "DEBUG COVER_OUTPUT_THUMB ${COVER_OUTPUT_THUMB}"
echo "DEBUG COVER_DIMENSION_THUMB ${COVER_DIMENSION_THUMB}"
fi
# cover creation
if [ -f ${COVER_OUTPUT_SIMPLE} ] && [[ ! ${WAZZUF_UI} == "GUI" ]]; then
FILE_NAME="${COVER_OUTPUT_SIMPLE} cover art"
file_exists
else
COVER_DIMENSION=${COVER_DIMENSION_SIMPLE}
COVER_OUTPUT=${COVER_OUTPUT_SIMPLE}
if [[ ${COVER_DIMENSION} == "" ]]; then
if [[ ${WAZZUF_UI} == "GUI" ]]; then
cp "${COVER_SOURCE_PATH}" ${COVER_OUTPUT}
else
echo -ne "\n *************************************\n"
echo " Copying cover art..."
cp -v "${COVER_SOURCE_PATH}" ${COVER_OUTPUT}
echo -ne "\n *************************************\n"
fi
else
if [[ ${WAZZUF_UI} == "GUI" ]]; then
cover_art_resize
else
echo -ne "\n *************************************\n"
echo " Resizing cover art..."
cover_art_resize
echo -ne "\n *************************************\n"
fi
fi
fi
# cover creation
if [ -f "${COVER_OUTPUT_SIMPLE}" ] && [[ ! "${WAZZUF_UI}" == "GUI" ]]; then
FILE_NAME="${COVER_OUTPUT_SIMPLE} cover art"
file_exists
else
COVER_DIMENSION="${COVER_DIMENSION_SIMPLE}"
COVER_OUTPUT="${COVER_OUTPUT_SIMPLE}"
if [[ "${COVER_DIMENSION}" == "" ]]; then
if [[ "${WAZZUF_UI}" == "GUI" ]]; then
cp "${COVER_SOURCE_PATH}" "${COVER_OUTPUT}"
else
echo -ne "\n *************************************\n"
echo " Copying cover art..."
cp -v "${COVER_SOURCE_PATH}" "${COVER_OUTPUT}"
echo -ne "\n *************************************\n"
fi
else
if [[ "${WAZZUF_UI}" == "GUI" ]]; then
cover_art_resize
else
echo -ne "\n *************************************\n"
echo " Resizing cover art..."
cover_art_resize
echo -ne "\n *************************************\n"
fi
fi
fi
# thumbnail cover creation
if [ -f ${COVER_OUTPUT_THUMB} ] && [[ ! ${WAZZUF_UI} == "GUI" ]]; then
FILE_NAME="${COVER_OUTPUT_THUMB} cover art thumbnail"
file_exists
else
COVER_DIMENSION=${COVER_DIMENSION_THUMB}
COVER_OUTPUT=${COVER_OUTPUT_THUMB}
if [[ ${WAZZUF_UI} == "GUI" ]]; then
cover_art_resize
else
echo -ne "\n *************************************\n"
echo " Cover art thumbnail generation..."
cover_art_resize
echo -ne "\n *************************************\n"
fi
fi
# thumbnail cover creation
if [ -f "${COVER_OUTPUT_THUMB}" ] && [[ ! "${WAZZUF_UI}" == "GUI" ]]; then
FILE_NAME="${COVER_OUTPUT_THUMB} cover art thumbnail"
file_exists
else
COVER_DIMENSION="${COVER_DIMENSION_THUMB}"
COVER_OUTPUT="${COVER_OUTPUT_THUMB}"
if [[ "${WAZZUF_UI}" == "GUI" ]]; then
cover_art_resize
else
echo -ne "\n *************************************\n"
echo " Cover art thumbnail generation..."
cover_art_resize
echo -ne "\n *************************************\n"
fi
fi
}
# dont_exists_warn
# need COVER_SOURCE_PATH
# COVER_DIMENSION
# need COVER_SOURCE_PATH
# COVER_DIMENSION
#
# return COVER_OUTPUT
cover_art_resize () {
convert "${COVER_SOURCE_PATH}" -resize ${COVER_DIMENSION}\> ${COVER_OUTPUT}
}
\ No newline at end of file
convert "${COVER_SOURCE_PATH}" -resize "${COVER_DIMENSION}"\> "${COVER_OUTPUT}"
}
#!/bin/bash
## IMDb function
# thanks to https://github.com/bgr/omdb-cli
# and https://www.omdbapi.com/
......@@ -5,68 +6,68 @@
# need TITLE_NAME
# return OMDB_RESPONSE ("True" or "False")
get_omdb_response_title () {
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" | sed -n '/^response/{n;p;}'"; fi
OMDB_RESPONSE=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" | sed -n '/^response/{n;p;}')
if [[ "${DEBUG}" == "1" ]]; then echo "DEBUG omdbtool -t \"${TITLE_NAME}\" --apikey=\"${OMDB_API_KEY}\" | sed -n '/^response/{n;p;}'"; fi
OMDB_RESPONSE=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" | sed -n '/^response/{n;p;}')
}
# need TITLE_NAME
# DATE
# return OMDB_RESPONSE ("True" or "False")
get_omdb_response_title_date () {
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" -y ${DATE} | sed -n '/^response/{n;p;}'"; fi
IMDB_RESPONSE=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" -y ${DATE} | sed -n '/^response/{n;p;}')
if [[ "${DEBUG}" == "1" ]]; then echo "DEBUG omdbtool -t \"${TITLE_NAME}\" --apikey=\"${OMDB_API_KEY}\" -y \"${DATE}\" | sed -n '/^response/{n;p;}'"; fi
IMDB_RESPONSE=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" -y "${DATE}" | sed -n '/^response/{n;p;}')
}
# need IMDB_FILE
# return OMDB_RESPONSE ("True" or "False")
get_omdb_response_file () {
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG sed -n '/^response/{n;p;}' ${IMDB_FILE}"; fi
OMDB_RESPONSE=$(sed -n '/^response/{n;p;}' ${IMDB_FILE})
if [[ "${DEBUG}" == "1" ]]; then echo "DEBUG sed -n '/^response/{n;p;}' \"${IMDB_FILE}\""; fi
OMDB_RESPONSE=$(sed -n '/^response/{n;p;}' "${IMDB_FILE}")
}
# need TITLE_NAME
# return IMDB_ID
get_imdb_id_title () {
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" | sed -n '/^imdbid/{n;p;}'"; fi
IMDB_ID=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" | sed -n '/^imdbid/{n;p;}')
if [[ "${DEBUG}" == "1" ]]; then echo "DEBUG omdbtool -t \"${TITLE_NAME}\" --apikey=\"${OMDB_API_KEY}\" | sed -n '/^imdbid/{n;p;}'"; fi
IMDB_ID=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" | sed -n '/^imdbid/{n;p;}')
}
# need TITLE_NAME
# DATE
# return IMDB_ID
get_imdb_id_title_date () {
if [[ ${DEBUG} == "1" ]]; then echo "DEBUG omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" -y ${DATE} | sed -n '/^imdbid/{n;p;}'"; fi
IMDB_ID=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" -y ${DATE} | sed -n '/^imdbid/{n;p;}')
if [[ "${DEBUG}" == "1" ]]; then echo "DEBUG omdbtool -t \"${TITLE_NAME}\" --apikey=\"${OMDB_API_KEY}\" -y \"${DATE}\" | sed -n '/^imdbid/{n;p;}'"; fi
IMDB_ID=$(omdbtool -t "${TITLE_NAME}" --apikey="${OMDB_API_KEY}" -y "${DATE}" | sed -n '/^imdbid/{n;p;}')
}
# need IMDB_ID
# SOURCE_DIRECTORY
download_imdb_poster () {
# check if local cover exists
if [ -f "${SOURCE_DIRECTORY}/cover.jpg" ]; then
echo " cover.jpg exists. Skipping Download..." && sleep 1
else
# check if IMDb cover exists
IMDB_POSTER=$(omdbtool -i ${IMDB_ID} --apikey="${OMDB_API_KEY}" | sed -n '/^poster/{n;p;}')