예제 #1
0
def pool_download(magnet):
    movie = db.Movie.query.filter_by(magnet=magnet).first()
    if movie:
        task_id = movie.taskid
        if movie.status is 1:
            return -1

    else:
        task_id = uuid.uuid4()
        movie = db.Movie(name='', magnet=magnet, taskid=task_id, status=0)
        movie.addtime = datetime.datetime.now().date()
        db.db.session.add(movie)
        db.db.session.commit()


    movie_path = default_movie_path
    future = download_pool.submit(download_bt, magnet, movie_path, task_id)

    return task_id, future
예제 #2
0
def update_movie_instance(movie, details, session):
    if not movie:
        movie = db.Movie()
    if details is not None:
        t_tags = t_languages = None
        if 'tags' in details:
            t_tags = details.pop('tags')
        if 'languages' in details:
            t_languages = details.pop('languages')
        #for i in db.tables.movies.columns.keys():
        for i in details:
            if i not in ('created', 'updated') and hasattr(movie, i):
                setattr(movie, i, details[i])

        # clear previous data (in case of updates)
        if movie.languages:
            movie.languages = []
        if movie.tags:
            movie.tags = []
        # languages
        if t_languages is not None:
            for lang in t_languages:
                if lang[0] > 0:
                    ml = db.MovieLang(lang_id=lang[0],
                                      type=lang[1],
                                      acodec_id=lang[2],
                                      achannel_id=lang[3],
                                      subformat_id=lang[4])
                    movie.languages.append(ml)
        # tags
        if t_tags is not None:
            for tag in t_tags.keys():
                dbTag = session.query(db.Tag).filter_by(tag_id=tag).one()
                #movie.tags.append(db.MovieTag(tag_id=tag))
                movie.tags.append(dbTag)
        if hasattr(
                movie, 'image'
        ) and movie.image:  # TODO: remove it once image will be removed from movies_table
            movie.image = None  # remove MD5 or link
    return movie
예제 #3
0
def clone_movie(self):
    session = self.db.Session()

    if self.selected_iter[0] is None:
        log.warn("cannot clone movie: no item selected")
        return False
    movie = session.query(db.Movie).filter_by(number=self.selected[0]).first()

    if movie is None:
        log.warn("cannot clone movie: Movie(%s) not found", number)
        return False

    next_number = gutils.find_next_available(self.db)

    # integer problem workaround
    if int(movie.seen) == 1:
        seen = True
    else:
        seen = False
    new_movie = db.Movie()

    # TODO: WARNING: loan problems (don't copy volume/collection data until resolved)
    new_movie.cast = movie.cast
    new_movie.classification = movie.classification
    new_movie.vcodec_id = movie.vcodec_id
    new_movie.barcode = movie.barcode
    new_movie.cameraman = movie.cameraman
    new_movie.collection_id = movie.collection_id
    new_movie.volume_id = movie.volume_id
    new_movie.color = movie.color
    new_movie.cond = movie.cond
    new_movie.country = movie.country
    new_movie.director = movie.director
    new_movie.genre = movie.genre
    new_movie.site = movie.site
    new_movie.loaned = movie.loaned
    new_movie.layers = movie.layers
    new_movie.medium_id = movie.medium_id
    new_movie.number = next_number
    new_movie.media_num = movie.media_num
    new_movie.notes = movie.notes
    new_movie.o_title = movie.o_title
    new_movie.plot = movie.plot
    new_movie.poster_md5 = movie.poster_md5
    new_movie.ratio_id = movie.ratio_id
    new_movie.rating = movie.rating
    new_movie.region = movie.region
    new_movie.runtime = movie.runtime
    new_movie.resolution = movie.resolution
    new_movie.screenplay = movie.screenplay
    new_movie.seen = seen
    new_movie.o_site = movie.o_site
    new_movie.studio = movie.studio
    new_movie.title = movie.title
    new_movie.trailer = movie.trailer
    new_movie.year = movie.year

    new_movie.tags = movie.tags
    new_movie.languages = movie.languages
    new_movie.loans = movie.loans

    # save
    session.add(new_movie)
    if not commit(session):
        return False

    if movie.poster_md5:
        image_path = gutils.get_image_fname(movie.poster_md5, self.db)
        if not image_path or not os.path.isfile(image_path):
            image_path = gutils.get_defaultimage_fname(self)
        handler = self.Image.set_from_file(image_path)

    # change_filter calls populate_treeview which updates the status bar
    quick_filter.change_filter(self)
예제 #4
0
                new_db.session.commit()
            except Exception, e:
                log.error(e)
                continue
            tag_mapper[i[0]] = o.tag_id

    # movies
    movie_mapper = {}
    old_cursor.execute("""
        SELECT id, volume_id, collection_id, original_title, title, director,
            number, image, plot, country, year, runtime, classification,
            genre, studio, site, imdb, actors, trailer, rating, loaned,
            media, num_media, obs, seen, region, condition, color, layers
        FROM movies ORDER BY number;""")
    for i in old_cursor.fetchall():
        o = db.Movie()
        o.number = digits_only(i[6])
        if i[1] in volume_mapper:
            o.volume_id = volume_mapper[i[1]]
        if i[2] in collection_mapper:
            o.collection_id = collection_mapper[i[2]]
        o.o_title = i[3][:255]
        o.title = i[4][:255]
        o.director = i[5][:255]
        o.image = i[7][:128]
        o.plot = i[8]
        o.country = i[9][:128]
        o.year = digits_only(i[10])
        o.runtime = digits_only(i[11])
        o.classification = i[12][:128]
        o.genre = i[13][:128]