ngovil21 / RequestChannel.bundle

Request Channel - A Plex Channel to create requests
158 stars 22 forks source link

CouchPotato not working #29

Closed Ackis closed 8 years ago

Ackis commented 8 years ago

My CP server is set up as: https://192.168.0.199:5050/

2016-04-25 11:06:58,406 (7f674d7fa700) :  DEBUG (runtime:717) - Handling request GET /video/plexrequestchannel
2016-04-25 11:06:59,408 (7f674d7fa700) :  DEBUG (runtime:814) - Found route matching /video/plexrequestchannel
2016-04-25 11:06:59,412 (7f674d7fa700) :  DEBUG (networking:166) - Requesting 'http://127.0.0.1:32400/myplex/account'
2016-04-25 11:06:59,415 (7f674d7fa700) :  DEBUG (Session:141) - Platform: Chrome
2016-04-25 11:06:59,415 (7f674d7fa700) :  DEBUG (Session:142) - Product: Plex Web
2016-04-25 11:06:59,416 (7f674d7fa700) :  DEBUG (Session:143) - Accept-Language: en
2016-04-25 11:06:59,416 (7f674d7fa700) :  DEBUG (Session:204) - User is Admin
2016-04-25 11:06:59,416 (7f674d7fa700) :  INFO (LocalePatch:76) - Locale Patch: found languages in Accept-Language header (en)
2016-04-25 11:06:59,416 (7f674d7fa700) :  INFO (LocalePatch:88) - Locale Patch: using available language "en".
2016-04-25 11:06:59,426 (7f674d7fa700) :  DEBUG (base:117) - Checking if com.plexapp.plugins.plexrequestschannel is broken
2016-04-25 11:06:59,427 (7f674d7fa700) :  DEBUG (networking:166) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCc                m9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMzkKY29tLnBsZXhhcHAucGx1Z2lucy5wbGV4cmVxdWVzdHNjaGFubmVsczEwCmlkZW50aWZpZXJyMAo_'
2016-04-25 11:06:59,444 (7f674d7fa700) :  DEBUG (runtime:88) - Sending packed state data (120 bytes)
2016-04-25 11:06:59,444 (7f674d7fa700) :  DEBUG (runtime:924) - Response: [200] MediaContainer, 3080 bytes
2016-04-25 11:06:59,795 (7f674d7fa700) :  DEBUG (runtime:717) - Handling request GET /video/plexrequestchannel/987f7ad9fcf3fa0243f8d00a4fb75f0c/managecouchpotato
2016-04-25 11:07:00,824 (7f674d7fa700) :  DEBUG (runtime:814) - Found route matching /video/plexrequestchannel/987f7ad9fcf3fa0243f8d00a4fb75f0c/managecouchpotato
2016-04-25 11:07:00,825 (7f674d7fa700) :  DEBUG (networking:166) - Requesting 'https://192.168.0.199:5050/api/APIKEY/movie.list'
2016-04-25 11:07:00,873 (7f674d7fa700) :  ERROR (networking:217) - Error opening URL 'https://192.168.0.199:5050/api/APIKEY/movie.list'
2016-04-25 11:07:00,874 (7f674d7fa700) :  DEBUG (Session:834) - Traceback (most recent call last):
  File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/PlexRequestChannel.bundle/Contents/Code/Session.py", line 831, in ManageCouchpotato
    movie_list = JSON.ObjectFromURL(couchpotato_url + "api/" + Prefs['couchpotato_api'] + "/movie.list", values=dict(status="active"))
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/parsekit.py", line 145, in ObjectFromURL
    method=method,
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/networkkit.py", line 67, in _http_request
    req = self._core.networking.http_request(url, *args, **kwargs)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 368, in http_request
    return HTTPRequest(self._core, url, data, h, url_cache, encoding, errors, timeout, immediate, sleep, opener, follow_redirects, method)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 141, in __init__
    self.load()
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 181, in load
    f = self._opener.open(req, timeout=self._timeout)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 444, in open
    response = meth(req, response)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 557, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 482, in error
    return self._call_chain(*args)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 416, in _call_chain
    result = func(*args)
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 565, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 405: Method Not Allowed

2016-04-25 11:07:00,875 (7f674d7fa700) :  DEBUG (Session:835) -
2016-04-25 11:07:00,875 (7f674d7fa700) :  INFO (LocalePatch:76) - Locale Patch: found languages in Accept-Language header (en)
2016-04-25 11:07:00,876 (7f674d7fa700) :  INFO (LocalePatch:88) - Locale Patch: using available language "en".
2016-04-25 11:07:00,878 (7f674d7fa700) :  DEBUG (runtime:88) - Sending packed state data (120 bytes)
2016-04-25 11:07:00,879 (7f674d7fa700) :  DEBUG (runtime:924) - Response: [200] MessageContainer, 135 bytes

