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

Uses new oauth_login from latest develop branch on gmusicapi #273

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MAINTAINER Spencer Julian <[email protected]>

RUN apk update \
&& apk upgrade \
&& apk add --update curl wget bash ruby ruby-bundler python3 python3-dev py3-pip dumb-init musl linux-headers build-base libffi-dev openssl-dev ruby-rdoc ruby-irb\
&& apk add --update git curl wget bash ruby ruby-bundler python3 python3-dev py3-pip libxml2-dev libxslt-dev dumb-init musl linux-headers build-base libffi-dev openssl-dev ruby-rdoc ruby-irb\
&& rm -rf /var/cache/apk/* \
&& mkdir /geemusic

Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ $ source .venv/bin/activate
$ pip3 install -r requirements.txt
```

Once the requirements are installed we'll need to create a file, `.env` to store our credentials. Here's an example:
You must first verify you can do this part, this might exception out and if
you're lucky, you can grab one of the alpha numeric strings at the bottom of
exception string and replace <device_id> below with that alpha numeric device
id.
```
python -c 'from gmusicapi import Mobileclient as MC; m = MC(); print(m.perform_oauth());'
python -c 'from gmusicapi import Mobileclient as MC; m = MC(); print(m.oauth_login("<device_id>")); print(m.get_all_songs()[0])'
```

Once the requirements are installed we'll need to create a file, `.env` to store our credentials. Here's an example:
```
# Google credentials
[email protected]
GOOGLE_PASSWORD=password
DEVICE_ID=device_id

# Publicly accessible URL to your server, WITHOUT trailing slash
APP_URL=https://alexa-geemusic.stevegattuso.me
Expand Down Expand Up @@ -193,8 +199,7 @@ Once you've named your app and the code has been deployed, the next step is to c

| Variable Name | Value |
| ------------- | ------------- |
| GOOGLE_EMAIL | YOUR_EMAIL |
| GOOGLE_PASSWORD | YOUR_PASSWORD |
| DEVICE_ID | YOUR_DEVICE_ID |
| APP_URL | https://[heroku_app_name].herokuapp.com |
| DEBUG_MODE | false |

Expand All @@ -219,7 +224,7 @@ $ docker build -t geemusic .
Finally, run the container with the appropriate environment variables and port forwards. Alternatively set up a compose file or your orchestration engine, but those are outside the scope of this readme.

```bash
$ docker run -d -e [email protected] -e GOOGLE_PASSWORD=[password] \
$ docker run -d -e DEVICE_ID=[device-id] \
-e APP_URL=http://alexa-geemusic.stevegattuso.me -p 5000:5000 geemusic
```

Expand Down
9 changes: 5 additions & 4 deletions geemusic/utils/music.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from builtins import object
from fuzzywuzzy import fuzz, process
from os import getenv
Expand All @@ -9,10 +10,10 @@


class GMusicWrapper(object):
def __init__(self, username, password, logger=None):
def __init__(self, device_id, logger=None):
self._api = Mobileclient()
self.logger = logger
success = self._api.login(username, password, getenv('ANDROID_ID', Mobileclient.FROM_MAC_ADDRESS))
success = self._api.oauth_login(device_id)

if not success:
raise Exception("Unsuccessful login. Aborting!")
Expand Down Expand Up @@ -236,7 +237,7 @@ def get_google_stream_url(self, song_id):
return self._api.get_stream_url(song_id)

def get_stream_url(self, song_id):
return "%s/alexa/stream/%s" % (getenv('APP_URL'), song_id)
return "%s/alexa/stream/%s" % (os.environ['APP_URL'], song_id)

def get_thumbnail(self, artist_art):
return artist_art.replace("http://", "https://")
Expand Down Expand Up @@ -358,5 +359,5 @@ def get_song_data(self, song_id):

@classmethod
def generate_api(cls, **kwargs):
return cls(getenv('GOOGLE_EMAIL'), getenv('GOOGLE_PASSWORD'),
return cls(os.environ['DEVICE_ID'],
**kwargs)
96 changes: 39 additions & 57 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,48 @@
aniso8601==1.2.1
aniso8601==1.2.0
appdirs==1.4.3
argcomplete==1.9.2
asn1crypto==0.24.0
base58==0.2.4
beautifulsoup4==4.6.0
boto3==1.7.16
botocore==1.10.16
certifi==2018.4.16
cffi==1.10.0
cfn-flip==1.0.3
beautifulsoup4==4.6.3
boto3==1.9.61
botocore==1.12.61
certifi==2018.11.29
cffi==1.11.5
chardet==3.0.4
click==6.7
cryptography==2.3.1
decorator==4.1.2
Click==7.0
cryptography==2.1.4
decorator==4.3.0
docutils==0.14
durationpy==0.5
enum34==1.1.6
Flask==0.12.2
Flask-Ask==0.9.8
funcsigs==1.0.2
future==0.16.0
fuzzywuzzy==0.15.1
gmusicapi==10.1.2
Flask==0.12.1
-e git+https://github.com/johnwheeler/flask-ask@fe407646ae404a8c90b363c86d5c4c201b6a5580#egg=Flask_Ask
future==0.17.1
fuzzywuzzy==0.17.0
-e git+https://github.com/simon-weber/gmusicapi@6937a11a26d3e1bf34e13b8bf50f59cb55cbdc03#egg=gmusicapi
gpsoauth==0.4.1
hjson==3.0.1
httplib2==0.10.3
idna==2.5
ipaddress==1.0.18
itsdangerous==0.24
Jinja2==2.9.6
httplib2==0.12.0
idna==2.7
itsdangerous==1.1.0
Jinja2==2.10
jmespath==0.9.3
kappa==0.6.0
lambda-packages==0.19.0
MarkupSafe==1.0
MechanicalSoup==0.7.0
lxml==4.2.5
MarkupSafe==1.1.0
MechanicalSoup==0.11.0
mock==2.0.0
mutagen==1.38
oauth2client==4.1.2
pbr==3.1.1
placebo==0.8.1
mutagen==1.41.1
oauth2client==4.1.3
pbr==5.1.1
proboscis==1.2.6.0
protobuf==3.3.0
pyasn1==0.3.2
pyasn1-modules==0.0.11
pycparser==2.18
pycryptodomex==3.4.6
pyOpenSSL==17.2.0
python-dateutil==2.6.1
python-Levenshtein==0.12.0
python-slugify==1.2.4
PyYAML==3.13
requests==2.18.3
rsa==3.4.2
protobuf==3.6.1
pyasn1==0.4.4
pyasn1-modules==0.2.2
pycparser==2.19
pycryptodomex==3.7.2
pyOpenSSL==17.0.0
python-dateutil==2.7.5
PyYAML==3.12
requests==2.20.1
rsa==4.0
s3transfer==0.1.13
six==1.10.0
testfixtures==6.2.0
toml==0.9.4
tqdm==4.19.1
troposphere==2.2.1
Unidecode==1.0.22
urllib3==1.22
validictory==1.1.1
Werkzeug==0.12.2
wsgi-request-logger==0.4.6
zappa==0.45.1
six==1.11.0
testfixtures==6.3.0
urllib3==1.24.1
validictory==1.1.2
Werkzeug==0.14.1
6 changes: 4 additions & 2 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
import os
import json
import uuid
import yaml

from os import getenv
from geemusic import app, ask
from flask_ask import audio

Expand Down Expand Up @@ -60,10 +60,12 @@ class EnglishAudioIntegrationTests(unittest.TestCase):
""" Integration tests of the english Audio Directives """

def setUp(self):
os.environ["ASK_VERIFY_REQUESTS"] = 'False'
os.environ["APP_URL"] = 'http://localhost'
self.app = app
self.ask = ask
self.client = self.app.test_client()
self.stream_url = getenv('APP_URL')
self.stream_url = os.environ['APP_URL']
self.custom_token = 'custom_uuid_{0}'.format(str(uuid.uuid4()))

@self.ask.intent('TestPlay')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GMusicWrapperNoLogUnitTests(unittest.TestCase):

def setUp(self):
surpress_warnings()
self.api = GMusicWrapper(getenv("GOOGLE_EMAIL"), getenv("GOOGLE_PASSWORD"))
self.api = GMusicWrapper(getenv("DEVICE_ID"))

def tearDown(self):
pass
Expand All @@ -44,7 +44,7 @@ class GMusicWrapperLogUnitTests(unittest.TestCase):
def setUp(self):
surpress_warnings()
logger = logging.getLogger()
self.api = GMusicWrapper(getenv("GOOGLE_EMAIL"), getenv("GOOGLE_PASSWORD"), logger)
self.api = GMusicWrapper(getenv("DEVICE_ID"), logger)

def tearDown(self):
pass
Expand Down