Browse Source

Add arguments, update README

pull/3/head
Wesley Kerfoot 5 years ago
parent
commit
e3430a1a80
  1. 23
      spotify_mpd_sync/msplaylist/spotify.py

23
spotify_mpd_sync/msplaylist/spotify.py

@ -11,11 +11,12 @@ from collections import defaultdict
from re import sub
from os import environ
import spotipy.util as util
import argparse
from spotify_mpd_sync.msplaylist.authenticate import prompt_for_user_token
class Spotify():
def __init__(self):
def __init__(self, host="localhost", port=6600):
self.username = environ.get("SPOTIFY_USERNAME")
scope = "playlist-read-private"
@ -25,7 +26,7 @@ class Spotify():
self.sp = spotipy.Spotify(auth=token)
self.mpd_client = MPDClient()
self.mpd_client.connect("127.0.0.1", 6600)
self.mpd_client.connect(host, port)
self._playlists = defaultdict(lambda: [])
@ -89,5 +90,21 @@ class Spotify():
def run_sync():
spotify = Spotify()
parser = argparse.ArgumentParser()
parser.add_argument("-H",
"--host",
default="localhost",
help="The MPD server you would like spotsync to use, defaults localhost")
parser.add_argument("-P",
"--port",
type=int,
default=6600,
help="The MPD port you would like spotsync to use, defaults to 6600")
args = parser.parse_args()
spotify = Spotify(host=args.host,
port=args.port)
spotify.persist_playlists()

Loading…
Cancel
Save