From b5a0418a368c0df888b0373b79da166de987b1a3 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 16:26:33 +0200 Subject: [PATCH 1/7] Make available space check optional fix #3973 --- couchpotato/core/plugins/renamer.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/plugins/renamer.py b/couchpotato/core/plugins/renamer.py index cd6255ce..d6deba6b 100755 --- a/couchpotato/core/plugins/renamer.py +++ b/couchpotato/core/plugins/renamer.py @@ -541,12 +541,13 @@ class Renamer(Plugin): (not keep_original or self.fileIsAdded(current_file, group)): remove_files.append(current_file) - total_space, available_space = getFreeSpace(destination) - renaming_size = getSize(rename_files.keys()) - if renaming_size > available_space: - log.error('Not enough space left, need %s MB but only %s MB available', (renaming_size, available_space)) - self.tagRelease(group = group, tag = 'not_enough_space') - continue + if self.conf('check_space'): + total_space, available_space = getFreeSpace(destination) + renaming_size = getSize(rename_files.keys()) + if renaming_size > available_space: + log.error('Not enough space left, need %s MB but only %s MB available', (renaming_size, available_space)) + self.tagRelease(group = group, tag = 'not_enough_space') + continue # Remove files delete_folders = [] @@ -1389,6 +1390,14 @@ config = [{ 'label': 'Folder-Separator', 'description': ('Replace all the spaces with a character.', 'Example: ".", "-" (without quotes). Leave empty to use spaces.'), }, + { + 'name': 'check_space', + 'label': 'Check space', + 'default': True, + 'type': 'bool', + 'description': ('Check if there\'s enough available space to rename the files', 'Disable when the filesystem doesn\'t return the proper value'), + 'advanced': True, + }, { 'name': 'default_file_action', 'label': 'Default File Action', From 2270b2a28bbaddb5b52cadbcf2b482ac425eff8c Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 16:50:01 +0200 Subject: [PATCH 2/7] Don't force parser for trailer searching --- .../core/media/movie/providers/trailer/hdtrailers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/media/movie/providers/trailer/hdtrailers.py b/couchpotato/core/media/movie/providers/trailer/hdtrailers.py index 828f017f..4cbb64d6 100644 --- a/couchpotato/core/media/movie/providers/trailer/hdtrailers.py +++ b/couchpotato/core/media/movie/providers/trailer/hdtrailers.py @@ -3,7 +3,7 @@ import re from bs4 import SoupStrainer, BeautifulSoup from couchpotato.core.helpers.encoding import tryUrlencode -from couchpotato.core.helpers.variable import mergeDicts, getTitle +from couchpotato.core.helpers.variable import mergeDicts, getTitle, getIdentifier from couchpotato.core.logger import CPLog from couchpotato.core.media.movie.providers.trailer.base import TrailerProvider from requests import HTTPError @@ -29,7 +29,7 @@ class HDTrailers(TrailerProvider): url = self.urls['api'] % self.movieUrlName(movie_name) try: - data = self.getCache('hdtrailers.%s' % group['identifier'], url, show_error = False) + data = self.getCache('hdtrailers.%s' % getIdentifier(group), url, show_error = False) except HTTPError: log.debug('No page found for: %s', movie_name) data = None @@ -59,7 +59,7 @@ class HDTrailers(TrailerProvider): url = "%s?%s" % (self.urls['backup'], tryUrlencode({'s':movie_name})) try: - data = self.getCache('hdtrailers.alt.%s' % group['identifier'], url, show_error = False) + data = self.getCache('hdtrailers.alt.%s' % getIdentifier(group), url, show_error = False) except HTTPError: log.debug('No alternative page found for: %s', movie_name) data = None @@ -68,7 +68,7 @@ class HDTrailers(TrailerProvider): return results try: - html = BeautifulSoup(data, 'html.parser', parse_only = self.only_tables_tags) + html = BeautifulSoup(data, parse_only = self.only_tables_tags) result_table = html.find_all('h2', text = re.compile(movie_name)) for h2 in result_table: @@ -90,7 +90,7 @@ class HDTrailers(TrailerProvider): results = {'480p':[], '720p':[], '1080p':[]} try: - html = BeautifulSoup(data, 'html.parser', parse_only = self.only_tables_tags) + html = BeautifulSoup(data, parse_only = self.only_tables_tags) result_table = html.find('table', attrs = {'class':'bottomTable'}) for tr in result_table.find_all('tr'): From 492f69b14914fd042e716a20c3d830633d85c64f Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 16:53:40 +0200 Subject: [PATCH 3/7] Actually use the smtp port from settings fix #4003 --- couchpotato/core/notifications/email_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/notifications/email_.py b/couchpotato/core/notifications/email_.py index a63eb3de..d0c65167 100644 --- a/couchpotato/core/notifications/email_.py +++ b/couchpotato/core/notifications/email_.py @@ -42,7 +42,7 @@ class Email(Notification): # Open the SMTP connection, via SSL if requested log.debug("Connecting to host %s on port %s" % (smtp_server, smtp_port)) log.debug("SMTP over SSL %s", ("enabled" if ssl == 1 else "disabled")) - mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server) + mailserver = smtplib.SMTP_SSL(smtp_server, smtp_port) if ssl == 1 else smtplib.SMTP(smtp_server, smtp_port) if starttls: log.debug("Using StartTLS to initiate the connection with the SMTP server") From 01f70051f8465da6e1601b860b937b5af1408c18 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 17:37:25 +0200 Subject: [PATCH 4/7] For people who can't read good --- couchpotato/core/plugins/log/static/log.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/plugins/log/static/log.js b/couchpotato/core/plugins/log/static/log.js index 6cb683bc..71a65d0d 100644 --- a/couchpotato/core/plugins/log/static/log.js +++ b/couchpotato/core/plugins/log/static/log.js @@ -241,7 +241,7 @@ Running on: ...\n\ 'href': 'https://github.com/RuudBurger/CouchPotatoServer/blob/develop/contributing.md' }), new Element('span', { - 'text': ' before posting (kittens die if you don\'t), then copy the text below.' + 'html': ' before posting, then copy the text below and FILL IN the dots.' }) ), textarea = new Element('textarea', { From e84f2aa04c0f8cafdf1760f4a1264d2767f8b0bb Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 17:47:21 +0200 Subject: [PATCH 5/7] Don't load charts if suggestion tab is enabled --- .../core/media/movie/charts/static/charts.js | 24 ++++++++++++++----- couchpotato/static/scripts/page/home.js | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js index a04e248f..e41b7ba2 100644 --- a/couchpotato/core/media/movie/charts/static/charts.js +++ b/couchpotato/core/media/movie/charts/static/charts.js @@ -2,6 +2,8 @@ var Charts = new Class({ Implements: [Options, Events], + shown_once: false, + initialize: function(options){ var self = this; self.setOptions(options); @@ -40,17 +42,27 @@ var Charts = new Class({ ) ); - if( Cookie.read('suggestions_charts_menu_selected') === 'charts') - self.el.show(); + if( Cookie.read('suggestions_charts_menu_selected') === 'charts'){ + self.show(); + self.fireEvent.delay(0, self, 'created'); + } else self.el.hide(); - self.api_request = Api.request('charts.view', { - 'onComplete': self.fill.bind(self) - }); + }, - self.fireEvent.delay(0, self, 'created'); + show: function(){ + var self = this; + self.el.show(); + + if(!self.shown_once){ + self.api_request = Api.request('charts.view', { + 'onComplete': self.fill.bind(self) + }); + + self.shown_once = true; + } }, fill: function(json){ diff --git a/couchpotato/static/scripts/page/home.js b/couchpotato/static/scripts/page/home.js index 792b4a07..fc1702e6 100644 --- a/couchpotato/static/scripts/page/home.js +++ b/couchpotato/static/scripts/page/home.js @@ -218,7 +218,7 @@ Page.Home = new Class({ self.el_toggle_menu_charts.removeClass('active'); break; case 'charts': - if($(self.charts)) $(self.charts).show(); + if($(self.charts)) self.charts.show(); self.el_toggle_menu_charts.addClass('active'); if($(self.suggestion_list)) $(self.suggestion_list).hide(); self.el_toggle_menu_suggestions.removeClass('active'); From 20f10760375d08ac0d61507b7ef8ab589a4517b7 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 21:48:46 +0200 Subject: [PATCH 6/7] Don't load suggestions when chartview active --- .../core/media/movie/charts/static/charts.js | 32 ++++---- .../media/movie/suggestion/static/suggest.js | 31 +++++-- couchpotato/static/scripts/page/home.js | 82 ++++++++----------- 3 files changed, 79 insertions(+), 66 deletions(-) diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js index e41b7ba2..3d70f7f8 100644 --- a/couchpotato/core/media/movie/charts/static/charts.js +++ b/couchpotato/core/media/movie/charts/static/charts.js @@ -51,20 +51,6 @@ var Charts = new Class({ }, - show: function(){ - var self = this; - - self.el.show(); - - if(!self.shown_once){ - self.api_request = Api.request('charts.view', { - 'onComplete': self.fill.bind(self) - }); - - self.shown_once = true; - } - }, - fill: function(json){ var self = this; @@ -169,6 +155,24 @@ var Charts = new Class({ }, + show: function(){ + var self = this; + + self.el.show(); + + if(!self.shown_once){ + self.api_request = Api.request('charts.view', { + 'onComplete': self.fill.bind(self) + }); + + self.shown_once = true; + } + }, + + hide: function(){ + this.el.hide(); + }, + afterAdded: function(m){ $(m).getElement('div.chart_number') diff --git a/couchpotato/core/media/movie/suggestion/static/suggest.js b/couchpotato/core/media/movie/suggestion/static/suggest.js index 494f0459..ca4b07c2 100644 --- a/couchpotato/core/media/movie/suggestion/static/suggest.js +++ b/couchpotato/core/media/movie/suggestion/static/suggest.js @@ -2,6 +2,8 @@ var SuggestList = new Class({ Implements: [Options, Events], + shown_once: false, + initialize: function(options){ var self = this; self.setOptions(options); @@ -44,12 +46,13 @@ var SuggestList = new Class({ } }); - var cookie_menu_select = Cookie.read('suggestions_charts_menu_selected'); - if( cookie_menu_select === 'suggestions' || cookie_menu_select === null ) self.el.show(); else self.el.hide(); + var cookie_menu_select = Cookie.read('suggestions_charts_menu_selected') || 'suggestions'; + if( cookie_menu_select === 'suggestions') + self.show(); + else + self.hide(); - self.api_request = Api.request('suggestion.view', { - 'onComplete': self.fill.bind(self) - }); + self.fireEvent('created'); }, @@ -145,6 +148,24 @@ var SuggestList = new Class({ }, + show: function(){ + var self = this; + + self.el.show(); + + if(!self.shown_once){ + self.api_request = Api.request('suggestion.view', { + 'onComplete': self.fill.bind(self) + }); + + self.shown_once = true; + } + }, + + hide: function(){ + this.el.hide(); + }, + toElement: function(){ return this.el; } diff --git a/couchpotato/static/scripts/page/home.js b/couchpotato/static/scripts/page/home.js index fc1702e6..4d18cac7 100644 --- a/couchpotato/static/scripts/page/home.js +++ b/couchpotato/static/scripts/page/home.js @@ -146,13 +146,13 @@ Page.Home = new Class({ var self = this; // Suggest - self.suggestion_list = new SuggestList({ - 'onLoaded': function(){ + self.suggestions_list = new SuggestList({ + 'onCreated': function(){ self.chain.callChain(); } }); - $(self.suggestion_list).inject(self.el); + $(self.suggestions_list).inject(self.el); }, @@ -160,46 +160,38 @@ Page.Home = new Class({ var self = this; // Charts - self.charts = new Charts({ + self.charts_list = new Charts({ 'onCreated': function(){ self.chain.callChain(); } }); - $(self.charts).inject(self.el); + $(self.charts_list).inject(self.el); }, createSuggestionsChartsMenu: function(){ - var self = this; + var self = this, + suggestion_tab, charts_tab; - self.el_toggle_menu_suggestions = new Element('a.toggle_suggestions.active', { - 'href': '#', - 'events': { 'click': function(e) { - e.preventDefault(); - self.toggleSuggestionsCharts('suggestions'); - } - } - }).grab( new Element('h2', {'text': 'Suggestions'})); + self.el_toggle_menu = new Element('div.toggle_menu', { + 'events': { + 'click:relay(a)': function(e, el) { + e.preventDefault(); + self.toggleSuggestionsCharts(el.get('data-container'), el); + } + } + }).adopt( + suggestion_tab = new Element('a.toggle_suggestions', { + 'data-container': 'suggestions' + }).grab(new Element('h2', {'text': 'Suggestions'})), + charts_tab = new Element('a.toggle_charts', { + 'data-container': 'charts' + }).grab( new Element('h2', {'text': 'Charts'})) + ); - self.el_toggle_menu_charts = new Element('a.toggle_charts', { - 'href': '#', - 'events': { 'click': function(e) { - e.preventDefault(); - self.toggleSuggestionsCharts('charts'); - } - } - }).grab( new Element('h2', {'text': 'Charts'})); - - self.el_toggle_menu = new Element('div.toggle_menu').grab( - self.el_toggle_menu_suggestions - ).grab( - self.el_toggle_menu_charts - ); - - var menu_selected = Cookie.read('suggestions_charts_menu_selected'); - if( menu_selected === null ) menu_selected = 'suggestions'; - self.toggleSuggestionsCharts( menu_selected ); + var menu_selected = Cookie.read('suggestions_charts_menu_selected') || 'suggestions'; + self.toggleSuggestionsCharts(menu_selected, menu_selected == 'suggestions' ? suggestion_tab : charts_tab); self.el_toggle_menu.inject(self.el); @@ -207,23 +199,19 @@ Page.Home = new Class({ }, - toggleSuggestionsCharts: function(menu_id){ + toggleSuggestionsCharts: function(menu_id, el){ var self = this; - switch(menu_id) { - case 'suggestions': - if($(self.suggestion_list)) $(self.suggestion_list).show(); - self.el_toggle_menu_suggestions.addClass('active'); - if($(self.charts)) $(self.charts).hide(); - self.el_toggle_menu_charts.removeClass('active'); - break; - case 'charts': - if($(self.charts)) self.charts.show(); - self.el_toggle_menu_charts.addClass('active'); - if($(self.suggestion_list)) $(self.suggestion_list).hide(); - self.el_toggle_menu_suggestions.removeClass('active'); - break; - } + // Toggle ta + self.el_toggle_menu.getElements('.active').removeClass('active'); + if(el) el.addClass('active'); + + // Hide both + if(self.suggestions_list) self.suggestions_list.hide(); + if(self.charts_list) self.charts_list.hide(); + + var toggle_to = self[menu_id + '_list']; + if(toggle_to) toggle_to.show(); Cookie.write('suggestions_charts_menu_selected', menu_id, {'duration': 365}); }, From f8674f9baa2448dd17701c26d6a908b754f51b7e Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Oct 2014 22:17:58 +0200 Subject: [PATCH 7/7] Grammar --- couchpotato/core/media/movie/searcher.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/media/movie/searcher.py b/couchpotato/core/media/movie/searcher.py index 50b2d446..2dad7378 100755 --- a/couchpotato/core/media/movie/searcher.py +++ b/couchpotato/core/media/movie/searcher.py @@ -55,6 +55,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase): if self.conf('run_on_launch'): addEvent('app.load', self.searchAll) + addEvent('app.load', self.searchAll) def searchAllView(self, **kwargs): @@ -141,17 +142,17 @@ class MovieSearcher(SearcherBase, MovieTypeBase): previous_releases = movie.get('releases', []) too_early_to_search = [] outside_eta_results = 0 - alway_search = self.conf('always_search') + always_search = self.conf('always_search') ignore_eta = manual total_result_count = 0 fireEvent('notify.frontend', type = 'movie.searcher.started', data = {'_id': movie['_id']}, message = 'Searching for "%s"' % default_title) # Ignore eta once every 7 days - if not alway_search: + if not always_search: prop_name = 'last_ignored_eta.%s' % movie['_id'] last_ignored_eta = float(Env.prop(prop_name, default = 0)) - if last_ignored_eta > time.time() - 604800: + if last_ignored_eta < time.time() - 604800: ignore_eta = True Env.prop(prop_name, value = time.time()) @@ -170,7 +171,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase): } could_not_be_released = not self.couldBeReleased(q_identifier in pre_releases, release_dates, movie['info']['year']) - if not alway_search and could_not_be_released: + if not always_search and could_not_be_released: too_early_to_search.append(q_identifier) # Skip release, if ETA isn't ignored @@ -196,7 +197,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase): break quality = fireEvent('quality.single', identifier = q_identifier, single = True) - log.info('Search for %s in %s%s', (default_title, quality['label'], ' ignoring ETA' if alway_search or ignore_eta else '')) + log.info('Search for %s in %s%s', (default_title, quality['label'], ' ignoring ETA' if always_search or ignore_eta else '')) # Extend quality with profile customs quality['custom'] = quality_custom @@ -223,7 +224,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase): log.debug('Found %s releases for "%s", but ETA isn\'t correct yet.', (results_count, default_title)) # Try find a valid result and download it - if (force_download or not could_not_be_released or alway_search) and fireEvent('release.try_download_result', results, movie, quality_custom, single = True): + if (force_download or not could_not_be_released or always_search) and fireEvent('release.try_download_result', results, movie, quality_custom, single = True): ret = True # Remove releases that aren't found anymore