*Almost* working via Centos7+httpd+wsgi+ssl+python2.7
I'm so excited to get this working!! I'm not sure if you can help me, but everything is working: Httpd/SSL---->WSGI--->Plexmusicplayer (with correct permissions). I've been putting some print statements in my wsgi log to see if the URL is correct and it is. I see your script spitting out the correct XML MediaContainer when I request the artist/song, but amazon isn't seeing it for some reason and sending this response:
{ "version": "1.0", "response": { "outputSpeech": { "type": "PlainText", "text": "I was not able to find blackened by Metallica in your library." }, "shouldEndSession": true }, "sessionAttributes": {} }
Can you verify if this is correct modification in the methods.py file below? Basically, I just replaced the os.environ variables with my plex server info (which I have changed below for security):
stream_base_url = "https://999-9-9-9.029438lakfmlskfjlkjlsksfjdld472a45345345534.plex.direct:32400" plex_token = "X-Plex-Token=" + "kalskfjdlsdkfjlsdkjslfdksdfsdf" try: base_url = "https://192-168-1-2.029438lakfmlskfjlkjlsksfjdld472a45345345534.plex.direct:32400" except: base_url = stream_base_url
Anything else I missed? Thoughts?
I'd be glad to help out with the project in any way! After I get this working, I'd be happy to provide documentation for those trying to set this up from scratch on their local boxes and skipping the third party (Heroku).
Oh, and here's the JSON that was sent, which resulted in the "not found" above (with ID information changed):
{ "session": { "sessionId": "SessionId.SLFDKJLKJ-5SDADc5-8ASDA275-1ADSDASf", "application": { "applicationId": "amzn1.ask.skill.1bedddda-42cf-4c4b-a6a0-716f94a337a8" }, "attributes": {}, "user": { "userId": "amzn1.ask.account.HKLJFHASKLFHASLKJDFHASLKJFDHASLKJFHA238472498372498742398234 }, "new": true }, "request": { "type": "IntentRequest", "requestId": "EdwRequestId.0411928374239a-6234239-42429-b2342e-68FWER234234", "locale": "en-US", "timestamp": "2017-03-05T15:36:41Z", "intent": { "name": "PlexPlayTrackByArtistIntent", "slots": { "artist": { "name": "artist", "value": "Metallica" }, "track": { "name": "track", "value": "blackened" } } } }, "version": "1.0" }
Hi! Thank you for trying out this project! Anyone who is eager to help out is always more than welcome! I think you should try to set your
plex_token = "X-Plex-Token=" + "kalskfjdlsdkfjlsdkjslfdksdfsdf"
to
plex_token = "kalskfjdlsdkfjlsdkjslfdksdfsdf"
Let me know if this works!
I tried removing it, but it resulted in a bad request.
This is what the XML looks like with the "X-Plex-Token" piece in the string. Maybe you can see something funky that I dont, but it appears to find the song:
<MediaContainer size="1" identifier="com.plexapp.plugins.library" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1486782857">
<Track allowSync="1" librarySectionID="12" librarySectionTitle="Music" librarySectionUUID="a81sdfsdf60b56-sdfds2-4sdfsd-asdfds-9sdfsdfb5000" parentKey="/library/metadata/5363" personal="1" sourceTitle="Plex Server" ratingKey="5364" key="/library/metadata/5364" parentRatingKey="5363" grandparentRatingKey="5312" type="track" title="Battery" grandparentKey="/library/metadata/5312" grandparentTitle="Metallica" parentTitle="Master Of Puppets" summary="" index="1" parentIndex="1" ratingCount="4465694" viewCount="1" lastViewedAt="1483568588" year="1986" thumb="/library/metadata/5363/thumb/1485831949" art="/library/metadata/5312/art/1488532776" parentThumb="/library/metadata/5363/thumb/1485831949" grandparentThumb="/library/metadata/5312/thumb/1488532776" grandparentArt="/library/metadata/5312/art/1488532776" duration="312744" addedAt="1052091936" updatedAt="1485831949">
<Media id="5176" duration="312744" bitrate="160" audioChannels="2" audioCodec="mp3" container="mp3">
<Part id="5771" key="/library/parts/5771/1052091936/file.mp3" duration="312744" file="/mnt/backup3/Backup/MP3/Metallica/Master of Puppets/Metallica - Battery.mp3" size="6265127" container="mp3" hasThumbnail="1"/>
</Media>
</Track>
</MediaContainer>
I got this working (with my local box instead of using Heroku)! :) I'll pull my notes together and get something up soon!
Happy to hear you've got it working! :+1: I'm curious as how you managed to get it online! :)
Did you have a chance to get your notes together evilgrinners? I was looking on setting this up locally on my ESXI box this weekend, and would love to avoid any of the pitfalls that you dodged.
Hi all, I've kinda followed evilgrinners vague how to above and got it working via: apache->WSGI->plexmusicplayer on an Ubuntu server. The working code is in my fork of this project. Thanks to Tyzer34 for all the hard work that I've piggybacked on!
@redspike Thanks for this! Just tried this on the RPi where my Plex server is and I get no errors when I restart Apache, and Alexa's request looks good to me, but Alexa's saying "The remote endpoint could not be called, or the response it returned was invalid." and the access and error logs are empty. Can anyone recommend debugging steps for an Apache noob?
A rundown of what I've done, just in case anyone can spot something obviously missing/wrong:
- SSL keys generated per Amazon's docs
- plex.conf in sites-available and sites-enabled with my FQDN and SSL dets completed.
- rest of source in /var/www/plex
- methods.py: raw_plex_token = actuallymytoken, plex_port = "34000", plex_server_name = "raspberrypi", base_url = "http://127.0.0.1:"+plex_port
- ran a2enmod for ssl and wsgi
- DNS record pointing to my IP, ports 80 (not sure whether this is necessary) and 443 forwarded
- Alexa skill set up using self-signed cert
- used intentschema as provided with the exception that I replaced 4 built-in slot types using data from geemusic's non-US, since I'm a UK user: https://github.com/stevenleeg/geemusic/tree/master/speech_assets/non_us_custom_slot_version
Any help would be appreciated! In return, here's my intentSchema.json to combine with the data from geemusic: https://gist.github.com/WaferMouse/929fd728f01568478429e5cb8f7db238
What's your endpoint set as on Amazons developer portal? Mine is set as https://fqdn/plex Also make sure that you've restarted apache
@redspike I had it set to https://fqdn but now I've added /plex, but that's made no difference. I must've restarted Apache ~20 times in the last half hour tinkering with it :)
I wondered whether I might be hitting a firewall somewhere along the way, so I figured I'd shove the endpoint into Chrome and I got ERR_CONNECTION_REFUSED, same on the local IP as well.
@WaferMouse in your apache error.log do you have any lines for "mod_wsgi" or "Python" in there?