summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkiz <skiznet@aol.com>2024-11-16 16:49:27 -0500
committerSkiz <skiznet@aol.com>2024-11-16 16:49:27 -0500
commit2bc738b9ee4fd8e2f526487c34e3d9a8bbf181ae (patch)
tree84dbc9443de2b64ddc289f65d398e8788c7ebc59
parentb0c98a8ff5fc292fb68486acf6441257fa1f39e4 (diff)
Added error handling
-rwxr-xr-xmediachad15
1 files changed, 11 insertions, 4 deletions
diff --git a/mediachad b/mediachad
index fdba6ef..03dd86f 100755
--- a/mediachad
+++ b/mediachad
@@ -33,9 +33,17 @@ program_check "yt-dlp"
#ytfzf --pages=3 --force-youtube -L "$input" | grep "youtube.com" | xargs -I {} yt-dlp -o - --quiet "{}" | mpv - --pause > /dev/null 2>&1
# Code to work with .yt-history
-link=$(ytfzf --pages=3 --force-youtube -L "$input" | grep "youtube.com")
-# Plays the video:
-yt-dlp -o - --quiet "$link" | mpv - --pause > /dev/null 2>&1 || exit 1
+link=$(ytfzf --pages=3 --force-youtube -L "$input")
+
+if [ -z "$link" ]; then
+ # echo "Exited!"
+ exit 1
+else
+ # Plays the video:
+ yt-dlp -o - --quiet "$link" | mpv - --pause > /dev/null 2>&1 &
+fi
+
+# Saves the video data to ".yt-history"
file=".yt-history"
time=$(date +%T-%m-%d-%y)
@@ -43,7 +51,6 @@ title=$(yt-dlp --get-title --quiet "$link")
echo -e "Search: $input \nDate: $time \nTitle: $title \nLink: $link \n"
-
# USING YT-DLP
#yt-dlp -o - --quiet "link" | mpv - --pause > /dev/null 2>&1