Cleanup after database use
This commit is contained in:
@@ -65,6 +65,7 @@ class CoreNotifier(Notification):
|
|||||||
q.update({Notif.read: True})
|
q.update({Notif.read: True})
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
db.close()
|
||||||
|
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
@@ -90,6 +91,7 @@ class CoreNotifier(Notification):
|
|||||||
ndict['type'] = 'notification'
|
ndict['type'] = 'notification'
|
||||||
notifications.append(ndict)
|
notifications.append(ndict)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
'empty': len(notifications) == 0,
|
'empty': len(notifications) == 0,
|
||||||
@@ -114,7 +116,8 @@ class CoreNotifier(Notification):
|
|||||||
ndict['time'] = time.time()
|
ndict['time'] = time.time()
|
||||||
self.messages.append(ndict)
|
self.messages.append(ndict)
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
|
return True
|
||||||
|
|
||||||
def frontend(self, type = 'notification', data = {}):
|
def frontend(self, type = 'notification', data = {}):
|
||||||
self.messages.append({
|
self.messages.append({
|
||||||
@@ -143,6 +146,8 @@ class CoreNotifier(Notification):
|
|||||||
ndict['type'] = 'notification'
|
ndict['type'] = 'notification'
|
||||||
messages.append(ndict)
|
messages.append(ndict)
|
||||||
|
|
||||||
|
db.close()
|
||||||
|
|
||||||
self.messages = []
|
self.messages = []
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
|
|||||||
@@ -22,3 +22,6 @@ class History(Notification):
|
|||||||
)
|
)
|
||||||
db.add(history)
|
db.add(history)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class FileManager(Plugin):
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
type_dict = ft.to_dict()
|
type_dict = ft.to_dict()
|
||||||
db.remove()
|
db.close()
|
||||||
return type_dict
|
return type_dict
|
||||||
|
|
||||||
def getTypes(self):
|
def getTypes(self):
|
||||||
@@ -100,4 +100,5 @@ class FileManager(Plugin):
|
|||||||
for type_object in results:
|
for type_object in results:
|
||||||
types.append(type_object.to_dict())
|
types.append(type_object.to_dict())
|
||||||
|
|
||||||
|
db.close()
|
||||||
return types
|
return types
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class LibraryPlugin(Plugin):
|
|||||||
|
|
||||||
library_dict = l.to_dict(self.default_dict)
|
library_dict = l.to_dict(self.default_dict)
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return library_dict
|
return library_dict
|
||||||
|
|
||||||
def update(self, identifier, default_title = '', force = False):
|
def update(self, identifier, default_title = '', force = False):
|
||||||
@@ -130,7 +130,7 @@ class LibraryPlugin(Plugin):
|
|||||||
|
|
||||||
fireEvent('library.update_finish', data = library_dict)
|
fireEvent('library.update_finish', data = library_dict)
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return library_dict
|
return library_dict
|
||||||
|
|
||||||
def updateReleaseDate(self, identifier):
|
def updateReleaseDate(self, identifier):
|
||||||
@@ -144,7 +144,7 @@ class LibraryPlugin(Plugin):
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
dates = library.info.get('release_date', {})
|
dates = library.info.get('release_date', {})
|
||||||
db.remove()
|
db.close()
|
||||||
|
|
||||||
return dates
|
return dates
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from couchpotato.core.helpers.request import getParams, jsonified, getParam
|
|||||||
from couchpotato.core.helpers.variable import getImdb
|
from couchpotato.core.helpers.variable import getImdb
|
||||||
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 Movie, Library, LibraryTitle
|
from couchpotato.core.settings.model import Library, LibraryTitle, Movie
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from sqlalchemy.orm import joinedload_all
|
from sqlalchemy.orm import joinedload_all
|
||||||
from sqlalchemy.sql.expression import or_, asc, not_
|
from sqlalchemy.sql.expression import or_, asc, not_
|
||||||
@@ -109,10 +109,12 @@ class MoviePlugin(Plugin):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
m = db.query(Movie).filter_by(id = movie_id).first()
|
m = db.query(Movie).filter_by(id = movie_id).first()
|
||||||
|
|
||||||
|
results = None
|
||||||
if m:
|
if m:
|
||||||
return m.to_dict(self.default_dict)
|
results = m.to_dict(self.default_dict)
|
||||||
|
|
||||||
return None
|
db.close()
|
||||||
|
return results
|
||||||
|
|
||||||
def list(self, status = ['active'], limit_offset = None, starts_with = None, search = None):
|
def list(self, status = ['active'], limit_offset = None, starts_with = None, search = None):
|
||||||
|
|
||||||
@@ -175,6 +177,7 @@ class MoviePlugin(Plugin):
|
|||||||
})
|
})
|
||||||
movies.append(temp)
|
movies.append(temp)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return movies
|
return movies
|
||||||
|
|
||||||
def availableChars(self, status = ['active']):
|
def availableChars(self, status = ['active']):
|
||||||
@@ -200,6 +203,7 @@ class MoviePlugin(Plugin):
|
|||||||
if char not in chars:
|
if char not in chars:
|
||||||
chars += char
|
chars += char
|
||||||
|
|
||||||
|
db.close()
|
||||||
return chars
|
return chars
|
||||||
|
|
||||||
def listView(self):
|
def listView(self):
|
||||||
@@ -246,6 +250,7 @@ class MoviePlugin(Plugin):
|
|||||||
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True)
|
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True)
|
||||||
fireEventAsync('searcher.single', movie.to_dict(self.default_dict))
|
fireEventAsync('searcher.single', movie.to_dict(self.default_dict))
|
||||||
|
|
||||||
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
})
|
})
|
||||||
@@ -319,6 +324,7 @@ class MoviePlugin(Plugin):
|
|||||||
if (force_readd or do_search) and search_after:
|
if (force_readd or do_search) and search_after:
|
||||||
fireEventAsync('searcher.single', movie_dict)
|
fireEventAsync('searcher.single', movie_dict)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return movie_dict
|
return movie_dict
|
||||||
|
|
||||||
|
|
||||||
@@ -365,6 +371,7 @@ class MoviePlugin(Plugin):
|
|||||||
movie_dict = m.to_dict(self.default_dict)
|
movie_dict = m.to_dict(self.default_dict)
|
||||||
fireEventAsync('searcher.single', movie_dict)
|
fireEventAsync('searcher.single', movie_dict)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
})
|
})
|
||||||
@@ -419,6 +426,7 @@ class MoviePlugin(Plugin):
|
|||||||
else:
|
else:
|
||||||
fireEvent('movie.restatus', movie.id, single = True)
|
fireEvent('movie.restatus', movie.id, single = True)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def restatus(self, movie_id):
|
def restatus(self, movie_id):
|
||||||
@@ -447,5 +455,6 @@ class MoviePlugin(Plugin):
|
|||||||
m.status_id = active_status.get('id') if move_to_wanted else done_status.get('id')
|
m.status_id = active_status.get('id') if move_to_wanted else done_status.get('id')
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
db.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class ProfilePlugin(Plugin):
|
|||||||
for profile in profiles:
|
for profile in profiles:
|
||||||
temp.append(profile.to_dict(self.to_dict))
|
temp.append(profile.to_dict(self.to_dict))
|
||||||
|
|
||||||
|
db.close()
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
@@ -83,6 +84,7 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
profile_dict = p.to_dict(self.to_dict)
|
profile_dict = p.to_dict(self.to_dict)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
'profile': profile_dict
|
'profile': profile_dict
|
||||||
@@ -92,8 +94,10 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
default = db.query(Profile).first()
|
default = db.query(Profile).first()
|
||||||
|
default_dict = default.to_dict(self.to_dict)
|
||||||
|
db.close()
|
||||||
|
|
||||||
return default.to_dict(self.to_dict)
|
return default_dict
|
||||||
|
|
||||||
def saveOrder(self):
|
def saveOrder(self):
|
||||||
|
|
||||||
@@ -109,6 +113,7 @@ class ProfilePlugin(Plugin):
|
|||||||
order += 1
|
order += 1
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
db.close()
|
||||||
|
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
@@ -133,6 +138,8 @@ class ProfilePlugin(Plugin):
|
|||||||
message = 'Failed deleting Profile: %s' % e
|
message = 'Failed deleting Profile: %s' % e
|
||||||
log.error(message)
|
log.error(message)
|
||||||
|
|
||||||
|
db.close()
|
||||||
|
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': success,
|
'success': success,
|
||||||
'message': message
|
'message': message
|
||||||
@@ -180,4 +187,5 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
order += 1
|
order += 1
|
||||||
|
|
||||||
|
db.close()
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class QualityPlugin(Plugin):
|
|||||||
q = mergeDicts(self.getQuality(quality.identifier), quality.to_dict())
|
q = mergeDicts(self.getQuality(quality.identifier), quality.to_dict())
|
||||||
temp.append(q)
|
temp.append(q)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
def single(self, identifier = ''):
|
def single(self, identifier = ''):
|
||||||
@@ -79,6 +80,7 @@ class QualityPlugin(Plugin):
|
|||||||
if quality:
|
if quality:
|
||||||
quality_dict = dict(self.getQuality(quality.identifier), **quality.to_dict())
|
quality_dict = dict(self.getQuality(quality.identifier), **quality.to_dict())
|
||||||
|
|
||||||
|
db.close()
|
||||||
return quality_dict
|
return quality_dict
|
||||||
|
|
||||||
def getQuality(self, identifier):
|
def getQuality(self, identifier):
|
||||||
@@ -98,6 +100,7 @@ class QualityPlugin(Plugin):
|
|||||||
setattr(quality, params.get('value_type'), params.get('value'))
|
setattr(quality, params.get('value_type'), params.get('value'))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
@@ -149,6 +152,7 @@ class QualityPlugin(Plugin):
|
|||||||
order += 1
|
order += 1
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
db.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def guess(self, files, extra = {}):
|
def guess(self, files, extra = {}):
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Release(Plugin):
|
|||||||
|
|
||||||
fireEvent('movie.restatus', movie.id)
|
fireEvent('movie.restatus', movie.id)
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class Release(Plugin):
|
|||||||
rel.delete()
|
rel.delete()
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
@@ -126,7 +126,7 @@ class Release(Plugin):
|
|||||||
rel.status_id = available_status.get('id') if rel.status_id is ignored_status.get('id') else ignored_status.get('id')
|
rel.status_id = available_status.get('id') if rel.status_id is ignored_status.get('id') else ignored_status.get('id')
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
@@ -153,14 +153,14 @@ class Release(Plugin):
|
|||||||
'files': {}
|
'files': {}
|
||||||
}), manual = True)
|
}), manual = True)
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error('Couldn\'t find release with id: %s' % id)
|
log.error('Couldn\'t find release with id: %s' % id)
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': False
|
'success': False
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ class Renamer(Plugin):
|
|||||||
if self.shuttingDown():
|
if self.shuttingDown():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
db.close()
|
||||||
self.renaming_started = False
|
self.renaming_started = False
|
||||||
|
|
||||||
def getRenameExtras(self, extra_type = '', replacements = {}, folder_name = '', file_name = '', destination = '', group = {}, current_file = ''):
|
def getRenameExtras(self, extra_type = '', replacements = {}, folder_name = '', file_name = '', destination = '', group = {}, current_file = ''):
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ from couchpotato.core.settings.model import File
|
|||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
from enzyme.exceptions import NoParserError, ParseError
|
from enzyme.exceptions import NoParserError, ParseError
|
||||||
from guessit import guess_movie_info
|
from guessit import guess_movie_info
|
||||||
from subliminal.videos import scan
|
from subliminal.videos import scan, Video
|
||||||
import enzyme
|
import enzyme
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
@@ -102,12 +101,12 @@ class Scanner(Plugin):
|
|||||||
if group['library']:
|
if group['library']:
|
||||||
fireEvent('release.add', group = group)
|
fireEvent('release.add', group = group)
|
||||||
|
|
||||||
def scanFolderToLibrary(self, folder = None, newer_than = None):
|
def scanFolderToLibrary(self, folder = None, newer_than = None, simple = True):
|
||||||
|
|
||||||
if not os.path.isdir(folder):
|
if not os.path.isdir(folder):
|
||||||
return
|
return
|
||||||
|
|
||||||
groups = self.scan(folder = folder)
|
groups = self.scan(folder = folder, simple = simple)
|
||||||
|
|
||||||
added_identifier = []
|
added_identifier = []
|
||||||
while True and not self.shuttingDown():
|
while True and not self.shuttingDown():
|
||||||
@@ -128,7 +127,7 @@ class Scanner(Plugin):
|
|||||||
return added_identifier
|
return added_identifier
|
||||||
|
|
||||||
|
|
||||||
def scan(self, folder = None, files = []):
|
def scan(self, folder = None, files = [], simple = False):
|
||||||
|
|
||||||
if not folder or not os.path.isdir(folder):
|
if not folder or not os.path.isdir(folder):
|
||||||
log.error('Folder doesn\'t exists: %s' % folder)
|
log.error('Folder doesn\'t exists: %s' % folder)
|
||||||
@@ -292,7 +291,7 @@ class Scanner(Plugin):
|
|||||||
group['meta_data'] = self.getMetaData(group)
|
group['meta_data'] = self.getMetaData(group)
|
||||||
|
|
||||||
# Subtitle meta
|
# Subtitle meta
|
||||||
group['subtitle_language'] = self.getSubtitleLanguage(group)
|
group['subtitle_language'] = self.getSubtitleLanguage(group) if not simple else {}
|
||||||
|
|
||||||
# Get parent dir from movie files
|
# Get parent dir from movie files
|
||||||
for movie_file in group['files']['movie']:
|
for movie_file in group['files']['movie']:
|
||||||
@@ -393,7 +392,9 @@ class Scanner(Plugin):
|
|||||||
scan_result = []
|
scan_result = []
|
||||||
for p in paths:
|
for p in paths:
|
||||||
if not group['is_dvd']:
|
if not group['is_dvd']:
|
||||||
scan_result.extend(scan(p))
|
video = Video.from_path(p)
|
||||||
|
video_result = [(video, video.scan())]
|
||||||
|
scan_result.extend(video_result)
|
||||||
|
|
||||||
for video, detected_subtitles in scan_result:
|
for video, detected_subtitles in scan_result:
|
||||||
for s in detected_subtitles:
|
for s in detected_subtitles:
|
||||||
@@ -454,7 +455,7 @@ class Scanner(Plugin):
|
|||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
db.remove()
|
db.close()
|
||||||
|
|
||||||
# Search based on OpenSubtitleHash
|
# Search based on OpenSubtitleHash
|
||||||
if not imdb_id and not group['is_dvd']:
|
if not imdb_id and not group['is_dvd']:
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class Searcher(Plugin):
|
|||||||
if self.shuttingDown():
|
if self.shuttingDown():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
db.close()
|
||||||
self.in_progress = False
|
self.in_progress = False
|
||||||
|
|
||||||
def single(self, movie):
|
def single(self, movie):
|
||||||
@@ -147,7 +148,7 @@ class Searcher(Plugin):
|
|||||||
if self.shuttingDown():
|
if self.shuttingDown():
|
||||||
break
|
break
|
||||||
|
|
||||||
db.remove()
|
db.close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def download(self, data, movie, manual = False):
|
def download(self, data, movie, manual = False):
|
||||||
@@ -190,6 +191,7 @@ class Searcher(Plugin):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Failed marking movie finished: %s %s' % (e, traceback.format_exc()))
|
log.error('Failed marking movie finished: %s %s' % (e, traceback.format_exc()))
|
||||||
|
|
||||||
|
db.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
log.info('Tried to download, but none of the downloaders are enabled')
|
log.info('Tried to download, but none of the downloaders are enabled')
|
||||||
|
|||||||
@@ -48,7 +48,10 @@ class StatusPlugin(Plugin):
|
|||||||
def getById(self, id):
|
def getById(self, id):
|
||||||
db = get_session()
|
db = get_session()
|
||||||
status = db.query(Status).filter_by(id = id).first()
|
status = db.query(Status).filter_by(id = id).first()
|
||||||
return status.to_dict()
|
status_dict = status.to_dict()
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
return status_dict
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
|
|
||||||
@@ -61,6 +64,7 @@ class StatusPlugin(Plugin):
|
|||||||
s = status.to_dict()
|
s = status.to_dict()
|
||||||
temp.append(s)
|
temp.append(s)
|
||||||
|
|
||||||
|
db.close()
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
def add(self, identifier):
|
def add(self, identifier):
|
||||||
@@ -78,6 +82,7 @@ class StatusPlugin(Plugin):
|
|||||||
|
|
||||||
status_dict = s.to_dict()
|
status_dict = s.to_dict()
|
||||||
|
|
||||||
|
db.close()
|
||||||
return status_dict
|
return status_dict
|
||||||
|
|
||||||
def fill(self):
|
def fill(self):
|
||||||
@@ -97,3 +102,5 @@ class StatusPlugin(Plugin):
|
|||||||
s.label = toUnicode(label)
|
s.label = toUnicode(label)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class Subtitle(Plugin):
|
|||||||
# get subtitles for those files
|
# get subtitles for those files
|
||||||
subliminal.list_subtitles(files, cache_dir = Env.get('cache_dir'), multi = True, languages = self.getLanguages(), services = self.services)
|
subliminal.list_subtitles(files, cache_dir = Env.get('cache_dir'), multi = True, languages = self.getLanguages(), services = self.services)
|
||||||
|
|
||||||
|
db.close()
|
||||||
|
|
||||||
def searchSingle(self, group):
|
def searchSingle(self, group):
|
||||||
|
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ class MovieResultModifier(Plugin):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Add release info from current library
|
# Add release info from current library
|
||||||
|
db = get_session()
|
||||||
try:
|
try:
|
||||||
db = get_session()
|
|
||||||
l = db.query(Library).filter_by(identifier = imdb).first()
|
l = db.query(Library).filter_by(identifier = imdb).first()
|
||||||
if l:
|
if l:
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@ class MovieResultModifier(Plugin):
|
|||||||
except:
|
except:
|
||||||
log.error('Tried getting more info on searched movies: %s' % traceback.format_exc())
|
log.error('Tried getting more info on searched movies: %s' % traceback.format_exc())
|
||||||
|
|
||||||
|
db.close()
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
def checkLibrary(self, result):
|
def checkLibrary(self, result):
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class CouchPotatoApi(MovieProvider):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
active_movies = db.query(Movie).filter(Movie.status.has(identifier = 'active')).all()
|
active_movies = db.query(Movie).filter(Movie.status.has(identifier = 'active')).all()
|
||||||
movies = [x.library.identifier for x in active_movies]
|
movies = [x.library.identifier for x in active_movies]
|
||||||
|
db.close()
|
||||||
|
|
||||||
suggestions = self.suggest(movies, ignore)
|
suggestions = self.suggest(movies, ignore)
|
||||||
|
|
||||||
|
|||||||
@@ -197,11 +197,15 @@ class Settings(object):
|
|||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
prop = None
|
||||||
try:
|
try:
|
||||||
prop = db.query(Properties).filter_by(identifier = identifier).first()
|
propert = db.query(Properties).filter_by(identifier = identifier).first()
|
||||||
return prop.value if prop else None
|
prop = propert.value
|
||||||
except:
|
except:
|
||||||
return None
|
pass
|
||||||
|
|
||||||
|
db.close()
|
||||||
|
return prop
|
||||||
|
|
||||||
def setProperty(self, identifier, value = ''):
|
def setProperty(self, identifier, value = ''):
|
||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
@@ -217,3 +221,4 @@ class Settings(object):
|
|||||||
p.value = toUnicode(value)
|
p.value = toUnicode(value)
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
db.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user