Library info as json
This commit is contained in:
@@ -5,7 +5,6 @@ from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import Library, LibraryTitle, File
|
||||
from string import ascii_letters
|
||||
import json
|
||||
import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
@@ -75,7 +74,7 @@ class LibraryPlugin(Plugin):
|
||||
library.tagline = toUnicode(info.get('tagline', ''))
|
||||
library.year = info.get('year', 0)
|
||||
library.status_id = done_status.get('id')
|
||||
library.info = toUnicode(json.dumps(info))
|
||||
library.info = info
|
||||
db.commit()
|
||||
|
||||
# Titles
|
||||
|
||||
@@ -2,7 +2,6 @@ from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.helpers.variable import mergeDicts
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import traceback
|
||||
@@ -31,11 +30,7 @@ class MetaDataBase(Plugin):
|
||||
|
||||
root = self.getRootName(release)
|
||||
|
||||
try:
|
||||
movie_info = json.loads(release['library'].get('info'))
|
||||
except:
|
||||
log.error('Failed to parse movie info: %s' % traceback.format_exc())
|
||||
movie_info = {}
|
||||
movie_info = release['library'].get('info')
|
||||
|
||||
for file_type in ['nfo', 'thumbnail', 'fanart']:
|
||||
try:
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from elixir.entity import Entity
|
||||
from elixir.fields import Field
|
||||
from elixir.options import options_defaults, using_options
|
||||
from elixir.relationships import ManyToMany, OneToMany, ManyToOne
|
||||
from libs.elixir.relationships import OneToOne
|
||||
from sqlalchemy.types import Integer, Unicode, UnicodeText, Boolean, Float, \
|
||||
String
|
||||
String, TypeDecorator
|
||||
import json
|
||||
|
||||
options_defaults["shortnames"] = True
|
||||
|
||||
@@ -16,6 +18,16 @@ options_defaults["shortnames"] = True
|
||||
__session__ = None
|
||||
|
||||
|
||||
class JsonType(TypeDecorator):
|
||||
impl = UnicodeText
|
||||
|
||||
def process_bind_param(self, value, dialect):
|
||||
return toUnicode(json.dumps(value))
|
||||
|
||||
def process_result_value(self, value, dialect):
|
||||
return json.loads(value)
|
||||
|
||||
|
||||
class Movie(Entity):
|
||||
"""Movie Resource a movie could have multiple releases
|
||||
The files belonging to the movie object are global for the whole movie
|
||||
@@ -35,11 +47,10 @@ class Library(Entity):
|
||||
|
||||
year = Field(Integer)
|
||||
identifier = Field(String(20), index = True)
|
||||
rating = Field(Float)
|
||||
|
||||
plot = Field(UnicodeText)
|
||||
tagline = Field(UnicodeText(255))
|
||||
info = Field(UnicodeText)
|
||||
info = Field(JsonType)
|
||||
|
||||
status = ManyToOne('Status')
|
||||
movies = OneToMany('Movie')
|
||||
|
||||
Reference in New Issue
Block a user