コード例 #1
0
def start():

    sslcontext = ssl.create_default_context(cafile=certifi.where())
    conn = aiohttp.TCPConnector(ssl_context=sslcontext)

    with ClientSession(connector=conn) as session:

        google_email = input("Enter Google email address: ")
        google_pass = getpass("Enter Google password: "******"Invalid Google username/password")
            sys.exit(1)

        uprint("Go to {0} and get an oauth token".format(OAUTH_URL))
        spotify_token = input("Enter Spotify oauth token: ")

        s = SpotifyClient(session, spotify_token)

        logged_in = yield from s.loggedin()
        if not logged_in:
            uprint("Invalid Spotify token")
            sys.exit(1)

        playlists = yield from s.fetch_spotify_playlists()
        playlists = [l['uri'] for l in playlists]
        yield from app.transfer_playlists(None, s, g, playlists)
コード例 #2
0
ファイル: copy_all.py プロジェクト: Wasson101/pyportify
def start():

    sslcontext = ssl.create_default_context(cafile=certifi.where())
    conn = aiohttp.TCPConnector(ssl_context=sslcontext)

    with ClientSession(connector=conn) as session:

        google_email = input("Enter Google email address: ")
        google_pass = getpass("Enter Google password: "******"Invalid Google username/password")
            sys.exit(1)

        uprint("Go to {0} and get an oauth token".format(OAUTH_URL))
        spotify_token = input("Enter Spotify oauth token: ")

        s = SpotifyClient(session, spotify_token)

        logged_in = yield from s.loggedin()
        if not logged_in:
            uprint("Invalid Spotify token")
            sys.exit(1)

        playlists = yield from s.fetch_spotify_playlists()
        yield from app.transfer_playlists(None, s, g, playlists)
コード例 #3
0
def start():
    sslcontext = ssl.create_default_context(cafile=certifi.where())
    conn = aiohttp.TCPConnector(ssl_context=sslcontext)

    with ClientSession(connector=conn) as session:
        conf = dict(
            google_email=None,
            google_pass=None,
            spotify_token=None,
        )

        try:
            with open(CONFIG_FILE, 'r') as f:
                conf.update(yaml.load(f))
        except Exception as exc:
            if not os.path.exists(CONFIG_FILE):
                log.info('Could not load from config file {}: {}'.format(
                    CONFIG_FILE, exc))

        if not conf['google_email']:
            conf['google_email'] = input("Enter Google email address: ")
        if not conf['google_pass']:
            conf['google_pass'] = getpass("Enter Google password: "******"Invalid Google username/password")
            sys.exit(1)

        if not conf['spotify_token']:
            log.info("Go to {0} and get an oauth token".format(OAUTH_URL))
            conf['spotify_token'] = input("Enter Spotify oauth token: ")

        s = SpotifyClient(session, conf['spotify_token'])

        logged_in = yield from s.loggedin()
        if not logged_in:
            log.info("Invalid Spotify token")
            sys.exit(1)

        log.info('Caching all playlists from Google')
        if os.path.exists('google_playlists.pickle'):
            with open('google_playlists.pickle', 'rb') as f:
                g._playlists = pickle.load(f)
        else:
            yield from g.cache_playlists()
            with open('google_playlists.pickle', 'wb') as f:
                pickle.dump(g._playlists, f)

        log.info('Fetching Spotify playlists')
        playlists = yield from s.fetch_spotify_playlists()

        log.info('Starting sync')
        done = yield from app.transfer_playlists(None, s, g, playlists)
        log.debug('done=%s', done)

        log.info('Success!')
コード例 #4
0
def spotify_playlists(request):
    with ClientSession() as session:
        c = SpotifyClient(session, user_scope.spotify_token)
        ret_playlists = yield from c.fetch_spotify_playlists()
        return json_response({
            "status": 200,
            "message": "ok",
            "data": ret_playlists
        })
コード例 #5
0
ファイル: app.py プロジェクト: Wasson101/pyportify
def spotify_playlists(request):
    with ClientSession() as session:
        c = SpotifyClient(session, user_scope.spotify_token)
        ret_playlists = yield from c.fetch_spotify_playlists()
        return json_response({
            "status": 200,
            "message": "ok",
            "data": ret_playlists
        })
コード例 #6
0
ファイル: copy_user_playlist.py プロジェクト: atinm/pyportify
def start():

    sslcontext = ssl.create_default_context(cafile=certifi.where())
    conn = aiohttp.TCPConnector(ssl_context=sslcontext)

    with ClientSession(connector=conn) as session:

        google_email = input("Enter Google email address: ")
        google_pass = getpass("Enter Google password: "******"Invalid Google username/password")
            sys.exit(1)

        user_id = input("Enter Spotify User to copy playlist from: ")
        playlist = input(
            "Enter the User's Spotify playlist you want to copy: ")
        explicit = input("Enter Y if you want to include explicit songs: ")
        if explicit == 'Y':
            content_type = 'E'
        else:
            content_type = 'R'

        uprint("Go to {0} and get an oauth token".format(OAUTH_URL))
        spotify_token = input("Enter Spotify oauth token: ")

        s = SpotifyClient(session, spotify_token, user_id)

        logged_in = yield from s.loggedin()
        if not logged_in:
            uprint("Invalid Spotify token")
            sys.exit(1)

        playlists = yield from s.fetch_spotify_playlists()
        yield from app.transfer_playlists(None, s, g, playlist, content_type,
                                          playlists)
コード例 #7
0
ファイル: copy_user_playlist.py プロジェクト: atinm/pyportify
def start():

    sslcontext = ssl.create_default_context(cafile=certifi.where())
    conn = aiohttp.TCPConnector(ssl_context=sslcontext)

    with ClientSession(connector=conn) as session:

        google_email = input("Enter Google email address: ")
        google_pass = getpass("Enter Google password: "******"Invalid Google username/password")
            sys.exit(1)

        user_id = input("Enter Spotify User to copy playlist from: ")
        playlist = input("Enter the User's Spotify playlist you want to copy: ")
        explicit = input("Enter Y if you want to include explicit songs: ")
        if explicit == 'Y':
            content_type = 'E'
        else:
            content_type = 'R'

        uprint("Go to {0} and get an oauth token".format(OAUTH_URL))
        spotify_token = input("Enter Spotify oauth token: ")

        s = SpotifyClient(session, spotify_token, user_id)

        logged_in = yield from s.loggedin()
        if not logged_in:
            uprint("Invalid Spotify token")
            sys.exit(1)

        playlists = yield from s.fetch_spotify_playlists()
        yield from app.transfer_playlists(None, s, g, playlist, content_type, playlists)