예제 #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
    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
    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
    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
    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
    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
    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