forked from alireza-amirsamimi/mymplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mymplayer
executable file
·42 lines (42 loc) · 1.36 KB
/
mymplayer
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
#!/bin/bash
#My Mplayer is written by alireza.amirsamimi@gmail.com
#checking file neme!if file not exist then zenity's file-selection form will open for selecting the file.
file_name="$@"
if [ ! -f "$file_name" ];then
file_name=`zenity --file-selection --title="My Mplayer" `
if [ $? -eq 1 ]
then
notify-send "exit"
exit
fi
fi
#finding subtitle file!
file_name_extension="${file_name##*/}"
extension="${file_name_extension##*.}"
file_name_with_out_extension=${file_name_extension%$extension}
file_name_path="${file_name%$file_name_extension}"
ls "$file_name_path" | grep "$file_name_with_out_extension" > /tmp/m_player_script_temp.txt
while read -r line;do
if [ "$line" != "$file_name_extension" ];then
subtitle_extension="${line##*.}"
for i in srt sub gsub aqt jss pjs psb rt smi stl ssf ssa ass usf ; do
if [ "$subtitle_extension" == "$i" ];then
subtitle_file_name="$line"
flag="1"
break
fi
done
fi
done < /tmp/m_player_script_temp.txt
if [ "$flag" != "1" ];then
notify-send "No Subtitle file founded"
fi
rm /tmp/m_player_script_temp.txt
#cheking Subtitle's encoding!
subtitle_encoding=$(file --mime-encoding -b "$file_name_path/$subtitle_file_name")
if [ "$subtitle_encoding" == "unknown-8bit" ];then
subtitle_encoding="WINDOWS-1256"
fi
#set mplayer for subtitle
mplayer "$file_name" -subcp "$subtitle_encoding"
exit