-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeezer
More file actions
executable file
·135 lines (108 loc) · 2.84 KB
/
deezer
File metadata and controls
executable file
·135 lines (108 loc) · 2.84 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# run: $HOME/work/deezer-cli/deezer status
#### Set this occording to your pinned tab settings
tab_number=2
####
path_to_queue_header='$("#panel-queuelist > div > h3").text()'
function run_javascript() {
osascript -e "
tell application \"Safari\"
set playScript to \""$1\""
do JavaScript playScript in tab $tab_number of first window
end tell
"
}
function queue() {
(>&2 echo "Not yet working")
run_javascript $path_to_queue_header
}
function title() {
run_javascript "document.title"
}
function goto() {
url="$1"
osascript -e "
tell application \"Safari\"
set playScript to \"window.location.href = '$url'\"
do JavaScript playScript in tab $tab_number of first window
end tell
"
}
function activate() {
osascript -e "
tell front window of application \"Safari\"
set current tab to tab $tab_number
end tell
"
}
function next() {
run_javascript "document.getElementsByClassName('control')[0].click();"
}
function playpause() {
run_javascript "document.getElementsByClassName('control')[1].click();"
}
function next() {
run_javascript "document.getElementsByClassName('control')[2].click();"
}
function status() {
run_javascript "document.getElementsByClassName('control')[1].title;" |
sed 's/Play/◼/g' | sed 's/Pause/▶/g'
}
function play() {
playpause
}
function pause() {
playpause
}
function track() {
title | awk -F" - " '{print $2 " - " $1}'
}
function usage() {
echo """usage: $0 [--help] <command>
Control Playback:
play play track
pause pause track
next play next track
prev play previous track
Information:
track get title of track
status show playback status
Control Deezer Window:
title get title of Deezer window
goto change url of Deezer window
activate activate window if Deezer is not loaded yet. Will be run at every start.
Help:
usage this message
"""
}
status=$(status)
if [[ "$status" == "" ]];then
(>&2 echo "Activating $tab_number because window was inactive")
activate
sleep 5s
fi
case $1 in
track) $1
;;
goto) $1 $2
;;
activate) $1
;;
title) $1
;;
pause) $1
;;
play) $1
;;
queue) $1
;;
next) $1
;;
status) $1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac