Double genres because of trailing spaces
This commit is contained in:
1 parent
f204309ed7
commit
3ffc6e122e
9 files changed
+27
-21
No files matched your search
@@ -135,3 +135,5 @@ def getTitle(library_dict):
|
|||||||
def randomString(size = 8, chars = string.ascii_uppercase + string.digits):
|
def randomString(size = 8, chars = string.ascii_uppercase + string.digits):
|
||||||
return ''.join(random.choice(chars) for x in range(size))
|
return ''.join(random.choice(chars) for x in range(size))
|
||||||
|
|
||||||
|
def splitString(str, split_on = ','):
|
||||||
|
return [x.strip() for x in str.split(split_on)]
|
||||||
@@ -3,7 +3,7 @@ from couchpotato.api import addApiView, addNonBlockApiView
|
|||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
from couchpotato.core.helpers.request import jsonified, getParam
|
from couchpotato.core.helpers.request import jsonified, getParam
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.notifications.base import Notification
|
from couchpotato.core.notifications.base import Notification
|
||||||
from couchpotato.core.settings.model import Notification as Notif
|
from couchpotato.core.settings.model import Notification as Notif
|
||||||
@@ -67,7 +67,7 @@ class CoreNotifier(Notification):
|
|||||||
|
|
||||||
ids = None
|
ids = None
|
||||||
if getParam('ids'):
|
if getParam('ids'):
|
||||||
ids = [x.strip() for x in getParam('ids').split(',')]
|
ids = splitString(getParam('ids'))
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class CoreNotifier(Notification):
|
|||||||
q = db.query(Notif)
|
q = db.query(Notif)
|
||||||
|
|
||||||
if limit_offset:
|
if limit_offset:
|
||||||
splt = [x.strip() for x in limit_offset.split(',')]
|
splt = splitString(limit_offset)
|
||||||
limit = splt[0]
|
limit = splt[0]
|
||||||
offset = 0 if len(splt) is 1 else splt[1]
|
offset = 0 if len(splt) is 1 else splt[1]
|
||||||
q = q.limit(limit).offset(offset)
|
q = q.limit(limit).offset(offset)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.notifications.base import Notification
|
from couchpotato.core.notifications.base import Notification
|
||||||
import pynma
|
import pynma
|
||||||
@@ -11,7 +12,7 @@ class NotifyMyAndroid(Notification):
|
|||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
nma = pynma.PyNMA()
|
nma = pynma.PyNMA()
|
||||||
keys = [x.strip() for x in self.conf('api_key').split(',')]
|
keys = splitString(self.conf('api_key'))
|
||||||
nma.addkey(keys)
|
nma.addkey(keys)
|
||||||
nma.developerkey(self.conf('dev_key'))
|
nma.developerkey(self.conf('dev_key'))
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.notifications.base import Notification
|
from couchpotato.core.notifications.base import Notification
|
||||||
from pynmwp import PyNMWP
|
from pynmwp import PyNMWP
|
||||||
@@ -10,7 +11,7 @@ class NotifyMyWP(Notification):
|
|||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
keys = [x.strip() for x in self.conf('api_key').split(',')]
|
keys = splitString(self.conf('api_key'))
|
||||||
p = PyNMWP(keys, self.conf('dev_key'))
|
p = PyNMWP(keys, self.conf('dev_key'))
|
||||||
|
|
||||||
response = p.push(application = self.default_title, event = message, description = message, priority = self.conf('priority'), batch_mode = len(keys) > 1)
|
response = p.push(application = self.default_title, event = message, description = message, priority = self.conf('priority'), batch_mode = len(keys) > 1)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.notifications.base import Notification
|
from couchpotato.core.notifications.base import Notification
|
||||||
import base64
|
import base64
|
||||||
@@ -13,7 +14,7 @@ class XBMC(Notification):
|
|||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
hosts = [x.strip() for x in self.conf('host').split(",")]
|
hosts = splitString(self.conf('host'))
|
||||||
successful = 0
|
successful = 0
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
if self.send({'command': 'ExecBuiltIn', 'parameter': 'Notification(CouchPotato, %s)' % message}, host):
|
if self.send({'command': 'ExecBuiltIn', 'parameter': 'Notification(CouchPotato, %s)' % message}, host):
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.api import addApiView
|
|||||||
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||||
from couchpotato.core.helpers.request import getParams, jsonified, getParam
|
from couchpotato.core.helpers.request import getParams, jsonified, getParam
|
||||||
from couchpotato.core.helpers.variable import getImdb
|
from couchpotato.core.helpers.variable import getImdb, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Library, LibraryTitle, Movie
|
from couchpotato.core.settings.model import Library, LibraryTitle, Movie
|
||||||
@@ -166,7 +166,7 @@ class MoviePlugin(Plugin):
|
|||||||
.options(joinedload_all('files'))
|
.options(joinedload_all('files'))
|
||||||
|
|
||||||
if limit_offset:
|
if limit_offset:
|
||||||
splt = [x.strip() for x in limit_offset.split(',')]
|
splt = splitString(limit_offset)
|
||||||
limit = splt[0]
|
limit = splt[0]
|
||||||
offset = 0 if len(splt) is 1 else splt[1]
|
offset = 0 if len(splt) is 1 else splt[1]
|
||||||
q2 = q2.limit(limit).offset(offset)
|
q2 = q2.limit(limit).offset(offset)
|
||||||
@@ -244,7 +244,7 @@ class MoviePlugin(Plugin):
|
|||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
for id in getParam('id').split(','):
|
for id in splitString(getParam('id')):
|
||||||
movie = db.query(Movie).filter_by(id = id).first()
|
movie = db.query(Movie).filter_by(id = id).first()
|
||||||
|
|
||||||
if movie:
|
if movie:
|
||||||
@@ -386,7 +386,7 @@ class MoviePlugin(Plugin):
|
|||||||
|
|
||||||
available_status = fireEvent('status.get', 'available', single = True)
|
available_status = fireEvent('status.get', 'available', single = True)
|
||||||
|
|
||||||
ids = [x.strip() for x in params.get('id').split(',')]
|
ids = splitString(params.get('id'))
|
||||||
for movie_id in ids:
|
for movie_id in ids:
|
||||||
|
|
||||||
m = db.query(Movie).filter_by(id = movie_id).first()
|
m = db.query(Movie).filter_by(id = movie_id).first()
|
||||||
@@ -422,7 +422,7 @@ class MoviePlugin(Plugin):
|
|||||||
|
|
||||||
params = getParams()
|
params = getParams()
|
||||||
|
|
||||||
ids = [x.strip() for x in params.get('id').split(',')]
|
ids = splitString(params.get('id'))
|
||||||
for movie_id in ids:
|
for movie_id in ids:
|
||||||
self.delete(movie_id, delete_from = params.get('delete_from', 'all'))
|
self.delete(movie_id, delete_from = params.get('delete_from', 'all'))
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
from couchpotato.core.helpers.variable import splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Library, FileType
|
from couchpotato.core.settings.model import Library, FileType
|
||||||
@@ -67,4 +68,4 @@ class Subtitle(Plugin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def getLanguages(self):
|
def getLanguages(self):
|
||||||
return [x.strip() for x in self.conf('languages').split(',')]
|
return splitString(self.conf('languages'))
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import tryInt, tryFloat
|
from couchpotato.core.helpers.variable import tryInt, tryFloat, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.movie.base import MovieProvider
|
from couchpotato.core.providers.movie.base import MovieProvider
|
||||||
import json
|
import json
|
||||||
@@ -97,10 +97,10 @@ class IMDBAPI(MovieProvider):
|
|||||||
'released': movie.get('Released', ''),
|
'released': movie.get('Released', ''),
|
||||||
'year': year if isinstance(year, (int)) else None,
|
'year': year if isinstance(year, (int)) else None,
|
||||||
'plot': movie.get('Plot', ''),
|
'plot': movie.get('Plot', ''),
|
||||||
'genres': movie.get('Genre', '').split(','),
|
'genres': splitString(movie.get('Genre', '')),
|
||||||
'directors': movie.get('Director', '').split(','),
|
'directors': splitString(movie.get('Director', '')),
|
||||||
'writers': movie.get('Writer', '').split(','),
|
'writers': splitString(movie.get('Writer', '')),
|
||||||
'actors': movie.get('Actors', '').split(','),
|
'actors': splitString(movie.get('Actors', '')),
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
log.error('Failed parsing IMDB API json: %s', traceback.format_exc())
|
log.error('Failed parsing IMDB API json: %s', traceback.format_exc())
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import cleanHost
|
from couchpotato.core.helpers.variable import cleanHost, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
@@ -161,9 +161,9 @@ class Newznab(NZBProvider, RSS):
|
|||||||
|
|
||||||
def getHosts(self):
|
def getHosts(self):
|
||||||
|
|
||||||
uses = [x.strip() for x in str(self.conf('use')).split(',')]
|
uses = splitString(str(self.conf('use')))
|
||||||
hosts = [x.strip() for x in self.conf('host').split(',')]
|
hosts = splitString(self.conf('host'))
|
||||||
api_keys = [x.strip() for x in self.conf('api_key').split(',')]
|
api_keys = splitString(self.conf('api_key'))
|
||||||
|
|
||||||
list = []
|
list = []
|
||||||
for nr in range(len(hosts)):
|
for nr in range(len(hosts)):
|
||||||
|
|||||||
Reference in new issue
Block a user