mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
Split test and lint workflows (#1183)
This commit is contained in:
parent
2243e135df
commit
84f8b0a64b
10
.github/workflows/integration_tests.yml
vendored
10
.github/workflows/integration_tests.yml
vendored
@ -9,17 +9,19 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
SPOTIPY_CLIENT_ID: ${{ secrets.SPOTIPY_CLIENT_ID }}
|
SPOTIPY_CLIENT_ID: ${{ secrets.SPOTIPY_CLIENT_ID }}
|
||||||
SPOTIPY_CLIENT_SECRET: ${{ secrets.SPOTIPY_CLIENT_SECRET }}
|
SPOTIPY_CLIENT_SECRET: ${{ secrets.SPOTIPY_CLIENT_SECRET }}
|
||||||
PYTHON_VERSION: "3.10"
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install .[test]
|
pip install .
|
||||||
- name: Run non user endpoints integration tests
|
- name: Run non user endpoints integration tests
|
||||||
run: |
|
run: |
|
||||||
python -m unittest discover -v tests/integration/non_user_endpoints
|
python -m unittest discover -v tests/integration/non_user_endpoints
|
||||||
|
|||||||
24
.github/workflows/lint.yml
vendored
Normal file
24
.github/workflows/lint.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.x" # Lint can be done on latest Python only
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install .[test]
|
||||||
|
- name: Check pep8 with flake8
|
||||||
|
run: |
|
||||||
|
flake8 . --count --show-source --statistics
|
||||||
|
- name: Check sorted imports with isort
|
||||||
|
run: |
|
||||||
|
isort . -c
|
||||||
@ -1,6 +1,6 @@
|
|||||||
name: Tests
|
name: Unit tests
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -18,12 +18,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install .[test]
|
pip install .
|
||||||
- name: Lint with flake8
|
|
||||||
run: |
|
|
||||||
pip install -Iv enum34==1.1.6 # https://bitbucket.org/stoneleaf/enum34/issues/27/enum34-118-broken
|
|
||||||
pip install flake8
|
|
||||||
flake8 . --count --show-source --statistics
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: |
|
run: |
|
||||||
python -m unittest discover -v tests/unit
|
python -m unittest discover -v tests/unit
|
||||||
@ -40,6 +40,10 @@ Add your changes below.
|
|||||||
- category_playlists
|
- category_playlists
|
||||||
- Added FAQ entry for inaccessible playlists
|
- Added FAQ entry for inaccessible playlists
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Split test and lint workflows
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Audiobook integration tests
|
- Audiobook integration tests
|
||||||
- Edited docstrings for certain functions in client.py for functions that are no longer in use and have been replaced.
|
- Edited docstrings for certain functions in client.py for functions that are no longer in use and have been replaced.
|
||||||
|
|||||||
@ -29,7 +29,7 @@ $ source env/bin/activate
|
|||||||
|
|
||||||
### Lint
|
### Lint
|
||||||
|
|
||||||
To automatically fix the code style:
|
To automatically fix some of the code style:
|
||||||
|
|
||||||
pip install autopep8
|
pip install autopep8
|
||||||
autopep8 --in-place --aggressive --recursive .
|
autopep8 --in-place --aggressive --recursive .
|
||||||
@ -42,7 +42,11 @@ To verify the code style:
|
|||||||
To make sure if the import lists are stored correctly:
|
To make sure if the import lists are stored correctly:
|
||||||
|
|
||||||
pip install isort
|
pip install isort
|
||||||
isort . -c -v
|
isort . -c
|
||||||
|
|
||||||
|
Sort them automatically with:
|
||||||
|
|
||||||
|
isort .
|
||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,8 @@
|
|||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: add_saved_episodes.py -e episode_id episode_id ...
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: add_saved_shows.py -s show_id show_id ...
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,10 @@ Run app.py
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from flask import Flask, session, request, redirect
|
|
||||||
|
from flask import Flask, redirect, request, session
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
logger = logging.getLogger('examples.artist_albums')
|
logger = logging.getLogger('examples.artist_albums')
|
||||||
logging.basicConfig(level='INFO')
|
logging.basicConfig(level='INFO')
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
logger = logging.getLogger('examples.artist_discography')
|
logger = logging.getLogger('examples.artist_discography')
|
||||||
logging.basicConfig(level='INFO')
|
logging.basicConfig(level='INFO')
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import logging
|
|||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('examples.artist_recommendations')
|
logger = logging.getLogger('examples.artist_recommendations')
|
||||||
logging.basicConfig(level='INFO')
|
logging.basicConfig(level='INFO')
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
# shows audio analysis for the given track
|
# shows audio analysis for the given track
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import json
|
import json
|
||||||
import spotipy
|
|
||||||
import time
|
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
# shows acoustic features for tracks for the given artist
|
# shows acoustic features for tracks for the given artist
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import json
|
import json
|
||||||
import spotipy
|
|
||||||
import time
|
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import spotipy
|
import matplotlib.pyplot as plt
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
|
|
||||||
# Import the extra necessary libraries for this example
|
# Import the extra necessary libraries for this example
|
||||||
# These libraries are not included in the default packages
|
# These libraries are not included in the default packages
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import seaborn as sns
|
import seaborn as sns
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
# Set up Spotify credentials
|
# Set up Spotify credentials
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
# shows acoustic features for tracks for the given artist
|
# shows acoustic features for tracks for the given artist
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import json
|
import json
|
||||||
import spotipy
|
|
||||||
import time
|
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: check_show_is_saved -s show_id show_id ...
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: delete_saved_episodes.py -e episode_id episode_id ...
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# Follow a playlist
|
# Follow a playlist
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: get_audiobooks_chapters_info.py -a audiobook_id
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -4,9 +4,11 @@ Usage: get_audiobooks_info.py -a audiobook_id audiobook_id ...
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser(description='Get information for a list of audiobooks')
|
parser = argparse.ArgumentParser(description='Get information for a list of audiobooks')
|
||||||
# Defaults set to The Great Gatsby, The Chronicles of Narnia and Dune
|
# Defaults set to The Great Gatsby, The Chronicles of Narnia and Dune
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import spotipy
|
import spotipy
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
# set open_browser=False to prevent Spotipy from attempting to open the default browser
|
# set open_browser=False to prevent Spotipy from attempting to open the default browser
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
|
from pprint import pprint
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
import spotipy.util as util
|
import spotipy.util as util
|
||||||
|
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
username = input("Type the Spotify user ID to use: ")
|
username = input("Type the Spotify user ID to use: ")
|
||||||
token = util.prompt_for_user_token(username, show_dialog=True)
|
token = util.prompt_for_user_token(username, show_dialog=True)
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import spotipy
|
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
|
||||||
|
|
||||||
# Import the extra necessary libraries for this example
|
# Import the extra necessary libraries for this example
|
||||||
# These libraries are not included in the default packages
|
# These libraries are not included in the default packages
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from sklearn.cluster import KMeans
|
from sklearn.cluster import KMeans
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
# Set up Spotify credentials
|
# Set up Spotify credentials
|
||||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
|
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
|
||||||
client_id="YOUR_APP_CLIENT_ID",
|
client_id="YOUR_APP_CLIENT_ID",
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import spotipy
|
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
scope = "user-read-playback-state,user-modify-playback-state"
|
scope = "user-read-playback-state,user-modify-playback-state"
|
||||||
sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))
|
sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# get all non-local tracks of a playlist
|
# get all non-local tracks of a playlist
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
# playlist id of global top 50
|
# playlist id of global top 50
|
||||||
PlaylistExample = '37i9dQZEVXbMDoHDwVN2tF'
|
PlaylistExample = '37i9dQZEVXbMDoHDwVN2tF'
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
|
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
|
||||||
|
|
||||||
pl_id = 'spotify:playlist:5RIbzhG2QqdkaP24iXLnZX'
|
pl_id = 'spotify:playlist:5RIbzhG2QqdkaP24iXLnZX'
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import sys
|
|||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
playlist_id = sys.argv[1]
|
playlist_id = sys.argv[1]
|
||||||
track_ids = sys.argv[2:]
|
track_ids = sys.argv[2:]
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
# shows artist info for a URN or URL
|
# shows artist info for a URN or URL
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
|
||||||
import pprint
|
import pprint
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
search_str = sys.argv[1]
|
search_str = sys.argv[1]
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
# shows album info for a URN or URL
|
# shows album info for a URN or URL
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
import sys
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
urn = sys.argv[1]
|
urn = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
# shows artist info for a URN or URL
|
# shows artist info for a URN or URL
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
import sys
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
urn = sys.argv[1]
|
urn = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
# shows artist info for a URN or URL
|
# shows artist info for a URN or URL
|
||||||
# scope is not required for this function
|
# scope is not required for this function
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
urn = sys.argv[1]
|
urn = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
# usage: python tracks.py [artist name]
|
# usage: python tracks.py [artist name]
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
# usage: featured_artists.py spotify:album:[album urn]
|
# usage: featured_artists.py spotify:album:[album urn]
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import sys
|
import sys
|
||||||
import spotipy
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
urn = sys.argv[1]
|
urn = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
# shows related artists for the given seed artist
|
# shows related artists for the given seed artist
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
artist_name = sys.argv[1]
|
artist_name = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
# shows track info for a URN or URL
|
# shows track info for a URN or URL
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
import sys
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
urn = sys.argv[1]
|
urn = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
given a list of track IDs show the artist and track name
|
given a list of track IDs show the artist and track name
|
||||||
'''
|
'''
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
|
||||||
import spotipy
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser(description='Print artist and track name given a list of track IDs')
|
parser = argparse.ArgumentParser(description='Print artist and track name given a list of track IDs')
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
# Shows artist info for a URN or URL
|
# Shows artist info for a URN or URL
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import sys
|
|
||||||
import pprint
|
import pprint
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
username = sys.argv[1]
|
username = sys.argv[1]
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
|
birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
lz_uri = 'spotify:artist:36QJpDe2go2KgaRleHCDTp'
|
lz_uri = 'spotify:artist:36QJpDe2go2KgaRleHCDTp'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import spotipy
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
spotify = spotipy.Spotify(auth_manager=spotipy.SpotifyOAuth())
|
spotify = spotipy.Spotify(auth_manager=spotipy.SpotifyOAuth())
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
client_credentials_manager = SpotifyClientCredentials()
|
client_credentials_manager = SpotifyClientCredentials()
|
||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
# Shows the name of the artist/band and their image by giving a link
|
# Shows the name of the artist/band and their image by giving a link
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
|
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
|
||||||
import spotipy
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
'''
|
'''
|
||||||
generates a list of songs where the first word in each subsequent song
|
generates a list of songs where the first word in each subsequent song
|
||||||
matches the last word of the previous song.
|
matches the last word of the previous song.
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
import random
|
|
||||||
|
|
||||||
# Set up Spotify credentials
|
# Set up Spotify credentials
|
||||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
|
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# Shows a user's playlists (need to be authenticated via oauth)
|
# Shows a user's playlists (need to be authenticated via oauth)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: user_saved_episodes -l <num> -o <num>
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Usage: user_saved_shows -l <num> -o <num>
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|||||||
8
setup.py
8
setup.py
@ -8,7 +8,13 @@ memcache_cache_reqs = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
extra_reqs = {
|
extra_reqs = {
|
||||||
'memcache': memcache_cache_reqs
|
'memcache': [
|
||||||
|
'pymemcache>=3.5.2'
|
||||||
|
],
|
||||||
|
'test': [
|
||||||
|
'flake8>=7.1.1',
|
||||||
|
'isort>=5.13.2'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|||||||
@ -11,10 +11,11 @@ import errno
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from spotipy.util import CLIENT_CREDS_ENV_VARS
|
|
||||||
|
|
||||||
from redis import RedisError
|
from redis import RedisError
|
||||||
|
|
||||||
|
from spotipy.util import CLIENT_CREDS_ENV_VARS
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,14 +6,13 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import warnings
|
import warnings
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from spotipy.exceptions import SpotifyException
|
from spotipy.exceptions import SpotifyException
|
||||||
from spotipy.util import Retry
|
from spotipy.util import Retry
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,14 +11,14 @@ import base64
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import urllib.parse as urllibparse
|
||||||
import warnings
|
import warnings
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
import requests
|
|
||||||
import urllib.parse as urllibparse
|
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from urllib.parse import parse_qsl, urlparse
|
from urllib.parse import parse_qsl, urlparse
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
from spotipy.cache_handler import CacheFileHandler, CacheHandler
|
from spotipy.cache_handler import CacheFileHandler, CacheHandler
|
||||||
from spotipy.exceptions import SpotifyOauthError, SpotifyStateError
|
from spotipy.exceptions import SpotifyOauthError, SpotifyStateError
|
||||||
from spotipy.util import CLIENT_CREDS_ENV_VARS, get_host_port, normalize_scope
|
from spotipy.util import CLIENT_CREDS_ENV_VARS, get_host_port, normalize_scope
|
||||||
|
|||||||
@ -9,10 +9,10 @@ import os
|
|||||||
import warnings
|
import warnings
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
|
|
||||||
import spotipy
|
|
||||||
|
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CLIENT_CREDS_ENV_VARS = {
|
CLIENT_CREDS_ENV_VARS = {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import base64
|
import base64
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
from spotipy import (
|
|
||||||
Spotify,
|
|
||||||
SpotifyClientCredentials,
|
|
||||||
SpotifyException
|
|
||||||
)
|
|
||||||
import spotipy
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
from spotipy import Spotify, SpotifyClientCredentials, SpotifyException
|
||||||
|
|
||||||
|
|
||||||
class AuthTestSpotipy(unittest.TestCase):
|
class AuthTestSpotipy(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from spotipy import (
|
|
||||||
CLIENT_CREDS_ENV_VARS as CCEV,
|
|
||||||
prompt_for_user_token,
|
|
||||||
Spotify,
|
|
||||||
SpotifyException,
|
|
||||||
SpotifyImplicitGrant,
|
|
||||||
SpotifyPKCE
|
|
||||||
)
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from spotipy import CLIENT_CREDS_ENV_VARS as CCEV
|
||||||
|
from spotipy import (Spotify, SpotifyException, SpotifyImplicitGrant,
|
||||||
|
SpotifyPKCE, prompt_for_user_token)
|
||||||
from tests import helpers
|
from tests import helpers
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import unittest.mock as mock
|
import unittest.mock as mock
|
||||||
import urllib.parse as urllibparse
|
import urllib.parse as urllibparse
|
||||||
|
|
||||||
from spotipy import SpotifyOAuth, SpotifyImplicitGrant, SpotifyPKCE
|
from spotipy import SpotifyImplicitGrant, SpotifyOAuth, SpotifyPKCE
|
||||||
from spotipy.cache_handler import MemoryCacheHandler
|
from spotipy.cache_handler import MemoryCacheHandler
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials, SpotifyOauthError
|
from spotipy.oauth2 import (SpotifyClientCredentials, SpotifyOauthError,
|
||||||
from spotipy.oauth2 import SpotifyStateError
|
SpotifyStateError)
|
||||||
|
|
||||||
patch = mock.patch
|
patch = mock.patch
|
||||||
DEFAULT = mock.DEFAULT
|
DEFAULT = mock.DEFAULT
|
||||||
@ -487,8 +486,8 @@ class TestSpotifyPKCE(unittest.TestCase):
|
|||||||
self.assertTrue(auth.code_challenge)
|
self.assertTrue(auth.code_challenge)
|
||||||
|
|
||||||
def test_code_verifier_and_code_challenge_are_correct(self):
|
def test_code_verifier_and_code_challenge_are_correct(self):
|
||||||
import hashlib
|
|
||||||
import base64
|
import base64
|
||||||
|
import hashlib
|
||||||
auth = SpotifyPKCE("CLID", "REDIR")
|
auth = SpotifyPKCE("CLID", "REDIR")
|
||||||
auth.get_pkce_handshake_parameters()
|
auth.get_pkce_handshake_parameters()
|
||||||
self.assertEqual(auth.code_challenge,
|
self.assertEqual(auth.code_challenge,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user