field in NFO, unable to find a ID", logger.WARNING)
diff --git a/sickbeard/metadata/helpers.py b/sickbeard/metadata/helpers.py
index 67f9751d..80870d5e 100644
--- a/sickbeard/metadata/helpers.py
+++ b/sickbeard/metadata/helpers.py
@@ -24,11 +24,11 @@ def getShowImage(url, imgNum=None):
image_data = None # @UnusedVariable
- if url == None:
+ if url is None:
return None
# if they provided a fanart number try to use it instead
- if imgNum != None:
+ if imgNum is not None:
tempURL = url.split('-')[0] + "-" + str(imgNum) + ".jpg"
else:
tempURL = url
diff --git a/sickbeard/metadata/mediabrowser.py b/sickbeard/metadata/mediabrowser.py
index f882c1bc..19bcef61 100644
--- a/sickbeard/metadata/mediabrowser.py
+++ b/sickbeard/metadata/mediabrowser.py
@@ -261,7 +261,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
indexerid.text = myShow['id']
indexer = etree.SubElement(tv_node, "indexer")
- if show_obj.indexer != None:
+ if show_obj.indexer is not None:
indexer.text = show_obj.indexer
SeriesName = etree.SubElement(tv_node, "SeriesName")
@@ -363,7 +363,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
cur_actor_type.text = "Actor"
cur_actor_role = etree.SubElement(cur_actor, "Role")
cur_actor_role_text = actor['role']
- if cur_actor_role_text != None:
+ if cur_actor_role_text is not None:
cur_actor_role.text = cur_actor_role_text
helpers.indentXML(tv_node)
@@ -433,7 +433,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
episode = rootNode
EpisodeName = etree.SubElement(episode, "EpisodeName")
- if curEpToWrite.name != None:
+ if curEpToWrite.name is not None:
EpisodeName.text = curEpToWrite.name
else:
EpisodeName.text = ""
@@ -462,7 +462,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
MetadataType.text = "Episode"
Overview = etree.SubElement(episode, "Overview")
- if curEpToWrite.description != None:
+ if curEpToWrite.description is not None:
Overview.text = curEpToWrite.description
else:
Overview.text = ""
@@ -471,7 +471,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
Rating = etree.SubElement(episode, "Rating")
if getattr(myEp, 'rating', None) is not None:
rating_text = myEp['rating']
- if rating_text != None:
+ if rating_text is not None:
Rating.text = rating_text
IMDB_ID = etree.SubElement(episode, "IMDB_ID")
diff --git a/sickbeard/metadata/wdtv.py b/sickbeard/metadata/wdtv.py
index df3d93bb..263e2428 100644
--- a/sickbeard/metadata/wdtv.py
+++ b/sickbeard/metadata/wdtv.py
@@ -229,7 +229,7 @@ class WDTVMetadata(generic.GenericMetadata):
seriesName.text = myShow["seriesname"]
episodeName = etree.SubElement(episode, "episode_name")
- if curEpToWrite.name != None:
+ if curEpToWrite.name is not None:
episodeName.text = curEpToWrite.name
seasonNumber = etree.SubElement(episode, "season_number")
@@ -264,7 +264,7 @@ class WDTVMetadata(generic.GenericMetadata):
director = etree.SubElement(episode, "director")
if getattr(myEp, 'director', None) is not None:
director_text = myEp['director']
- if director_text != None:
+ if director_text is not None:
director.text = director_text
if getattr(myShow, '_actors', None) is not None:
@@ -274,11 +274,11 @@ class WDTVMetadata(generic.GenericMetadata):
cur_actor_name.text = actor['name']
cur_actor_role = etree.SubElement(cur_actor, "role")
cur_actor_role_text = actor['role']
- if cur_actor_role_text != None:
+ if cur_actor_role_text is not None:
cur_actor_role.text = cur_actor_role_text
overview = etree.SubElement(episode, "overview")
- if curEpToWrite.description != None:
+ if curEpToWrite.description is not None:
overview.text = curEpToWrite.description
# Make it purdy
diff --git a/sickbeard/metadata/xbmc_12plus.py b/sickbeard/metadata/xbmc_12plus.py
index bfc02190..7eef407f 100644
--- a/sickbeard/metadata/xbmc_12plus.py
+++ b/sickbeard/metadata/xbmc_12plus.py
@@ -193,12 +193,12 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
cur_actor_role = etree.SubElement(cur_actor, "role")
cur_actor_role_text = actor['role']
- if cur_actor_role_text != None:
+ if cur_actor_role_text is not None:
cur_actor_role.text = cur_actor_role_text
cur_actor_thumb = etree.SubElement(cur_actor, "thumb")
cur_actor_thumb_text = actor['image']
- if cur_actor_thumb_text != None:
+ if cur_actor_thumb_text is not None:
cur_actor_thumb.text = cur_actor_thumb_text
# Make it purdy
@@ -267,11 +267,11 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
episode = rootNode
title = etree.SubElement(episode, "title")
- if curEpToWrite.name != None:
+ if curEpToWrite.name is not None:
title.text = curEpToWrite.name
showtitle = etree.SubElement(episode, "showtitle")
- if curEpToWrite.show.name != None:
+ if curEpToWrite.show.name is not None:
showtitle.text = curEpToWrite.show.name
season = etree.SubElement(episode, "season")
@@ -290,7 +290,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
aired.text = ''
plot = etree.SubElement(episode, "plot")
- if curEpToWrite.description != None:
+ if curEpToWrite.description is not None:
plot.text = curEpToWrite.description
runtime = etree.SubElement(episode, "runtime")
@@ -301,18 +301,18 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
displayseason = etree.SubElement(episode, "displayseason")
if getattr(myEp, 'airsbefore_season', None) is not None:
displayseason_text = myEp['airsbefore_season']
- if displayseason_text != None:
+ if displayseason_text is not None:
displayseason.text = displayseason_text
displayepisode = etree.SubElement(episode, "displayepisode")
if getattr(myEp, 'airsbefore_episode', None) is not None:
displayepisode_text = myEp['airsbefore_episode']
- if displayepisode_text != None:
+ if displayepisode_text is not None:
displayepisode.text = displayepisode_text
thumb = etree.SubElement(episode, "thumb")
thumb_text = getattr(myEp, 'filename', None)
- if thumb_text != None:
+ if thumb_text is not None:
thumb.text = thumb_text
watched = etree.SubElement(episode, "watched")
@@ -320,17 +320,17 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
credits = etree.SubElement(episode, "credits")
credits_text = getattr(myEp, 'writer', None)
- if credits_text != None:
+ if credits_text is not None:
credits.text = credits_text
director = etree.SubElement(episode, "director")
director_text = getattr(myEp, 'director', None)
- if director_text != None:
+ if director_text is not None:
director.text = director_text
rating = etree.SubElement(episode, "rating")
rating_text = getattr(myEp, 'rating', None)
- if rating_text != None:
+ if rating_text is not None:
rating.text = rating_text
gueststar_text = getattr(myEp, 'gueststars', None)
@@ -351,12 +351,12 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
cur_actor_role = etree.SubElement(cur_actor, "role")
cur_actor_role_text = actor['role']
- if cur_actor_role_text != None:
+ if cur_actor_role_text is not None:
cur_actor_role.text = cur_actor_role_text
cur_actor_thumb = etree.SubElement(cur_actor, "thumb")
cur_actor_thumb_text = actor['image']
- if cur_actor_thumb_text != None:
+ if cur_actor_thumb_text is not None:
cur_actor_thumb.text = cur_actor_thumb_text
# Make it purdy
diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py
index 044d056f..ab07048a 100644
--- a/sickbeard/name_parser/parser.py
+++ b/sickbeard/name_parser/parser.py
@@ -154,7 +154,7 @@ class NameParser(object):
b = getattr(second, attr)
# if a is good use it
- if a != None or (type(a) == list and len(a)):
+ if a is not None or (type(a) == list and len(a)):
return a
# if not use b (if b isn't set it'll just be default)
else:
@@ -242,7 +242,7 @@ class NameParser(object):
final_result.which_regex += dir_name_result.which_regex
# if there's no useful info in it then raise an exception
- if final_result.season_number == None and not final_result.episode_numbers and final_result.air_date == None and not final_result.series_name:
+ if final_result.season_number is None and not final_result.episode_numbers and final_result.air_date is None and not final_result.series_name:
raise InvalidNameException("Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace'))
name_parser_cache.add(name, final_result)
@@ -363,11 +363,11 @@ class ParseResult(object):
return True
def __str__(self):
- if self.series_name != None:
+ if self.series_name is not None:
to_return = self.series_name + u' - '
else:
to_return = u''
- if self.season_number != None:
+ if self.season_number is not None:
to_return += 'S'+str(self.season_number)
if self.episode_numbers and len(self.episode_numbers):
for e in self.episode_numbers:
@@ -386,7 +386,7 @@ class ParseResult(object):
return to_return.encode('utf-8')
def _is_air_by_date(self):
- if self.season_number == None and len(self.episode_numbers) == 0 and self.air_date:
+ if self.season_number is None and len(self.episode_numbers) == 0 and self.air_date:
return True
return False
air_by_date = property(_is_air_by_date)
@@ -397,7 +397,7 @@ class ParseResult(object):
tvdb numbering, if necessary.
"""
if self.air_by_date: return self # scene numbering does not apply to air-by-date
- if self.season_number == None: return self # can't work without a season
+ if self.season_number is None: return self # can't work without a season
if len(self.episode_numbers) == 0: return self # need at least one episode
indexer_id = NameParser.series_name_to_indexer_id(self.series_name, True, True, False)
diff --git a/sickbeard/naming.py b/sickbeard/naming.py
index f355a97a..21eaa86c 100644
--- a/sickbeard/naming.py
+++ b/sickbeard/naming.py
@@ -65,12 +65,12 @@ def check_force_season_folders(pattern=None, multi=None):
Returns true if season folders need to be forced on or false otherwise.
"""
- if pattern == None:
+ if pattern is None:
pattern = sickbeard.NAMING_PATTERN
valid = not validate_name(pattern, None, file_only=True)
- if multi != None:
+ if multi is not None:
valid = valid or not validate_name(pattern, multi, file_only=True)
return valid
@@ -81,13 +81,13 @@ def check_valid_naming(pattern=None, multi=None):
Returns true if the naming is valid, false if not.
"""
- if pattern == None:
+ if pattern is None:
pattern = sickbeard.NAMING_PATTERN
logger.log(u"Checking whether the pattern "+pattern+" is valid for a single episode", logger.DEBUG)
valid = validate_name(pattern, None)
- if multi != None:
+ if multi is not None:
logger.log(u"Checking whether the pattern "+pattern+" is valid for a multi episode", logger.DEBUG)
valid = valid and validate_name(pattern, multi)
@@ -99,7 +99,7 @@ def check_valid_abd_naming(pattern=None):
Returns true if the naming is valid, false if not.
"""
- if pattern == None:
+ if pattern is None:
pattern = sickbeard.NAMING_PATTERN
logger.log(u"Checking whether the pattern "+pattern+" is valid for an air-by-date episode", logger.DEBUG)
@@ -156,7 +156,7 @@ def _generate_sample_ep(multi=None, abd=False):
else:
ep._release_name = 'Show.Name.S02E03.HDTV.XviD-RLSGROUP'
- if multi != None:
+ if multi is not None:
ep._name = "Ep Name (1)"
ep._release_name = 'Show.Name.S02E03E04E05.HDTV.XviD-RLSGROUP'
diff --git a/sickbeard/notifiers/boxcar.py b/sickbeard/notifiers/boxcar.py
index 633245f1..416dc37e 100644
--- a/sickbeard/notifiers/boxcar.py
+++ b/sickbeard/notifiers/boxcar.py
@@ -52,7 +52,7 @@ class BoxcarNotifier:
# if this is a subscription notification then act accordingly
if subscribe:
data = urllib.urlencode({'email': email})
- curUrl = curUrl + "/subscribe"
+ curUrl += "/subscribe"
# for normal requests we need all these parameters
else:
diff --git a/sickbeard/notifiers/emailnotify.py b/sickbeard/notifiers/emailnotify.py
index f872e75f..a943d8f2 100644
--- a/sickbeard/notifiers/emailnotify.py
+++ b/sickbeard/notifiers/emailnotify.py
@@ -32,145 +32,145 @@ from sickbeard import db
from sickbeard.exceptions import ex
class EmailNotifier:
- def __init__(self):
- self.last_err = None
-
- def test_notify(self, host, port, smtp_from, use_tls, user, pwd, to):
- msg = MIMEText('This is a test message from Sick Beard. If you\'re reading this, the test succeeded.')
- msg['Subject'] = 'Sick Beard: Test Message'
- msg['From'] = smtp_from
- msg['To'] = to
- return self._sendmail(host, port, smtp_from, use_tls, user, pwd, [to], msg, True)
+ def __init__(self):
+ self.last_err = None
- def notify_snatch(self, ep_name, title="Snatched:"):
- """
- Send a notification that an episode was snatched
-
- ep_name: The name of the episode that was snatched
- title: The title of the notification (optional)
- """
- if sickbeard.EMAIL_NOTIFY_ONSNATCH:
- show = self._parseEp(ep_name)
- to = self._generate_recepients(show)
- if len(to) == 0:
- logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
- else:
- try:
- msg = MIMEMultipart('alternative')
- msg.attach(MIMEText("Sick Beard Notification - Snatched
\nShow: " + re.search("(.+?) -.+", ep_name).group(1) + "
\nEpisode: " + re.search(".+ - (.+?-.+) -.+", ep_name).group(1) + "
\n\n", 'html'))
- except:
- msg = MIMEText(ep_name)
-
- msg['Subject'] = 'Snatched: ' + ep_name
- msg['From'] = sickbeard.EMAIL_FROM
- msg['To'] = ','.join(to)
- if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
- logger.log("Snatch notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
- else:
- logger.log("Snatch notification ERROR: %s" % self.last_err, logger.ERROR)
+ def test_notify(self, host, port, smtp_from, use_tls, user, pwd, to):
+ msg = MIMEText('This is a test message from Sick Beard. If you\'re reading this, the test succeeded.')
+ msg['Subject'] = 'Sick Beard: Test Message'
+ msg['From'] = smtp_from
+ msg['To'] = to
+ return self._sendmail(host, port, smtp_from, use_tls, user, pwd, [to], msg, True)
- def notify_download(self, ep_name, title="Completed:"):
- """
- Send a notification that an episode was downloaded
-
- ep_name: The name of the episode that was downloaded
- title: The title of the notification (optional)
- """
- if sickbeard.EMAIL_NOTIFY_ONDOWNLOAD:
- show = self._parseEp(ep_name)
- to = self._generate_recepients(show)
- if len(to) == 0:
- logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
- else:
- try:
- msg = MIMEMultipart('alternative')
- msg.attach(MIMEText("Sick Beard Notification - Downloaded
\nShow: " + re.search("(.+?) -.+", ep_name).group(1) + "
\nEpisode: " + re.search(".+ - (.+?-.+) -.+", ep_name).group(1) + "
\n\n", 'html'))
- except:
- msg = MIMEText(ep_name)
-
- msg['Subject'] = 'Downloaded: ' + ep_name
- msg['From'] = sickbeard.EMAIL_FROM
- msg['To'] = ','.join(to)
- if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
- logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
- else:
- logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
+ def notify_snatch(self, ep_name, title="Snatched:"):
+ """
+ Send a notification that an episode was snatched
- def notify_subtitle_download(self, ep_name, lang, title="Downloaded subtitle:"):
- """
- Send a notification that an subtitle was downloaded
-
- ep_name: The name of the episode that was downloaded
- lang: Subtitle language wanted
- """
- if sickbeard.EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD:
- show = self._parseEp(ep_name)
- to = self._generate_recepients(show)
- if len(to) == 0:
- logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
- else:
- try:
- msg = MIMEMultipart('alternative')
- msg.attach(MIMEText("Sick Beard Notification - Subtitle Downloaded
\nShow: " + re.search("(.+?) -.+", ep_name).group(1) + "
\nEpisode: " + re.search(".+ - (.+?-.+) -.+", ep_name).group(1) + "
\nLanguage: " + lang + "
\n\n", 'html'))
- except:
- msg = MIMEText(ep_name + ": " + lang)
-
- msg['Subject'] = lang + ' Subtitle Downloaded: ' + ep_name
- msg['From'] = sickbeard.EMAIL_FROM
- msg['To'] = ','.join(to)
- if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
- logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
- else:
- logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
+ ep_name: The name of the episode that was snatched
+ title: The title of the notification (optional)
+ """
+ if sickbeard.EMAIL_NOTIFY_ONSNATCH:
+ show = self._parseEp(ep_name)
+ to = self._generate_recepients(show)
+ if len(to) == 0:
+ logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
+ else:
+ try:
+ msg = MIMEMultipart('alternative')
+ msg.attach(MIMEText("Sick Beard Notification - Snatched
\nShow: " + re.search("(.+?) -.+", ep_name).group(1) + "
\nEpisode: " + re.search(".+ - (.+?-.+) -.+", ep_name).group(1) + "
\n\n", 'html'))
+ except:
+ msg = MIMEText(ep_name)
- def _generate_recepients(self, show):
- addrs = []
+ msg['Subject'] = 'Snatched: ' + ep_name
+ msg['From'] = sickbeard.EMAIL_FROM
+ msg['To'] = ','.join(to)
+ if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
+ logger.log("Snatch notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
+ else:
+ logger.log("Snatch notification ERROR: %s" % self.last_err, logger.ERROR)
- # Grab the global recipients
- for addr in sickbeard.EMAIL_LIST.split(','):
- if(len(addr.strip()) > 0):
- addrs.append(addr)
+ def notify_download(self, ep_name, title="Completed:"):
+ """
+ Send a notification that an episode was downloaded
- # Grab the recipients for the show
- mydb = db.DBConnection()
- for s in show:
- for subs in mydb.select("SELECT notify_list FROM tv_shows WHERE show_name = ?", (s,)):
- if subs['notify_list']:
- for addr in subs['notify_list'].split(','):
- if(len(addr.strip()) > 0):
- addrs.append(addr)
-
- addrs = set(addrs)
- logger.log('Notification recepients: %s' % addrs, logger.DEBUG)
- return addrs
-
- def _sendmail(self, host, port, smtp_from, use_tls, user, pwd, to, msg, smtpDebug=False):
- logger.log('HOST: %s; PORT: %s; FROM: %s, TLS: %s, USER: %s, PWD: %s, TO: %s' % (host, port, smtp_from, use_tls, user, pwd, to), logger.DEBUG)
- srv = smtplib.SMTP(host, int(port))
- if smtpDebug:
- srv.set_debuglevel(1)
- try:
- if (use_tls == '1' or use_tls == True) or (len(user) > 0 and len(pwd) > 0):
- srv.ehlo()
- logger.log('Sent initial EHLO command!', logger.DEBUG)
- if use_tls == '1' or use_tls == True:
- srv.starttls()
- logger.log('Sent STARTTLS command!', logger.DEBUG)
- if len(user) > 0 and len(pwd) > 0:
- srv.login(user, pwd)
- logger.log('Sent LOGIN command!', logger.DEBUG)
- srv.sendmail(smtp_from, to, msg.as_string())
- srv.quit()
- return True
- except Exception as e:
- self.last_err = '%s' % e
- return False
+ ep_name: The name of the episode that was downloaded
+ title: The title of the notification (optional)
+ """
+ if sickbeard.EMAIL_NOTIFY_ONDOWNLOAD:
+ show = self._parseEp(ep_name)
+ to = self._generate_recepients(show)
+ if len(to) == 0:
+ logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
+ else:
+ try:
+ msg = MIMEMultipart('alternative')
+ msg.attach(MIMEText("Sick Beard Notification - Downloaded
\nShow: " + re.search("(.+?) -.+", ep_name).group(1) + "
\nEpisode: " + re.search(".+ - (.+?-.+) -.+", ep_name).group(1) + "
\n\n", 'html'))
+ except:
+ msg = MIMEText(ep_name)
+
+ msg['Subject'] = 'Downloaded: ' + ep_name
+ msg['From'] = sickbeard.EMAIL_FROM
+ msg['To'] = ','.join(to)
+ if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
+ logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
+ else:
+ logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
+
+ def notify_subtitle_download(self, ep_name, lang, title="Downloaded subtitle:"):
+ """
+ Send a notification that an subtitle was downloaded
+
+ ep_name: The name of the episode that was downloaded
+ lang: Subtitle language wanted
+ """
+ if sickbeard.EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD:
+ show = self._parseEp(ep_name)
+ to = self._generate_recepients(show)
+ if len(to) == 0:
+ logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
+ else:
+ try:
+ msg = MIMEMultipart('alternative')
+ msg.attach(MIMEText("Sick Beard Notification - Subtitle Downloaded
\nShow: " + re.search("(.+?) -.+", ep_name).group(1) + "
\nEpisode: " + re.search(".+ - (.+?-.+) -.+", ep_name).group(1) + "
\nLanguage: " + lang + "
\n\n", 'html'))
+ except:
+ msg = MIMEText(ep_name + ": " + lang)
+
+ msg['Subject'] = lang + ' Subtitle Downloaded: ' + ep_name
+ msg['From'] = sickbeard.EMAIL_FROM
+ msg['To'] = ','.join(to)
+ if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
+ logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
+ else:
+ logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
+
+ def _generate_recepients(self, show):
+ addrs = []
+
+ # Grab the global recipients
+ for addr in sickbeard.EMAIL_LIST.split(','):
+ if(len(addr.strip()) > 0):
+ addrs.append(addr)
+
+ # Grab the recipients for the show
+ mydb = db.DBConnection()
+ for s in show:
+ for subs in mydb.select("SELECT notify_list FROM tv_shows WHERE show_name = ?", (s,)):
+ if subs['notify_list']:
+ for addr in subs['notify_list'].split(','):
+ if(len(addr.strip()) > 0):
+ addrs.append(addr)
+
+ addrs = set(addrs)
+ logger.log('Notification recepients: %s' % addrs, logger.DEBUG)
+ return addrs
+
+ def _sendmail(self, host, port, smtp_from, use_tls, user, pwd, to, msg, smtpDebug=False):
+ logger.log('HOST: %s; PORT: %s; FROM: %s, TLS: %s, USER: %s, PWD: %s, TO: %s' % (host, port, smtp_from, use_tls, user, pwd, to), logger.DEBUG)
+ srv = smtplib.SMTP(host, int(port))
+ if smtpDebug:
+ srv.set_debuglevel(1)
+ try:
+ if (use_tls == '1' or use_tls == True) or (len(user) > 0 and len(pwd) > 0):
+ srv.ehlo()
+ logger.log('Sent initial EHLO command!', logger.DEBUG)
+ if use_tls == '1' or use_tls == True:
+ srv.starttls()
+ logger.log('Sent STARTTLS command!', logger.DEBUG)
+ if len(user) > 0 and len(pwd) > 0:
+ srv.login(user, pwd)
+ logger.log('Sent LOGIN command!', logger.DEBUG)
+ srv.sendmail(smtp_from, to, msg.as_string())
+ srv.quit()
+ return True
+ except Exception as e:
+ self.last_err = '%s' % e
+ return False
+
+ def _parseEp(self, ep_name):
+ sep = " - "
+ titles = ep_name.split(sep)
+ titles.sort(key=len, reverse=True)
+ logger.log("TITLES: %s" % titles, logger.DEBUG)
+ return titles
- def _parseEp(self, ep_name):
- sep = " - "
- titles = ep_name.split(sep)
- titles.sort(key=len, reverse=True)
- logger.log("TITLES: %s" % titles, logger.DEBUG)
- return titles
-
notifier = EmailNotifier
diff --git a/sickbeard/notifiers/growl.py b/sickbeard/notifiers/growl.py
index 86d901be..ebedb4f4 100644
--- a/sickbeard/notifiers/growl.py
+++ b/sickbeard/notifiers/growl.py
@@ -88,10 +88,10 @@ class GrowlNotifier:
if not sickbeard.USE_GROWL and not force:
return False
- if name == None:
+ if name is None:
name = title
- if host == None:
+ if host is None:
hostParts = sickbeard.GROWL_HOST.split(':')
else:
hostParts = host.split(':')
@@ -114,7 +114,7 @@ class GrowlNotifier:
opts['priority'] = None
opts['debug'] = False
- if password == None:
+ if password is None:
opts['password'] = sickbeard.GROWL_PASSWORD
else:
opts['password'] = password
@@ -141,7 +141,7 @@ class GrowlNotifier:
def _sendRegistration(self, host=None, password=None, name='Sick Beard Notification'):
opts = {}
- if host == None:
+ if host is None:
hostParts = sickbeard.GROWL_HOST.split(':')
else:
hostParts = host.split(':')
@@ -155,7 +155,7 @@ class GrowlNotifier:
opts['port'] = port
- if password == None:
+ if password is None:
opts['password'] = sickbeard.GROWL_PASSWORD
else:
opts['password'] = password
diff --git a/sickbeard/notifiers/nma.py b/sickbeard/notifiers/nma.py
index 1c67990f..e3bc1557 100644
--- a/sickbeard/notifiers/nma.py
+++ b/sickbeard/notifiers/nma.py
@@ -27,10 +27,10 @@ class NMA_Notifier:
if not sickbeard.USE_NMA and not force:
return False
- if nma_api == None:
+ if nma_api is None:
nma_api = sickbeard.NMA_API
- if nma_priority == None:
+ if nma_priority is None:
nma_priority = sickbeard.NMA_PRIORITY
logger.log(u"NMA title: " + title, logger.DEBUG)
diff --git a/sickbeard/notifiers/nmjv2.py b/sickbeard/notifiers/nmjv2.py
index 95dd4436..15187b04 100644
--- a/sickbeard/notifiers/nmjv2.py
+++ b/sickbeard/notifiers/nmjv2.py
@@ -65,7 +65,7 @@ class NMJv2Notifier:
xml = parseString(response1)
time.sleep (300.0 / 1000.0)
for node in xml.getElementsByTagName('path'):
- xmlTag=node.toxml();
+ xmlTag=node.toxml()
xmlData=xmlTag.replace('','').replace('','').replace('[=]','')
url_db = "http://" + host + ":8008/metadata_database?arg0=check_database&arg1="+ xmlData
reqdb = urllib2.Request(url_db)
diff --git a/sickbeard/notifiers/prowl.py b/sickbeard/notifiers/prowl.py
index 4f0e932c..1ece0c8f 100644
--- a/sickbeard/notifiers/prowl.py
+++ b/sickbeard/notifiers/prowl.py
@@ -53,10 +53,10 @@ class ProwlNotifier:
if not sickbeard.USE_PROWL and not force:
return False
- if prowl_api == None:
+ if prowl_api is None:
prowl_api = sickbeard.PROWL_API
- if prowl_priority == None:
+ if prowl_priority is None:
prowl_priority = sickbeard.PROWL_PRIORITY
diff --git a/sickbeard/notifiers/pushalot.py b/sickbeard/notifiers/pushalot.py
index 3d3d634d..72d8f742 100644
--- a/sickbeard/notifiers/pushalot.py
+++ b/sickbeard/notifiers/pushalot.py
@@ -46,7 +46,7 @@ class PushalotNotifier:
if not sickbeard.USE_PUSHALOT and not force:
return False
- if pushalot_authorizationtoken == None:
+ if pushalot_authorizationtoken is None:
pushalot_authorizationtoken = sickbeard.PUSHALOT_AUTHORIZATIONTOKEN
logger.log(u"Pushalot event: " + event, logger.DEBUG)
diff --git a/sickbeard/notifiers/pushbullet.py b/sickbeard/notifiers/pushbullet.py
index 8135c803..a024d3d8 100644
--- a/sickbeard/notifiers/pushbullet.py
+++ b/sickbeard/notifiers/pushbullet.py
@@ -50,9 +50,9 @@ class PushbulletNotifier:
if not sickbeard.USE_PUSHBULLET and not force:
return False
- if pushbullet_api == None:
+ if pushbullet_api is None:
pushbullet_api = sickbeard.PUSHBULLET_API
- if pushbullet_device == None:
+ if pushbullet_device is None:
pushbullet_device = sickbeard.PUSHBULLET_DEVICE
if method == 'POST':
@@ -70,7 +70,7 @@ class PushbulletNotifier:
authString = base64.encodestring('%s:' % (pushbullet_api)).replace('\n', '')
- if notificationType == None:
+ if notificationType is None:
testMessage = True
try:
logger.log(u"Testing Pushbullet authentication and retrieving the device list.", logger.DEBUG)
diff --git a/sickbeard/notifiers/xbmc.py b/sickbeard/notifiers/xbmc.py
index 0013c1e4..2c7def38 100644
--- a/sickbeard/notifiers/xbmc.py
+++ b/sickbeard/notifiers/xbmc.py
@@ -185,8 +185,6 @@ class XBMCNotifier:
logger.log(u"Failed to detect XBMC version for '" + host + "', check configuration and try again.", logger.DEBUG)
return False
- return False
-
##############################################################################
# Legacy HTTP API (pre XBMC 12) methods
##############################################################################
@@ -525,7 +523,7 @@ class XBMCNotifier:
return True
else:
logger.log(u"Failed to detect XBMC version for '" + host + "', check configuration and try again.", logger.ERROR)
- result = result + 1
+ result += 1
# needed for the 'update xbmc' submenu command
# as it only cares of the final result vs the individual ones
diff --git a/sickbeard/nzbSplitter.py b/sickbeard/nzbSplitter.py
index bc8a4a69..61ca86f3 100644
--- a/sickbeard/nzbSplitter.py
+++ b/sickbeard/nzbSplitter.py
@@ -124,7 +124,7 @@ def splitResult(result):
return False
# bust it up
- season = parse_result.season_number if parse_result.season_number != None else 1
+ season = parse_result.season_number if parse_result.season_number is not None else 1
separateNZBs, xmlns = getSeasonNZBs(result.name, urlData, season)
@@ -143,7 +143,8 @@ def splitResult(result):
return False
# make sure the result is sane
- if (parse_result.season_number != None and parse_result.season_number != season) or (parse_result.season_number == None and season != 1):
+ if (parse_result.season_number is not None and parse_result.season_number != season) or (
+ parse_result.season_number is None and season != 1):
logger.log(u"Found " + newNZB + " inside " + result.name + " but it doesn't seem to belong to the same season, ignoring it", logger.WARNING)
continue
elif len(parse_result.episode_numbers) == 0:
diff --git a/sickbeard/nzbget.py b/sickbeard/nzbget.py
index 076c1ddc..f5d78623 100644
--- a/sickbeard/nzbget.py
+++ b/sickbeard/nzbget.py
@@ -39,7 +39,7 @@ def sendNZB(nzb, proper = False):
nzbgetprio = 0
nzbgetXMLrpc = "http://%(username)s:%(password)s@%(host)s/xmlrpc"
- if sickbeard.NZBGET_HOST == None:
+ if sickbeard.NZBGET_HOST is None:
logger.log(u"No NZBget host found in configuration. Please configure it.", logger.ERROR)
return False
@@ -83,7 +83,7 @@ def sendNZB(nzb, proper = False):
if nzb.resultType == "nzb":
genProvider = GenericProvider("")
data = genProvider.getURL(nzb.url)
- if (data == None):
+ if (data is None):
return False
# if we get a raw data result thats even better
diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py
index e4151dcc..00f0b94c 100644
--- a/sickbeard/postProcessor.py
+++ b/sickbeard/postProcessor.py
@@ -171,7 +171,7 @@ class PostProcessor(object):
base_name = file_path.rpartition('.')[0]
if not base_name_only:
- base_name = base_name + '.'
+ base_name += '.'
# don't strip it all and use cwd by accident
if not base_name:
@@ -476,10 +476,10 @@ class PostProcessor(object):
# remember whether it's a proper
if parse_result.extra_info:
- self.is_proper = re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info, re.I) != None
+ self.is_proper = re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', parse_result.extra_info, re.I) is not None
# if the result is complete then remember that for later
- if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group:
+ if parse_result.series_name and parse_result.season_number is not None and parse_result.episode_numbers and parse_result.release_group:
test_name = os.path.basename(name)
if test_name == self.nzb_name:
self.good_results[self.NZB_NAME] = True
@@ -591,7 +591,7 @@ class PostProcessor(object):
# if we already did a successful history lookup then keep that indexer_id value
if cur_indexer_id and not (self.in_history and indexer_id):
indexer_id = cur_indexer_id
- if cur_season != None:
+ if cur_season is not None:
season = cur_season
if cur_episodes:
episodes = cur_episodes
@@ -604,7 +604,7 @@ class PostProcessor(object):
indexer_lang = None
try:
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
- if(showObj != None):
+ if(showObj is not None):
# set the language of the show
indexer_lang = showObj.lang
self.indexer = showObj.indexer
@@ -636,14 +636,14 @@ class PostProcessor(object):
continue
# if there's no season then we can hopefully just use 1 automatically
- elif season == None and indexer_id:
+ elif season is None and indexer_id:
myDB = db.DBConnection()
numseasonsSQlResult = myDB.select("SELECT COUNT(DISTINCT season) as numseasons FROM tv_episodes WHERE showid = ? and season != 0", [indexer_id])
- if int(numseasonsSQlResult[0][0]) == 1 and season == None:
+ if int(numseasonsSQlResult[0][0]) == 1 and season is None:
self._log(u"Don't have a season number, but this show appears to only have 1 season, setting seasonnumber to 1...", logger.DEBUG)
season = 1
- if indexer_id and season != None and episodes:
+ if indexer_id and season is not None and episodes:
return (indexer_id, season, episodes)
return (indexer_id, season, episodes)
@@ -689,7 +689,7 @@ class PostProcessor(object):
raise exceptions.PostProcessingFailed()
# associate all the episodes together under a single root episode
- if root_ep == None:
+ if root_ep is None:
root_ep = curEp
root_ep.relatedEps = []
elif curEp not in root_ep.relatedEps:
@@ -830,14 +830,14 @@ class PostProcessor(object):
# try to find the file info
(indexer_id, season, episodes) = self._find_info()
- if indexer_id and season != None and episodes:
+ if indexer_id and season is not None and episodes:
break
self._log(u"Can't find show on " + self.indexer + ", auto trying next indexer in list", logger.WARNING)
else:
(indexer_id, season, episodes) = self._find_info()
- if not indexer_id or season == None or not episodes:
+ if not indexer_id or season is None or not episodes:
self._log(u"Can't find show id from ANY of the indexers or season or episode, skipping", logger.WARNING)
return False
diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py
index 69840830..6d91bff4 100644
--- a/sickbeard/processTV.py
+++ b/sickbeard/processTV.py
@@ -345,11 +345,11 @@ def delete_files(processPath, notwantedFiles):
try:
ek.ek(os.chmod,cur_file_path,stat.S_IWRITE)
except OSError, e:
- returnStr += logHelper(u"Cannot change permissions of " + cur_file_path + ': ' + e.strerror, logger.DEBUG)
+ returnStr += logHelper(u"Cannot change permissions of " + cur_file_path + ': ' + str(e.strerror), logger.DEBUG)
try:
ek.ek(os.remove, cur_file_path)
except OSError, e:
- returnStr += logHelper(u"Unable to delete file " + cur_file + ': ' + e.strerror, logger.DEBUG)
+ returnStr += logHelper(u"Unable to delete file " + cur_file + ': ' + str(e.strerror), logger.DEBUG)
def delete_dir(processPath):
diff --git a/sickbeard/properFinder.py b/sickbeard/properFinder.py
index f9d1f3fb..9d302aba 100644
--- a/sickbeard/properFinder.py
+++ b/sickbeard/properFinder.py
@@ -118,7 +118,7 @@ class ProperFinder():
curProper.season = -1
curProper.episode = parse_result.air_date
else:
- curProper.season = parse_result.season_number if parse_result.season_number != None else 1
+ curProper.season = parse_result.season_number if parse_result.season_number is not None else 1
curProper.episode = parse_result.episode_numbers[0]
curProper.quality = Quality.nameQuality(curProper.name)
@@ -236,7 +236,7 @@ class ProperFinder():
# get the episode object
showObj = helpers.findCertainShow(sickbeard.showList, curProper.indexerid)
- if showObj == None:
+ if showObj is None:
logger.log(u"Unable to find the show with indexerid " + str(curProper.indexerid) + " so unable to download the proper", logger.ERROR)
continue
epObj = showObj.getEpisode(curProper.season, curProper.episode)
diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py
index 20f6f624..3111d79d 100644
--- a/sickbeard/providers/btn.py
+++ b/sickbeard/providers/btn.py
@@ -128,8 +128,9 @@ class BTNProvider(generic.TorrentProvider):
return []
- def _api_call(self, apikey, params={}, results_per_page=1000, offset=0):
+ def _api_call(self, apikey, params=None, results_per_page=1000, offset=0):
+ if not params: params = {}
server = jsonrpclib.Server('http://api.btnapps.net')
parsedJSON = {}
diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py
index 127e7376..994fab7e 100644
--- a/sickbeard/providers/generic.py
+++ b/sickbeard/providers/generic.py
@@ -125,7 +125,7 @@ class GenericProvider:
data = self.getURL(result.url)
- if data == None:
+ if data is None:
return False
# use the appropriate watch folder
@@ -323,7 +323,8 @@ class GenericProvider:
if not show.air_by_date:
# this check is meaningless for non-season searches
- if (parse_result.season_number != None and parse_result.season_number != season) or (parse_result.season_number == None and season != 1):
+ if (parse_result.season_number is not None and parse_result.season_number != season) or (
+ parse_result.season_number is None and season != 1):
logger.log(u"The result " + title + " doesn't seem to be a valid episode for season " + str(season) + ", ignoring", logger.DEBUG)
continue
diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py
index 3365b34c..730691e9 100644
--- a/sickbeard/providers/kat.py
+++ b/sickbeard/providers/kat.py
@@ -134,7 +134,7 @@ class KATProvider(generic.TorrentProvider):
quality = Quality.sceneQuality(os.path.basename(fileName))
if quality != Quality.UNKNOWN: break
- if fileName!=None and quality == Quality.UNKNOWN:
+ if fileName is not None and quality == Quality.UNKNOWN:
quality = Quality.assumeQuality(os.path.basename(fileName))
if quality == Quality.UNKNOWN:
diff --git a/sickbeard/providers/nzbs_org_old.py b/sickbeard/providers/nzbs_org_old.py
index 33db0b65..20bd1395 100644
--- a/sickbeard/providers/nzbs_org_old.py
+++ b/sickbeard/providers/nzbs_org_old.py
@@ -81,7 +81,7 @@ class NZBsProvider(generic.NZBProvider):
# Pause to avoid 503's
time.sleep(5)
- if data == None:
+ if data is None:
return []
try:
@@ -126,7 +126,7 @@ class NZBsProvider(generic.NZBProvider):
resultDate = datetime.datetime.strptime(match.group(1), "%a, %d %b %Y %H:%M:%S")
- if date == None or resultDate > date:
+ if date is None or resultDate > date:
results.append(classes.Proper(title, url, resultDate))
return results
diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py
index 3cb1f2f5..80f160e4 100644
--- a/sickbeard/providers/rsstorrent.py
+++ b/sickbeard/providers/rsstorrent.py
@@ -33,7 +33,7 @@ from sickbeard.exceptions import ex
from lib import requests
from bs4 import BeautifulSoup
-from lib.bencode import bdecode
+from lib import bencode
class TorrentRssProvider(generic.TorrentProvider):
@@ -116,7 +116,7 @@ class TorrentRssProvider(generic.TorrentProvider):
torrent_file = self.getURL(url)
try:
- bdecode(torrent_file)
+ bencode.bdecode(torrent_file)
except Exception, e:
self.dumpHTML(torrent_file)
return (False, 'Torrent link is not a valid torrent file: ' + ex(e))
diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py
index 4b8a3bbd..50e4011a 100644
--- a/sickbeard/providers/thepiratebay.py
+++ b/sickbeard/providers/thepiratebay.py
@@ -144,7 +144,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
quality = Quality.sceneQuality(os.path.basename(fileName))
if quality != Quality.UNKNOWN: break
- if fileName!=None and quality == Quality.UNKNOWN:
+ if fileName is not None and quality == Quality.UNKNOWN:
quality = Quality.assumeQuality(os.path.basename(fileName))
if quality == Quality.UNKNOWN:
@@ -254,7 +254,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
continue
#Accept Torrent only from Good People for every Episode Search
- if sickbeard.THEPIRATEBAY_TRUSTED and re.search('(VIP|Trusted|Helper)',torrent.group(0))== None:
+ if sickbeard.THEPIRATEBAY_TRUSTED and re.search('(VIP|Trusted|Helper)',torrent.group(0)) is None:
logger.log(u"ThePirateBay Provider found result " + torrent.group('title') + " but that doesn't seem like a trusted result so I'm ignoring it", logger.DEBUG)
continue
diff --git a/sickbeard/sab.py b/sickbeard/sab.py
index dbb692a1..54044b02 100644
--- a/sickbeard/sab.py
+++ b/sickbeard/sab.py
@@ -43,13 +43,13 @@ def sendNZB(nzb):
# set up a dict with the URL params in it
params = {}
- if sickbeard.SAB_USERNAME != None:
+ if sickbeard.SAB_USERNAME is not None:
params['ma_username'] = sickbeard.SAB_USERNAME
- if sickbeard.SAB_PASSWORD != None:
+ if sickbeard.SAB_PASSWORD is not None:
params['ma_password'] = sickbeard.SAB_PASSWORD
- if sickbeard.SAB_APIKEY != None:
+ if sickbeard.SAB_APIKEY is not None:
params['apikey'] = sickbeard.SAB_APIKEY
- if sickbeard.SAB_CATEGORY != None:
+ if sickbeard.SAB_CATEGORY is not None:
params['cat'] = sickbeard.SAB_CATEGORY
# use high priority if specified (recently aired episode)
@@ -105,7 +105,7 @@ def sendNZB(nzb):
return False
# this means we couldn't open the connection or something just as bad
- if f == None:
+ if f is None:
logger.log(u"No data returned from SABnzbd, NZB not sent", logger.ERROR)
return False
@@ -173,7 +173,7 @@ def _sabURLOpenSimple(url):
except httplib.InvalidURL, e:
logger.log(u"Invalid SAB host, check your config: " + ex(e), logger.ERROR)
return False, "Invalid SAB host"
- if f == None:
+ if f is None:
logger.log(u"No data returned from SABnzbd", logger.ERROR)
return False, "No data returned from SABnzbd"
else:
diff --git a/sickbeard/scheduler.py b/sickbeard/scheduler.py
index af9e9924..c5964819 100644
--- a/sickbeard/scheduler.py
+++ b/sickbeard/scheduler.py
@@ -45,7 +45,7 @@ class Scheduler:
self.abort = False
def initThread(self):
- if self.thread == None or not self.thread.isAlive():
+ if self.thread is None or not self.thread.isAlive():
self.thread = threading.Thread(None, self.runAction, self.threadName)
def timeLeft(self):
diff --git a/sickbeard/search.py b/sickbeard/search.py
index b48a1bce..02672a5f 100644
--- a/sickbeard/search.py
+++ b/sickbeard/search.py
@@ -53,7 +53,7 @@ def _downloadResult(result):
newResult = False
- if resProvider == None:
+ if resProvider is None:
logger.log(u"Invalid provider name - this is a coding error, report it please", logger.ERROR)
return False
@@ -143,7 +143,7 @@ def snatchEpisode(result, endStatus=SNATCHED):
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
- if dlResult == False:
+ if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
@@ -244,7 +244,7 @@ def pickBestResult(results, quality_list=None):
logger.log(cur_result.name + u" has previously failed, rejecting it")
continue
- if not bestResult or bestResult.quality < cur_result.quality and cur_result.quality != Quality.UNKNOWN:
+ if not bestResult or bestResult.quality < cur_result.quality != Quality.UNKNOWN:
bestResult = cur_result
elif bestResult.quality == cur_result.quality:
if "proper" in cur_result.name.lower() or "repack" in cur_result.name.lower():
diff --git a/sickbeard/searchBacklog.py b/sickbeard/searchBacklog.py
index f63d64ad..d3ddc141 100644
--- a/sickbeard/searchBacklog.py
+++ b/sickbeard/searchBacklog.py
@@ -75,7 +75,7 @@ class BacklogSearcher:
else:
show_list = sickbeard.showList
- if self.amActive == True:
+ if self.amActive:
logger.log(u"Backlog is still running, not starting it again", logger.DEBUG)
return
@@ -147,7 +147,7 @@ class BacklogSearcher:
if len(sqlResults) == 0:
lastBacklog = 1
- elif sqlResults[0]["last_backlog"] == None or sqlResults[0]["last_backlog"] == "":
+ elif sqlResults[0]["last_backlog"] is None or sqlResults[0]["last_backlog"] == "":
lastBacklog = 1
else:
lastBacklog = int(sqlResults[0]["last_backlog"])
diff --git a/sickbeard/search_queue.py b/sickbeard/search_queue.py
index eede681d..8a9aa225 100644
--- a/sickbeard/search_queue.py
+++ b/sickbeard/search_queue.py
@@ -110,14 +110,14 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
providerModule = foundEpisode.provider
if not result:
ui.notifications.error('Error while attempting to snatch ' + foundEpisode.name+', check your logs')
- elif providerModule == None:
+ elif providerModule is None:
ui.notifications.error('Provider is configured incorrectly, unable to download')
self.success = result
def finish(self):
# don't let this linger if something goes wrong
- if self.success == None:
+ if self.success is None:
self.success = False
generic_queue.QueueItem.finish(self)
@@ -160,7 +160,7 @@ class RSSSearchQueueItem(generic_queue.QueueItem):
logger.log(u"ERROR: expected to find a single show matching " + sqlEp["showid"])
return None
- if show == None:
+ if show is None:
logger.log(u"Unable to find the show with ID " + str(sqlEp["showid"]) + " in your show list! DB value was " + str(sqlEp), logger.ERROR)
return None
diff --git a/sickbeard/showUpdater.py b/sickbeard/showUpdater.py
index 46b4d0a3..d5cb40fa 100644
--- a/sickbeard/showUpdater.py
+++ b/sickbeard/showUpdater.py
@@ -48,7 +48,7 @@ class ShowUpdater():
hour_diff = update_datetime.time().hour - run_updater_time.hour
# if it's less than an interval after the update time then do an update (or if we're forcing it)
- if hour_diff >= 0 and hour_diff < self.updateInterval.seconds / 3600 or force:
+ if 0 <= hour_diff < self.updateInterval.seconds / 3600 or force:
logger.log(u"Doing full update on all shows")
else:
return
diff --git a/sickbeard/show_name_helpers.py b/sickbeard/show_name_helpers.py
index 32864d73..d7f2d443 100644
--- a/sickbeard/show_name_helpers.py
+++ b/sickbeard/show_name_helpers.py
@@ -194,12 +194,7 @@ def isGoodResult(name, show, log=True):
escaped_name = re.sub('\\\\[\\s.-]', '\W+', re.escape(curName))
if show.startyear:
escaped_name += "(?:\W+" + str(show.startyear) + ")?"
- curRegex = '^' + escaped_name + '\W+(?:(?:S\d[\dE._ -])|' \
- '(?:\d\d?x)|' \
- '(?:\d{4}\W\d\d\W\d\d)|' \
- '(?:(?:part|pt)[\._ -]?(\d|[ivx]))|' \
- 'Season\W+\d+\W+|E\d+\W+)|' \
- '((.+)[. _-]+)(\d{1,2}[a-zA-Z]{2})[. _-]+([a-zA-Z]{3,})[. _-]+(\d{4})*(.+)([. _-])()((([^- ]+))?)?$'
+ curRegex = '^' + escaped_name + '\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))'
if log:
logger.log(u"Checking if show " + name + " matches " + curRegex, logger.DEBUG)
diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py
index c40b79ec..779ca557 100644
--- a/sickbeard/show_queue.py
+++ b/sickbeard/show_queue.py
@@ -44,7 +44,7 @@ class ShowQueue(generic_queue.GenericQueue):
return show in [x.show for x in self.queue if x.action_id in actions]
def _isBeingSomethinged(self, show, actions):
- return self.currentItem != None and show == self.currentItem.show and \
+ return self.currentItem is not None and show == self.currentItem.show and \
self.currentItem.action_id in actions
def isInUpdateQueue(self, show):
@@ -75,7 +75,7 @@ class ShowQueue(generic_queue.GenericQueue):
return self._isBeingSomethinged(show, (ShowQueueActions.SUBTITLE,))
def _getLoadingShowList(self):
- return [x for x in self.queue + [self.currentItem] if x != None and x.isLoading]
+ return [x for x in self.queue + [self.currentItem] if x is not None and x.isLoading]
loadingShowList = property(_getLoadingShowList)
@@ -205,7 +205,7 @@ class QueueItemAdd(ShowQueueItem):
Returns the show name if there is a show object created, if not returns
the dir that the show is being added to.
"""
- if self.show == None:
+ if self.show is None:
return self.showDir
return self.show.name
@@ -216,7 +216,7 @@ class QueueItemAdd(ShowQueueItem):
Returns True if we've gotten far enough to have a show object, or False
if we still only know the folder name.
"""
- if self.show == None:
+ if self.show is None:
return True
return False
@@ -269,9 +269,9 @@ class QueueItemAdd(ShowQueueItem):
# set up initial values
self.show.location = self.showDir
- self.show.subtitles = self.subtitles if self.subtitles != None else sickbeard.SUBTITLES_DEFAULT
+ self.show.subtitles = self.subtitles if self.subtitles is not None else sickbeard.SUBTITLES_DEFAULT
self.show.quality = self.quality if self.quality else sickbeard.QUALITY_DEFAULT
- self.show.flatten_folders = self.flatten_folders if self.flatten_folders != None else sickbeard.FLATTEN_FOLDERS_DEFAULT
+ self.show.flatten_folders = self.flatten_folders if self.flatten_folders is not None else sickbeard.FLATTEN_FOLDERS_DEFAULT
self.show.paused = False
# be smartish about this
@@ -354,7 +354,7 @@ class QueueItemAdd(ShowQueueItem):
self.finish()
def _finishEarly(self):
- if self.show != None:
+ if self.show is not None:
self.show.deleteShow()
self.finish()
@@ -483,7 +483,7 @@ class QueueItemUpdate(ShowQueueItem):
logger.log(u"Unable to get info from " + self.show.indexer + ", the show info will not be refreshed: " + ex(e), logger.ERROR)
IndexerEpList = None
- if IndexerEpList == None:
+ if IndexerEpList is None:
logger.log(u"No data returned from " + self.show.indexer + ", unable to update this show", logger.ERROR)
else:
diff --git a/sickbeard/subtitles.py b/sickbeard/subtitles.py
index e4b0bfd5..fcdd3d4c 100644
--- a/sickbeard/subtitles.py
+++ b/sickbeard/subtitles.py
@@ -112,7 +112,7 @@ class SubtitlesFinder():
return
rules = self._getRules()
- now = datetime.datetime.now();
+ now = datetime.datetime.now()
for epToSub in sqlResults:
if not ek.ek(os.path.isfile, epToSub['location']):
logger.log('Episode file does not exist, cannot download subtitles for episode %dx%d of show %s' % (epToSub['season'], epToSub['episode'], epToSub['show_name']), logger.DEBUG)
diff --git a/sickbeard/traktWatchListChecker.py b/sickbeard/traktWatchListChecker.py
index 26f1a3e8..eda53b61 100644
--- a/sickbeard/traktWatchListChecker.py
+++ b/sickbeard/traktWatchListChecker.py
@@ -86,7 +86,7 @@ class TraktChecker():
Adds a new show with the default settings
"""
showObj = helpers.findCertainShow(sickbeard.showList, int(indexerid))
- if showObj != None:
+ if showObj is not None:
return
logger.log(u"Adding show " + indexerid)
root_dirs = sickbeard.ROOT_DIRS.split('|')
@@ -106,7 +106,7 @@ class TraktChecker():
Sets an episode to wanted, only is it is currently skipped
"""
epObj = show.getEpisode(int(s), int(e))
- if epObj == None:
+ if epObj is None:
return
with epObj.lock:
if epObj.status != SKIPPED:
diff --git a/sickbeard/tv.py b/sickbeard/tv.py
index a50917e6..a516de4f 100644
--- a/sickbeard/tv.py
+++ b/sickbeard/tv.py
@@ -88,7 +88,7 @@ class TVShow(object):
self.episodes = {}
otherShow = helpers.findCertainShow(sickbeard.showList, self.indexerid)
- if otherShow != None:
+ if otherShow is not None:
raise exceptions.MultipleShowObjectsException("Can't create a show if it already exists")
self.loadFromDB()
@@ -132,7 +132,7 @@ class TVShow(object):
sql_selection = "SELECT season, episode, "
# subselection to detect multi-episodes early, share_location > 0
- sql_selection = sql_selection + " (SELECT COUNT (*) FROM tv_episodes WHERE showid = tve.showid AND season = tve.season AND location != '' AND location = tve.location AND episode != tve.episode) AS share_location "
+ sql_selection += " (SELECT COUNT (*) FROM tv_episodes WHERE showid = tve.showid AND season = tve.season AND location != '' AND location = tve.location AND episode != tve.episode) AS share_location "
sql_selection = sql_selection + " FROM tv_episodes tve WHERE showid = " + str(self.indexerid)
@@ -152,10 +152,10 @@ class TVShow(object):
sql_selection = sql_selection + " AND airdate >= " + str(min_date.toordinal()) + " AND airdate <= " + str(max_date.toordinal())
if has_location:
- sql_selection = sql_selection + " AND location != '' "
+ sql_selection += " AND location != '' "
# need ORDER episode ASC to rename multi-episodes in order S01E01-02
- sql_selection = sql_selection + " ORDER BY season ASC, episode ASC"
+ sql_selection += " ORDER BY season ASC, episode ASC"
results = myDB.select(sql_selection)
@@ -186,18 +186,18 @@ class TVShow(object):
ep = None
- if not episode in self.episodes[season] or self.episodes[season][episode] == None:
+ if not episode in self.episodes[season] or self.episodes[season][episode] is None:
if noCreate:
return None
logger.log(str(self.indexerid) + u": An object for episode " + str(season) + "x" + str(episode) + " didn't exist in the cache, trying to create it", logger.DEBUG)
- if file != None:
+ if file is not None:
ep = TVEpisode(self, season, episode, file)
else:
ep = TVEpisode(self, season, episode)
- if ep != None:
+ if ep is not None:
self.episodes[season][episode] = ep
return self.episodes[season][episode]
@@ -221,7 +221,7 @@ class TVShow(object):
if sql_result:
last_airdate = datetime.date.fromordinal(sql_result[0]['airdate'])
- if last_airdate >= (update_date - graceperiod) and last_airdate <= (update_date + graceperiod):
+ if (update_date - graceperiod) <= last_airdate <= (update_date + graceperiod):
return True
# get next upcoming UNAIRED episode to compare against today + graceperiod
@@ -329,7 +329,7 @@ class TVShow(object):
curEpisode.release_name = ep_file_name
# store the reference in the show
- if curEpisode != None:
+ if curEpisode is not None:
if self.subtitles:
try:
curEpisode.refreshSubtitles()
@@ -382,7 +382,7 @@ class TVShow(object):
try:
curEp = self.getEpisode(curSeason, curEpisode)
- # if we found out that the ep is no longer on TVDB then delete it from our database too
+ # if we found out that the ep is no longer on Indexers then delete it from our database too
if deleteEp:
curEp.deleteEpisode()
@@ -498,7 +498,7 @@ class TVShow(object):
return None
# for now lets assume that any episode in the show dir belongs to that show
- season = parse_result.season_number if parse_result.season_number != None else 1
+ season = parse_result.season_number if parse_result.season_number is not None else 1
episodes = parse_result.episode_numbers
rootEp = None
@@ -535,7 +535,7 @@ class TVShow(object):
same_file = False
curEp = self.getEpisode(season, episode)
- if curEp == None:
+ if curEp is None:
try:
curEp = self.getEpisode(season, episode, file)
except exceptions.EpisodeNotFoundException:
@@ -559,7 +559,7 @@ class TVShow(object):
curEp.checkForMetaFiles()
- if rootEp == None:
+ if rootEp is None:
rootEp = curEp
else:
if curEp not in rootEp.relatedEps:
@@ -600,7 +600,7 @@ class TVShow(object):
elif oldStatus not in (SNATCHED, SNATCHED_PROPER):
newStatus = DOWNLOADED
- if newStatus != None:
+ if newStatus is not None:
with curEp.lock:
logger.log(u"STATUS: we have an associated file, so setting the status from " + str(curEp.status) + u" to DOWNLOADED/" + str(Quality.statusFromName(file)), logger.DEBUG)
curEp.status = Quality.compositeStatus(newStatus, newQuality)
@@ -817,7 +817,7 @@ class TVShow(object):
params = [self.indexerid, datetime.date.today().toordinal()] + innerParams + [UNAIRED]
sqlResults = myDB.select(query, params)
- if sqlResults == None or len(sqlResults) == 0:
+ if sqlResults is None or len(sqlResults) == 0:
logger.log(str(self.indexerid) + u": No episode found... need to implement show status", logger.DEBUG)
return []
else:
@@ -1046,7 +1046,7 @@ class TVShow(object):
elif epStatus in (SNATCHED, SNATCHED_PROPER, SNATCHED_BEST):
return Overview.SNATCHED
# if they don't want re-downloads then we call it good if they have anything
- elif maxBestQuality == None:
+ elif maxBestQuality is None:
return Overview.GOOD
# if they have one but it's not the best they want then mark it as qual
elif curQuality < maxBestQuality:
@@ -1236,14 +1236,14 @@ class TVEpisode(object):
pass
# if we tried loading it from NFO and didn't find the NFO, try the Indexers
- if self.hasnfo == False:
+ if not self.hasnfo:
try:
result = self.loadFromIndexer(season, episode)
except exceptions.EpisodeDeletedException:
result = False
# if we failed SQL *and* NFO, Indexers then fail
- if result == False:
+ if not result:
raise exceptions.EpisodeNotFoundException("Couldn't find episode " + str(season) + "x" + str(episode))
def loadFromDB(self, season, episode):
@@ -1346,7 +1346,7 @@ class TVEpisode(object):
if getattr(myEp, 'episodename', None) is None:
logger.log(u"This episode (" + self.show.name + " - " + str(season) + "x" + str(episode) + ") has no name on " + self.indexer + "")
- # if I'm incomplete on TVDB but I once was complete then just delete myself from the DB for now
+ # if I'm incomplete on Indexers but I once was complete then just delete myself from the DB for now
if self.indexerid != -1:
self.deleteEpisode()
return False
@@ -1367,7 +1367,7 @@ class TVEpisode(object):
self.airdate = datetime.date(rawAirdate[0], rawAirdate[1], rawAirdate[2])
except ValueError:
logger.log(u"Malformed air date retrieved from " + self.indexer + " ("+self.show.name+" - "+str(season)+"x"+str(episode)+")", logger.ERROR)
- # if I'm incomplete on TVDB but I once was complete then just delete myself from the DB for now
+ # if I'm incomplete on Indexers but I once was complete then just delete myself from the DB for now
if self.indexerid != -1:
self.deleteEpisode()
return False
@@ -1607,7 +1607,7 @@ class TVEpisode(object):
myDB.upsert("tv_episodes", newValueDict, controlValueDict)
def fullPath(self):
- if self.location == None or self.location == "":
+ if self.location is None or self.location == "":
return None
else:
return ek.ek(os.path.join, self.show.location, self.location)
@@ -1648,7 +1648,7 @@ class TVEpisode(object):
singleName = False
break
- if curGoodName == None:
+ if curGoodName is None:
curGoodName = match.group(1)
elif curGoodName != match.group(1):
singleName = False
@@ -1754,10 +1754,10 @@ class TVEpisode(object):
Manipulates an episode naming pattern and then fills the template in
"""
- if pattern == None:
+ if pattern is None:
pattern = sickbeard.NAMING_PATTERN
- if multi == None:
+ if multi is None:
multi = sickbeard.NAMING_MULTI_EP
replace_map = self._replace_map()
@@ -1892,7 +1892,7 @@ class TVEpisode(object):
Just the folder name of the episode
"""
- if pattern == None:
+ if pattern is None:
# we only use ABD if it's enabled, this is an ABD show, AND this is not a multi-ep
if self.show.air_by_date and sickbeard.NAMING_CUSTOM_ABD and not self.relatedEps:
pattern = sickbeard.NAMING_ABD_PATTERN
@@ -1912,7 +1912,7 @@ class TVEpisode(object):
Just the filename of the episode, formatted based on the naming settings
"""
- if pattern == None:
+ if pattern is None:
# we only use ABD if it's enabled, this is an ABD show, AND this is not a multi-ep
if self.show.air_by_date and sickbeard.NAMING_CUSTOM_ABD and not self.relatedEps:
pattern = sickbeard.NAMING_ABD_PATTERN
@@ -1967,17 +1967,17 @@ class TVEpisode(object):
# move related files
for cur_related_file in related_files:
cur_result = helpers.rename_ep_file(cur_related_file, absolute_proper_path, absolute_current_path_no_ext_length)
- if cur_result == False:
+ if not cur_result:
logger.log(str(self.indexerid) + u": Unable to rename file " + cur_related_file, logger.ERROR)
for cur_related_sub in related_subs:
cur_result = helpers.rename_ep_file(cur_related_sub, absolute_proper_subs_path, absolute_current_path_no_ext_length)
- if cur_result == False:
+ if not cur_result:
logger.log(str(self.indexerid) + u": Unable to rename file " + cur_related_sub, logger.ERROR)
# save the ep
with self.lock:
- if result != False:
+ if result:
self.location = absolute_proper_path + file_ext
for relEp in self.relatedEps:
relEp.location = absolute_proper_path + file_ext
diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py
index 5652c9c8..c6b99476 100644
--- a/sickbeard/tvcache.py
+++ b/sickbeard/tvcache.py
@@ -195,14 +195,16 @@ class TVCache():
def shouldUpdate(self):
# if we've updated recently then skip the update
+
if datetime.datetime.today() - self.lastUpdate < datetime.timedelta(minutes=self.minTime):
logger.log(u"Last update was too soon, using old cache: today()-" + str(self.lastUpdate) + "<" + str(datetime.timedelta(minutes=self.minTime)), logger.DEBUG)
return False
return True
- def _addCacheEntry(self, name, url, season=None, episodes=None, indexer_id=0, quality=None, extraNames=[]):
+ def _addCacheEntry(self, name, url, season=None, episodes=None, indexer_id=0, quality=None, extraNames=None):
+ if not extraNames: extraNames = []
myDB = self._getDB()
parse_result = None
@@ -246,7 +248,7 @@ class TVCache():
indexer_id = name_cache.retrieveNameFromCache(parse_result.series_name)
# remember if the cache lookup worked or not so we know whether we should bother updating it later
- if indexer_id == None:
+ if indexer_id is None:
logger.log(u"No cache results returned, continuing on with the search", logger.DEBUG)
from_cache = False
else:
@@ -254,7 +256,7 @@ class TVCache():
from_cache = True
# if the cache failed, try looking up the show name in the database
- if indexer_id == None:
+ if indexer_id is None:
logger.log(u"Trying to look the show up in the show database", logger.DEBUG)
showResult = helpers.searchDBForShow(parse_result.series_name)
if showResult:
@@ -262,7 +264,7 @@ class TVCache():
indexer_id = showResult[1]
# if the DB lookup fails then do a comprehensive regex search
- if indexer_id == None:
+ if indexer_id is None:
logger.log(u"Couldn't figure out a show name straight from the DB, trying a regex search instead", logger.DEBUG)
for curShow in sickbeard.showList:
if show_name_helpers.isGoodResult(name, curShow, False):
@@ -276,7 +278,7 @@ class TVCache():
name_cache.addNameToCache(parse_result.series_name, indexer_id)
# if we came out with indexer_id = None it means we couldn't figure it out at all, just use 0 for that
- if indexer_id == None:
+ if indexer_id is None:
indexer_id = 0
# if we found the show then retrieve the show object
@@ -291,7 +293,7 @@ class TVCache():
# if we weren't provided with season/episode information then get it from the name that we parsed
if not season:
- season = parse_result.season_number if parse_result.season_number != None else 1
+ season = parse_result.season_number if parse_result.season_number is not None else 1
if not episodes:
episodes = parse_result.episode_numbers
@@ -300,7 +302,7 @@ class TVCache():
try:
lINDEXER_API_PARMS = {'indexer': self.indexer}
- if not (indexer_lang == "" or indexer_lang == "en" or indexer_lang == None):
+ if not (indexer_lang == "" or indexer_lang == "en" or indexer_lang is None):
lINDEXER_API_PARMS['language'] = indexer_lang
t = indexer_api.indexerApi(**lINDEXER_API_PARMS)
@@ -340,7 +342,7 @@ class TVCache():
sql = "SELECT * FROM [" + self.providerID + "] WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%'"
- if date != None:
+ if date is not None:
sql += " AND time >= " + str(int(time.mktime(date.timetuple())))
#return filter(lambda x: x['indexerid'] != 0, myDB.select(sql))
diff --git a/sickbeard/ui.py b/sickbeard/ui.py
index b8e1b3d3..4b439b86 100644
--- a/sickbeard/ui.py
+++ b/sickbeard/ui.py
@@ -112,7 +112,8 @@ class Notification(object):
class ProgressIndicator():
- def __init__(self, percentComplete=0, currentStatus={'title': ''}):
+ def __init__(self, percentComplete=0, currentStatus=None):
+ if not currentStatus: currentStatus = {'title': ''}
self.percentComplete = percentComplete
self.currentStatus = currentStatus
@@ -129,7 +130,7 @@ class ProgressIndicators():
# if any of the progress indicators are done take them off the list
for curPI in ProgressIndicators._pi[name]:
- if curPI != None and curPI.percentComplete() == 100:
+ if curPI is not None and curPI.percentComplete() == 100:
ProgressIndicators._pi[name].remove(curPI)
# return the list of progress indicators associated with this name
diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py
index a60ca71f..1c9eb398 100644
--- a/sickbeard/versionChecker.py
+++ b/sickbeard/versionChecker.py
@@ -511,9 +511,6 @@ class GitUpdateManager(UpdateManager):
else:
return False
- return False
-
-
class SourceUpdateManager(UpdateManager):
def __init__(self):
diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py
index 683821fa..3518b4b1 100644
--- a/sickbeard/webapi.py
+++ b/sickbeard/webapi.py
@@ -91,7 +91,7 @@ class Api:
logger.log(accessMsg, logger.DEBUG)
else:
logger.log(accessMsg, logger.WARNING)
- return outputCallbackDict['default'](_responds(RESULT_DENIED, msg=accessMsg))
+ return outputCallbackDict['default'](_responds(RESULT_DENIED, msg=str(accessMsg)))
# set the original call_dispatcher as the local _call_dispatcher
_call_dispatcher = call_dispatcher
@@ -171,7 +171,7 @@ class Api:
try:
out = json.dumps(dict, indent=self.intent, sort_keys=True)
callback = request.params.get('callback') or request.params.get('jsonp')
- if callback != None:
+ if callback is not None:
out = callback + '(' + out + ');' # wrap with JSONP call if requested
except Exception, e: # if we fail to generate the output fake an error
logger.log(u"API :: " + traceback.format_exc(), logger.DEBUG)
@@ -189,7 +189,7 @@ class Api:
else:
del kwargs["apikey"]
- if sickbeard.USE_API != True:
+ if not sickbeard.USE_API:
msg = u"API :: " + remoteIp + " - SB API Disabled. ACCESS DENIED"
return False, msg, args, kwargs
elif apiKey == realKey:
@@ -223,7 +223,7 @@ def call_dispatcher(args, kwargs):
del kwargs["cmd"]
outDict = {}
- if cmds != None:
+ if cmds is not None:
cmds = cmds.split("|")
multiCmds = bool(len(cmds) > 1)
for cmd in cmds:
@@ -758,14 +758,14 @@ class CMD_ComingEpisodes(ApiCall):
status = "missed"
elif ep["airdate"] >= next_week:
status = "later"
- elif ep["airdate"] >= today and ep["airdate"] < next_week:
+ elif today <= ep["airdate"] < next_week:
if ep["airdate"] == today:
status = "today"
else:
status = "soon"
# skip unwanted
- if self.type != None and not status in self.type:
+ if self.type is not None and not status in self.type:
continue
ordinalAirdate = int(ep["airdate"])
@@ -878,7 +878,7 @@ class CMD_EpisodeSearch(ApiCall):
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) #@UndefinedVariable
# wait until the queue item tells us whether it worked or not
- while ep_queue_item.success == None: #@UndefinedVariable
+ while ep_queue_item.success is None: #@UndefinedVariable
time.sleep(1)
# return the correct json value
@@ -930,7 +930,7 @@ class CMD_EpisodeSetStatus(ApiCall):
ep_list = []
if self.e:
epObj = showObj.getEpisode(self.s, self.e)
- if epObj == None:
+ if epObj is None:
return _responds(RESULT_FAILURE, msg="Episode not found")
ep_list = [epObj]
else:
@@ -945,7 +945,7 @@ class CMD_EpisodeSetStatus(ApiCall):
start_backlog = False
ep_segment = None
for epObj in ep_list:
- if ep_segment == None and self.status == WANTED:
+ if ep_segment is None and self.status == WANTED:
# figure out what segment the episode is in and remember it so we can backlog it
if showObj.air_by_date:
ep_segment = str(epObj.airdate)[:7]
@@ -955,7 +955,7 @@ class CMD_EpisodeSetStatus(ApiCall):
with epObj.lock:
# don't let them mess up UNAIRED episodes
if epObj.status == UNAIRED:
- if self.e != None: # setting the status of a unaired is only considert a failure if we directly wanted this episode, but is ignored on a season request
+ if self.e is not None: # setting the status of a unaired is only considert a failure if we directly wanted this episode, but is ignored on a season request
ep_results.append(_epResult(RESULT_FAILURE, epObj, "Refusing to change status because it is UNAIRED"))
failure = True
continue
@@ -1051,7 +1051,7 @@ class CMD_Exceptions(ApiCall):
""" display scene exceptions for all or a given show """
myDB = db.DBConnection("cache.db", row_type="dict")
- if self.indexerid == None:
+ if self.indexerid is None:
sqlResults = myDB.select("SELECT show_name, indexer_id AS 'indexerid' FROM scene_exceptions")
scene_exceptions = {}
for row in sqlResults:
@@ -1455,7 +1455,7 @@ class CMD_SickBeardPauseBacklog(ApiCall):
def run(self):
""" pause the backlog search """
- if self.pause == True:
+ if self.pause:
sickbeard.searchQueueScheduler.action.pause_backlog() #@UndefinedVariable
return _responds(RESULT_SUCCESS, msg="Backlog paused")
else:
@@ -1637,10 +1637,10 @@ class CMD_SickBeardSetDefaults(ApiCall):
raise ApiError("Status Prohibited")
sickbeard.STATUS_DEFAULT = self.status
- if self.flatten_folders != None:
+ if self.flatten_folders is not None:
sickbeard.FLATTEN_FOLDERS_DEFAULT = int(self.flatten_folders)
- if self.future_show_paused != None:
+ if self.future_show_paused is not None:
sickbeard.COMING_EPS_DISPLAY_PAUSED = int(self.future_show_paused)
return _responds(RESULT_SUCCESS, msg="Saved defaults")
@@ -2064,16 +2064,13 @@ class CMD_ShowPause(ApiCall):
if not showObj:
return _responds(RESULT_FAILURE, msg="Show not found")
- if self.pause == True:
+ if self.pause:
showObj.paused = 1
return _responds(RESULT_SUCCESS, msg=str(showObj.name) + " has been paused")
else:
showObj.paused = 0
return _responds(RESULT_SUCCESS, msg=str(showObj.name) + " has been unpaused")
- return _responds(RESULT_FAILURE, msg=str(showObj.name) + " was unable to be paused")
-
-
class CMD_ShowRefresh(ApiCall):
_help = {"desc": "refresh a show in sickbeard",
"requiredParameters": {"indexerid": {"desc": "thetvdb.com unique id of a show"},
@@ -2160,7 +2157,7 @@ class CMD_ShowSeasons(ApiCall):
myDB = db.DBConnection(row_type="dict")
- if self.season == None:
+ if self.season is None:
sqlResults = myDB.select("SELECT name, episode, airdate, status, season FROM tv_episodes WHERE showid = ?", [self.indexerid])
seasons = {}
for row in sqlResults:
@@ -2408,7 +2405,7 @@ class CMD_Shows(ApiCall):
if (len(nextEps) != 0):
nextAirdate = _ordinal_to_dateForm(nextEps[0].airdate.toordinal())
- if self.paused != None and bool(self.paused) != bool(curShow.paused):
+ if self.paused is not None and bool(self.paused) != bool(curShow.paused):
continue
showDict = {"paused": curShow.paused,
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index 36af98e7..f36f6bd9 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -154,17 +154,17 @@ def _genericMessage(subject, message):
def _getEpisode(show, season, episode):
- if show == None or season == None or episode == None:
+ if show is None or season is None or episode is None:
return "Invalid parameters"
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return "Show not in show list"
epObj = showObj.getEpisode(int(season), int(episode))
- if epObj == None:
+ if epObj is None:
return "Episode couldn't be retrieved"
return epObj
@@ -177,7 +177,7 @@ def ManageMenu():
{ 'title': 'Episode Status Management', 'path': 'manage/episodeStatuses/' },]
if sickbeard.USE_TORRENTS and sickbeard.TORRENT_METHOD != 'blackhole' \
- and (sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'https' \
+ and (sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'https'
or not sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'http:'):
manageMenu.append({ 'title': 'Manage Torrents', 'path': 'manage/manageTorrents/'})
@@ -438,7 +438,7 @@ class Manage:
to_download[cur_indexer_id] = [str(x["season"]) + 'x' + str(x["episode"]) for x in all_eps_results]
for epResult in to_download[cur_indexer_id]:
- season, episode = epResult.split('x');
+ season, episode = epResult.split('x')
show = sickbeard.helpers.findCertainShow(sickbeard.showList, int(cur_indexer_id))
subtitles = show.getEpisode(int(season), int(episode)).downloadSubtitles()
@@ -569,9 +569,10 @@ class Manage:
return _munge(t)
@cherrypy.expose
- def massEditSubmit(self, paused=None, flatten_folders=None, quality_preset=False, subtitles=None,
- anyQualities=[], bestQualities=[], toEdit=None, *args, **kwargs):
+ def massEditSubmit(self, paused=None, flatten_folders=None, quality_preset=False, subtitles=None, anyQualities=[],
+ bestQualities=None, toEdit=None, *args, **kwargs):
+ if not bestQualities: bestQualities = []
dir_map = {}
for cur_arg in kwargs:
if not cur_arg.startswith('orig_root_dir_'):
@@ -635,32 +636,32 @@ class Manage:
@cherrypy.expose
def massUpdate(self, toUpdate=None, toRefresh=None, toRename=None, toDelete=None, toMetadata=None, toSubtitle=None):
- if toUpdate != None:
+ if toUpdate is not None:
toUpdate = toUpdate.split('|')
else:
toUpdate = []
- if toRefresh != None:
+ if toRefresh is not None:
toRefresh = toRefresh.split('|')
else:
toRefresh = []
- if toRename != None:
+ if toRename is not None:
toRename = toRename.split('|')
else:
toRename = []
- if toSubtitle != None:
+ if toSubtitle is not None:
toSubtitle = toSubtitle.split('|')
else:
toSubtitle = []
- if toDelete != None:
+ if toDelete is not None:
toDelete = toDelete.split('|')
else:
toDelete = []
- if toMetadata != None:
+ if toMetadata is not None:
toMetadata = toMetadata.split('|')
else:
toMetadata = []
@@ -678,7 +679,7 @@ class Manage:
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(curShowID))
- if showObj == None:
+ if showObj is None:
continue
if curShowID in toDelete:
@@ -761,7 +762,7 @@ class Manage:
t.webui_url = '/'.join(s.strip('/') for s in (t.webui_url, 'gui/'))
if sickbeard.TORRENT_METHOD == 'download_station':
if helpers.check_url(t.webui_url + 'download/'):
- t.webui_url = t.webui_url + 'download/'
+ t.webui_url += 'download/'
else:
t.info_download_station = 'To have a better experience please set the Download Station alias as download
, you can check this setting in the Synology DSM Control Panel > Application Portal. Make sure you allow DSM to be embedded with iFrames too in Control Panel > DSM Settings > Security.
There is more information about this available here.
'
@@ -777,7 +778,7 @@ class Manage:
else:
sqlResults = myDB.select("SELECT * FROM failed LIMIT ?", [limit])
- toRemove = toRemove.split("|") if toRemove != None else []
+ toRemove = toRemove.split("|") if toRemove is not None else []
for release in toRemove:
myDB.action('DELETE FROM failed WHERE release = ?', [release])
@@ -810,9 +811,9 @@ class History:
for sql_result in sqlResults:
- if not any((history['show_id'] == sql_result['showid'] \
- and history['season'] == sql_result['season'] \
- and history['episode'] == sql_result['episode'] \
+ if not any((history['show_id'] == sql_result['showid']
+ and history['season'] == sql_result['season']
+ and history['episode'] == sql_result['episode']
and history['quality'] == sql_result['quality'])\
for history in compact):
@@ -1179,7 +1180,7 @@ class ConfigPostProcessing:
@cherrypy.expose
def testNaming(self, pattern=None, multi=None, abd=False):
- if multi != None:
+ if multi is not None:
multi = int(multi)
result = naming.test_name(pattern, multi, abd)
@@ -1190,7 +1191,7 @@ class ConfigPostProcessing:
@cherrypy.expose
def isNamingValid(self, pattern=None, multi=None, abd=False):
- if pattern == None:
+ if pattern is None:
return "invalid"
# air by date shows just need one check, we don't need to worry about season folders
@@ -1756,7 +1757,7 @@ class ConfigSubtitles:
subtitles_finder_frequency = 1
if use_subtitles == "on":
- if sickbeard.subtitlesFinderScheduler.thread == None or not sickbeard.subtitlesFinderScheduler.thread.isAlive():
+ if sickbeard.subtitlesFinderScheduler.thread is None or not sickbeard.subtitlesFinderScheduler.thread.isAlive():
sickbeard.subtitlesFinderScheduler.silent = False
sickbeard.subtitlesFinderScheduler.initThread()
else:
@@ -1870,7 +1871,7 @@ class HomePostProcess:
redirect("/home/postprocess/")
else:
result = processTV.processDir(dir, nzbName, process_method=process_method, force=force, is_priority=is_priority, failed=failed, type=type, indexer=indexer)
- if quiet != None and int(quiet) == 1:
+ if quiet is not None and int(quiet) == 1:
return result
result = result.replace("\n","
\n")
@@ -2422,7 +2423,7 @@ class Home:
host = config.clean_host(host, default_port=23053)
result = notifiers.growl_notifier.test_notify(host, password)
- if password == None or password == '':
+ if password is None or password == '':
pw_append = ''
else:
pw_append = " with password: " + password
@@ -2694,12 +2695,12 @@ class Home:
@cherrypy.expose
def displayShow(self, show=None):
- if show == None:
+ if show is None:
return _genericMessage("Error", "Invalid show ID")
else:
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return _genericMessage("Error", "Show not in show list")
showObj.exceptions = scene_exceptions.get_scene_exceptions(showObj.indexerid)
@@ -2805,9 +2806,14 @@ class Home:
return result['description'] if result else 'Episode not found.'
@cherrypy.expose
- def editShow(self, show=None, location=None, anyQualities=[], bestQualities=[], exceptions_list=[], flatten_folders=None, paused=None, directCall=False, air_by_date=None, dvdorder=None, indexerLang=None, subtitles=None, archive_firstmatch=None):
+ def editShow(self, show=None, location=None, anyQualities=None, bestQualities=None, exceptions_list=None,
+ flatten_folders=None, paused=None, directCall=False, air_by_date=None, dvdorder=None, indexerLang=None,
+ subtitles=None, archive_firstmatch=None):
- if show == None:
+ if not anyQualities: anyQualities = []
+ if not bestQualities: bestQualities = []
+ if not exceptions_list: exceptions_list = []
+ if show is None:
errString = "Invalid show ID: " + str(show)
if directCall:
return [errString]
@@ -2816,7 +2822,7 @@ class Home:
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
errString = "Unable to find the specified show: " + str(show)
if directCall:
return [errString]
@@ -2942,12 +2948,12 @@ class Home:
@cherrypy.expose
def deleteShow(self, show=None):
- if show == None:
+ if show is None:
return _genericMessage("Error", "Invalid show ID")
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return _genericMessage("Error", "Unable to find the specified show")
if sickbeard.showQueueScheduler.action.isBeingAdded(showObj) or sickbeard.showQueueScheduler.action.isBeingUpdated(showObj): # @UndefinedVariable
@@ -2961,12 +2967,12 @@ class Home:
@cherrypy.expose
def refreshShow(self, show=None):
- if show == None:
+ if show is None:
return _genericMessage("Error", "Invalid show ID")
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return _genericMessage("Error", "Unable to find the specified show")
# force the update from the DB
@@ -2983,12 +2989,12 @@ class Home:
@cherrypy.expose
def updateShow(self, show=None, force=0):
- if show == None:
+ if show is None:
return _genericMessage("Error", "Invalid show ID")
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return _genericMessage("Error", "Unable to find the specified show")
# force the update
@@ -3006,12 +3012,12 @@ class Home:
@cherrypy.expose
def subtitleShow(self, show=None, force=0):
- if show == None:
+ if show is None:
return _genericMessage("Error", "Invalid show ID")
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return _genericMessage("Error", "Unable to find the specified show")
# search and download subtitles
@@ -3049,7 +3055,7 @@ class Home:
@cherrypy.expose
def setStatus(self, show=None, eps=None, status=None, direct=False):
- if show == None or eps == None or status == None:
+ if show is None or eps is None or status is None:
errMsg = "You must specify a show and at least one episode"
if direct:
ui.notifications.error('Error', errMsg)
@@ -3067,7 +3073,7 @@ class Home:
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
errMsg = "Error", "Show not in show list"
if direct:
ui.notifications.error('Error', errMsg)
@@ -3078,7 +3084,7 @@ class Home:
wanted_segments = []
failed_segments = {}
- if eps != None:
+ if eps is not None:
sql_l = []
for curEp in eps.split('|'):
@@ -3089,7 +3095,7 @@ class Home:
epObj = showObj.getEpisode(int(epInfo[0]), int(epInfo[1]))
- if epObj == None:
+ if epObj is None:
return _genericMessage("Error", "Episode couldn't be retrieved")
if int(status) in (WANTED, FAILED):
@@ -3155,12 +3161,12 @@ class Home:
@cherrypy.expose
def testRename(self, show=None):
- if show == None:
+ if show is None:
return _genericMessage("Error", "You must specify a show")
showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if showObj == None:
+ if showObj is None:
return _genericMessage("Error", "Show not in show list")
try:
@@ -3201,13 +3207,13 @@ class Home:
@cherrypy.expose
def doRename(self, show=None, eps=None):
- if show == None or eps == None:
+ if show is None or eps is None:
errMsg = "You must specify a show and at least one episode"
return _genericMessage("Error", errMsg)
show_obj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show))
- if show_obj == None:
+ if show_obj is None:
errMsg = "Error", "Show not in show list"
return _genericMessage("Error", errMsg)
@@ -3218,7 +3224,7 @@ class Home:
myDB = db.DBConnection()
- if eps == None:
+ if eps is None:
redirect("/home/displayShow?show=" + show)
for curEp in eps.split('|'):
@@ -3258,7 +3264,7 @@ class Home:
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
# wait until the queue item tells us whether it worked or not
- while ep_queue_item.success == None: # @UndefinedVariable
+ while ep_queue_item.success is None: # @UndefinedVariable
time.sleep(1)
# return the correct json value
@@ -3356,7 +3362,7 @@ class Home:
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
# wait until the queue item tells us whether it worked or not
- while ep_queue_item.success == None: # @UndefinedVariable
+ while ep_queue_item.success is None: # @UndefinedVariable
time.sleep(1)
# return the correct json value
@@ -3636,7 +3642,7 @@ class WebInterface:
air_date_time = network_timezones.parse_date_time(episode['airdate'], show["airs"], show['network'])
# Create event for episode
- ical = ical + 'BEGIN:VEVENT\r\n'
+ ical += 'BEGIN:VEVENT\r\n'
ical = ical + 'DTSTART;VALUE=DATE:' + str(air_date_time.date()).replace("-", "") + '\r\n'
ical = ical + 'SUMMARY:' + show['show_name'] + ': ' + episode['name'] + '\r\n'
ical = ical + 'UID:Sick-Beard-' + str(datetime.date.today().isoformat()) + '-' + show['show_name'].replace(" ", "-") + '-E' + str(episode['episode']) + 'S' + str(episode['season']) + '\r\n'
@@ -3645,7 +3651,7 @@ class WebInterface:
else:
ical = ical + 'DESCRIPTION:' + show['airs'] + ' on ' + show['network'] + '\r\n'
ical = ical + 'LOCATION:' + 'Episode ' + str(episode['episode']) + ' - Season ' + str(episode['season']) + '\r\n'
- ical = ical + 'END:VEVENT\r\n'
+ ical += 'END:VEVENT\r\n'
# Ending the iCal
ical += 'END:VCALENDAR'
diff --git a/sickbeard/webserveInit.py b/sickbeard/webserveInit.py
index 130be29f..724869bb 100644
--- a/sickbeard/webserveInit.py
+++ b/sickbeard/webserveInit.py
@@ -27,7 +27,8 @@ from sickbeard.webserve import WebInterface
from sickbeard.helpers import create_https_certificates
-def initWebServer(options = {}):
+def initWebServer(options=None):
+ if not options: options = {}
options.setdefault('port', 8081)
options.setdefault('host', '0.0.0.0')
options.setdefault('log_dir', None)