コード例 #1
0
    def add(self, attrs={}, update_after=True):

        db = get_session()

        l = db.query(Library).filter_by(
            identifier=attrs.get('identifier')).first()
        if not l:
            status = fireEvent('status.get', 'needs_update', single=True)
            l = Library(year=attrs.get('year'),
                        identifier=attrs.get('identifier'),
                        plot=attrs.get('plot'),
                        tagline=attrs.get('tagline'),
                        status_id=status.get('id'))

            title = LibraryTitle(title=attrs.get('title'))

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after:
            fireEventAsync('library.update',
                           identifier=l.identifier,
                           default_title=attrs.get('title', ''))

        return l.to_dict(self.default_dict)
コード例 #2
0
ファイル: main.py プロジェクト: mvanderberg/CouchPotatoServer
    def add(self, attrs={}, update_after=True):

        db = get_session()

        l = db.query(Library).filter_by(identifier=attrs.get("identifier")).first()
        if not l:
            status = fireEvent("status.get", "needs_update", single=True)
            l = Library(
                year=attrs.get("year"),
                identifier=attrs.get("identifier"),
                plot=toUnicode(attrs.get("plot")),
                tagline=toUnicode(attrs.get("tagline")),
                status_id=status.get("id"),
            )

            title = LibraryTitle(
                title=toUnicode(attrs.get("title")), simple_title=self.simplifyTitle(attrs.get("title"))
            )

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after is not False:
            handle = fireEventAsync if update_after is "async" else fireEvent
            handle("library.update", identifier=l.identifier, default_title=attrs.get("title", ""))

        return l.to_dict(self.default_dict)
コード例 #3
0
    def add(self, attrs={}, update_after=True):

        db = get_session()

        l = db.query(Library).filter_by(
            identifier=attrs.get('identifier')).first()
        if not l:
            status = fireEvent('status.get', 'needs_update', single=True)
            l = Library(year=attrs.get('year'),
                        identifier=attrs.get('identifier'),
                        plot=toUnicode(attrs.get('plot')),
                        tagline=toUnicode(attrs.get('tagline')),
                        status_id=status.get('id'))

            title = LibraryTitle(title=toUnicode(attrs.get('title')),
                                 simple_title=self.simplifyTitle(
                                     attrs.get('title')))

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after is not False:
            handle = fireEventAsync if update_after is 'async' else fireEvent
            handle('library.update',
                   identifier=l.identifier,
                   default_title=toUnicode(attrs.get('title', '')))

        library_dict = l.to_dict(self.default_dict)

        return library_dict
コード例 #4
0
ファイル: main.py プロジェクト: Selissi/CouchPotatoServer
    def add(self, attrs = {}, update_after = True):

        db = get_session()

        l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first()
        if not l:
            status = fireEvent('status.get', 'needs_update', single = True)
            l = Library(
                year = attrs.get('year'),
                identifier = attrs.get('identifier'),
                plot = attrs.get('plot'),
                tagline = attrs.get('tagline'),
                status_id = status.get('id')
            )

            title = LibraryTitle(
                title = attrs.get('title')
            )

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after:
            fireEventAsync('library.update', identifier = l.identifier, default_title = attrs.get('title', ''))

        return l.to_dict(self.default_dict)
コード例 #5
0
ファイル: main.py プロジェクト: xbgmsharp/CouchPotatoServer
    def add(self, attrs = {}, update_after = True):

        db = get_session()

        l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first()
        if not l:
            status = fireEvent('status.get', 'needs_update', single = True)
            l = Library(
                year = attrs.get('year'),
                identifier = attrs.get('identifier'),
                plot = toUnicode(attrs.get('plot')),
                tagline = toUnicode(attrs.get('tagline')),
                status_id = status.get('id')
            )

            title = LibraryTitle(
                title = toUnicode(attrs.get('title')),
                simple_title = self.simplifyTitle(attrs.get('title')),
            )

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after is not False:
            handle = fireEventAsync if update_after is 'async' else fireEvent
            handle('library.update', identifier = l.identifier, default_title = toUnicode(attrs.get('title', '')))

        library_dict = l.to_dict(self.default_dict)

        return library_dict
コード例 #6
0
ファイル: main.py プロジェクト: Xice/CouchPotato
    def add(self, attrs={}):

        db = get_session()

        l = db.query(Library).filter_by(
            identifier=attrs.get('identifier')).first()
        if not l:
            l = Library(year=attrs.get('year'),
                        identifier=attrs.get('identifier'),
                        plot=attrs.get('plot'),
                        tagline=attrs.get('tagline'))

            title = LibraryTitle(title=attrs.get('title'))

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        fireEventAsync('library.update',
                       library=l,
                       default_title=attrs.get('title', ''))

        #db.remove()
        return l
