Merge branch 'refs/heads/develop' into nosql
Conflicts: couchpotato/core/media/__init__.py couchpotato/core/notifications/trakt/main.py
This commit is contained in:
commit
6437079be3
25 files changed
+877
-482
No files matched your search
@@ -36,7 +36,7 @@ class NZBVortex(Downloader):
|
||||
|
||||
time.sleep(10)
|
||||
raw_statuses = self.call('nzb')
|
||||
nzb_id = [nzb['id'] for nzb in raw_statuses.get('nzbs', []) if os.path.basename(item['nzbFileName']) == nzb_filename][0]
|
||||
nzb_id = [nzb['id'] for nzb in raw_statuses.get('nzbs', []) if os.path.basename(nzb['nzbFileName']) == nzb_filename][0]
|
||||
return self.downloadReturnId(nzb_id)
|
||||
except:
|
||||
log.error('Something went wrong sending the NZB file: %s', traceback.format_exc())
|
||||
|
||||
@@ -25,6 +25,7 @@ class rTorrent(Downloader):
|
||||
super(rTorrent, self).__init__()
|
||||
|
||||
addEvent('app.load', self.migrate)
|
||||
addEvent('setting.save.rtorrent.*.after', self.settingsChanged)
|
||||
|
||||
def migrate(self):
|
||||
|
||||
@@ -38,12 +39,20 @@ class rTorrent(Downloader):
|
||||
|
||||
self.deleteConf('url')
|
||||
|
||||
def settingsChanged(self):
|
||||
# Reset active connection if settings have changed
|
||||
if self.rt:
|
||||
log.debug('Settings have changed, closing active connection')
|
||||
|
||||
self.rt = None
|
||||
return True
|
||||
|
||||
def connect(self):
|
||||
# Already connected?
|
||||
if self.rt is not None:
|
||||
return self.rt
|
||||
|
||||
url = cleanHost(self.conf('host'), protocol = True, ssl = self.conf('ssl')) + '/' + self.conf('rpc_url').strip('/ ') + '/'
|
||||
url = cleanHost(self.conf('host'), protocol = True, ssl = self.conf('ssl')) + self.conf('rpc_url')
|
||||
|
||||
if self.conf('username') and self.conf('password'):
|
||||
self.rt = RTorrent(
|
||||
@@ -56,7 +65,7 @@ class rTorrent(Downloader):
|
||||
|
||||
return self.rt
|
||||
|
||||
def _update_provider_group(self, name, data):
|
||||
def updateProviderGroup(self, name, data):
|
||||
if data.get('seed_time'):
|
||||
log.info('seeding time ignored, not supported')
|
||||
|
||||
@@ -105,7 +114,7 @@ class rTorrent(Downloader):
|
||||
return False
|
||||
|
||||
group_name = 'cp_' + data.get('provider').lower()
|
||||
if not self._update_provider_group(group_name, data):
|
||||
if not self.updateProviderGroup(group_name, data):
|
||||
return False
|
||||
|
||||
torrent_params = {}
|
||||
|
||||
@@ -136,9 +136,25 @@ def getExt(filename):
|
||||
|
||||
|
||||
def cleanHost(host, protocol = True, ssl = False, username = None, password = None):
|
||||
"""Return a cleaned up host with given url options set
|
||||
|
||||
Changes protocol to https if ssl is set to True and http if ssl is set to false.
|
||||
>>> cleanHost("localhost:80", ssl=True)
|
||||
'https://localhost:80/'
|
||||
>>> cleanHost("localhost:80", ssl=False)
|
||||
'http://localhost:80/'
|
||||
|
||||
Username and password is managed with the username and password variables
|
||||
>>> cleanHost("localhost:80", username="user", password="passwd")
|
||||
'http://user:passwd@localhost:80/'
|
||||
|
||||
Output without scheme (protocol) can be forced with protocol=False
|
||||
>>> cleanHost("localhost:80", protocol=False)
|
||||
'localhost:80'
|
||||
"""
|
||||
|
||||
if not '://' in host and protocol:
|
||||
host = 'https://' if ssl else 'http://' + host
|
||||
host = ('https://' if ssl else 'http://') + host
|
||||
|
||||
if not protocol:
|
||||
host = host.split('://', 1)[-1]
|
||||
|
||||
@@ -11,6 +11,7 @@ class Trakt(Notification):
|
||||
'base': 'http://api.trakt.tv/%s',
|
||||
'library': 'movie/library/%s',
|
||||
'unwatchlist': 'movie/unwatchlist/%s',
|
||||
'test': 'account/test/%s',
|
||||
}
|
||||
|
||||
listen_to = ['movie.downloaded']
|
||||
@@ -18,25 +19,39 @@ class Trakt(Notification):
|
||||
def notify(self, message = '', data = None, listener = None):
|
||||
if not data: data = {}
|
||||
|
||||
post_data = {
|
||||
'username': self.conf('automation_username'),
|
||||
'password' : self.conf('automation_password'),
|
||||
'movies': [{
|
||||
'imdb_id': data['identifier'],
|
||||
'title': getTitle(data),
|
||||
'year': data['info']['year']
|
||||
}] if data else []
|
||||
}
|
||||
if listener == 'test':
|
||||
|
||||
result = self.call((self.urls['library'] % self.conf('automation_api_key')), post_data)
|
||||
if self.conf('remove_watchlist_enabled'):
|
||||
result = result and self.call((self.urls['unwatchlist'] % self.conf('automation_api_key')), post_data)
|
||||
post_data = {
|
||||
'username': self.conf('automation_username'),
|
||||
'password': self.conf('automation_password'),
|
||||
}
|
||||
|
||||
return result
|
||||
result = self.call((self.urls['test'] % self.conf('automation_api_key')), post_data)
|
||||
|
||||
return result
|
||||
|
||||
else:
|
||||
|
||||
post_data = {
|
||||
'username': self.conf('automation_username'),
|
||||
'password': self.conf('automation_password'),
|
||||
'movies': [{
|
||||
'imdb_id': data['identifier'],
|
||||
'title': getTitle(data),
|
||||
'year': data['info']['year']
|
||||
}] if data else []
|
||||
}
|
||||
|
||||
result = self.call((self.urls['library'] % self.conf('automation_api_key')), post_data)
|
||||
if self.conf('remove_watchlist_enabled'):
|
||||
result = result and self.call((self.urls['unwatchlist'] % self.conf('automation_api_key')), post_data)
|
||||
|
||||
return result
|
||||
|
||||
def call(self, method_url, post_data):
|
||||
|
||||
try:
|
||||
|
||||
response = self.getJsonData(self.urls['base'] % method_url, data = post_data, cache_timeout = 1)
|
||||
if response:
|
||||
if response.get('status') == "success":
|
||||
|
||||
@@ -190,7 +190,10 @@ class Plugin(object):
|
||||
log.info('Opening url: %s %s, data: %s', (method, url, [x for x in data.keys()] if isinstance(data, dict) else 'with data'))
|
||||
response = r.request(method, url, verify = False, **kwargs)
|
||||
|
||||
data = response.content
|
||||
if response.status_code == requests.codes.ok:
|
||||
data = response.content
|
||||
else:
|
||||
response.raise_for_status()
|
||||
|
||||
self.http_failed_request[host] = 0
|
||||
except (IOError, MaxRetryError, Timeout):
|
||||
|
||||
@@ -323,7 +323,7 @@ class Renamer(Plugin):
|
||||
cd = 1 if multiple else 0
|
||||
|
||||
for current_file in sorted(list(group['files'][file_type])):
|
||||
current_file = toUnicode(current_file)
|
||||
current_file = sp(current_file)
|
||||
|
||||
# Original filename
|
||||
replacements['original'] = os.path.splitext(os.path.basename(current_file))[0]
|
||||
@@ -610,7 +610,7 @@ class Renamer(Plugin):
|
||||
rename_files = {}
|
||||
|
||||
def test(s):
|
||||
return current_file[:-len(replacements['ext'])] in s
|
||||
return current_file[:-len(replacements['ext'])] in sp(s)
|
||||
|
||||
for extra in set(filter(test, group['files'][extra_type])):
|
||||
replacements['ext'] = getExt(extra)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.helpers.encoding import sp
|
||||
from couchpotato.core.helpers.variable import mergeDicts
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
@@ -47,6 +48,9 @@ class MetaDataBase(Plugin):
|
||||
if content:
|
||||
log.debug('Creating %s file: %s', (file_type, name))
|
||||
if os.path.isfile(content):
|
||||
content = sp(content)
|
||||
name = sp(name)
|
||||
|
||||
shutil.copy2(content, name)
|
||||
shutil.copyfile(content, name)
|
||||
|
||||
@@ -58,7 +62,7 @@ class MetaDataBase(Plugin):
|
||||
group['renamed_files'].append(name)
|
||||
|
||||
try:
|
||||
os.chmod(name, Env.getPermission('file'))
|
||||
os.chmod(sp(name), Env.getPermission('file'))
|
||||
except:
|
||||
log.debug('Failed setting permissions for %s: %s', (name, traceback.format_exc()))
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ log = CPLog(__name__)
|
||||
class NZBClub(NZBProvider, RSS):
|
||||
|
||||
urls = {
|
||||
'search': 'http://www.nzbclub.com/nzbfeed.aspx?%s',
|
||||
'search': 'http://www.nzbclub.com/nzbfeeds.aspx?%s',
|
||||
}
|
||||
|
||||
http_time_between_calls = 4 #seconds
|
||||
|
||||
@@ -20,12 +20,12 @@ class TorrentBytes(TorrentProvider):
|
||||
}
|
||||
|
||||
cat_ids = [
|
||||
([5], ['720p', '1080p']),
|
||||
([5], ['720p', '1080p', 'bd50']),
|
||||
([19], ['cam']),
|
||||
([19], ['ts', 'tc']),
|
||||
([19], ['r5', 'scr']),
|
||||
([19], ['dvdrip']),
|
||||
([5], ['brrip']),
|
||||
([19], ['brrip']),
|
||||
([20], ['dvdr']),
|
||||
]
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ class Settings(object):
|
||||
|
||||
# After save (for re-interval etc)
|
||||
fireEvent('setting.save.%s.%s.after' % (section, option), single = True)
|
||||
fireEvent('setting.save.%s.*.after' % section, single = True)
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
|
||||
Reference in new issue
Block a user