initial working commit
This commit is contained in:
commit
6ab6d75b7b
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
venv
|
||||||
|
demo_client.py
|
||||||
|
test.py
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "yt diskLoad",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"args":[
|
||||||
|
// "Daft Punk RAM - ytmusic:album:MPREb_K8qWMWVqXGi"
|
||||||
|
" Xtra Reloaded - http://media-ice.musicradio.com/CapitalXTRAReloadedMP3.m3u"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "current_track",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"args":[
|
||||||
|
"current_track"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
10
SongLocations
Normal file
10
SongLocations
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Chris Brown Indigo - ytmusic:album:MPREb_jlY9mqAHYjR
|
||||||
|
|
||||||
|
Daft Punk RAM -
|
||||||
|
ytmusic:album:MPREb_K8qWMWVqXGi
|
||||||
|
|
||||||
|
My Likes -
|
||||||
|
ytmusic:liked
|
||||||
|
|
||||||
|
Radio
|
||||||
|
http://media-ice.musicradio.com/CapitalXTRAReloadedMP3.m3u
|
82
player.py
Normal file
82
player.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import asyncio
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from mopidy_async_client import MopidyClient
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="Mopdiy FloppyPlayer")
|
||||||
|
parser.add_argument("URI_string", help="Mopdiy URI to Album/Playlist.")
|
||||||
|
args = parser.parse_args()
|
||||||
|
inputURI = args.URI_string
|
||||||
|
|
||||||
|
|
||||||
|
async def playback_started_handler(data):
|
||||||
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
|
async def all_events_handler(event, data):
|
||||||
|
print(event, data)
|
||||||
|
|
||||||
|
|
||||||
|
async def main3():
|
||||||
|
if inputURI == "stop":
|
||||||
|
await stop()
|
||||||
|
elif inputURI == "current_track":
|
||||||
|
await current_track()
|
||||||
|
else:
|
||||||
|
await main1()
|
||||||
|
|
||||||
|
|
||||||
|
async def stop():
|
||||||
|
mopidy = await MopidyClient().connect()
|
||||||
|
await mopidy.playback.stop()
|
||||||
|
await mopidy.disconnect()
|
||||||
|
|
||||||
|
|
||||||
|
async def current_track():
|
||||||
|
mopidy = await MopidyClient().connect()
|
||||||
|
res = await mopidy.playback.get_current_track()
|
||||||
|
current_data = {
|
||||||
|
"Artist": res["artists"][0]["name"],
|
||||||
|
"Album": res["album"]["name"],
|
||||||
|
"Song": res["name"],
|
||||||
|
}
|
||||||
|
print(current_data)
|
||||||
|
await mopidy.disconnect()
|
||||||
|
|
||||||
|
|
||||||
|
async def main1():
|
||||||
|
link = inputURI.split(" - ")[1]
|
||||||
|
async with MopidyClient(
|
||||||
|
url="ws://127.0.0.1:6680/mopidy/ws"
|
||||||
|
) as mopidy: # close connection explicit
|
||||||
|
await mopidy.playback.stop()
|
||||||
|
await mopidy.tracklist.clear()
|
||||||
|
await mopidy.tracklist.add(uris=[link])
|
||||||
|
await mopidy.playback.play()
|
||||||
|
|
||||||
|
|
||||||
|
async def main2():
|
||||||
|
mopidy = await MopidyClient().connect()
|
||||||
|
await mopidy.playback.stop()
|
||||||
|
await mopidy.tracklist.clear()
|
||||||
|
await mopidy.tracklist.add(uris=[inputURI])
|
||||||
|
await mopidy.playback.play()
|
||||||
|
mopidy.listener.bind("track_playback_started", playback_started_handler)
|
||||||
|
mopidy.listener.bind("*", all_events_handler)
|
||||||
|
|
||||||
|
# your app logic
|
||||||
|
for i in range(10):
|
||||||
|
# res = await mopidy.tracklist.get_tracks()
|
||||||
|
res = await mopidy.playback.get_current_track()
|
||||||
|
print(res)
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
|
||||||
|
# end your app logic
|
||||||
|
|
||||||
|
await mopidy.disconnect() # close connection implicit
|
||||||
|
|
||||||
|
|
||||||
|
# asyncio.run(main1())
|
||||||
|
# or
|
||||||
|
# asyncio.run(main2())
|
||||||
|
asyncio.run(main3())
|
20
requirements.txt
Normal file
20
requirements.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Adafruit-GPIO==1.0.4
|
||||||
|
Adafruit-PureIO==1.1.9
|
||||||
|
Adafruit-SSD1306==1.6.2
|
||||||
|
black==21.10b0
|
||||||
|
click==8.0.3
|
||||||
|
future==0.18.2
|
||||||
|
importlib-metadata==4.8.1
|
||||||
|
mopidy-async-client==0.6.4
|
||||||
|
mypy-extensions==0.4.3
|
||||||
|
pathspec==0.9.0
|
||||||
|
pkg-resources==0.0.0
|
||||||
|
platformdirs==2.4.0
|
||||||
|
regex==2021.10.23
|
||||||
|
spidev==3.5
|
||||||
|
tomli==1.2.2
|
||||||
|
typed-ast==1.4.3
|
||||||
|
typing-extensions==3.10.0.2
|
||||||
|
websocket-client==1.2.1
|
||||||
|
websockets==10.0
|
||||||
|
zipp==3.6.0
|
Loading…
x
Reference in New Issue
Block a user