I imported calendar and datetime and added the following lines:
if (config['date_days_back_to_search'] == 31):
now = datetime.datetime.now()
if (now.month == 1):
config['date_days_back_to_search'] = calendar.monthrange(now.year - 1, 12)[1]
else:
config['date_days_back_to_search'] = calendar.monthrange(now.year, now.month - 1)[1]
with this change you can have a monthly newsletter that will start from the same day of the previous month. For example, if you would put in 31 days and run it today, it would collect the data from 28/03 until 28/04.
Thanks for looking at this. All the emails should be correct since it is pulling them from the Users, BUT... the first email is not there. For instance...
the first user email listed is usrname1@somemail.com
but at the bottom, when it shows them all in this format : ['username1@somemail.com', 'username2@somemail.com',]
it starts as [ ' ', 'username1@somemail.com', 'username2@somemail.com'].... it is like it missed one from the top list, but it didn't... unless it is suppose to be putting mine in there, which is't in the list at all. (I would like to see mine there so I get the email also)
Sorry for the delayed response, I've been busy at work and haven't had a chance to get to this yet. I'm aiming to have something for you tomorrow that will shed some more light on why there is an empty email along side better handling of that case.
Hi,
I changed the following to your script:
I imported calendar and datetime and added the following lines:
if (config['date_days_back_to_search'] == 31):
now = datetime.datetime.now()
if (now.month == 1):
config['date_days_back_to_search'] = calendar.monthrange(now.year - 1, 12)[1]
else:
config['date_days_back_to_search'] = calendar.monthrange(now.year, now.month - 1)[1]
with this change you can have a monthly newsletter that will start from the same day of the previous month. For example, if you would put in 31 days and run it today, it would collect the data from 28/03 until 28/04.
Cool, I'll look at integrating it into the script in case there are others that want the script to be monthly.
Have you considered making a dedicated panel in the Plex Server Config? It allow things to be very simple and hassle free for new users :) And with plex, Im sure you'll find a way to port it in with the scheduled task too :)
Sorry for the delayed response, I've been busy at work and haven't had a chance to get to this yet. I'm aiming to have something for you tomorrow that will shed some more light on why there is an empty email along side better handling of that case.
No worries man. I know this is a side project. I appreciate the time you can spend on it.
File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\PlexEmail-master\scripts\plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
DatabaseError: file is encrypted or is not a database
Traceback (most recent call last):
File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\PlexEmail-master\scripts\plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
DatabaseError: file is encrypted or is not a database
File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\PlexEmail-master\scripts\plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
DatabaseError: file is encrypted or is not a database
Traceback (most recent call last):
File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\PlexEmail-master\scripts\plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
DatabaseError: file is encrypted or is not a database
No worries man. I know this is a side project. I appreciate the time you can spend on it.
Here is a modified script that should exclude empty emails and also prints out the whole response of shared users we get when calling the API. If you could send it to me I'll take a look at what I can do.
No more error when i run the script but im not getting any emails. Already double checked the settings left them default since im using gmail and added my email info. :(
No more error when i run the script but im not getting any emails. Already double checked the settings left them default since im using gmail and added my email info. :(
Can you try following these instructions? The default gmail settings won't let you send emails from a python script.
I have installed this on my media server running Ubuntu Server 14.04.
I've followed the instructions to install and I get the following error:
Traceback (most recent call last):
File "plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
sqlite3.OperationalError: unable to open database file
I'm not sure if this error comes from the fact that the IP Address in the SQL call is 127.0.0.1 and not the Media Server IP Address, but I've changed it in the code and it came out with the same error - so I think I can rule that out?
If someone can help me out I'd be really grateful.
I have installed this on my media server running Ubuntu Server 14.04.
I've followed the instructions to install and I get the following error:
Traceback (most recent call last):
File "plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
sqlite3.OperationalError: unable to open database file
I'm not sure if this error comes from the fact that the IP Address in the SQL call is 127.0.0.1 and not the Media Server IP Address, but I've changed it in the code and it came out with the same error - so I think I can rule that out?
If someone can help me out I'd be really grateful.
Not sure what is happening there, but 127.0.0.1 is a loop back address. Basically it is saying that the source is local (on the same machine). You can manually put in the local LAN IP address and it would do the same thing.
Got it set-up and working well - quick question though - is anyone else using the Gmail SMTP server? And if so did you have to enable access for 'Less Secure Apps' - I had to do this as SSL auth didn't seem to work. I'd rather not have this enabled as i'm not that comfortable with it - any workaround?
I have installed this on my media server running Ubuntu Server 14.04.
I've followed the instructions to install and I get the following error:
Traceback (most recent call last):
File "plexEmail.py", line 656, in
cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";')
sqlite3.OperationalError: unable to open database file
I'm not sure if this error comes from the fact that the IP Address in the SQL call is 127.0.0.1 and not the Media Server IP Address, but I've changed it in the code and it came out with the same error - so I think I can rule that out?
If someone can help me out I'd be really grateful.
I have not seen this issue yet. Can you verify that the user running the script has write access to the Plex Media Server/Plug-in Support/Databases folder? This is a query to find the unique server ID for the linking functionality (so should stay as is).
This is awesome - thanks for creating it :D
Got it set-up and working well - quick question though - is anyone else using the Gmail SMTP server? And if so did you have to enable access for 'Less Secure Apps' - I had to do this as SSL auth didn't seem to work. I'd rather not have this enabled as i'm not that comfortable with it - any workaround?
Cheers
It's necessary to do that to use Gmail. Alternatives would be to create a new gmail account to send these plex emails or to use another provider.
I have not seen this issue yet. Can you verify that the user running the script has write access to the Plex Media Server/Plug-in Support/Databases folder? This is a query to find the unique server ID for the linking functionality (so should stay as is).
Thanks for getting back to me, just to let you know that once I added sudo before the python plexMail.py it worked :)
The feature to send mail to the shared users is superb!! If I setup the email_individually to true will this send to my shared users individually or does this only work with the send to array list?
Thanks for getting back to me, just to let you know that once I added sudo before the python plexMail.py it worked :)
The feature to send mail to the shared users is superb!! If I setup the email_individually to true will this send to my shared users individually or does this only work with the send to array list?
Thanks
I could be wrong here, but as I understand it, it will send out individually to all the users in the array. Otherwise I think it sends one email with everyone's email address in the TO field (not desirable) that is in the array. Either way you need to add the email addresses in there.
Thanks for getting back to me, just to let you know that once I added sudo before the python plexMail.py it worked :)
The feature to send mail to the shared users is superb!! If I setup the email_individually to true will this send to my shared users individually or does this only work with the send to array list?
Thanks
I could be wrong here, but as I understand it, it will send out individually to all the users in the array. Otherwise I think it sends one email with everyone's email address in the TO field (not desirable) that is in the array. Either way you need to add the email addresses in there.
Foebik,
You are correct in one aspect, and incorrect in another.
If you set email_individually to true, it will send each email separate, and set to false will send one email to all (making all email addresses public) as you stated. I have suggested setting it up if possible to use BCC.
If you are using the newest version and have Plex API Authentication set up, the script will get all the email addresses from your users automatically, therefore, you do not need to fill out the email addresses in the ##Email section.
Although, if you want a copy of the email, you do have to add your email to the ##Email section, as the API wont pull the owners email.