Skip to content

Commit

Permalink
bug fixes + newer version of Python SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerBOSS2019 committed Mar 21, 2023
1 parent 039d349 commit a8abb82
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 100 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
*.tpp
34 changes: 7 additions & 27 deletions TouchPortalYTMusic/TPYTMD.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,13 @@

YTMD_server = "localhost"
LoginPass = None
isBeta = False
lyricsRange = [-5, 5]
lyricsStatesList = []
statesData = ""
http = urllib3.PoolManager(num_pools=10)
isYTMDRunning = False
running = False

def createDebug():
if os.path.isfile("./log.txt"):
os.remove("log.txt")

print('log file has been created')
Logfile = open('log.txt', 'w')
currenttime = (strftime('[%I:%M:%S:%p] '))
Logfile.write("log file created At: "+currenttime)
Logfile.write('\n')
Logfile.write('--------------------------------------------\n')
Logfile.close()
def writeServerData(Serverinfo):
currenttime = (strftime('[%I:%M:%S:%p] '))
logfile = open('log.txt', 'a')
Expand Down Expand Up @@ -83,16 +71,12 @@ def stateUpdate():
print("Updating playlist")
oldPlaylist = currentPlaylist
TPClient.choiceUpdate("KillerBOSS.TouchPortal.Plugin.YTMD.Action.AddToPlaylist.Value", oldPlaylist)
TPClient.choiceUpdate("KillerBOSS.TouchPortal.Plugin.YTMD.Action.StartPlaylist.playlistName", oldPlaylist)

if statesData['track']['title'] != oldMusicTitle[0] or oldMusicTitle[1] != queryQueue['currentIndex']:
oldMusicTitle = (statesData['track']['title'], queryQueue['currentIndex']);
#print(oldMusicTitle, statesData['track']['title'])
if statesData['track']['cover']:
TPClient.stateUpdate("KillerBOSS.TouchPortal.Plugin.YTMD.States.Playercover", base64.b64encode(requests.get(statesData['track']['cover']).content).decode('utf-8'))
if isBeta:
YTMD_Actions("show-lyrics-hidden", showdata=False)
HiddenLyrics = True
lyricsClock = 0
totalTimewait = 0
def get5Line(Lyrics, currentindex):
Expand Down Expand Up @@ -192,7 +176,7 @@ def updateLyrics(index):
},
{
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.States.PlayerVPercent",
"value": str(statesData['player']['volumePercent'])
"value": str(int(statesData['player']['volumePercent']))
},
{
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.States.Trackdurationhuman",
Expand All @@ -216,33 +200,29 @@ def updateLyrics(index):
},
{
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.States.Inlibrary",
"value": statesData['track']['inLibrary']
"value": str(statesData['track']['inLibrary'])
},
{
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.States.repeatType",
"value": statesData['player']['repeatType']
"value": str(statesData['player']['repeatType'])
}
])
TPClient.connectorUpdate("KillerBOSS.TP.Plugins.YTMD.connectors.APPcontrol", TPClient.currentStates['KillerBOSS.TouchPortal.Plugin.YTMD.States.PlayerVPercent'])
TPClient.connectorUpdate("KillerBOSS.TP.Plugins.YTMD.connectors.APPcontrol", int(TPClient.currentStates['KillerBOSS.TouchPortal.Plugin.YTMD.States.PlayerVPercent']))
except:
pass
sleep(0.23)

@TPClient.on(TYPES.onConnect)
def onConnect(data):
global YTMD_server, LoginPass, isBeta, lyricsRange, lyricsStatesList
global YTMD_server, LoginPass, lyricsRange, lyricsStatesList
global running
print(data)
createDebug()
running = True

YTMD_server = data['settings'][0]['IPv4 address']
LoginPass = data['settings'][1]['Passcode']
if data['settings'][2]["beta"] == "True":
print("Beta is enabled")
isBeta = True

lyricsRange = data['settings'][3]['Lyrics Range']
lyricsRange = data['settings'][2]['Lyrics Range']
lyricsRange = lyricsRange.split(",")
#print(lyricsRange)
print(list(range(int(lyricsRange[0]), int(lyricsRange[1]))))
Expand Down Expand Up @@ -331,7 +311,7 @@ def Actions(data):
YTMD_Actions("start-playlist", data['data'][0]['value'])
if data['actionId'] == "KillerBOSS.TouchPortal.Plugin.YTMD.Action.PlayURL":
YTMD_Actions("play-url", data['data'][0]['value'])
if data['actionId'] == "KillerBOSS.TouchPortal.Plugin.YTMD.Action.SkiAd":
if data['actionId'] == "KillerBOSS.TouchPortal.Plugin.YTMD.Action.SkipAd":
YTMD_Actions("skip-ad")

