From f9bdf6da1cfe3eca1885ff620516f77747064af5 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 22:42:26 +0100 Subject: [PATCH 1/6] Send correct headers to SABNZBd. fix #1406 --- couchpotato/core/downloaders/sabnzbd/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py index 91302780..a287f119 100644 --- a/couchpotato/core/downloaders/sabnzbd/main.py +++ b/couchpotato/core/downloaders/sabnzbd/main.py @@ -2,6 +2,7 @@ from couchpotato.core.downloaders.base import Downloader from couchpotato.core.helpers.encoding import tryUrlencode, ss from couchpotato.core.helpers.variable import cleanHost, mergeDicts from couchpotato.core.logger import CPLog +from couchpotato.environment import Env from urllib2 import URLError import json import traceback @@ -38,9 +39,9 @@ class Sabnzbd(Downloader): try: if params.get('mode') is 'addfile': - sab = self.urlopen(url, timeout = 60, params = {'nzbfile': (ss(nzb_filename), filedata)}, multipart = True, show_error = False) + sab = self.urlopen(url, timeout = 60, params = {'nzbfile': (ss(nzb_filename), filedata)}, multipart = True, show_error = False, headers = {'User-Agent': Env.getIdentifier()}) else: - sab = self.urlopen(url, timeout = 60, show_error = False) + sab = self.urlopen(url, timeout = 60, show_error = False, headers = {'User-Agent': Env.getIdentifier()}) except URLError: log.error('Failed sending release, probably wrong HOST: %s', traceback.format_exc(0)) return False @@ -139,7 +140,7 @@ class Sabnzbd(Downloader): 'output': 'json' })) - data = self.urlopen(url, timeout = 60, show_error = False) + data = self.urlopen(url, timeout = 60, show_error = False, headers = {'User-Agent': Env.getIdentifier()}) if use_json: d = json.loads(data) if d.get('error'): From 3908e00650492fbb1a83856e7f3669a3b24fa788 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 22:49:44 +0100 Subject: [PATCH 2/6] Stop progress search on fail. fix #1409 --- couchpotato/static/scripts/page/manage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/static/scripts/page/manage.js b/couchpotato/static/scripts/page/manage.js index c06c655b..0e44e767 100644 --- a/couchpotato/static/scripts/page/manage.js +++ b/couchpotato/static/scripts/page/manage.js @@ -88,7 +88,7 @@ Page.Manage = new Class({ 'onComplete': function(json){ self.update_in_progress = true; - if(!json.progress){ + if(!json || !json.progress){ clearInterval(self.progress_interval); self.update_in_progress = false; if(self.progress_container){ From af0cf523e332660e6611bf68714e6040b402ec05 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 22:56:02 +0100 Subject: [PATCH 3/6] Fedora init script. closes #1399 --- init/fedora | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/init/fedora b/init/fedora index 791b676d..47352471 100644 --- a/init/fedora +++ b/init/fedora @@ -14,6 +14,11 @@ prog=couchpotato lockfile=/var/lock/subsys/$prog +# Source couchpotato configuration +if [ -f /etc/sysconfig/couchpotato ]; then + . /etc/sysconfig/couchpotato +fi + ## Edit user configuation in /etc/sysconfig/couchpotato to change ## the defaults username=${CP_USER-couchpotato} @@ -22,11 +27,6 @@ datadir=${CP_DATA-~/.couchpotato} pidfile=${CP_PIDFILE-/var/run/couchpotato/couchpotato.pid} ## -# Source couchpotato configuration -if [ -f /etc/sysconfig/couchpotato ]; then - . /etc/sysconfig/couchpotato -fi - pidpath=`dirname ${pidfile}` options=" --daemon --pid_file=${pidfile} --data_dir=${datadir}" @@ -87,4 +87,4 @@ case "$1" in *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 -esac \ No newline at end of file +esac From 4ede2c20a1afcdc0e62cb91616a53ea40165b2e9 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 23:10:34 +0100 Subject: [PATCH 4/6] Goodfilm automation provider. closes #1366 --- .../automation/goodfilms/__init__.py | 28 +++++++++++++++ .../providers/automation/goodfilms/main.py | 36 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 couchpotato/core/providers/automation/goodfilms/__init__.py create mode 100644 couchpotato/core/providers/automation/goodfilms/main.py diff --git a/couchpotato/core/providers/automation/goodfilms/__init__.py b/couchpotato/core/providers/automation/goodfilms/__init__.py new file mode 100644 index 00000000..795e21da --- /dev/null +++ b/couchpotato/core/providers/automation/goodfilms/__init__.py @@ -0,0 +1,28 @@ +from .main import Goodfilms + +def start(): + return Goodfilms() + +config = [{ + 'name': 'goodfilms', + 'groups': [ + { + 'tab': 'automation', + 'list': 'watchlist_providers', + 'name': 'goodfilms_automation', + 'label': 'Goodfilms', + 'description': 'import movies from your Goodfilms queue', + 'options': [ + { + 'name': 'automation_enabled', + 'default': False, + 'type': 'enabler', + }, + { + 'name': 'automation_username', + 'label': 'Username', + }, + ], + }, + ], +}] \ No newline at end of file diff --git a/couchpotato/core/providers/automation/goodfilms/main.py b/couchpotato/core/providers/automation/goodfilms/main.py new file mode 100644 index 00000000..dd4b1aef --- /dev/null +++ b/couchpotato/core/providers/automation/goodfilms/main.py @@ -0,0 +1,36 @@ +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.automation.base import Automation +from bs4 import BeautifulSoup + +log = CPLog(__name__) + + +class Goodfilms(Automation): + + url = 'http://goodfil.ms/%s/queue' + + def getIMDBids(self): + + if not self.conf('automation_username'): + log.error('Please fill in your username') + return [] + + movies = [] + + for movie in self.getWatchlist(): + imdb_id = self.search(movie.get('title'), movie.get('year'), imdb_only = True) + movies.append(imdb_id) + + return movies + + def getWatchlist(self): + + url = self.url % self.conf('automation_username') + soup = BeautifulSoup(self.getHTMLData(url)) + + movies = [] + + for movie in soup.find_all('div', attrs = { 'class': 'movie', 'data-film-title': True }): + movies.append({ 'title': movie['data-film-title'], 'year': movie['data-film-year'] }) + + return movies From 0a11dc66738529b3b43c12a2f3f594c38162c579 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 23:12:40 +0100 Subject: [PATCH 5/6] Set file permissions on .nzb or torrent file. closes #1362 Thanks clinton --- couchpotato/core/downloaders/blackhole/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/couchpotato/core/downloaders/blackhole/main.py b/couchpotato/core/downloaders/blackhole/main.py index becfb6b5..aad9ea7f 100644 --- a/couchpotato/core/downloaders/blackhole/main.py +++ b/couchpotato/core/downloaders/blackhole/main.py @@ -1,6 +1,7 @@ from __future__ import with_statement from couchpotato.core.downloaders.base import Downloader from couchpotato.core.logger import CPLog +from couchpotato.environment import Env import os import traceback @@ -36,6 +37,7 @@ class Blackhole(Downloader): log.info('Downloading %s to %s.', (data.get('type'), fullPath)) with open(fullPath, 'wb') as f: f.write(filedata) + os.chmod(fullPath, Env.getPermission('file')) return True else: log.info('File %s already exists.', fullPath) From 4e45c94fc389fdca007091a7a215c1a283f85138 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 23:23:18 +0100 Subject: [PATCH 6/6] Renamer NTFS permission fix #778 --- couchpotato/core/plugins/renamer/__init__.py | 10 ++++++++++ couchpotato/core/plugins/renamer/main.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/couchpotato/core/plugins/renamer/__init__.py b/couchpotato/core/plugins/renamer/__init__.py index 88989695..6ce21922 100644 --- a/couchpotato/core/plugins/renamer/__init__.py +++ b/couchpotato/core/plugins/renamer/__init__.py @@ -1,4 +1,5 @@ from couchpotato.core.plugins.renamer.main import Renamer +import os def start(): return Renamer() @@ -111,6 +112,15 @@ config = [{ 'label': 'Separator', 'description': 'Replace all the spaces with a character. Example: ".", "-" (without quotes). Leave empty to use spaces.', }, + { + 'advanced': True, + 'name': 'ntfs_permission', + 'label': 'NTFS Permission', + 'type': 'bool', + 'hidden': os.name != 'nt', + 'description': 'Set permission of moved files to that of destination folder (Windows NTFS only).', + 'default': False, + }, ], }, { 'tab': 'renamer', diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 62358dde..be6e4eaa 100644 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -455,6 +455,8 @@ class Renamer(Plugin): try: os.chmod(dest, Env.getPermission('file')) + if os.name == 'nt' and self.conf('ntfs_permission'): + os.popen('icacls "' + dest + '"* /reset /T') except: log.error('Failed setting permissions for file: %s, %s', (dest, traceback.format_exc(1)))