`

I then change my cp server to https://couchpotato.local/ 2016-04-25 11:10:36,753 (7f674d7fa700) : DEBUG (networking:166) - Requesting 'https://couchpotato.local/api/APIKEY/movie.list' 2016-04-25 11:10:41,757 (7f674d7fa700) : DEBUG (Session:834) - Traceback (most recent call last): File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/PlexRequestChannel.bundle/Contents/Code/Session.py", line 831, in ManageCouchpotato movie_list = JSON.ObjectFromURL(couchpotato_url + "api/" + Prefs['couchpotato_api'] + "/movie.list", values=dict(status="active")) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/parsekit.py", line 145, in ObjectFromURL method=method, File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/networkkit.py", line 67, in _http_request req = self._core.networking.http_request(url, *args, **kwargs) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 368, in http_request return HTTPRequest(self._core, url, data, h, url_cache, encoding, errors, timeout, immediate, sleep, opener, follow_redirects, method) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 141, in __init__ self.load() File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 181, in load f = self._opener.open(req, timeout=self._timeout) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 438, in open response = self._open(req, data) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 456, in _open '_open', req) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 416, in _call_chain result = func(*args) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 1225, in https_open return self.do_open(httplib.HTTPSConnection, req) File "/usr/lib/plexmediaserver/Resources/Plug-ins-81a3bf0/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2_new.py", line 1192, in do_open raise URLError(err) URLError: <urlopen error [Errno -2] Name or service not known>

I'm getting similar problems with Sonarr.

On a side note, you might want to consider changing this from debug to error:

(7f674d7fa700) : DEBUG (Session:834) - Traceback (most recent call last):

ngovil21 commented 8 years ago

Everything works for me so it may be an issue with your setup. I'm assuming you've replaced the couchpotato api key with APIKEY in the logs here.

It may be related to using https, can you try using an http address? Hopefully the ssl security is not necessary over your local network.

The second url didn't work because your DNS is not forwarding couchpotato.local to the right ip address.

Ackis commented 8 years ago

Yes - I've replaced the API key.

Interesting point about the second url not working - didn't notice that. Lookup works on other PC's but it seems anything with a .local domain doesn't want to work on Ubuntu.

My sonarr setup isn't on ssl yet, and it works it looks like now that I've changed to using the IP.

ngovil21 commented 8 years ago

Do you have a base url setup for your couchpotato? Something like https://192.168.0.199:5050/couchpotato? Also can you try using http://192.168.0.199:5050 and not https for the couchpotato url.

Trying to see what may be causing the problem, becomes everything is working fine for me.

Ackis commented 8 years ago

Yes - I have a base URL. And http doesn't work - I probably need to change some settings in CP but I haven't had a chance yet.

I'm using nginx and dnsmasq to let me access the site via: http://home.local/couchpotato -> (Redirects to https://home.local/couchpotato/) https://home.local/couchpotato http://couchpotato.local/ -> (Redirects to https://couchpotato.local//) https://couchpotato.local/

From my understanding, that's not exactly a normal setup - usually you pick one or another but I've been using this as a learning experience/home lab.

002-home.local:

server {
        listen 443 ssl;
        server_name home.local;

        access_log      /var/log/nginx/access.log;
        error_log       /var/log/nginx/error.log;

        if ( $scheme = http )
        {
                rewrite ^ https://$server_name$request_uri? permanent;
        }

        include /etc/nginx/conf.d/ssl.conf;

        location / {
                root            /var/www/intranet;
                index           index.html index.htm;
                access_log      /var/log/nginx/sites/intranet/access.443.log;
                error_log       /var/log/nginx/sites/intranet/error.443.log;
        }
}

004-media.local:

server {
        listen          80;
        server_name     couchpotato.local;
        return          301 https://$server_name$request_uri;

        access_log      /var/log/nginx/sites/couchpotato/access.80.log;
        error_log       /var/log/nginx/sites/couchpotato/error.80.log;
}

server {
        listen 443 ssl;
        server_name couchpotato.local;

        include /etc/nginx/conf.d/ssl.conf;

        location / {
                proxy_pass https://192.168.0.199:5050/;
                proxy_redirect https://192.168.0.199:5050/couchpotato/ /;
                proxy_set_header X-Forwarded-Proto https;

                access_log /var/log/nginx/sites/couchpotato/access.443.log;
                error_log /var/log/nginx/sites/couchpotato/error.443.log;
        }
        location /couchpotato {
               include         /etc/nginx/conf.d/proxy.conf;
               proxy_pass      https://192.168.0.199:5050/couchpotato;

                access_log      /var/log/nginx/sites/couchpotato/access.home.log;
                error_log       /var/log/nginx/sites/couchpotato/error.home.log;
        }

}
ngovil21 commented 8 years ago

Ok that does seem a bit more complicated. I use a reverse proxy as well through apache and it works well with the plugin even with https.

But if we are just using the ip address, then your reverse proxy setup doesn't matter. If you have a base url setup in the couch potato settings, then you will need to include that in the url, so use: https://192.168.0.199:5050/couchpotato

as the couchpotato url. Or try: http://192.168.0.199:5050/couchpotato

Ackis commented 8 years ago

That worked. Didn't think I had to do that because I'm able to connect directly to https://192.168.0.199:5050/ and it "works".

ngovil21 commented 8 years ago

Ya the couchpotato server will redirect your browser, but the code in the channel doesn't follow redirects, so it will have the wrong link. I should mention the base url is needed in the preferences.