# Path: seedbox/common/timeutil.py
# def utcnow():
# def is_older_than(before, seconds):
# def is_newer_than(after, seconds):
# def delta_seconds(before, after):
# def total_seconds(delta):
# ONE_WEEK = total_seconds(datetime.timedelta(weeks=1))
# 
# Path: seedbox/constants.py
# INIT = 'init'
# READY = 'ready'
# ACTIVE = 'active'
# DONE = 'done'
# CANCELLED = 'cancelled'
# STATES = [INIT, READY, ACTIVE, DONE, CANCELLED]
# ACTIVE_STATES = [INIT, READY, ACTIVE]
# INACTIVE_STATES = [DONE, CANCELLED]
# 
# Path: seedbox/db/models.py
# class Model(object):
# class Torrent(Model):
# class MediaFile(Model):
# class AppState(Model):
#     PK_NAME = 'id'
#     PK_NAME = 'torrent_id'
#     PK_NAME = 'media_id'
#     PK_NAME = 'name'
#     def __init__(self, **kwds):
#     def as_dict(self):
#     def items(self):
#     def __eq__(self, other):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def __setitem__(self, name, value):
#     def __contains__(self, name):
#     def __str__(self):
#     def pk_filter(cls, value=None):
#     def make_empty(cls):
#     def __init__(self, torrent_id, name, created_at=None, updated_at=None,
#                  state=None, retry_count=None, failed=None, error_msg=None,
#                  invalid=None, purged=None, media_files=None):
#     def __init__(self, media_id, torrent_id, filename, file_ext,
#                  file_path=None, size=None, compressed=None, synced=None,
#                  missing=None, skipped=None, error_msg=None, total_time=None):
#     def __init__(self, name, value):


import logging
import os
from seedbox.common import timeutil
from seedbox import constants
from seedbox.db import models
        """
        return self.impl.save(media)

    def bulk_create_medias(self, medias):
        """Saves metadata for multiple media files.

        Perform save (insert) operation on a list of instances of media.

        :param medias: a list of instances of media file
        :return: media file instance(s)
        :rtype: :class:`~seedbox.db.models.MediaFile`
        """
        return list(self.impl.bulk_create(medias))

    def delete_media(self, media):
        """Deletes metadata for media file.

        Perform delete operation on an instance of media.

        :param media: an instance of media file
        """
        self.impl.delete(media)

    def delete_medias(self, qfilter):
        """Deletes metadata for multiple media files.

        Perform delete operation on a list of instances of media.

        :param qfilter: query filter to determine instances to delete
        """

# Path: seedbox/common/timeutil.py
# def utcnow():
# def is_older_than(before, seconds):
# def is_newer_than(after, seconds):
# def delta_seconds(before, after):
# def total_seconds(delta):
# ONE_WEEK = total_seconds(datetime.timedelta(weeks=1))
# 
# Path: seedbox/constants.py
# INIT = 'init'
# READY = 'ready'
# ACTIVE = 'active'
# DONE = 'done'
# CANCELLED = 'cancelled'
# STATES = [INIT, READY, ACTIVE, DONE, CANCELLED]
# ACTIVE_STATES = [INIT, READY, ACTIVE]
# INACTIVE_STATES = [DONE, CANCELLED]
# 
# Path: seedbox/db/models.py
# class Model(object):
# class Torrent(Model):
# class MediaFile(Model):
# class AppState(Model):
#     PK_NAME = 'id'
#     PK_NAME = 'torrent_id'
#     PK_NAME = 'media_id'
#     PK_NAME = 'name'
#     def __init__(self, **kwds):
#     def as_dict(self):
#     def items(self):
#     def __eq__(self, other):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def __setitem__(self, name, value):
#     def __contains__(self, name):
#     def __str__(self):
#     def pk_filter(cls, value=None):
#     def make_empty(cls):
#     def __init__(self, torrent_id, name, created_at=None, updated_at=None,
#                  state=None, retry_count=None, failed=None, error_msg=None,
#                  invalid=None, purged=None, media_files=None):
#     def __init__(self, media_id, torrent_id, filename, file_ext,
#                  file_path=None, size=None, compressed=None, synced=None,
#                  missing=None, skipped=None, error_msg=None, total_time=None):
#     def __init__(self, name, value):


# Path: seedbox/db/api.py
import logging
import os
from seedbox.common import timeutil
from seedbox import constants
from seedbox.db import models

        """
        return self.impl.save(media)

    def bulk_create_medias(self, medias):
        """Saves metadata for multiple media files.

        Perform save (insert) operation on a list of instances of media.

        :param medias: a list of instances of media file
        :return: media file instance(s)
        :rtype: :class:`~seedbox.db.models.MediaFile`
        """
        return list(self.impl.bulk_create(medias))

    def delete_media(self, media):
        """Deletes metadata for media file.

        Perform delete operation on an instance of media.

        :param media: an instance of media file
        """
        self.impl.delete(media)

    def delete_medias(self, qfilter):
        """Deletes metadata for multiple media files.

        Perform delete operation on a list of instances of media.

        :param qfilter: query filter to determine instances to delete
        """

        self.impl.delete_by(models.MediaFile, qfilter)