From 104d92d246bea7cfc230da60227e77c12aad606f Mon Sep 17 00:00:00 2001 From: very-doge-wow Date: Mon, 1 Jan 2024 13:26:51 +0100 Subject: [PATCH] docs: readme --- .gitignore | 132 ++++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 72 ++++++++++++++++++++++++++ README.md | 46 ++++++++++++----- app.py | 2 +- 4 files changed, 238 insertions(+), 14 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.gitignore b/.gitignore index 18ac92f..868bb0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,135 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ +.idea/ + +# Custom __pycache__ .idea lol.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8f894f2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,72 @@ +# Contributing to `amazify` + +I love your input! I want to make contributing to this project as easy and +transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features +- Becoming a maintainer + +## Develop with GitHub + +I use GitHub to host code, to track issues and feature requests, as well as +accept pull requests. + +## Use GitHub Flow + +All code changes happen through Pull Requests. + +Pull requests are the best way to propose changes to the codebase +(I use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow)). +I actively welcome your pull requests: + +1. Fork the repo and create your branch from `main`. +2. If you've added code that should be tested, add tests. +3. If you've changed behavior, update the documentation. +4. Ensure the tests pass (locally and in GitHub). +5. Make sure your code lints. +6. Open a pull request! + +## Any contributions you make will be under the MIT Software License + +In short, when you submit code changes, your submissions are understood +to be under the same [MIT License](http://choosealicense.com/licenses/mit/) +that covers the project. Feel free to contact the maintainers/me if that's a +concern. + +## Report bugs using GitHub Issues + +I use GitHub issues to track public bugs. Report a bug by +[opening a new issue](https://github.com/very-doge-wow/amazify/issues/new/choose). +It's that easy! + +## Write bug reports with detail, background, and sample code + +**Great Bug Reports** tend to have: + +- A quick summary and/or background, explain the context +- What you expected would happen +- What actually happens +- Steps to reproduce + - Be specific! + - Provide sample code. +- Notes (possibly including why you think this might be happening, or stuff + you tried that didn't work) + +## Use a Consistent Coding Style + +Try using the same coding style as other code in the repository. You can try +running a linter for style clarification. However, keep in mind that we +do not want to `die in beauty` - function over form. + +## Use Conventional Commits + +Commits should follow the pattern as specified +[here](https://www.conventionalcommits.org/en/v1.0.0/). + +## References + +This document was adapted from the open-source contribution guidelines for +[Facebook's Draft](https://github.com/facebook/draft-js/blob/main/CONTRIBUTING.md). \ No newline at end of file diff --git a/README.md b/README.md index 8eb0054..8445346 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,48 @@ -# amazify +# 🎵 amazify -Migrate your playlists from Amazon Music to Spotify. +![logo](logo.png) + +Migrate your playlists from Amazon Music to Spotify using a simple Flask web interface. ## Setup and Startup -### Spotify Authentication +### Spotify Authentication via OAuth -First you need to navigate to [developer.spotify.com](https://developer.spotify.com/dashboard) and -create a new app. Use the following as callback URL: +Navigate to [developer.spotify.com](https://developer.spotify.com/dashboard) and +create a new app. Use this as the callback URL: ``` http://127.0.0.1:5000/callback ``` -### Amazon Authentication +### Amazon Authentication (Workaround) -Currently, the Amazon Music API won't let us create applications ourselves without +Currently, the Amazon Music API won't let us create applications for OAuth ourselves without them needing to be approved by Amazon. Since we only want to perform a one-time -migration, we can obtain an OAuth token via Amazon's own API reference, hence elemininating +migration, we can obtain an OAuth token via Amazon's own API reference, hence eliminating the need for us to be able to create our own application. Navigate to [dashboard.music.amazon.dev](https://dashboard.music.amazon.dev/console/api/get-playlist/) and press the button `Get Token` in order to retrieve a valid token. Login using your Amazon Music profile's credentials when prompted. + Copy the resulting token and set it as environment variable as described in the next step. Make sure to also copy the `x-api-key` value as provided in the example `curl` command given on Amazon's website as well. ### Required Environment Variables -Next set some environment variables. Get the client id and client + +Next set these environment variables. Get the client id and client secret from the spotify app you have just created. ```shell -export FLASK_APP=app.py +# client id and client secret of your spotify application export SPOTIFY_CLIENT_ID=XXX export SPOTIFY_CLIENT_SECRET=XXX +# token and x-api-key from the interactive amazon API reference export AMAZON_TOKEN=XXX +# example: amzn1.application.72b599tbc0b549339095eb1234c3c7d1 export AMAZON_X_API_KEY=XXX -export SECRET_KEY=fakekey ``` ### Installation of Dependencies @@ -48,9 +53,24 @@ Install the dependencies using pipenv: pipenv install ``` -### Actual Startup -Next you can start the flask server like this: +### Startup + +Start the flask server like this: ```shell pipenv run python -m flask run ``` + +You can then open the webinterface under the URL `https://127.0.0.1:5000`. +Press the button for authenticating at Spotify before running any migration. +Errors will be printed in the Flask app's log, if any occurred. + +## Caveats + +The following limitations exist: + +1. Do **not** run multiple migrations simultaneously. This will probably result in rate-limits being exceeded and the progress bar breaking. +2. The Amazon token will expire after about `30min`. Keep that in mind when running migrations. +3. The app does **not** check if a playlist with the same name already exists. A new playlist is created each time you start a migration. +4. If a song from the Amazon Playlist is not present in Spotify, the Spotify Search API might return false songs, which will then be added to the playlist. Make sure to check the result after the migration has finished. + diff --git a/app.py b/app.py index 76487f4..b4220ab 100644 --- a/app.py +++ b/app.py @@ -17,7 +17,7 @@ # Startup app = Flask(__name__) -app.secret_key = os.environ['SECRET_KEY'] +app.secret_key = generate_random_string(32) @app.route('/auth/spotify')