-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
48 lines (39 loc) · 1.23 KB
/
Copy pathserver.py
File metadata and controls
48 lines (39 loc) · 1.23 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
from flask import Flask
import os
app = Flask(__name__)
# Function to play video on Netflix in any tab across all Chrome windows
@app.route('/start')
def start_video():
os.system("""
osascript -e '
tell application "Google Chrome"
repeat with win in windows
repeat with t in tabs of win
if URL of t contains "netflix.com" then
tell t to execute javascript "document.querySelector(\\\"video\\\").play();"
return
end if
end repeat
end repeat
end tell'
""")
return "Started Netflix video"
# Function to pause video on Netflix in any tab across all Chrome windows
@app.route('/pause')
def pause_video():
os.system("""
osascript -e '
tell application "Google Chrome"
repeat with win in windows
repeat with t in tabs of win
if URL of t contains "netflix.com" then
tell t to execute javascript "document.querySelector(\\\"video\\\").pause();"
return
end if
end repeat
end repeat
end tell'
""")
return "Paused Netflix video"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7222)