# Path: vodmanagement/models.py
# class UserPermission(models.Model):
# class VodManager(models.Manager):
# class FileDirectory(models.Model):
#     class Meta:
# class VideoRegion(models.Model):
#     class Meta:
# class VideoCategory(models.Model):
#     class Meta:
# class MultipleUpload(models.Model):
#     class Meta:
# class Restore(models.Model):
#     class Meta:
# class Vod(models.Model):
#     class Meta:
#     def __str__(self):
#     def has_permision(self):
#     def active(self, *args, **kwargs):
# def upload_location(instance, filename):
# def upload_image_location(instance, filename):
# def upload_record_image_location(instance, filename):
# def default_description(instance):
# def default_filedir():
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def __str__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def colored_level(self):
#     def save(self, force_insert=False, force_update=False, using=None,
#              update_fields=None):
#     def save(self, without_valid=False, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def image_tag(self):
#     def get_absolute_url(self):
#     def add_view_count(self):
#     def colored_active(self):
#     def video_format(self):
# def pre_save_post_receiver(sender, instance, *args, **kwargs):
# def post_init_receiver(sender, instance, *args, **kwargs):
# TYPES = (
#     ('common', 'Common'),
#     ('special', 'Special purpose'),
# )
# VIDEO_QUALITY = [
#     ('SD', '标清'),
#     ('HD', '高清'),
#     ('FHD', '超清'),
# ]
# SAVE_PATH = (
#     ('', settings.LOCAL_MEDIA_ROOT),
# )


import logging
import os
import re
import zipfile
from pathlib import Path
from django.core.files.base import File
from django.conf import settings
from vodmanagement import models
from datetime import datetime
        for file in file_zip.namelist():
            file_zip.extract(file, self.storage.location)
        file_zip.close()
        logging.debug('解压文件完成',self.storage.location)
        os.remove(file_zip.filename)

    def save_model(self, model, save_path, request):
        category_id = request.POST['category']
        if category_id is '':
            category_id = models.VideoCategory.objects.first().id
        logging.debug("multiple category is ", category_id)
        (short_name, extension) = os.path.splitext(os.path.basename(self.base_filename))
        file_url = Path(self.storage.base_url).relative_to(settings.MEDIA_URL) / self.base_filename
        obj = model.objects.filter(title=short_name)
        if extension.lower() in self.video_allow:
            if obj:
                obj.update(video=file_url)
                logging.debug("obj exists , update video")
            else:
                obj = model(title=short_name, save_path=save_path, category=models.VideoCategory.objects.get(id=category_id))
                obj.video.name = file_url
                obj.save()
                logging.debug("model video name=", obj.video.name)
                logging.debug("video save model done:", self.filename)

        if extension.lower() in self.image_allow:
            if obj:
                obj.update(image=file_url)
                logging.debug("obj exists , update image")
            else:

# Path: vodmanagement/models.py
# class UserPermission(models.Model):
# class VodManager(models.Manager):
# class FileDirectory(models.Model):
#     class Meta:
# class VideoRegion(models.Model):
#     class Meta:
# class VideoCategory(models.Model):
#     class Meta:
# class MultipleUpload(models.Model):
#     class Meta:
# class Restore(models.Model):
#     class Meta:
# class Vod(models.Model):
#     class Meta:
#     def __str__(self):
#     def has_permision(self):
#     def active(self, *args, **kwargs):
# def upload_location(instance, filename):
# def upload_image_location(instance, filename):
# def upload_record_image_location(instance, filename):
# def default_description(instance):
# def default_filedir():
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def __str__(self):
#     def __str__(self):
#     def save(self, *args, **kwargs):
#     def colored_level(self):
#     def save(self, force_insert=False, force_update=False, using=None,
#              update_fields=None):
#     def save(self, without_valid=False, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
#     def image_tag(self):
#     def get_absolute_url(self):
#     def add_view_count(self):
#     def colored_active(self):
#     def video_format(self):
# def pre_save_post_receiver(sender, instance, *args, **kwargs):
# def post_init_receiver(sender, instance, *args, **kwargs):
# TYPES = (
#     ('common', 'Common'),
#     ('special', 'Special purpose'),
# )
# VIDEO_QUALITY = [
#     ('SD', '标清'),
#     ('HD', '高清'),
#     ('FHD', '超清'),
# ]
# SAVE_PATH = (
#     ('', settings.LOCAL_MEDIA_ROOT),
# )


# Path: admin_resumable/files.py
import logging
import os
import re
import zipfile
from pathlib import Path
from django.core.files.base import File
from django.conf import settings
from vodmanagement import models
from datetime import datetime

        for file in file_zip.namelist():
            file_zip.extract(file, self.storage.location)
        file_zip.close()
        logging.debug('解压文件完成',self.storage.location)
        os.remove(file_zip.filename)

    def save_model(self, model, save_path, request):
        category_id = request.POST['category']
        if category_id is '':
            category_id = models.VideoCategory.objects.first().id
        logging.debug("multiple category is ", category_id)
        (short_name, extension) = os.path.splitext(os.path.basename(self.base_filename))
        file_url = Path(self.storage.base_url).relative_to(settings.MEDIA_URL) / self.base_filename
        obj = model.objects.filter(title=short_name)
        if extension.lower() in self.video_allow:
            if obj:
                obj.update(video=file_url)
                logging.debug("obj exists , update video")
            else:
                obj = model(title=short_name, save_path=save_path, category=models.VideoCategory.objects.get(id=category_id))
                obj.video.name = file_url
                obj.save()
                logging.debug("model video name=", obj.video.name)
                logging.debug("video save model done:", self.filename)

        if extension.lower() in self.image_allow:
            if obj:
                obj.update(image=file_url)
                logging.debug("obj exists , update image")
            else:

                obj = model(title=short_name, save_path=save_path, category=models.VideoCategory.objects.get(id=category_id))