Browse Source

Library info as json

pull/84/head
Ruud 13 years ago
parent
commit
63225f7e5c
  1. 3
      couchpotato/core/plugins/library/main.py
  2. 7
      couchpotato/core/providers/metadata/base.py
  3. 17
      couchpotato/core/settings/model.py

3
couchpotato/core/plugins/library/main.py

@ -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

7
couchpotato/core/providers/metadata/base.py

@ -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:

17
couchpotato/core/settings/model.py

@ -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')

Loading…
Cancel
Save