Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally import credentials from external file and resolve #28 #29

Merged
merged 2 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.DS_Store
.project
.pydevproject
.pydevproject
credentials.py
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@ These are incredibly simple scripts, but do require a few small configurations.
* If you do not have pip or are running windows, please see [Unofficial Google Music API usage](http://unofficial-google-music-api.readthedocs.org/en/latest/usage.html)

### Change login credentials
* Near line 89, change the 'username' and 'password' to your Google account credentials.
* Near line 12 in the script, change the 'username' and 'password' to your Google account credentials.
* Alternatively, create an empty file called 'credentials.py' in the script directory and set the username and password variables there.

```python
# credentials.py
username = '[email protected]'
password = 'changeme'
#android_id = 'deadbeefc0decafe'
```

* NOTE: Users with 2-step authentication enabled will have to create an App Specific Key/Password.
Login into your Google account and head to https://security.google.com/settings/security/apppasswords, there you will be able to manually generate an App Specific password.
After creating the Key/Password, just use it to login into this App, together with your usual Google username/email.

* NOTE: If you see the error message "a valid MAC could not be determined."
you are running into a [known issue](https://github.com/simon-weber/gmusicapi/issues/408) with the Google Music API.
To workaround, set a new 16 digit hexadecimal number as your android_id on line 17 or in credentials.py.

### Run kill_dupes
* The script will automatically detect and remove duplicates on any songs in your library.

Expand Down
17 changes: 16 additions & 1 deletion kill_dupes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ import sys

from gmusicapi import Mobileclient

try:
import credentials
# credentials.py is in .gitignore and can be shared with other scripts
username = credentials.username
password = credentials.password
except ImportError:
username = 'username'
password = 'password'

try:
# optionally hardcode id to workaround https://github.com/simon-weber/gmusicapi/issues/408
android_id = credentials.android_id
except (NameError, AttributeError):
android_id = Mobileclient.FROM_MAC_ADDRESS


def map_track_duplication(tracks):
album_track_duplicate_map = {}
Expand Down Expand Up @@ -109,7 +124,7 @@ def get_track_ids(tracks):


api = Mobileclient()
logged_in = api.login('username', 'password', Mobileclient.FROM_MAC_ADDRESS)
logged_in = api.login(username, password, android_id)

if logged_in:
print("Successfully logged in. Beginning duplicate detection process.")
Expand Down
17 changes: 15 additions & 2 deletions kill_playlist_dupes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ import sys

from gmusicapi import Mobileclient


try:
import credentials
# credentials.py is in .gitignore and can be shared with other scripts
username = credentials.username
password = credentials.password
except ImportError:
username = 'username'
password = 'password'

try:
# optionally hardcode id to workaround https://github.com/simon-weber/gmusicapi/issues/408
android_id = credentials.android_id
except (NameError, AttributeError):
android_id = Mobileclient.FROM_MAC_ADDRESS

def get_dupes_in_playlist(playlist):
duplicate_Ids = []
Expand Down Expand Up @@ -58,7 +71,7 @@ def query_yes_no(question, default="yes"):


api = Mobileclient()
logged_in = api.login('username', 'password', Mobileclient.FROM_MAC_ADDRESS)
logged_in = api.login(username, password, android_id)

if logged_in:
print("Successfully logged in. Beginning duplicate detection process.")
Expand Down