2013-02-18 17:40:32 +00:00
|
|
|
# This file is part of mylar.
|
|
|
|
#
|
|
|
|
# mylar is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# mylar is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with mylar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
from mylar import logger
|
|
|
|
import base64
|
|
|
|
import cherrypy
|
|
|
|
import urllib
|
|
|
|
import urllib2
|
|
|
|
import mylar
|
|
|
|
from httplib import HTTPSConnection
|
|
|
|
from urllib import urlencode
|
|
|
|
import os.path
|
|
|
|
import subprocess
|
2013-09-07 06:05:32 +00:00
|
|
|
import time
|
2016-09-07 04:04:42 +00:00
|
|
|
import simplejson
|
2015-01-31 22:21:42 +00:00
|
|
|
import json
|
2016-09-07 04:04:42 +00:00
|
|
|
import requests
|
2019-03-01 11:27:46 +00:00
|
|
|
import smtplib
|
|
|
|
from email.mime.multipart import MIMEMultipart
|
|
|
|
from email.mime.text import MIMEText
|
2019-10-09 04:47:18 +00:00
|
|
|
from email.utils import formatdate, make_msgid
|
2013-02-18 17:40:32 +00:00
|
|
|
|
|
|
|
# This was obviously all taken from headphones with great appreciation :)
|
|
|
|
|
|
|
|
class PROWL:
|
|
|
|
|
|
|
|
keys = []
|
|
|
|
priority = []
|
|
|
|
|
|
|
|
def __init__(self):
|
2017-10-25 18:33:56 +00:00
|
|
|
self.enabled = mylar.CONFIG.PROWL_ENABLED
|
|
|
|
self.keys = mylar.CONFIG.PROWL_KEYS
|
|
|
|
self.priority = mylar.CONFIG.PROWL_PRIORITY
|
2013-02-18 17:40:32 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def conf(self, options):
|
|
|
|
return cherrypy.config['config'].get('Prowl', options)
|
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
def notify(self, message, event, module=None):
|
2017-10-25 18:33:56 +00:00
|
|
|
if not mylar.CONFIG.PROWL_ENABLED:
|
2013-02-18 17:40:32 +00:00
|
|
|
return
|
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
if module is None:
|
|
|
|
module = ''
|
|
|
|
module += '[NOTIFIER]'
|
|
|
|
|
2013-02-18 17:40:32 +00:00
|
|
|
http_handler = HTTPSConnection("api.prowlapp.com")
|
2015-05-22 08:32:51 +00:00
|
|
|
|
2017-10-25 18:33:56 +00:00
|
|
|
data = {'apikey': mylar.CONFIG.PROWL_KEYS,
|
2013-02-18 17:40:32 +00:00
|
|
|
'application': 'Mylar',
|
|
|
|
'event': event,
|
|
|
|
'description': message.encode("utf-8"),
|
2017-10-25 18:33:56 +00:00
|
|
|
'priority': mylar.CONFIG.PROWL_PRIORITY}
|
2013-02-18 17:40:32 +00:00
|
|
|
|
|
|
|
http_handler.request("POST",
|
|
|
|
"/publicapi/add",
|
|
|
|
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
|
|
|
body = urlencode(data))
|
|
|
|
response = http_handler.getresponse()
|
|
|
|
request_status = response.status
|
|
|
|
|
|
|
|
if request_status == 200:
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.info(module + ' Prowl notifications sent.')
|
2013-02-18 17:40:32 +00:00
|
|
|
return True
|
2015-05-22 08:32:51 +00:00
|
|
|
elif request_status == 401:
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.info(module + ' Prowl auth failed: %s' % response.reason)
|
2013-02-18 17:40:32 +00:00
|
|
|
return False
|
|
|
|
else:
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.info(module + ' Prowl notification failed.')
|
2013-02-18 17:40:32 +00:00
|
|
|
return False
|
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
def test_notify(self):
|
2013-02-18 17:40:32 +00:00
|
|
|
self.notify('ZOMG Lazors Pewpewpew!', 'Test Message')
|
2015-05-22 08:32:51 +00:00
|
|
|
|
2013-04-22 04:13:56 +00:00
|
|
|
# 2013-04-01 Added Pushover.net notifications, based on copy of Prowl class above.
|
|
|
|
# No extra care has been put into API friendliness at the moment (read: https://pushover.net/api#friendly)
|
|
|
|
class PUSHOVER:
|
|
|
|
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
def __init__(self, test_apikey=None, test_userkey=None, test_device=None):
|
|
|
|
if all([test_apikey is None, test_userkey is None, test_device is None]):
|
|
|
|
self.PUSHOVER_URL = 'https://api.pushover.net/1/messages.json'
|
2018-07-31 20:12:07 +00:00
|
|
|
self.test = False
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
else:
|
|
|
|
self.PUSHOVER_URL = 'https://api.pushover.net/1/users/validate.json'
|
2018-07-31 20:12:07 +00:00
|
|
|
self.test = True
|
2017-10-25 18:33:56 +00:00
|
|
|
self.enabled = mylar.CONFIG.PUSHOVER_ENABLED
|
2017-06-09 00:23:59 +00:00
|
|
|
if test_apikey is None:
|
2017-10-25 18:33:56 +00:00
|
|
|
if mylar.CONFIG.PUSHOVER_APIKEY is None or mylar.CONFIG.PUSHOVER_APIKEY == 'None':
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
logger.warn('No Pushover Apikey is present. Fix it')
|
|
|
|
return False
|
2017-06-09 00:23:59 +00:00
|
|
|
else:
|
2017-10-25 18:33:56 +00:00
|
|
|
self.apikey = mylar.CONFIG.PUSHOVER_APIKEY
|
2017-06-09 00:23:59 +00:00
|
|
|
else:
|
|
|
|
self.apikey = test_apikey
|
|
|
|
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
if test_device is None:
|
|
|
|
self.device = mylar.CONFIG.PUSHOVER_DEVICE
|
|
|
|
else:
|
|
|
|
self.device = test_device
|
|
|
|
|
2017-06-09 00:23:59 +00:00
|
|
|
if test_userkey is None:
|
2017-10-25 18:33:56 +00:00
|
|
|
self.userkey = mylar.CONFIG.PUSHOVER_USERKEY
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
else:
|
2017-06-09 00:23:59 +00:00
|
|
|
self.userkey = test_userkey
|
|
|
|
|
2017-10-25 18:33:56 +00:00
|
|
|
self.priority = mylar.CONFIG.PUSHOVER_PRIORITY
|
2015-05-22 08:32:51 +00:00
|
|
|
|
2015-10-06 17:16:27 +00:00
|
|
|
self._session = requests.Session()
|
|
|
|
self._session.headers = {'Content-type': "application/x-www-form-urlencoded"}
|
2013-04-22 04:13:56 +00:00
|
|
|
|
2016-09-11 21:48:01 +00:00
|
|
|
def notify(self, event, message=None, snatched_nzb=None, prov=None, sent_to=None, module=None):
|
2018-07-31 20:12:07 +00:00
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
if module is None:
|
|
|
|
module = ''
|
|
|
|
module += '[NOTIFIER]'
|
2013-04-22 04:13:56 +00:00
|
|
|
|
2016-09-11 21:48:01 +00:00
|
|
|
if snatched_nzb:
|
|
|
|
if snatched_nzb[-1] == '\.':
|
|
|
|
snatched_nzb = snatched_nzb[:-1]
|
IMP: Added 'Force to TPB/GN' option for printed editions and 'Force to Print' option for TPB/GN's (this WILL impact how files are scanned in - so make sure you have files named appropriately), IMP: Added One-Shot as a Type, FIX: Fixed incorrect variable reference to seriesvolume during post-processing of TPB series, FIX: Fixed refresh to fire off every 5 minutes, FIX: When post-processing and metatagging a cbz file with rename files not enabled, would indicate the new filename as being a copy of the existing file (ie. (1).cbz) which would carry over to a final filename, IMP: Allow Mylar to populate the alias list on add/refresh of a series if the aliases don't already exist in the Alternate Series field for the series, FIX: Fixed a problem with single quotes in series titles when using experimental search,
IMP: When searching for a one-off series, will accept either issues with an issue number or those with no issue numbers as acceptable search results when searching, IMP: Updated search code to utilize the existing filename parser within Mylar when parsing the search results for more consistency
2018-12-22 22:48:14 +00:00
|
|
|
message = "Mylar has snatched: " + snatched_nzb + " from " + prov + " and " + sent_to
|
2016-09-11 21:48:01 +00:00
|
|
|
|
2017-10-25 18:33:56 +00:00
|
|
|
data = {'token': mylar.CONFIG.PUSHOVER_APIKEY,
|
|
|
|
'user': mylar.CONFIG.PUSHOVER_USERKEY,
|
2013-04-22 04:13:56 +00:00
|
|
|
'message': message.encode("utf-8"),
|
|
|
|
'title': event,
|
2017-10-25 18:33:56 +00:00
|
|
|
'priority': mylar.CONFIG.PUSHOVER_PRIORITY}
|
2013-04-22 04:13:56 +00:00
|
|
|
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
if all([self.device is not None, self.device != 'None']):
|
|
|
|
data.update({'device': self.device})
|
|
|
|
|
FIX: One-off Failed Download handling will now work, IMP: Some better error handling when detecting one-off's during post-processing, FIX:(#1143) When series contained a digit preceded by a dash, would incorrectly assume it as a negative issue number, FIX: Improved being able to detect corresponding annuals on CV when refreshing/importing a series when the annuals are new (ie. no data on CV), FIX: Alt_Pull method for weekly pull list retrieval working again, FIX: Fixed nzbid detection for experimental search, IMP: Mass Import button now available on Import Results screen (will attempt to import all series that are in a 'Not Imported' status), IMP: When searching for arc issues using the 'Search for Missing' option, the call is now threaded so it runs in the background, IMP: Changed IssueYear to IssueDate for Story Arc Issues on the arc details page, FIX:(#1156) Typo that caused error when attempting to view cbz comics in the series detail page, FIX:(#1145) Select All option via top checkbox (on series detail page), FIX: Auto-Want feature via weeklypull will better match to titles that contain 'the' and have hypens in differing character positions, FIX:(#1160) Would incorrectly take the length of a decimal placed issue when searching and never complete the issue number cylcing search, FIX:(#1161) When annuals not enabled, and series in watchlist and series annual in pullist, would error out trying to link series to pullist.
2015-11-18 06:32:40 +00:00
|
|
|
r = self._session.post(self.PUSHOVER_URL, data=data, verify=True)
|
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
|
|
|
|
2015-10-06 17:16:27 +00:00
|
|
|
if r.status_code == 200:
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
try:
|
|
|
|
response = r.json()
|
2018-07-31 20:12:07 +00:00
|
|
|
if 'devices' in response and self.test is True:
|
|
|
|
logger.fdebug('%s Available devices: %s' % (module, response))
|
|
|
|
if any([self.device is None, self.device == 'None']):
|
|
|
|
self.device = 'all available devices'
|
|
|
|
|
|
|
|
r = self._session.post('https://api.pushover.net/1/messages.json', data=data, verify=True)
|
|
|
|
if r.status_code == 200:
|
|
|
|
logger.info('%s PushOver notifications sent to %s.' % (module, self.device))
|
|
|
|
elif r.status_code >=400 and r.status_code < 500:
|
|
|
|
logger.error('%s PushOver request failed to %s: %s' % (module, self.device, r.content))
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
logger.error('%s PushOver notification failed serverside.' % module)
|
|
|
|
return False
|
FIX:(#1905) Unicode errors when logging and system language is not a subset of english, IMP: Added post-processing queue (currently just for forceProcess api, but will be used by default for all post-processing actions soon), IMP: Multiple Torznab support added, IMP: Logging values for number of files and size/file added to config, IMP: Pushover notifications can be sent to specific device now, IMP: Added nzbget, newznab, nzb.su and dognzb test options, IMP: Added graphical checkmark/x when performing various tests (providers, downloaders, notifiers) within configuration, IMP: Removed some more unnecessary logging lines from searches
2018-04-06 17:46:39 +00:00
|
|
|
else:
|
|
|
|
logger.info('%s PushOver notifications sent.' % module)
|
|
|
|
except Exception as e:
|
|
|
|
logger.warn('%s[ERROR] - %s' % (module, e))
|
2018-07-31 20:12:07 +00:00
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
2015-10-06 17:16:27 +00:00
|
|
|
elif r.status_code >= 400 and r.status_code < 500:
|
2018-07-31 20:12:07 +00:00
|
|
|
logger.error('%s PushOver request failed: %s' % (module, r.content))
|
2015-10-06 17:16:27 +00:00
|
|
|
return False
|
2013-04-22 04:13:56 +00:00
|
|
|
else:
|
2018-07-31 20:12:07 +00:00
|
|
|
logger.error('%s PushOver notification failed serverside.' % module)
|
2015-10-06 17:16:27 +00:00
|
|
|
return False
|
2013-04-22 04:13:56 +00:00
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
def test_notify(self):
|
2018-07-31 20:12:07 +00:00
|
|
|
return self.notify(event='Test Message', message='Release the Ninjas!')
|
2013-09-07 06:05:32 +00:00
|
|
|
|
|
|
|
class BOXCAR:
|
|
|
|
|
2015-05-22 08:32:51 +00:00
|
|
|
#new BoxCar2 API
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
self.url = 'https://new.boxcar.io/api/notifications'
|
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
def _sendBoxcar(self, msg, title, module):
|
2013-09-07 06:05:32 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
Sends a boxcar notification to the address provided
|
|
|
|
|
|
|
|
msg: The message to send (unicode)
|
|
|
|
title: The title of the message
|
|
|
|
|
|
|
|
returns: True if the message succeeded, False otherwise
|
|
|
|
"""
|
|
|
|
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
try:
|
2013-09-07 06:05:32 +00:00
|
|
|
|
|
|
|
data = urllib.urlencode({
|
2017-10-25 18:33:56 +00:00
|
|
|
'user_credentials': mylar.CONFIG.BOXCAR_TOKEN,
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
'notification[title]': title.encode('utf-8').strip(),
|
2014-08-08 06:52:38 +00:00
|
|
|
'notification[long_message]': msg.encode('utf-8'),
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
'notification[sound]': "done"
|
2013-09-07 06:05:32 +00:00
|
|
|
})
|
|
|
|
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
req = urllib2.Request(self.url)
|
2013-09-07 06:05:32 +00:00
|
|
|
handle = urllib2.urlopen(req, data)
|
|
|
|
handle.close()
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
return True
|
2013-09-07 06:05:32 +00:00
|
|
|
|
|
|
|
except urllib2.URLError, e:
|
|
|
|
# if we get an error back that doesn't have an error code then who knows what's really happening
|
|
|
|
if not hasattr(e, 'code'):
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.error(module + 'Boxcar2 notification failed. %s' % e)
|
2013-09-07 06:05:32 +00:00
|
|
|
# If you receive an HTTP status code of 400, it is because you failed to send the proper parameters
|
|
|
|
elif e.code == 400:
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.info(module + ' Wrong data sent to boxcar')
|
|
|
|
logger.info(module + ' data:' + data)
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
else:
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.error(module + ' Boxcar2 notification failed. Error code: ' + str(e.code))
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
return False
|
2013-09-07 06:05:32 +00:00
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.fdebug(module + ' Boxcar2 notification successful.')
|
2013-09-07 06:05:32 +00:00
|
|
|
return True
|
|
|
|
|
2014-11-19 20:50:49 +00:00
|
|
|
def notify(self, prline=None, prline2=None, sent_to=None, snatched_nzb=None, force=False, module=None, snline=None):
|
2013-09-07 06:05:32 +00:00
|
|
|
"""
|
|
|
|
Sends a boxcar notification based on the provided info or SB config
|
|
|
|
|
|
|
|
title: The title of the notification to send
|
|
|
|
message: The message string to send
|
|
|
|
force: If True then the notification will be sent even if Boxcar is disabled in the config
|
|
|
|
"""
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
if module is None:
|
|
|
|
module = ''
|
|
|
|
module += '[NOTIFIER]'
|
2013-09-07 06:05:32 +00:00
|
|
|
|
2017-10-25 18:33:56 +00:00
|
|
|
if not mylar.CONFIG.BOXCAR_ENABLED and not force:
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.fdebug(module + ' Notification for Boxcar not enabled, skipping this notification.')
|
2013-09-07 06:05:32 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
# if no username was given then use the one from the config
|
|
|
|
if snatched_nzb:
|
2014-11-19 20:50:49 +00:00
|
|
|
title = snline
|
IMP: Added 'Force to TPB/GN' option for printed editions and 'Force to Print' option for TPB/GN's (this WILL impact how files are scanned in - so make sure you have files named appropriately), IMP: Added One-Shot as a Type, FIX: Fixed incorrect variable reference to seriesvolume during post-processing of TPB series, FIX: Fixed refresh to fire off every 5 minutes, FIX: When post-processing and metatagging a cbz file with rename files not enabled, would indicate the new filename as being a copy of the existing file (ie. (1).cbz) which would carry over to a final filename, IMP: Allow Mylar to populate the alias list on add/refresh of a series if the aliases don't already exist in the Alternate Series field for the series, FIX: Fixed a problem with single quotes in series titles when using experimental search,
IMP: When searching for a one-off series, will accept either issues with an issue number or those with no issue numbers as acceptable search results when searching, IMP: Updated search code to utilize the existing filename parser within Mylar when parsing the search results for more consistency
2018-12-22 22:48:14 +00:00
|
|
|
message = "Mylar has snatched: " + snatched_nzb + " and " + sent_to
|
2013-09-07 06:05:32 +00:00
|
|
|
else:
|
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
|
|
|
title = prline
|
|
|
|
message = prline2
|
2013-09-07 06:05:32 +00:00
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
logger.info(module + ' Sending notification to Boxcar2')
|
2013-09-07 06:05:32 +00:00
|
|
|
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
self._sendBoxcar(message, title, module)
|
2013-09-07 06:05:32 +00:00
|
|
|
return True
|
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
def test_notify(self):
|
|
|
|
self.notify(prline='Test Message',prline2='ZOMG Lazors Pewpewpew!')
|
|
|
|
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
class PUSHBULLET:
|
|
|
|
|
2017-05-12 18:24:35 +00:00
|
|
|
def __init__(self, test_apikey=None):
|
2015-07-21 06:37:41 +00:00
|
|
|
self.PUSH_URL = "https://api.pushbullet.com/v2/pushes"
|
2017-05-12 18:24:35 +00:00
|
|
|
if test_apikey is None:
|
2017-10-25 18:33:56 +00:00
|
|
|
self.apikey = mylar.CONFIG.PUSHBULLET_APIKEY
|
2017-05-12 18:24:35 +00:00
|
|
|
else:
|
|
|
|
self.apikey = test_apikey
|
2017-10-25 18:33:56 +00:00
|
|
|
self.deviceid = mylar.CONFIG.PUSHBULLET_DEVICEID
|
|
|
|
self.channel_tag = mylar.CONFIG.PUSHBULLET_CHANNEL_TAG
|
2015-08-19 18:12:20 +00:00
|
|
|
self._json_header = {'Content-Type': 'application/json',
|
2017-05-12 18:24:35 +00:00
|
|
|
'Authorization': 'Basic %s' % base64.b64encode(self.apikey + ":")}
|
2015-07-21 06:37:41 +00:00
|
|
|
self._session = requests.Session()
|
|
|
|
self._session.headers.update(self._json_header)
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
|
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
|
|
|
def get_devices(self, api):
|
|
|
|
return self.notify(method="GET")
|
|
|
|
|
|
|
|
def notify(self, snline=None, prline=None, prline2=None, snatched=None, sent_to=None, prov=None, module=None, method=None):
|
IMP:(#753) Better handling of cbz files when using metatagging option, IMP: Added option for MetaTagging to enable/disable overwriting of existing metadata on cbz files, IMP: Post-Processing will now delete folders that are identical to filenames after successful post-processing, FIX:(#756) Fix for Manual Search for an Issue which resulted in traceback errors upon not finding any matches (Windows), IMP: Added module-name to logging for some modules to help troubleshooting (eventually all will be done), IMP: If a filename contained repeated characters for spaces (ie. ___ or ...), it would fail on post-processing due to the nzbname being off, IMP: Monitoring of CV API will now be persitent on restarts/shutdowns/etc, IMP: Added a maximum CV API global so that it can be adjusted for monitoring more easily should API requirements change, IMP: When Adding new series, will now only mark issues that are actually upcoming as Wanted (based on Store Date)
2014-06-22 08:32:45 +00:00
|
|
|
if module is None:
|
|
|
|
module = ''
|
|
|
|
module += '[NOTIFIER]'
|
2015-07-21 06:37:41 +00:00
|
|
|
|
|
|
|
# http_handler = HTTPSConnection("api.pushbullet.com")
|
2015-05-22 08:32:51 +00:00
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
# if method == 'GET':
|
|
|
|
# uri = '/v2/devices'
|
|
|
|
# else:
|
|
|
|
# method = 'POST'
|
|
|
|
# uri = '/v2/pushes'
|
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
# authString = base64.b64encode(self.apikey + ":")
|
2015-01-31 22:21:42 +00:00
|
|
|
|
|
|
|
if method == 'GET':
|
2015-07-21 06:37:41 +00:00
|
|
|
pass
|
|
|
|
# http_handler.request(method, uri, None, headers={'Authorization': 'Basic %s:' % authString})
|
2015-01-31 22:21:42 +00:00
|
|
|
else:
|
|
|
|
if snatched:
|
|
|
|
if snatched[-1] == '.': snatched = snatched[:-1]
|
|
|
|
event = snline
|
IMP: Added 'Force to TPB/GN' option for printed editions and 'Force to Print' option for TPB/GN's (this WILL impact how files are scanned in - so make sure you have files named appropriately), IMP: Added One-Shot as a Type, FIX: Fixed incorrect variable reference to seriesvolume during post-processing of TPB series, FIX: Fixed refresh to fire off every 5 minutes, FIX: When post-processing and metatagging a cbz file with rename files not enabled, would indicate the new filename as being a copy of the existing file (ie. (1).cbz) which would carry over to a final filename, IMP: Allow Mylar to populate the alias list on add/refresh of a series if the aliases don't already exist in the Alternate Series field for the series, FIX: Fixed a problem with single quotes in series titles when using experimental search,
IMP: When searching for a one-off series, will accept either issues with an issue number or those with no issue numbers as acceptable search results when searching, IMP: Updated search code to utilize the existing filename parser within Mylar when parsing the search results for more consistency
2018-12-22 22:48:14 +00:00
|
|
|
message = "Mylar has snatched: " + snatched + " from " + prov + " and " + sent_to
|
2015-01-31 22:21:42 +00:00
|
|
|
else:
|
|
|
|
event = prline + ' complete!'
|
|
|
|
message = prline2
|
|
|
|
|
|
|
|
data = {'type': "note", #'device_iden': self.deviceid,
|
|
|
|
'title': event.encode('utf-8'), #"mylar",
|
2015-05-22 08:32:51 +00:00
|
|
|
'body': message.encode('utf-8')}
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
|
2017-07-18 04:26:40 +00:00
|
|
|
if self.channel_tag:
|
|
|
|
data['channel_tag'] = self.channel_tag
|
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
r = self._session.post(self.PUSH_URL, data=json.dumps(data))
|
2017-05-12 18:24:35 +00:00
|
|
|
dt = r.json()
|
2015-07-21 06:37:41 +00:00
|
|
|
if r.status_code == 200:
|
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
|
|
|
if method == 'GET':
|
2017-05-12 18:24:35 +00:00
|
|
|
return dt
|
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
|
|
|
else:
|
2015-01-31 22:21:42 +00:00
|
|
|
logger.info(module + ' PushBullet notifications sent.')
|
2017-05-12 18:24:35 +00:00
|
|
|
return {'status': True,
|
|
|
|
'message': 'APIKEY verified OK / notification sent'}
|
2015-07-21 06:37:41 +00:00
|
|
|
elif r.status_code >= 400 and r.status_code < 500:
|
|
|
|
logger.error(module + ' PushBullet request failed: %s' % r.content)
|
2017-05-12 18:24:35 +00:00
|
|
|
return {'status': False,
|
|
|
|
'message': '[' + str(r.status_code) + '] ' + dt['error']['message']}
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
else:
|
2017-05-12 18:24:35 +00:00
|
|
|
logger.error(module + ' PushBullet notification failed serverside: %s' % r.content)
|
|
|
|
return {'status': False,
|
|
|
|
'message': '[' + str(r.status_code) + '] ' + dt['error']['message']}
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
|
2015-07-21 06:37:41 +00:00
|
|
|
def test_notify(self):
|
2015-08-19 18:12:20 +00:00
|
|
|
return self.notify(prline='Test Message', prline2='Release the Ninjas!')
|
2013-09-07 06:05:32 +00:00
|
|
|
|
2016-11-08 08:11:51 +00:00
|
|
|
class TELEGRAM:
|
2017-06-09 00:23:59 +00:00
|
|
|
def __init__(self, test_userid=None, test_token=None):
|
2016-11-08 08:11:51 +00:00
|
|
|
self.TELEGRAM_API = "https://api.telegram.org/bot%s/%s"
|
2017-06-09 00:23:59 +00:00
|
|
|
if test_userid is None:
|
2017-10-25 18:33:56 +00:00
|
|
|
self.userid = mylar.CONFIG.TELEGRAM_USERID
|
2017-06-09 00:23:59 +00:00
|
|
|
else:
|
|
|
|
self.userid = test_userid
|
|
|
|
if test_token is None:
|
2017-10-25 18:33:56 +00:00
|
|
|
self.token = mylar.CONFIG.TELEGRAM_TOKEN
|
2017-06-09 00:23:59 +00:00
|
|
|
else:
|
|
|
|
self.token = test_token
|
2016-11-08 08:11:51 +00:00
|
|
|
|
2020-01-31 13:38:38 +00:00
|
|
|
def notify(self, message, imageUrl=None):
|
|
|
|
# Construct message
|
|
|
|
payload = {'chat_id': self.userid, 'text': message}
|
|
|
|
sendMethod = "sendMessage"
|
|
|
|
|
|
|
|
if imageUrl:
|
2020-01-31 13:13:44 +00:00
|
|
|
# Construct message
|
2020-01-31 13:38:38 +00:00
|
|
|
payload = {'chat_id': self.userid, 'caption': message, 'photo': imageUrl}
|
|
|
|
sendMethod = "sendPhoto"
|
2020-01-31 13:13:44 +00:00
|
|
|
|
2020-01-31 13:38:38 +00:00
|
|
|
# Send message to user using Telegram's Bot API
|
|
|
|
try:
|
|
|
|
response = requests.post(self.TELEGRAM_API % (self.token, sendMethod), json=payload, verify=True)
|
|
|
|
except Exception as e:
|
|
|
|
logger.info('Telegram notify failed: ' + str(e))
|
2016-11-08 08:11:51 +00:00
|
|
|
|
|
|
|
# Error logging
|
2020-01-31 14:41:12 +00:00
|
|
|
sent_successfully = True
|
2016-11-08 08:11:51 +00:00
|
|
|
if not response.status_code == 200:
|
2017-05-16 18:15:11 +00:00
|
|
|
logger.info(u'Could not send notification to TelegramBot (token=%s). Response: [%s]' % (self.token, response.text))
|
2020-01-31 14:41:12 +00:00
|
|
|
sent_successfully = False
|
|
|
|
|
|
|
|
if not sent_successfully and sendMethod != "sendMessage":
|
|
|
|
return self.notify(message)
|
2016-11-08 08:11:51 +00:00
|
|
|
|
|
|
|
logger.info(u"Telegram notifications sent.")
|
2020-01-31 14:41:12 +00:00
|
|
|
return sent_successfully
|
2016-11-08 08:11:51 +00:00
|
|
|
|
|
|
|
def test_notify(self):
|
2018-02-27 18:06:28 +00:00
|
|
|
return self.notify('Test Message: Release the Ninjas!')
|
2017-06-20 02:05:53 +00:00
|
|
|
|
2019-03-01 11:27:46 +00:00
|
|
|
class EMAIL:
|
|
|
|
def __init__(self, test_emailfrom=None, test_emailto=None, test_emailsvr=None, test_emailport=None, test_emailuser=None, test_emailpass=None, test_emailenc=None):
|
|
|
|
self.emailfrom = mylar.CONFIG.EMAIL_FROM if test_emailfrom is None else test_emailfrom
|
|
|
|
self.emailto = mylar.CONFIG.EMAIL_TO if test_emailto is None else test_emailto
|
|
|
|
self.emailsvr = mylar.CONFIG.EMAIL_SERVER if test_emailsvr is None else test_emailsvr
|
|
|
|
self.emailport = mylar.CONFIG.EMAIL_PORT if test_emailport is None else test_emailport
|
|
|
|
self.emailuser = mylar.CONFIG.EMAIL_USER if test_emailuser is None else test_emailuser
|
|
|
|
self.emailpass = mylar.CONFIG.EMAIL_PASSWORD if test_emailpass is None else test_emailpass
|
|
|
|
self.emailenc = mylar.CONFIG.EMAIL_ENC if test_emailenc is None else int(test_emailenc)
|
|
|
|
|
|
|
|
def notify(self, message, subject, module=None):
|
|
|
|
if module is None:
|
|
|
|
module = ''
|
|
|
|
module += '[NOTIFIER]'
|
|
|
|
sent_successfully = False
|
|
|
|
|
|
|
|
try:
|
|
|
|
logger.debug(module + u' Sending email notification. From: [%s] - To: [%s] - Server: [%s] - Port: [%s] - Username: [%s] - Password: [********] - Encryption: [%s] - Message: [%s]' % (self.emailfrom, self.emailto, self.emailsvr, self.emailport, self.emailuser, self.emailenc, message))
|
|
|
|
msg = MIMEMultipart()
|
|
|
|
msg['From'] = str(self.emailfrom)
|
|
|
|
msg['To'] = str(self.emailto)
|
|
|
|
msg['Subject'] = subject
|
2019-10-09 04:47:18 +00:00
|
|
|
msg['Date'] = formatdate()
|
|
|
|
msg['Message-ID'] = make_msgid('mylar')
|
2019-03-01 11:27:46 +00:00
|
|
|
msg.attach(MIMEText(message, 'plain'))
|
|
|
|
|
|
|
|
if self.emailenc is 1:
|
|
|
|
sock = smtplib.SMTP_SSL(self.emailsvr, str(self.emailport))
|
|
|
|
else:
|
|
|
|
sock = smtplib.SMTP(self.emailsvr, str(self.emailport))
|
|
|
|
|
|
|
|
if self.emailenc is 2:
|
|
|
|
sock.starttls()
|
|
|
|
|
|
|
|
if self.emailuser or self.emailpass:
|
|
|
|
sock.login(str(self.emailuser), str(self.emailpass))
|
|
|
|
|
|
|
|
sock.sendmail(str(self.emailfrom), str(self.emailto), msg.as_string())
|
|
|
|
sock.quit()
|
|
|
|
sent_successfully = True
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
logger.warn(module + u' Oh no!! Email notification failed: ' + str(e))
|
|
|
|
|
|
|
|
return sent_successfully
|
|
|
|
|
|
|
|
def test_notify(self):
|
|
|
|
return self.notify('Test Message: With great power comes great responsibility.', 'Mylar notification - Test')
|
|
|
|
|
2017-06-20 02:05:53 +00:00
|
|
|
class SLACK:
|
|
|
|
def __init__(self, test_webhook_url=None):
|
2017-10-25 18:33:56 +00:00
|
|
|
self.webhook_url = mylar.CONFIG.SLACK_WEBHOOK_URL if test_webhook_url is None else test_webhook_url
|
2018-08-03 20:19:52 +00:00
|
|
|
|
2018-07-30 20:44:17 +00:00
|
|
|
def notify(self, text, attachment_text, snatched_nzb=None, prov=None, sent_to=None, module=None):
|
2017-06-20 02:05:53 +00:00
|
|
|
if module is None:
|
|
|
|
module = ''
|
|
|
|
module += '[NOTIFIER]'
|
2018-08-03 20:19:52 +00:00
|
|
|
|
2019-04-18 19:48:05 +00:00
|
|
|
if 'snatched' in attachment_text.lower():
|
|
|
|
snatched_text = '%s: %s' % (attachment_text, snatched_nzb)
|
|
|
|
if all([sent_to is not None, prov is not None]):
|
|
|
|
snatched_text += ' from %s and %s' % (prov, sent_to)
|
|
|
|
elif sent_to is None:
|
|
|
|
snatched_text += ' from %s' % prov
|
|
|
|
attachment_text = snatched_text
|
2018-08-02 15:44:11 +00:00
|
|
|
else:
|
2018-08-03 20:19:52 +00:00
|
|
|
pass
|
2018-07-30 20:44:17 +00:00
|
|
|
|
2017-06-20 02:05:53 +00:00
|
|
|
payload = {
|
2018-02-26 15:22:34 +00:00
|
|
|
# "text": text,
|
|
|
|
# "attachments": [
|
|
|
|
# {
|
|
|
|
# "color": "#36a64f",
|
|
|
|
# "text": attachment_text
|
|
|
|
# }
|
|
|
|
# ]
|
|
|
|
# FIX: #1861 move notif from attachment to msg body - bbq
|
|
|
|
"text": attachment_text
|
2017-06-20 02:05:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try:
|
|
|
|
response = requests.post(self.webhook_url, json=payload, verify=True)
|
|
|
|
except Exception, e:
|
|
|
|
logger.info(module + u'Slack notify failed: ' + str(e))
|
|
|
|
|
|
|
|
# Error logging
|
|
|
|
sent_successfuly = True
|
|
|
|
if not response.status_code == 200:
|
|
|
|
logger.info(module + u'Could not send notification to Slack (webhook_url=%s). Response: [%s]' % (self.webhook_url, response.text))
|
|
|
|
sent_successfuly = False
|
|
|
|
|
|
|
|
logger.info(module + u"Slack notifications sent.")
|
|
|
|
return sent_successfuly
|
2018-07-31 20:12:07 +00:00
|
|
|
|
2017-06-20 02:05:53 +00:00
|
|
|
def test_notify(self):
|
|
|
|
return self.notify('Test Message', 'Release the Ninjas!')
|