mirror of
https://github.com/NohamR/AM-Exporter.git
synced 2026-05-25 04:07:11 +00:00
changes
This commit is contained in:
15
user/test.py
15
user/test.py
@@ -10,7 +10,11 @@ USER = os.getenv("USER")
|
||||
PASSWORD = os.getenv("PASSWORD")
|
||||
|
||||
def get_current_song():
|
||||
return subprocess.check_output(['osascript', 'test.applescript']).decode('utf-8').strip()
|
||||
try:
|
||||
output = subprocess.check_output(['osascript', 'export.applescript']).decode('utf-8').strip()
|
||||
return output
|
||||
except subprocess.CalledProcessError as e:
|
||||
return e
|
||||
|
||||
def get_track_extras(song, artist, album):
|
||||
query = f"{song} {artist} {album}"
|
||||
@@ -20,7 +24,6 @@ def get_track_extras(song, artist, album):
|
||||
json_data = r.json()
|
||||
if json_data["resultCount"] == 1:
|
||||
result = json_data["results"][0]
|
||||
pprint(result)
|
||||
elif json_data["resultCount"] > 1:
|
||||
result = json_data["results"][0]
|
||||
else :
|
||||
@@ -29,7 +32,6 @@ def get_track_extras(song, artist, album):
|
||||
artwork_url = result["artworkUrl100"] if result else None
|
||||
itunes_url = result["trackViewUrl"] if result else None
|
||||
artist_url = result["artistViewUrl"] if result else None
|
||||
# album_url = result["collectionViewUrl"] if result else None
|
||||
|
||||
return (artwork_url, itunes_url, artist_url)
|
||||
|
||||
@@ -43,8 +45,10 @@ def post(currentsong):
|
||||
else :
|
||||
return r.text
|
||||
|
||||
url = "http://192.168.1.58:3005" #RUN
|
||||
url = "https://api.noh.am" #RUN WEB
|
||||
url = "http://127.0.0.1:5000" #DEV
|
||||
url = "http://0.0.0.0:3005"
|
||||
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
|
||||
def main():
|
||||
@@ -52,7 +56,8 @@ def main():
|
||||
prevstatus = ''
|
||||
while True:
|
||||
print('getting data..')
|
||||
currentsong = json.loads(str(get_current_song()).replace("'''", '"'))
|
||||
# currentsong = json.loads(str(get_current_song()).replace("'''", '"'))
|
||||
currentsong = json.loads(get_current_song())
|
||||
|
||||
if currentsong['status'] == 'playing':
|
||||
if currentsong['persistent ID'] != persistendId:
|
||||
|
||||
Reference in New Issue
Block a user