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