123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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 selector():
- if "ytmusic" in inputURI or "http://" in inputURI:
- await run_floppy(inputURI)
- else:
- await action(inputURI)
- async def action(action):
- mopidy = await MopidyClient().connect()
- if action == "stop":
- await mopidy.playback.stop()
- elif action == "next":
- await mopidy.playback.next()
- elif action == "previous":
- await mopidy.playback.previous()
- elif action == "play":
- await mopidy.playback.play()
- elif action == "pause":
- await mopidy.playback.pause()
- elif action == "resume":
- await mopidy.playback.resume()
- elif action == "shuffle":
- await mopidy.tracklist.shuffle()
- await mopidy.disconnect()
- async def run_floppy(input):
- link = input.split(" - ")[1]
- mopidy = await MopidyClient().connect()
- await mopidy.playback.stop()
- await mopidy.tracklist.clear()
- await mopidy.tracklist.add(uris=[link])
- await mopidy.playback.play()
- await mopidy.disconnect()
- asyncio.run(selector())
|