Skip to content

Commit

Permalink
added readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
GurungAman committed Jul 21, 2021
1 parent 829507e commit b58c401
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
client_id = ""
playlist_url = ""
spotify_client_id = "spotify-client-id-here"
playlist_url = "spotify-playlist-url-here"
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Spotify to Youtube Playlist Converter

Converts your playlist from spotify to youtube.

## How does it Work?
You will need to have a valid spotify and youtube account to use this. Then, you will need to configure some settings to make this script work.
Check instructions below on how configure those settings.

## Instructions:

1. Register and create an app from spotify [dashboard](https://developer.spotify.com/dashboard/). Spotify will provide you with a Client ID.
- In .env file copy and paste the id inside "spotify_client_id".
- Copy the url of spotify playlist thay you want to convert and paste it in "playlist_url".
- Inside your spoitfy application open edit settings and set Redirect URI to :```http://127.0.0.1:8000/```

2. Open [google develoeprs console](https://console.cloud.google.com/apis/credentials).
- Create a new project.
- Search for "YouTube Data API v3" in Library and enable it for your app.
- To use this API you will need to create credentials. But before that you will need to create oauth consent.
- On OAuth consent screen select User Type External and create.
- Fill up the app registration form.
- Add ../auth/youtube scope.
- And add your email in test users.
- Now, from Credentials, Create OAuth client ID.
- Set application type to web application.
- Set Authorized redirect URI: ```http://127.0.0.1:8888/```
- An OAuth client will be created. Download the json file and move it to your working directory. And rename it to ```client_secret.json```.

3. Create a virtual environment and install requirements.
- Create venv: ```python3 -m venv env```
- Install requirements: ```pip install requirements.txt```
- Activate venv: ```source env/bin/activate```

4. Run the script as ```python3 playlist-converter.py```.
- The browser will open and request for Spotify access. On granting access, you will be redirected to a different url.
- Copy and paste the redirected url to the console.
- The browser will open again and ask for Youtube acces. On granting acces to youtube, it will create the playlist and songs from the spotify playlist.

## Notes:
- Do not set redirected URI of YouTube and Spotify to the same port.
- Make sure the ports are not being used.
- There is a strict limit on api request to Youtube API. You can find more about it from [here](https://developers.google.com/youtube/v3/getting-started#quota).

## Refrences:
- Spotify Authorization flow: [authorization guide](https://developer.spotify.com/documentation/general/guides/authorization-guide/
)
- [Youtube Api](https://developers.google.com/youtube/v3/getting-started)
2 changes: 1 addition & 1 deletion SpotifyAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SpotifyApi:
def __init__(self) -> None:
self.client_id = config("client_id")
self.client_id = config("spotify_client_id")
self.base_url = "https://accounts.spotify.com"
self.redirect_uri = "http://127.0.0.1:8000/"
self.spotify_api= f"https://api.spotify.com/v1/playlists"
Expand Down
1 change: 0 additions & 1 deletion playlist-converter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from requests.api import patch
from SpotifyAPI import SpotifyApi
from YoutubeAPI import YoutubeApi

Expand Down

0 comments on commit b58c401

Please sign in to comment.