diff --git a/Dockerfile b/Dockerfile index 02b4def..0188714 100755 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ MAINTAINER Spencer Julian 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 diff --git a/README.md b/README.md index d917f16..e84f713 100644 --- a/README.md +++ b/README.md @@ -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 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("")); 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 -GOOGLE_EMAIL=steve@stevegattuso.me -GOOGLE_PASSWORD=password +DEVICE_ID=device_id # Publicly accessible URL to your server, WITHOUT trailing slash APP_URL=https://alexa-geemusic.stevegattuso.me @@ -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 | @@ -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 GOOGLE_EMAIL=steve@stevegattuso.me -e GOOGLE_PASSWORD=[password] \ +$ docker run -d -e DEVICE_ID=[device-id] \ -e APP_URL=http://alexa-geemusic.stevegattuso.me -p 5000:5000 geemusic ``` diff --git a/geemusic/utils/music.py b/geemusic/utils/music.py index 73911ee..317822f 100644 --- a/geemusic/utils/music.py +++ b/geemusic/utils/music.py @@ -1,3 +1,4 @@ +import os from builtins import object from fuzzywuzzy import fuzz, process from os import getenv @@ -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!") @@ -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://") @@ -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) diff --git a/requirements.txt b/requirements.txt index 00f0a8d..884b541 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tests/test_functional.py b/tests/test_functional.py index 5b4cc0f..2ee1a3e 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -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 @@ -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') diff --git a/tests/test_log.py b/tests/test_log.py index 0a5c366..cb7cf1a 100644 --- a/tests/test_log.py +++ b/tests/test_log.py @@ -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 @@ -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