-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathm3u_utils.sh
More file actions
82 lines (73 loc) · 1.87 KB
/
m3u_utils.sh
File metadata and controls
82 lines (73 loc) · 1.87 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# #!/usr/bin/env bash
# jq.my() {
# local json="$1"
# local prop="$2"
# echo "$json" | jq -r "$prop"
# }
# m3u.gen() {
# local lang="en"
# local timeout='10000'
# # Takes "$NAUTILUS_SCRIPT_CURRENT_URI"
# local uri="$NAUTILUS_SCRIPT_CURRENT_URI"
# local i18n='
# {
# "en": {
# "succ": {
# "summ": "File Generated",
# "body": "Playlist has been created successfully."
# },
# "fail": {
# "summ": "Error",
# "body": "Playlist making failed. No media files found."
# },
# "open": "Open File",
# "del": "Delete File"
# }
# }
# '
# local types=( "wav" "wv" "flac" "ogg" "mp3" "mp4" "avi" "mkv" "m4a")
# local dirpath="${uri#file://}"
# dirpath="${dirpath//%20/ }"
# local dirname="${dirpath##*/}"
# local playlist_file="$dirpath/$dirname-Full.m3u"
# echo "#EXTM3U" > "$playlist_file"
# local find_cmd="find \"$dirpath\" -type f \("
# for i in "${!types[@]}"; do
# [[ $i -gt 0 ]] && find_cmd+=" -o"
# find_cmd+=" -iname \"*.${types[i]}\""
# done
# find_cmd+=" \)"
# local file_count=0
# local found_files=""
# while read -r file; do
# rel_path="${file#$dirpath/}"
# found_files+="$rel_path\n"
# ((file_count++))
# done < <(eval "$find_cmd")
# echo -e $found_files | sort >> "$playlist_file"
# if [ $file_count -gt 0 ]; then
# act=$(
# notify-send \
# "$(jq.my "$i18n" ".$lang.succ.summ")" \
# "$(jq.my "$i18n" ".$lang.succ.body")" \
# -A "open=$(jq.my "$i18n" ".$lang.open")" \
# -A "del=$(jq.my "$i18n" ".$lang.del")" \
# --wait \
# -t $timeout
# )
# case "$act" in
# "open") xdg-open "$playlist_file" ;;
# "del")
# if [ -f "$playlist_file" ]; then
# rm "$playlist_file"
# fi
# ;;
# esac
# else
# notify-send \
# "$(jq.my "$i18n" ".$lang.fail.summ")" \
# "$(jq.my "$i18n" ".$lang.fail.body")"
# [ -f "$playlist_file" ] && rm "$playlist_file"
# fi
# return 0
# }