コード例 #7
0
ファイル: main.py プロジェクト: willko23/CouchPotatoServer
    def add(self, attrs=None, update_after=True):
        if not attrs: attrs = {}

        primary_provider = attrs.get('primary_provider', 'imdb')

        try:
            db = get_session()

            l = db.query(Library).filter_by(
                identifier=attrs.get('identifier')).first()
            if not l:
                status = fireEvent('status.get', 'needs_update', single=True)
                l = Library(year=attrs.get('year'),
                            identifier=attrs.get('identifier'),
                            plot=toUnicode(attrs.get('plot')),
                            tagline=toUnicode(attrs.get('tagline')),
                            status_id=status.get('id'),
                            info={})

                title = LibraryTitle(
                    title=toUnicode(attrs.get('title')),
                    simple_title=self.simplifyTitle(attrs.get('title')),
                )

                l.titles.append(title)

                db.add(l)
                db.commit()

            # Update library info
            if update_after is not False:
                handle = fireEventAsync if update_after is 'async' else fireEvent
                handle('library.update.movie',
                       identifier=l.identifier,
                       default_title=toUnicode(attrs.get('title', '')))

            library_dict = l.to_dict(self.default_dict)
            return library_dict
        except:
            log.error('Failed adding media: %s', traceback.format_exc())
            db.rollback()
        finally:
            db.close()

        return {}
コード例 #8
0
ファイル: main.py プロジェクト: Jarosch/CouchPotatoServer
    def add(self, attrs = None, update_after = True):
        if not attrs: attrs = {}

        primary_provider = attrs.get('primary_provider', 'imdb')

        try:
            db = get_session()

            l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first()
            if not l:
                status = fireEvent('status.get', 'needs_update', single = True)
                l = Library(
                    year = attrs.get('year'),
                    identifier = attrs.get('identifier'),
                    plot = toUnicode(attrs.get('plot')),
                    tagline = toUnicode(attrs.get('tagline')),
                    status_id = status.get('id'),
                    info = {}
                )

                title = LibraryTitle(
                    title = toUnicode(attrs.get('title')),
                    simple_title = self.simplifyTitle(attrs.get('title')),
                )

                l.titles.append(title)

                db.add(l)
                db.commit()

            # Update library info
            if update_after is not False:
                handle = fireEventAsync if update_after is 'async' else fireEvent
                handle('library.update.movie', identifier = l.identifier, default_title = toUnicode(attrs.get('title', '')))

            library_dict = l.to_dict(self.default_dict)
            return library_dict
        except:
            log.error('Failed adding media: %s', traceback.format_exc())
            db.rollback()
        finally:
            db.close()

        return {}
コード例 #9
0
    def add(self, attrs={}, update_after=True):
        # movies don't yet contain these, so lets make sure to set defaults
        type = attrs.get('type', 'movie')
        primary_provider = attrs.get('primary_provider', 'imdb')

        db = get_session()

        l = db.query(Library).filter_by(
            type=type, identifier=attrs.get('identifier')).first()
        if not l:
            status = fireEvent('status.get', 'needs_update', single=True)
            l = Library(type=type,
                        primary_provider=primary_provider,
                        year=attrs.get('year'),
                        identifier=attrs.get('identifier'),
                        plot=toUnicode(attrs.get('plot')),
                        tagline=toUnicode(attrs.get('tagline')),
                        status_id=status.get('id'),
                        info={},
                        parent=None)

            title = LibraryTitle(
                title=toUnicode(attrs.get('title')),
                simple_title=self.simplifyTitle(attrs.get('title')),
            )

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after is not False:
            handle = fireEventAsync if update_after is 'async' else fireEvent
            handle('library.update.movie',
                   identifier=l.identifier,
                   default_title=toUnicode(attrs.get('title', '')))

        library_dict = l.to_dict(self.default_dict)

        db.expire_all()
        return library_dict
コード例 #10
0
ファイル: main.py プロジェクト: jadeco/CouchPotatoServer
    def add(self, attrs={}, update_after=True):
        # movies don't yet contain these, so lets make sure to set defaults
        type = attrs.get("type", "movie")
        primary_provider = attrs.get("primary_provider", "imdb")

        db = get_session()

        l = db.query(Library).filter_by(type=type, identifier=attrs.get("identifier")).first()
        if not l:
            status = fireEvent("status.get", "needs_update", single=True)
            l = Library(
                type=type,
                primary_provider=primary_provider,
                year=attrs.get("year"),
                identifier=attrs.get("identifier"),
                plot=toUnicode(attrs.get("plot")),
                tagline=toUnicode(attrs.get("tagline")),
                status_id=status.get("id"),
                info={},
                parent=None,
            )

            title = LibraryTitle(
                title=toUnicode(attrs.get("title")), simple_title=self.simplifyTitle(attrs.get("title"))
            )

            l.titles.append(title)

            db.add(l)
            db.commit()

        # Update library info
        if update_after is not False:
            handle = fireEventAsync if update_after is "async" else fireEvent
            handle("library.update.movie", identifier=l.identifier, default_title=toUnicode(attrs.get("title", "")))

        library_dict = l.to_dict(self.default_dict)

        db.expire_all()
        return library_dict