Closed jamespardon closed 9 years ago
Config :
email: title: ‘Plex New Stuff’ plex: server: 192.168.1.90 api_key: tcfjqQzU7qy4sqGkQ1Yq mail: address: smtp.gmail.com port: 587 username: myemail@gmail.com password: mypassword from: myemail@gmail.com subject: 'New' recipients_email: [‘email1’, ‘email2’] recipients: ['Test']
As far as I can see your config film looks just like the one I have on OS X
If I look the file mailreport.rb is see that lines 51-57 read as follows: if !$testEmail if $plexEmails plex_users = plexTv.get('/pms/friends/all') plex_users['MediaContainer']['User'].each do | user | users.push(user['email']) end end
The error occurs in the piece of code "plex_users['MediaContainer']['User'].each do | user |"
Have you tried to run it with the -t option. This will only generate an e-mail to your own e-mail address. If this works, then you know that your config file is OK
Next try to run it with the -n option. This will only use the e-mail addresses you have entered in your config file.
Great! Running with the -t option works sending to myself, does that help pinpoint the problem?
Go to 'http://< your_plex_server_ip >:32400/pms/friends/all' and paste the results here.
I actually get 404 not found for that,
Usual plex site that works for me is :
It sounds like you cannot reach your own Plex server from the machine running the script. 404 means that it isn't reachable for whatever reason. This isn't an issue with the script
Try running it on the same machine as the Plex server, changing your 'server' parameter to 'localhost'
Brian I just tested it both ways (IP and localhost). When I run it as you suggested, it runs into a #401 error because it can't set up a secure connection. I did get the xml list by running the following https://plex.tv/pms/friends/all
You are right, I looked at this too quickly.
What is the output of that XML?
Was testing from the plex media server mac itself, localhost is same result. https://plex.tv/pms/friends/all for me shows -
Brian, I just sent you the example of my file via e-mail
James, are you logged in to plex.tv? When I run it , it shows all the friends that also appear when I approach my server through plex.tv
it looks something like this
Yep, If I goto plex.tv and settings this is my screenshot :
If I type the address https://plex.tv/pms/friends/all I get the XML screenshot above. If I navigate to friends through plex.tv I get this address and screenshot -
is it as I have no shared libraries?
I am pretty sure your API key is incorrect. The script cannot connect to plex.tv.
To verify, update your script to the newest code. I added a check to throw an error to the log and cleanly exit if it cannot connect to plex.tv
Ok will do, when I view the config to get my API key there are 6 references to my plex server with different API keys, does this sound right?
Plex does not make it easy to get your API key. I am in the process of making that more simple and 'behind the scenes'. For me, when you look up your devices, it was the only one with the field 'provides="server"'
Does that help?
Yes that narrows it down to 1! I'll try that now
Switched to that API key and tried script again
ruby plexReport.rb
/Users/jamespardon/Documents/PlexReport/PlexReport/bin/mailReport.rb:54:in sendMail': undefined method
each' for nil:NilClass (NoMethodError)
from plexReport.rb:346:in main' from plexReport.rb:350:in
This is with the latest script
I don't think it is. That error shouldn't show up with the latest script at all.
Put here the contents of bin/plexTv.rb
require 'rubygems' require 'json' require 'httparty'
#
# class PlexTv include HTTParty
base_uri 'http://plex.tv/'
format :xml
def initialize(config)
$token = config['plex']['api_key']
end
def get(query, args=nil)
if args.nil?
new_query = query + "?X-Plex-Token=#{$token}"
else
new_query = query + "?X-Plex-Token=#{$token}&#{args}"
end
response = self.class.get(new_query, :verify => false)
if response.code != 200
$logger.error("Cannot connect to plex.tv! Change your connection and your Plex API key. Exiting.")
exit
end
return response
end
end
And the end of your log file?
The log file shows the movies matching, the errors im pasting are from the terminal window i'm launching script from:
what you could also try is create a plex user and invite it through plex.tv. It should show in the 'friends' screen on plex.tv and is suspect that it will also receive the e-mail. Brian is the script falling because it is getting no data thus NULL?
I mean,paste the end of your log file here
I, [2015-02-11T15:42:02.679776 #76622] INFO -- : Reporting Movie: The Love Punch E, [2015-02-11T15:42:02.705413 #76622] ERROR -- : Movie Stary Eyed using incompatiable agent I, [2015-02-11T15:42:04.123080 #76622] INFO -- : Reporting Movie: The Theory of Everything I, [2015-02-11T15:42:05.495313 #76622] INFO -- : Reporting Movie: Whiplash I, [2015-02-11T15:47:36.109725 #76816] INFO -- : Script complete. Ran in 15.776762 seconds
Update it again and run it with the '-v' flag
and paste the end of your log file
Is this enough of the log ?
@response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"content-type"=>["text/xml;charset=utf-8"], "content-length"=>["2430"], "connection"=>["close"], "x-plex-protocol"=>["1.0"], "cache-control"=>["no-cache"]}>
D, [2015-02-11T16:13:47.349266 #76878] DEBUG -- : Debug info for plexmediaserver connection
D, [2015-02-11T16:13:47.349325 #76878] DEBUG -- : 200
D, [2015-02-11T16:13:47.349352 #76878] DEBUG -- : #<HTTParty::Request:0x007fee1939cee8 @http_method=Net::HTTP::Get, @path=#<URI::Generic:0x007fee1939cd30 URL:/library/metadata/923>, @options={:limit=>5, :assume_utf16_is_big_endian=>true, :default_params=>{}, :follow_redirects=>true, :parser=>HTTParty::Parser, :connection_adapter=>HTTParty::ConnectionAdapter, :base_uri=>"http://192.168.1.90:32400", :format=>:xml, :headers=>{"X-Plen-Token"=>"zDyrQN9K4i6ke3XfBW8P", "X-Plex-Token"=>"zDyrQN9K4i6ke3XfBW8P"}}, @last_uri=#<URI::HTTP:0x007fee193a7d98 URL:http://192.168.1.90:32400/library/metadata/923>, @raw_request=#
Do you see anywhere in there that says "Plextv Response code" ?
No nothing at all
I'm on PMS version 0.9.9.7.429 if that helps
Wait a second...you have no Plex friends, right?
Try the newest code.
Correct no friends in Plex
Newest code results :
/Users/jamespardon/Documents/PlexReport/plexReport/bin/mailReport.rb:59:in []': no implicit conversion of String into Integer (TypeError) from /Users/jamespardon/Documents/PlexReport/plexReport/bin/mailReport.rb:59:in
block in sendMail'
from /Users/jamespardon/Documents/PlexReport/plexReport/bin/mailReport.rb:58:in each' from /Users/jamespardon/Documents/PlexReport/plexReport/bin/mailReport.rb:58:in
sendMail'
from PlexReport.rb:346:in main' from PlexReport.rb:350:in
With -V the end of log
D, [2015-02-11T22:19:02.137842 #86560] DEBUG -- : Debug info for plexmediaserver connection
D, [2015-02-11T22:19:02.137892 #86560] DEBUG -- : 200
D, [2015-02-11T22:19:02.137920 #86560] DEBUG -- : #<HTTParty::Request:0x007f894e1b7ef0 @http_method=Net::HTTP::Get, @path=#<URI::Generic:0x007f894e1b7d10 URL:/library/metadata/2443>, @options={:limit=>5, :assume_utf16_is_big_endian=>true, :default_params=>{}, :follow_redirects=>true, :parser=>HTTParty::Parser, :connection_adapter=>HTTParty::ConnectionAdapter, :base_uri=>"http://192.168.1.90:32400", :format=>:xml, :headers=>{"X-Plen-Token"=>"zDyrQN9K4i6ke3XfBW8P", "X-Plex-Token"=>"zDyrQN9K4i6ke3XfBW8P"}}, @last_uri=#<URI::HTTP:0x007f894e1b65f0 URL:http://192.168.1.90:32400/library/metadata/2443>, @raw_request=#
This should now be fixed.
/Users/jamespardon/Documents/PlexReport/plexReport/bin/mailReport.rb:58:in sendMail': undefined method
each' for nil:NilClass (NoMethodError)
from plexreport.rb:346:in main' from plexreport.rb:350:in
Not to worry, the -t is enough for me. Thanks for taking the time
As per the forum. I'm trying to run this on OSX Yosemite. Running I get the following when run -
Quantum:bin pardonator$ ruby plexReport.rb /Users/pardonator/Documents/PlexReport/plexReport/bin/mailReport.rb:54:in'
sendMail': undefined method
each' for nil:NilClass (NoMethodError) from plexReport.rb:346:inmain' from plexReport.rb:350:in