forked from sigma67/spotify_to_ytmusic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to oauth authentication for MobileClient and update Readme
- Loading branch information
Benedikt Putz
committed
Dec 10, 2018
1 parent
15f023b
commit bd680cf
Showing
8 changed files
with
45 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ venv.bak/ | |
.mypy_cache/ | ||
|
||
# specific | ||
.idea/ | ||
noresults.txt | ||
*.ini | ||
*.cred | ||
*.txt |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import sys | ||
import settings | ||
from gmusicapi import Musicmanager | ||
|
||
credentials = u'./oauth.cred' | ||
|
||
class GoogleMusicManager: | ||
def __init__(self): | ||
self.api = Musicmanager(debug_logging=False) | ||
self.api.login(credentials) | ||
self.api.login(settings['google']['musicmanager']) | ||
|
||
def upload_song(self, file): | ||
self.api.upload(file) | ||
|
||
if __name__ == "__main__": | ||
if sys.argv[0] == "setup": | ||
api = Musicmanager(debug_logging=True) | ||
api.perform_oauth(credentials) | ||
exit() | ||
|
||
gmusic = GoogleMusicManager() | ||
gmusic.upload_song(sys.argv[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
# spotifyplaylist_to_gmusic | ||
A simple script to clone a Spotify playlist to Google Play Music. | ||
|
||
Initially you should create a new settings.ini containing your credentials for Google Play Music and Spotify. | ||
Initially you should create a new settings.ini containing your Spotify credentials. Simply copy settings.ini.example to a new file settings.ini and fill in your client_id and client_secret from https://developer.spotify.com/my-applications | ||
|
||
For Google Play Music, get an app password from https://myaccount.google.com/apppasswords. | ||
For Google Play Music, run | ||
|
||
For Spotify, get your client_id and client_secret from https://developer.spotify.com/my-applications | ||
`python Setup.py <client>` | ||
|
||
After you've create the settings file, you can simply run the script from the command line using | ||
and follow the command line instructions to grant the app access to your account. All credentials are stored locally in the file `settings.ini`. | ||
|
||
Replace `<client>` with `mobileclient` to setup playlist transfers. Replace with `musicmanager` to be able to upload files with GoogleMusicManager.py. | ||
|
||
After you've created the settings file, you can simply run the script from the command line using | ||
|
||
`python GoogleMusic.py <spotifylink>` | ||
|
||
where `<spotifylink>` is a link like https://open.spotify.com/user/edmsauce/playlist/3yGp845Tz2duWCORALQHFO | ||
|
||
|
||
The script will log its progress and output songs that were not found in Google Play Music to **noresults.txt**. | ||
|
||
|
||
To upload songs, run | ||
|
||
`python GoogleMusic.py <filepath>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sys | ||
import settings | ||
from gmusicapi import Musicmanager, Mobileclient | ||
|
||
if __name__ == "__main__": | ||
if sys.argv[1] == "mobileclient": | ||
api = Mobileclient(debug_logging=True) | ||
settings['google']['mobileclient'] = api.perform_oauth(open_browser=True).to_json() | ||
elif sys.argv[1] == "musicmanager": | ||
api = Musicmanager(debug_logging=True) | ||
settings['google']['musicmanager'] = api.perform_oauth(open_browser=True).to_json() | ||
settings.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
[google] | ||
email = [email protected] | ||
password = 123kd72k1h | ||
|
||
|
||
[spotify] | ||
client_id = id_from_developer_console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters