diff --git a/couchpotato/core/downloaders/base.py b/couchpotato/core/downloaders/base.py index 3b160c6..08be4bd 100644 --- a/couchpotato/core/downloaders/base.py +++ b/couchpotato/core/downloaders/base.py @@ -49,7 +49,10 @@ class Downloader(Provider): return [] - def _download(self, data = {}, movie = {}, manual = False, filedata = None): + def _download(self, data = None, movie = None, manual = False, filedata = None): + if not movie: movie = {} + if not data: data = {} + if self.isDisabled(manual, data): return return self.download(data = data, movie = movie, filedata = filedata) @@ -128,15 +131,21 @@ class Downloader(Provider): 'id': download_id } - def isDisabled(self, manual = False, data = {}): + def isDisabled(self, manual = False, data = None): + if not data: data = {} + return not self.isEnabled(manual, data) - def _isEnabled(self, manual, data = {}): + def _isEnabled(self, manual, data = None): + if not data: data = {} + if not self.isEnabled(manual, data): return return True - def isEnabled(self, manual = False, data = {}): + def isEnabled(self, manual = False, data = None): + if not data: data = {} + d_manual = self.conf('manual', default = False) return super(Downloader, self).isEnabled() and \ (d_manual and manual or d_manual is False) and \ diff --git a/couchpotato/core/downloaders/blackhole/main.py b/couchpotato/core/downloaders/blackhole/main.py index 750c6c7..9a5a621 100644 --- a/couchpotato/core/downloaders/blackhole/main.py +++ b/couchpotato/core/downloaders/blackhole/main.py @@ -12,7 +12,9 @@ class Blackhole(Downloader): protocol = ['nzb', 'torrent', 'torrent_magnet'] - def download(self, data = {}, movie = {}, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} directory = self.conf('directory') if not directory or not os.path.isdir(directory): @@ -62,7 +64,8 @@ class Blackhole(Downloader): else: return ['nzb'] - def isEnabled(self, manual = False, data = {}): + def isEnabled(self, manual = False, data = None): + if not data: data = {} for_protocol = ['both'] if data and 'torrent' in data.get('protocol'): for_protocol.append('torrent') diff --git a/couchpotato/core/downloaders/nzbget/main.py b/couchpotato/core/downloaders/nzbget/main.py index adeedea..35d47de 100644 --- a/couchpotato/core/downloaders/nzbget/main.py +++ b/couchpotato/core/downloaders/nzbget/main.py @@ -19,7 +19,9 @@ class NZBGet(Downloader): url = 'http://%(username)s:%(password)s@%(host)s/xmlrpc' - def download(self, data = {}, movie = {}, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} if not filedata: log.error('Unable to get NZB file: %s', traceback.format_exc()) diff --git a/couchpotato/core/downloaders/nzbvortex/main.py b/couchpotato/core/downloaders/nzbvortex/main.py index 1e0a4b2..a652f11 100644 --- a/couchpotato/core/downloaders/nzbvortex/main.py +++ b/couchpotato/core/downloaders/nzbvortex/main.py @@ -23,7 +23,9 @@ class NZBVortex(Downloader): api_level = None session_id = None - def download(self, data = {}, movie = {}, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} # Send the nzb try: @@ -97,9 +99,10 @@ class NZBVortex(Downloader): return False - def call(self, call, parameters = {}, repeat = False, auth = True, *args, **kwargs): + def call(self, call, parameters = None, repeat = False, auth = True, *args, **kwargs): # Login first + if not parameters: parameters = {} if not self.session_id and auth: self.login() @@ -148,7 +151,8 @@ class NZBVortex(Downloader): return self.api_level - def isEnabled(self, manual = False, data = {}): + def isEnabled(self, manual = False, data = None): + if not data: data = {} return super(NZBVortex, self).isEnabled(manual, data) and self.getApiLevel() diff --git a/couchpotato/core/downloaders/pneumatic/main.py b/couchpotato/core/downloaders/pneumatic/main.py index 25923e0..643350e 100644 --- a/couchpotato/core/downloaders/pneumatic/main.py +++ b/couchpotato/core/downloaders/pneumatic/main.py @@ -12,7 +12,9 @@ class Pneumatic(Downloader): protocol = ['nzb'] strm_syntax = 'plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb=%s&nzbname=%s' - def download(self, data = {}, movie = {}, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} directory = self.conf('directory') if not directory or not os.path.isdir(directory): diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py index 110c55b..08ee409 100644 --- a/couchpotato/core/downloaders/sabnzbd/main.py +++ b/couchpotato/core/downloaders/sabnzbd/main.py @@ -15,7 +15,9 @@ class Sabnzbd(Downloader): protocol = ['nzb'] - def download(self, data = {}, movie = {}, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} log.info('Sending "%s" to SABnzbd.', data.get('name')) diff --git a/couchpotato/core/downloaders/synology/main.py b/couchpotato/core/downloaders/synology/main.py index 58ab099..d5082c7 100644 --- a/couchpotato/core/downloaders/synology/main.py +++ b/couchpotato/core/downloaders/synology/main.py @@ -12,7 +12,9 @@ class Synology(Downloader): protocol = ['nzb', 'torrent', 'torrent_magnet'] log = CPLog(__name__) - def download(self, data, movie, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} response = False log.error('Sending "%s" (%s) to Synology.', (data['name'], data['protocol'])) @@ -49,7 +51,9 @@ class Synology(Downloader): else: return ['nzb'] - def isEnabled(self, manual = False, data = {}): + def isEnabled(self, manual = False, data = None): + if not data: data = {} + for_protocol = ['both'] if data and 'torrent' in data.get('protocol'): for_protocol.append('torrent') diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py index e1b9938..d933007 100644 --- a/couchpotato/core/downloaders/utorrent/main.py +++ b/couchpotato/core/downloaders/utorrent/main.py @@ -36,7 +36,9 @@ class uTorrent(Downloader): return self.utorrent_api - def download(self, data, movie, filedata = None): + def download(self, data = None, movie = None, filedata = None): + if not movie: movie = {} + if not data: data = {} log.debug('Sending "%s" (%s) to uTorrent.', (data.get('name'), data.get('protocol'))) @@ -280,7 +282,9 @@ class uTorrentAPI(object): return settings_dict - def set_settings(self, settings_dict = {}): + def set_settings(self, settings_dict = None): + if not settings_dict: settings_dict = {} + for key in settings_dict: if isinstance(settings_dict[key], bool): settings_dict[key] = 1 if settings_dict[key] else 0 diff --git a/couchpotato/core/media/_base/searcher/main.py b/couchpotato/core/media/_base/searcher/main.py index 3222edb..89afd75 100644 --- a/couchpotato/core/media/_base/searcher/main.py +++ b/couchpotato/core/media/_base/searcher/main.py @@ -146,7 +146,8 @@ class Searcher(SearcherBase): return search_protocols - def containsOtherQuality(self, nzb, movie_year = None, preferred_quality = {}): + def containsOtherQuality(self, nzb, movie_year = None, preferred_quality = None): + if not preferred_quality: preferred_quality = {} name = nzb['name'] size = nzb.get('size', 0) diff --git a/couchpotato/core/media/movie/_base/main.py b/couchpotato/core/media/movie/_base/main.py index a8d890d..4299f56 100644 --- a/couchpotato/core/media/movie/_base/main.py +++ b/couchpotato/core/media/movie/_base/main.py @@ -346,7 +346,8 @@ class MovieBase(MovieTypeBase): 'movies': movies, } - def add(self, params = {}, force_readd = True, search_after = True, update_library = False, status_id = None): + def add(self, params = None, force_readd = True, search_after = True, update_library = False, status_id = None): + if not params: params = {} if not params.get('identifier'): msg = 'Can\'t add movie without imdb identifier.' diff --git a/couchpotato/core/media/movie/library/movie/main.py b/couchpotato/core/media/movie/library/movie/main.py index 12e6abc..718e739 100644 --- a/couchpotato/core/media/movie/library/movie/main.py +++ b/couchpotato/core/media/movie/library/movie/main.py @@ -20,7 +20,9 @@ class MovieLibraryPlugin(LibraryBase): addEvent('library.update.movie', self.update) addEvent('library.update.movie.release_date', self.updateReleaseDate) - def add(self, attrs = {}, update_after = True): + def add(self, attrs = None, update_after = True): + if not attrs: attrs = {} + primary_provider = attrs.get('primary_provider', 'imdb') db = get_session() diff --git a/couchpotato/core/notifications/base.py b/couchpotato/core/notifications/base.py index 61cb212..4c0d099 100644 --- a/couchpotato/core/notifications/base.py +++ b/couchpotato/core/notifications/base.py @@ -32,7 +32,9 @@ class Notification(Provider): addEvent(listener, self.createNotifyHandler(listener)) def createNotifyHandler(self, listener): - def notify(message = None, group = {}, data = None): + def notify(message = None, group = None, data = None): + if not group: group = {} + if not self.conf('on_snatch', default = True) and listener == 'movie.snatched': return return self._notify(message = message, data = data if data else group, listener = listener) @@ -47,8 +49,8 @@ class Notification(Provider): return self.notify(*args, **kwargs) return False - def notify(self, message = '', data = {}, listener = None): - pass + def notify(self, message = '', data = None, listener = None): + if not data: data = {} def test(self, **kwargs): diff --git a/couchpotato/core/notifications/boxcar/main.py b/couchpotato/core/notifications/boxcar/main.py index b30d487..0fca749 100644 --- a/couchpotato/core/notifications/boxcar/main.py +++ b/couchpotato/core/notifications/boxcar/main.py @@ -10,7 +10,8 @@ class Boxcar(Notification): url = 'https://boxcar.io/devices/providers/7MNNXY3UIzVBwvzkKwkC/notifications' - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} try: message = message.strip() diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index 21cd197..a9a20b0 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -128,7 +128,8 @@ class CoreNotifier(Notification): Env.prop(prop_name, value = last_check) - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} db = get_session() @@ -149,7 +150,8 @@ class CoreNotifier(Notification): return True - def frontend(self, type = 'notification', data = {}, message = None): + def frontend(self, type = 'notification', data = None, message = None): + if not data: data = {} log.debug('Notifying frontend') diff --git a/couchpotato/core/notifications/email/main.py b/couchpotato/core/notifications/email/main.py index 21fcf15..f94688d 100644 --- a/couchpotato/core/notifications/email/main.py +++ b/couchpotato/core/notifications/email/main.py @@ -11,7 +11,8 @@ log = CPLog(__name__) class Email(Notification): - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} # Extract all the settings from settings from_address = self.conf('from') diff --git a/couchpotato/core/notifications/growl/main.py b/couchpotato/core/notifications/growl/main.py index caad661..dabeea0 100644 --- a/couchpotato/core/notifications/growl/main.py +++ b/couchpotato/core/notifications/growl/main.py @@ -43,7 +43,8 @@ class Growl(Notification): else: log.error('Failed register of growl: %s', traceback.format_exc()) - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} self.register() diff --git a/couchpotato/core/notifications/nmj/main.py b/couchpotato/core/notifications/nmj/main.py index 43bb950..1479fb1 100644 --- a/couchpotato/core/notifications/nmj/main.py +++ b/couchpotato/core/notifications/nmj/main.py @@ -64,8 +64,9 @@ class NMJ(Notification): 'mount': mount, } - def addToLibrary(self, message = None, group = {}): + def addToLibrary(self, message = None, group = None): if self.isDisabled(): return + if not group: group = {} host = self.conf('host') mount = self.conf('mount') diff --git a/couchpotato/core/notifications/notifo/main.py b/couchpotato/core/notifications/notifo/main.py index 6e4d7ad..2d56ed7 100644 --- a/couchpotato/core/notifications/notifo/main.py +++ b/couchpotato/core/notifications/notifo/main.py @@ -12,7 +12,8 @@ class Notifo(Notification): url = 'https://api.notifo.com/v1/send_notification' - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} try: params = { diff --git a/couchpotato/core/notifications/notifymyandroid/main.py b/couchpotato/core/notifications/notifymyandroid/main.py index 5e5bfb9..92e5956 100644 --- a/couchpotato/core/notifications/notifymyandroid/main.py +++ b/couchpotato/core/notifications/notifymyandroid/main.py @@ -8,7 +8,8 @@ log = CPLog(__name__) class NotifyMyAndroid(Notification): - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} nma = pynma.PyNMA() keys = splitString(self.conf('api_key')) diff --git a/couchpotato/core/notifications/plex/main.py b/couchpotato/core/notifications/plex/main.py index 9becfb5..f6088f5 100644 --- a/couchpotato/core/notifications/plex/main.py +++ b/couchpotato/core/notifications/plex/main.py @@ -17,8 +17,9 @@ class Plex(Notification): super(Plex, self).__init__() addEvent('renamer.after', self.addToLibrary) - def addToLibrary(self, message = None, group = {}): + def addToLibrary(self, message = None, group = None): if self.isDisabled(): return + if not group: group = {} log.info('Sending notification to Plex') hosts = self.getHosts(port = 32400) @@ -45,7 +46,8 @@ class Plex(Notification): return True - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} hosts = self.getHosts(port = 3000) successful = 0 diff --git a/couchpotato/core/notifications/prowl/main.py b/couchpotato/core/notifications/prowl/main.py index e5c4678..a8a3dda 100644 --- a/couchpotato/core/notifications/prowl/main.py +++ b/couchpotato/core/notifications/prowl/main.py @@ -12,7 +12,8 @@ class Prowl(Notification): 'api': 'https://api.prowlapp.com/publicapi/add' } - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} data = { 'apikey': self.conf('api_key'), diff --git a/couchpotato/core/notifications/pushalot/main.py b/couchpotato/core/notifications/pushalot/main.py index 4c5e76c..4e3b6e7 100644 --- a/couchpotato/core/notifications/pushalot/main.py +++ b/couchpotato/core/notifications/pushalot/main.py @@ -11,7 +11,8 @@ class Pushalot(Notification): 'api': 'https://pushalot.com/api/sendmessage' } - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} data = { 'AuthorizationToken': self.conf('auth_token'), diff --git a/couchpotato/core/notifications/pushover/main.py b/couchpotato/core/notifications/pushover/main.py index ea5e774..76f730b 100644 --- a/couchpotato/core/notifications/pushover/main.py +++ b/couchpotato/core/notifications/pushover/main.py @@ -11,7 +11,8 @@ class Pushover(Notification): app_token = 'YkxHMYDZp285L265L3IwH3LmzkTaCy' - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} http_handler = HTTPSConnection("api.pushover.net:443") diff --git a/couchpotato/core/notifications/synoindex/main.py b/couchpotato/core/notifications/synoindex/main.py index 3980430..0f7775d 100644 --- a/couchpotato/core/notifications/synoindex/main.py +++ b/couchpotato/core/notifications/synoindex/main.py @@ -15,8 +15,9 @@ class Synoindex(Notification): super(Synoindex, self).__init__() addEvent('renamer.after', self.addToLibrary) - def addToLibrary(self, message = None, group = {}): + def addToLibrary(self, message = None, group = None): if self.isDisabled(): return + if not group: group = {} command = [self.index_path, '-A', group.get('destination_dir')] log.info('Executing synoindex command: %s ', command) diff --git a/couchpotato/core/notifications/toasty/main.py b/couchpotato/core/notifications/toasty/main.py index 79b021e..c65b6b4 100644 --- a/couchpotato/core/notifications/toasty/main.py +++ b/couchpotato/core/notifications/toasty/main.py @@ -11,7 +11,8 @@ class Toasty(Notification): 'api': 'http://api.supertoasty.com/notify/%s?%s' } - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} data = { 'title': self.default_title, diff --git a/couchpotato/core/notifications/trakt/main.py b/couchpotato/core/notifications/trakt/main.py index 86d4708..99d5553 100644 --- a/couchpotato/core/notifications/trakt/main.py +++ b/couchpotato/core/notifications/trakt/main.py @@ -13,7 +13,8 @@ class Trakt(Notification): listen_to = ['movie.downloaded'] - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} post_data = { 'username': self.conf('automation_username'), diff --git a/couchpotato/core/notifications/twitter/main.py b/couchpotato/core/notifications/twitter/main.py index 4a34d60..ad4fc31 100644 --- a/couchpotato/core/notifications/twitter/main.py +++ b/couchpotato/core/notifications/twitter/main.py @@ -30,7 +30,8 @@ class Twitter(Notification): addApiView('notify.%s.auth_url' % self.getName().lower(), self.getAuthorizationUrl) addApiView('notify.%s.credentials' % self.getName().lower(), self.getCredentials) - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} api = Api(self.consumer_key, self.consumer_secret, self.conf('access_token_key'), self.conf('access_token_secret')) diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py index 836b40c..dc185c4 100755 --- a/couchpotato/core/notifications/xbmc/main.py +++ b/couchpotato/core/notifications/xbmc/main.py @@ -17,7 +17,8 @@ class XBMC(Notification): use_json_notifications = {} http_time_between_calls = 0 - def notify(self, message = '', data = {}, listener = None): + def notify(self, message = '', data = None, listener = None): + if not data: data = {} hosts = splitString(self.conf('host')) diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index cdd67f5..2f458f7 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -83,7 +83,8 @@ class FileManager(Plugin): Env.get('app').add_handlers(".*$", [('%s%s' % (Env.get('api_base'), route), StaticFileHandler, {'path': Env.get('cache_dir')})]) - def download(self, url = '', dest = None, overwrite = False, urlopen_kwargs = {}): + def download(self, url = '', dest = None, overwrite = False, urlopen_kwargs = None): + if not urlopen_kwargs: urlopen_kwargs = {} if not dest: # to Cache dest = os.path.join(Env.get('cache_dir'), '%s.%s' % (md5(url), getExt(url))) @@ -100,7 +101,9 @@ class FileManager(Plugin): self.createFile(dest, filedata, binary = True) return dest - def add(self, path = '', part = 1, type_tuple = (), available = 1, properties = {}): + def add(self, path = '', part = 1, type_tuple = (), available = 1, properties = None): + if not properties: properties = {} + type_id = self.getType(type_tuple).get('id') db = get_session() diff --git a/couchpotato/core/plugins/manage/main.py b/couchpotato/core/plugins/manage/main.py index f1ffefa..3a475b7 100644 --- a/couchpotato/core/plugins/manage/main.py +++ b/couchpotato/core/plugins/manage/main.py @@ -26,7 +26,8 @@ class Manage(Plugin): addEvent('manage.diskspace', self.getDiskSpace) # Add files after renaming - def after_rename(message = None, group = {}): + def after_rename(message = None, group = None): + if not group: group = {} return self.scanFilesToLibrary(folder = group['destination_dir'], files = group['renamed_files']) addEvent('renamer.after', after_rename, priority = 110) @@ -168,7 +169,9 @@ class Manage(Plugin): fireEvent('notify.frontend', type = 'manage.updating', data = False) self.in_progress = False - def createAddToLibrary(self, folder, added_identifiers = []): + def createAddToLibrary(self, folder, added_identifiers = None): + if not added_identifiers: added_identifiers = [] + def addToLibrary(group, total_found, to_go): if self.in_progress[folder]['total'] is None: self.in_progress[folder] = { diff --git a/couchpotato/core/plugins/quality/main.py b/couchpotato/core/plugins/quality/main.py index 0e67a07..15710a8 100644 --- a/couchpotato/core/plugins/quality/main.py +++ b/couchpotato/core/plugins/quality/main.py @@ -152,7 +152,8 @@ class QualityPlugin(Plugin): return True - def guess(self, files, extra = {}): + def guess(self, files, extra = None): + if not extra: extra = {} # Create hash for cache hash = md5(str([f.replace('.' + getExt(f), '') for f in files])) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index a45a265..4bbf351 100644 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -495,7 +495,9 @@ class Renamer(Plugin): self.renaming_started = False - def getRenameExtras(self, extra_type = '', replacements = {}, folder_name = '', file_name = '', destination = '', group = {}, current_file = '', remove_multiple = False): + def getRenameExtras(self, extra_type = '', replacements = None, folder_name = '', file_name = '', destination = '', group = None, current_file = '', remove_multiple = False): + if not group: group = {} + if not replacements: replacements = {} replacements = replacements.copy() rename_files = {} @@ -843,11 +845,12 @@ Remove it if you want it to be renamed (again, or at least let it try again) def statusInfoComplete(self, item): return item['id'] and item['downloader'] and item['folder'] - + def movieInFromFolder(self, movie_folder): return movie_folder and self.conf('from') in movie_folder or not movie_folder - def extractFiles(self, folder = None, movie_folder = None, files = [], cleanup = False): + def extractFiles(self, folder = None, movie_folder = None, files = None, cleanup = False): + if not files: files = [] # RegEx for finding rar files archive_regex = '(?P^(?P(?:(?!\.part\d+\.rar$).)*)\.(?:(?:part0*1\.)?rar)$)' @@ -941,7 +944,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) self.makeDir(os.path.dirname(move_to)) self.moveFile(leftoverfile, move_to, cleanup) except Exception, e: - log.error('Failed moving left over file %s to %s: %s %s',(leftoverfile, move_to, e, traceback.format_exc())) + log.error('Failed moving left over file %s to %s: %s %s', (leftoverfile, move_to, e, traceback.format_exc())) # As we probably tried to overwrite the nfo file, check if it exists and then remove the original if os.path.isfile(move_to): if cleanup: @@ -964,7 +967,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) if extr_files: files.extend(extr_files) - # Cleanup files and folder if movie_folder was not provided + # Cleanup files and folder if movie_folder was not provided if not movie_folder: files = [] folder = None diff --git a/couchpotato/core/plugins/subtitle/main.py b/couchpotato/core/plugins/subtitle/main.py index 2aa22f4..e447dac 100644 --- a/couchpotato/core/plugins/subtitle/main.py +++ b/couchpotato/core/plugins/subtitle/main.py @@ -42,7 +42,6 @@ class Subtitle(Plugin): subliminal.list_subtitles(files, cache_dir = Env.get('cache_dir'), multi = True, languages = self.getLanguages(), services = self.services) def searchSingle(self, group): - if self.isDisabled(): return try: diff --git a/couchpotato/core/plugins/trailer/main.py b/couchpotato/core/plugins/trailer/main.py index 1a8955f..e27e3f9 100644 --- a/couchpotato/core/plugins/trailer/main.py +++ b/couchpotato/core/plugins/trailer/main.py @@ -12,8 +12,8 @@ class Trailer(Plugin): def __init__(self): addEvent('renamer.after', self.searchSingle) - def searchSingle(self, message = None, group = {}): - + def searchSingle(self, message = None, group = None): + if not group: group = {} if self.isDisabled() or len(group['files']['trailer']) > 0: return trailers = fireEvent('trailer.search', group = group, merge = True) @@ -40,4 +40,3 @@ class Trailer(Plugin): break return True - diff --git a/couchpotato/core/providers/info/couchpotatoapi/main.py b/couchpotato/core/providers/info/couchpotatoapi/main.py index cdbc513..ef7db1f 100644 --- a/couchpotato/core/providers/info/couchpotatoapi/main.py +++ b/couchpotato/core/providers/info/couchpotatoapi/main.py @@ -80,7 +80,10 @@ class CouchPotatoApi(MovieProvider): return dates - def getSuggestions(self, movies = [], ignore = []): + def getSuggestions(self, movies = None, ignore = None): + if not ignore: ignore = [] + if not movies: movies = [] + suggestions = self.getJsonData(self.urls['suggest'], params = { 'movies': ','.join(movies), 'ignore': ','.join(ignore), diff --git a/couchpotato/core/providers/metadata/base.py b/couchpotato/core/providers/metadata/base.py index 7a65568..f561003 100644 --- a/couchpotato/core/providers/metadata/base.py +++ b/couchpotato/core/providers/metadata/base.py @@ -17,8 +17,9 @@ class MetaDataBase(Plugin): def __init__(self): addEvent('renamer.after', self.create) - def create(self, message = None, group = {}): + def create(self, message = None, group = None): if self.isDisabled(): return + if not group: group = {} log.info('Creating %s metadata.', self.getName()) @@ -65,7 +66,8 @@ class MetaDataBase(Plugin): except: log.error('Unable to create %s file: %s', (file_type, traceback.format_exc())) - def getRootName(self, data = {}): + def getRootName(self, data = None): + if not data: data = {} return os.path.join(data['destination_dir'], data['filename']) def getFanartName(self, name, root): @@ -77,10 +79,13 @@ class MetaDataBase(Plugin): def getNfoName(self, name, root): return - def getNfo(self, movie_info = {}, data = {}): - return + def getNfo(self, movie_info = None, data = None): + if not data: data = {} + if not movie_info: movie_info = {} - def getThumbnail(self, movie_info = {}, data = {}, wanted_file_type = 'poster_original'): + def getThumbnail(self, movie_info = None, data = None, wanted_file_type = 'poster_original'): + if not data: data = {} + if not movie_info: movie_info = {} file_types = fireEvent('file.types', single = True) file_type = {} @@ -102,5 +107,7 @@ class MetaDataBase(Plugin): except: pass - def getFanart(self, movie_info = {}, data = {}): + def getFanart(self, movie_info = None, data = None): + if not data: data = {} + if not movie_info: movie_info = {} return self.getThumbnail(movie_info = movie_info, data = data, wanted_file_type = 'backdrop_original') diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index 820df15..e865e2d 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -24,7 +24,9 @@ class XBMC(MetaDataBase): def createMetaName(self, basename, name, root): return os.path.join(root, basename.replace('%s', name)) - def getNfo(self, movie_info = {}, data = {}): + def getNfo(self, movie_info = None, data = None): + if not data: data = {} + if not movie_info: movie_info = {} # return imdb url only if self.conf('meta_url_only'): diff --git a/couchpotato/core/settings/__init__.py b/couchpotato/core/settings/__init__.py index b75e5dd..61d982f 100644 --- a/couchpotato/core/settings/__init__.py +++ b/couchpotato/core/settings/__init__.py @@ -72,7 +72,9 @@ class Settings(object): addEvent('settings.register', self.registerDefaults) addEvent('settings.save', self.save) - def registerDefaults(self, section_name, options = {}, save = True): + def registerDefaults(self, section_name, options = None, save = True): + if not options: options = {} + self.addSection(section_name) for option_name, option in options.iteritems(): diff --git a/couchpotato/core/settings/model.py b/couchpotato/core/settings/model.py index 2737392..f39544b 100644 --- a/couchpotato/core/settings/model.py +++ b/couchpotato/core/settings/model.py @@ -137,7 +137,10 @@ class Release(Entity): files = ManyToMany('File') info = OneToMany('ReleaseInfo', cascade = 'all, delete-orphan') - def to_dict(self, deep = {}, exclude = []): + def to_dict(self, deep = None, exclude = None): + if not exclude: exclude = [] + if not deep: deep = {} + orig_dict = super(Release, self).to_dict(deep = deep, exclude = exclude) new_info = {} @@ -200,7 +203,10 @@ class Profile(Entity): movie = OneToMany('Movie') types = OneToMany('ProfileType', cascade = 'all, delete-orphan') - def to_dict(self, deep = {}, exclude = []): + def to_dict(self, deep = None, exclude = None): + if not exclude: exclude = [] + if not deep: deep = {} + orig_dict = super(Profile, self).to_dict(deep = deep, exclude = exclude) orig_dict['core'] = orig_dict.get('core') or False orig_dict['hide'] = orig_dict.get('hide') or False