-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzapper.sh
65 lines (52 loc) · 1.75 KB
/
zapper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# MOVIE RANDOM ZAPPER Script v0.2
# (needs figlet + vlc to work!)
# Clear the screen
clear
# Loop indefinitely
while [ 1 = 1 ]
do
# Specify the directory to use
DIR="/home/dan/Desktop/videos/"
# Set the Internal Field Separator to newline, so file names with spaces do not break the script
IFS=$'\n'
# Check if the specified directory exists
if [[ -d "${DIR}" ]]; then
# Run the 'find' command on the directory to find all movie files with supported extensions
file_matrix=($(find "${DIR}" -type f -true -name "*.mpg" -o -name "*.avi" -o -name "*.mpeg" -o -name "*.mp4" -o -name "*.ogv"))
# Get the number of movie files found
num_files=${#file_matrix[*]}
# Select a random movie file from the list
MOVIE="${file_matrix[$((RANDOM%num_files))]}"
# Clear the screen
clear
# Display a message using the 'figlet' command
figlet "Zapper!"
echo ""
tput setaf 3
echo "The New Zapping Experience!"
echo ""
tput setaf 7
echo "Now Playing:"
echo ""
tput setaf 6
echo $MOVIE
echo ""
tput setaf 7
# Get the size of the selected movie file
SIZE=$(stat --printf="%s" "$MOVIE")
# Determine the maximum range of the random start position based on the size of the selected movie file
if ((SIZE < 200000000)); then
RANGOMAX=100
else
RANGOMAX=3600
fi
# Display the maximum range of the random start position
echo "Max Range in Sec:" $RANGOMAX
echo ""
# Generate a random start position within the specified range
POSITION=$((RANDOM % RANGOMAX + 3))
# Play the selected movie file using VLC media player with the specified options
cvlc --start-time=$POSITION --play-and-exit -q -f --no-video-title-show "$MOVIE"
fi
done