|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import hashlib
|
|
|
|
|
import subprocess
|
|
|
|
|
from tempfile import gettempdir
|
|
|
|
|
from flask_babel import gettext as _
|
|
|
|
|
|
|
|
|
@ -84,6 +85,9 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
|
|
|
|
|
original_file_name,
|
|
|
|
|
original_file_extension,
|
|
|
|
|
rarExecutable)
|
|
|
|
|
elif ".WEBM" == extension_upper or ".MP4" == extension_upper:
|
|
|
|
|
meta = video_metadata(tmp_file_path, original_file_name, original_file_extension)
|
|
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
log.warning('cannot parse metadata, using default: %s', ex)
|
|
|
|
|
|
|
|
|
@ -238,7 +242,36 @@ def pdf_preview(tmp_file_path, tmp_dir):
|
|
|
|
|
log.warning('On Windows this error could be caused by missing ghostscript')
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def video_metadata(tmp_file_path, original_file_name, original_file_extension):
|
|
|
|
|
video_cover(tmp_file_path)
|
|
|
|
|
meta = BookMeta(
|
|
|
|
|
file_path=tmp_file_path,
|
|
|
|
|
extension=original_file_extension,
|
|
|
|
|
title=original_file_name,
|
|
|
|
|
author='Unknown',
|
|
|
|
|
cover=os.path.splitext(tmp_file_path)[0] + '.cover.jpg',
|
|
|
|
|
description='',
|
|
|
|
|
tags='',
|
|
|
|
|
series="",
|
|
|
|
|
series_id="",
|
|
|
|
|
languages="",
|
|
|
|
|
publisher="",
|
|
|
|
|
pubdate="",
|
|
|
|
|
identifiers=[])
|
|
|
|
|
return meta
|
|
|
|
|
|
|
|
|
|
def video_cover(tmp_file_path):
|
|
|
|
|
""" generate cover image from video using ffmpeg """
|
|
|
|
|
ffmpeg_executable = os.getenv('FFMPEG_PATH', 'ffmpeg')
|
|
|
|
|
try:
|
|
|
|
|
subprocess.call([ffmpeg_executable, '-i', tmp_file_path, '-vframes', '1', '-y', os.path.splitext(tmp_file_path)[0] + '.cover.jpg'])
|
|
|
|
|
tmp_file_path = os.path.splitext(tmp_file_path)[0] + '.cover.jpg'
|
|
|
|
|
return tmp_file_path
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
log.warning('Cannot extract cover image, using default: %s', ex)
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_magick_version():
|
|
|
|
|
ret = dict()
|
|
|
|
|
if not use_generic_pdf_cover:
|
|
|
|
|