diff --git a/couchpotato/core/downloaders/blackhole/main.py b/couchpotato/core/downloaders/blackhole/main.py index becfb6b52752a587e404dd9186d0006b756fce77..aad9ea7fc5d3251a64559ec444b3a7a9d4052d60 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) diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py index 91302780b2058a9f7c8540d129f294a42bba6aa0..a287f119ff00883178cc4d37064e6f0b32188ec8 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'): diff --git a/couchpotato/core/plugins/renamer/__init__.py b/couchpotato/core/plugins/renamer/__init__.py index 889896956707913b8f95e5ad3eb79d9f99c5c4f0..6ce21922d5138ad06ac1a73245fad9a09fe465bf 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 62358dde8bc63ada9383cb25f3983da8f3404585..be6e4eaa2612869d0c62e399128130725bb06fe4 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))) diff --git a/couchpotato/core/providers/automation/goodfilms/__init__.py b/couchpotato/core/providers/automation/goodfilms/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..795e21da499734b0173cdfad25012e5ac64c67bb --- /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 <a href="http://goodfil.ms">Goodfilms</a> 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 0000000000000000000000000000000000000000..dd4b1aef647ee8170c556adfb88f1ffd786a3a95 --- /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 diff --git a/couchpotato/static/scripts/page/manage.js b/couchpotato/static/scripts/page/manage.js index c06c655ba361adadd74d54fddfe2f17891db9673..0e44e7671700dd3ce83462396337e45fa3310cf4 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){ diff --git a/init/fedora b/init/fedora index 791b676d899310dc2e73dde482b3bc78fe5da17b..4735247188e4d1599121264958e1c5e745873bf1 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