-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlampPipe.py
56 lines (51 loc) · 2.87 KB
/
lampPipe.py
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
# Copyright (C) 2020 Hiroki Fujii <[email protected]>
import wx, configparser, re
import namedPipe, globalVars, constants, sys, os, m3uManager, listManager
pipeServer = None
def sendPipe():
pipeClient = namedPipe.Client(constants.PIPE_NAME)
while True:
try:
pipeClient.connect()
pipeClient.write(sys.argv[1])
return
except namedPipe.PipeServerNotFoundError as e:
pass
def startPipeServer():
global pipeServer
pipeServer = namedPipe.Server(constants.PIPE_NAME)
pipeServer.setReceiveCallback(onReceive)
pipeServer.start()
def stopPipeServer():
global pipeServer
if pipeServer != None:
pipeServer.exit()
pipeServer.close()
pipeServer = None
def onReceive(msg):
if os.path.exists(msg):
if os.path.isdir(msg) or os.path.splitext(msg)[1].lower() == ".url" or os.path.splitext(msg)[1].lower() in globalVars.fileExpansions:
setting = globalVars.app.config.getstring("player", "fileInterrupt", "play", ("play", "addPlaylist", "addQueue", "addQueueHead"))
if setting == "play":
if os.path.splitext(msg)[1].lower() == ".url":
try:
configP = configparser.ConfigParser()
configP.read(msg)
url = configP["InternetShortcut"]["url"]
if re.search("^https?://.+\..+/.*$", url)!=None: wx.CallAfter(globalVars.eventProcess.forcePlay, url)
except: pass
elif os.path.isfile(msg): wx.CallAfter(globalVars.eventProcess.forcePlay, msg)
else: wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.queueView, 0)
elif setting == "addPlaylist":
if os.path.isfile(msg): wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.playlistView)
else: wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.playlistView)
elif setting == "addQueue":
if os.path.isfile(msg): wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.queueView)
else: wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.queueView)
elif setting == "addQueueHead":
if os.path.isfile(msg): wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.queueView, 0)
else: wx.CallAfter(listManager.addItems, [msg], globalVars.app.hMainView.queueView, 0)
elif os.path.splitext(msg)[1].lower() == ".m3u" or os.path.splitext(msg)[1].lower() == ".m3u8":
setting = globalVars.app.config.getstring("player", "playlistInterrupt", "open", ("open", "add"))
if setting == "open": wx.CallAfter(m3uManager.loadM3u, msg, m3uManager.REPLACE)
elif setting == "add": wx.CallAfter(m3uManager.loadM3u, msg, m3uManager.ADD)