https://github.com/manoloesparta/playlist.py
Spotify playlist updater made with python
https://github.com/manoloesparta/playlist.py
playlist-generator python spotify-api
Last synced: 5 months ago
JSON representation
Spotify playlist updater made with python
- Host: GitHub
- URL: https://github.com/manoloesparta/playlist.py
- Owner: manoloesparta
- License: mit
- Created: 2018-11-23T00:07:58.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-25T17:09:48.000Z (over 6 years ago)
- Last Synced: 2024-08-02T13:34:15.347Z (about 1 year ago)
- Topics: playlist-generator, python, spotify-api
- Language: Python
- Homepage:
- Size: 72.3 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> Another way for discovering new music
I tend to listen a lot of albums, but I have more than a 130 albums pending to listen you can find a track from each album in this [playlist](https://open.spotify.com/user/manoloesparta/playlist/1ofx1iXeCqb5gPuEWSanfc?si=gN6ZmmDSQleNc7QLDiTXew). So this little script was made to randomize the way to choose albums to listen :D
It selects randomly 100 albums out of the 130+, and from each selected album, it selects one song randomly, appending all the songs to this other [playlist](https://open.spotify.com/user/manoloesparta/playlist/0iYFyrLsby2E0QBBPs2xWi?si=Yv6aajgYTTyMnEj4jbljWA). This is the playlist I listen daily.
## Requirements
```
git clone https://github.com/manoloesparta/playlist.py
cd playlist.py/
pip install -r requirements.txt
```
## Usage
First you need to create your new Spotify app in [this website](https://developer.spotify.com/dashboard/) in order to get your __Client ID__ and __Client ID Secret__. Then initiate your own __SpotifyUser__ object.
```python
from playlist.spotify import SpotifyUserusername = ' your spotify username '
client_id = ' your client id '
client_secret = ' your client secret id 'spotify_user = SpotifyUser(username, client_id, client_secret)
```
Get the URIs of your playlist from where you are retrieving the albums and songs, and the one you want to append them. ___(In other words your playlist source and playlist goal)___
```python
from playlist.source import Source
from playlist.goal import Goalplaylist_src = ' your playlist source URI '
playlist_goal = ' your playlist goal URI 'source = Source(playlist_src, spotify_user)
goal = Goal(playlist_goal, spotify_user)
```
Just update the playlist goal with your __Source__ object
```python
goal.update(source)
```
## Example
```python
from playlist.spotify import SpotifyUser
from playlist.source import Source
from playlist.goal import Goalusername = 'genericusername'
client_id = '9589a322e8bss2a0bfg6achdaw3cfb02'
client_secret = 'cd0629546544c959ebabcd23fd0239b'
spotify_user = SpotifyUser(username, client_id, client_secret)playlist_src = 'pq1x1iXehjl5gPuEWS54yc'
source = Source(playlist_src, spotify_user)playlist_goal = '45fdyrfrey2E0QBBP8teWi'
goal = Goal(playlist_goal, spotify_user)goal.update(source)
```
_All this data is invented_
## Docker
In order to build succesfully the docker image and run the src/main.py exactly as it is you need to build it with some enviroment variables. You can build it with this command:
```bash
docker build -t playlist.py \
--build-arg user='username' \
--build-arg id='8589a322e8b142a0bf76ac9da43cfb92' \
--build-arg secret='cd0629c79f544c959ebbbbb23fd0239b' \
--build-arg uri='http://google.com/' \
--build-arg src='1ofx1iXeCqb5gPuEWSanfc' \
--build-arg goal='0iYFyrLsby2E0QBBPs2xWi' .
```
For running the docker image:
```bash
docker run --rm -v $(pwd):/usr/src/ -it playlist.py bash
```
## License
This project is licensed under the MIT License