@TPClient.on(TYPES.onConnectorChange)
Expand Down
83 changes: 78 additions & 5 deletions TouchPortalYTMusic/build.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,95 @@
from TouchPortalAPI.tppbuild import *
"""
In order for buildScript to work, you need to have the following variables in your build file:
- PLUGIN_ROOT: (Required)
This lets the build script to know your plugin's root directory.
- OUTPUT_PATH: (Required)
This tells tppbuild where you want finished build tpp to be saved at. Default "./" meaning current dir where tppbuild is running from.
- PLUGIN_MAIN: (Required)
This lets tppbuild know where your main python plugin file is located so it will know which file to compile.
- PLUGIN_EXE_NAME: (Required)
This is the name of the executable file that is compiled by Pyinstaller.
- PLUGIN_EXE_ICON: (Optional)
This should be a path to a .ico file. However if png passed in, it will automatically converted to ico.
Otherwise, it will use pyinstaller's default icon.
- PLUGIN_ENTRY: (Required)
This can be either path to entry.tp or path to a python file that contains infomation about entry.
Note if you pass in a entry.tp, tppbuild will automatically validate the json. If you pass in a python file, it will
build entry.tp & validate it for you. If validation fails, tppbuild will exit.
- PLUGIN_ENTRY_INDENT: (Required)
Indent level (spaces) for generated JSON. Use 0 for only newlines, or -1 for the most compact representation. Default is 2 spaces.
- PLUGIN_VERSION: (Required)
A version string will be used as part of .tpp file.
- ADDITIONAL_FILES: (Optional)
If your plugin requires any additional files for your plugin to work, you can add them here.
- ADDITIONAL_PYINSTALLER_ARGS: (Optional)
If you have additional arguments for Pyinstaller, you can add them here. otherwise default it will use these arguments:
'--onefile', '--noconsole', '--distpath', 'dist', 'name', 'icon'
Even if you don't use all of the above variables, you still need to have the following variables in your build file
"""
from TouchPortalAPI import tppbuild

"""
PLUGIN_MAIN: This lets tppbuild know where your main python plugin file is located so it will know which file to compile.
"""
PLUGIN_MAIN = "TPYTMD.py"

"""
PLUGIN_EXE_NAME: This defines what you want your plugin executable to be named. tppbuild will also use this for the .tpp file in the format:
`pluginname + "_v" + version + "_" + os_name + ".tpp"`
If left blank, the file name from PLUGIN_MAIN is used (w/out .py extension).
"""
PLUGIN_EXE_NAME = "TPYTMD"

"""
PLUGIN_EXE_ICON: This should be a path to a .ico file. However if png passed in, it will automatically converted to ico.
"""
PLUGIN_EXE_ICON = "icon.ico"

PLUGIN_ENTRY = "entry.tp"

PLUGIN_ENTRY_INDENT = -1
"""
PLUGIN_ENTRY: This can be either path to entry.tp or path to a python file that contains infomation about entry.
Note if you pass in a entry.tp, tppbuild will automatically validate the json. If you pass in a python file, it will
build entry.tp & validate it for you. If validation fails, tppbuild will exit.
"""
PLUGIN_ENTRY = "entry.tp" # Here we just use the same file as the plugin's main code since that contains all the definitions for entry.tp.

"""
"""
PLUGIN_ENTRY_INDENT = 2

""" This is the root folder name that will be inside of .tpp """
PLUGIN_ROOT = "TouchPortalYTMusic"

""" Path to icon file used in entry.tp for category `imagepath`, if any. If left blank, TP will use a default icon. """
PLUGIN_ICON = "icon.png"

PLUGIN_VERSION = "2.1.2"
""" This tells tppbuild where you want finished build tpp to be saved at. Default "./" meaning current dir where tppbuild is running from. """
OUTPUT_PATH = r"./"

""" PLUGIN_VERSION: A version string for the generated .tpp file name. This example reads the `__version__` from the example plugin's code. """
PLUGIN_VERSION = "2.2.0"

# Or just set the PLUGIN_VERSION manually.
# PLUGIN_VERSION = "1.0.0-beta1"

"""
If you have any required file(s) that your plugin needs, put them in this list.
"""
ADDITIONAL_FILES = ["start.sh"]

"""
"""
ADDITIONAL_TPPSDK_ARGS = []

"""
Any additional arguments to be passed to Pyinstaller. Optional.
"""
ADDITIONAL_PYINSTALLER_ARGS = [
"--log-level=WARN"
]

# validateBuild()

if __name__ == "__main__":
runBuild()
tppbuild.runBuild()
51 changes: 0 additions & 51 deletions TouchPortalYTMusic/buildpackage.py

This file was deleted.

21 changes: 4 additions & 17 deletions TouchPortalYTMusic/entry.tp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": 6,
"version": 212,
"version": 220,
"name": "YouTube Music Desktop plugin",
"id": "YoutubeMusic",
"configuration": {
Expand All @@ -19,24 +19,12 @@
"type": "text",
"default": "XXXXX",
"readOnly": false
},
{
"name": "beta",
"type": "text",
"default": "False",
"readOnly": false
},
{
"name": "Lyrics Range",
"type": "text",
"default": "-5, 5",
"readOnly": false
},
{
"name": "Check for Update",
"type": "text",
"default": "True",
"readOnly": false
},
{
"name": "status",
Expand Down Expand Up @@ -280,9 +268,8 @@
{
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.Action.StartPlaylist.playlistName",
"label": "StartPlaylist",
"type": "choice",
"default": "",
"valueChoices": []
"type": "text",
"default": ""
}
]
},
Expand All @@ -303,7 +290,7 @@
]
},
{
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.Action.SkiAd",
"id": "KillerBOSS.TouchPortal.Plugin.YTMD.Action.SkipAd",
"prefix": "YT Music",
"name": "YT Music Skip Ad",
"format": "Skip ad (If button pops up)",
Expand Down
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit a8abb82

Please sign in to comment.