45 lines
1020 B
Python
45 lines
1020 B
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import curses
|
|
import argparse
|
|
|
|
from .auth import SpotifyAuth
|
|
from .client import SpotifyClient
|
|
from .ui import UI
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="spotify-cli - Terminal Spotify Client")
|
|
parser.add_argument("--login", action="store_true", help="Neu einloggen")
|
|
parser.add_argument("--logout", action="store_true", help="Ausloggen")
|
|
args = parser.parse_args()
|
|
|
|
auth = SpotifyAuth()
|
|
|
|
if args.logout:
|
|
auth.logout()
|
|
return
|
|
|
|
if args.login:
|
|
auth._full_auth()
|
|
return
|
|
|
|
token = auth.get_token()
|
|
if not token:
|
|
print("Nicht eingelogged. Fuehre 'spotify-cli --login' aus.")
|
|
sys.exit(1)
|
|
|
|
client = SpotifyClient(token)
|
|
|
|
try:
|
|
client.get_current_user()
|
|
except Exception:
|
|
print("Token abgelaufen. Bitte erneut einloggen: spotify-cli --login")
|
|
sys.exit(1)
|
|
|
|
curses.wrapper(lambda stdscr: UI(stdscr, client).run())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|