mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-22 00:03:28 +01:00
improvements on flake8 (#200)
This commit is contained in:
parent
6df942ac4e
commit
110695ae2f
@ -660,13 +660,13 @@ def produce_ffmpeg_commands(media_file, media_info, resolution, codec, output_fi
|
|||||||
|
|
||||||
if codec == "h264":
|
if codec == "h264":
|
||||||
encoder = "libx264"
|
encoder = "libx264"
|
||||||
ext = "mp4"
|
# ext = "mp4"
|
||||||
elif codec in ["h265", "hevc"]:
|
elif codec in ["h265", "hevc"]:
|
||||||
encoder = "libx265"
|
encoder = "libx265"
|
||||||
ext = "mp4"
|
# ext = "mp4"
|
||||||
elif codec == "vp9":
|
elif codec == "vp9":
|
||||||
encoder = "libvpx-vp9"
|
encoder = "libvpx-vp9"
|
||||||
ext = "webm"
|
# ext = "webm"
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ class Media(models.Model):
|
|||||||
"-y",
|
"-y",
|
||||||
tf,
|
tf,
|
||||||
]
|
]
|
||||||
ret = helpers.run_command(command)
|
helpers.run_command(command)
|
||||||
|
|
||||||
if os.path.exists(tf) and helpers.get_file_type(tf) == "image":
|
if os.path.exists(tf) and helpers.get_file_type(tf) == "image":
|
||||||
with open(tf, "rb") as f:
|
with open(tf, "rb") as f:
|
||||||
@ -657,7 +657,6 @@ class Media(models.Model):
|
|||||||
"""Property used on serializers"""
|
"""Property used on serializers"""
|
||||||
|
|
||||||
ret = {}
|
ret = {}
|
||||||
chunks_ret = {}
|
|
||||||
|
|
||||||
if self.media_type not in ["video"]:
|
if self.media_type not in ["video"]:
|
||||||
return ret
|
return ret
|
||||||
|
@ -391,7 +391,7 @@ def produce_sprite_from_video(friendly_token):
|
|||||||
tmpdirname,
|
tmpdirname,
|
||||||
output_name,
|
output_name,
|
||||||
)
|
)
|
||||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
|
subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
|
||||||
if os.path.exists(output_name) and get_file_type(output_name) == "image":
|
if os.path.exists(output_name) and get_file_type(output_name) == "image":
|
||||||
with open(output_name, "rb") as f:
|
with open(output_name, "rb") as f:
|
||||||
myfile = File(f)
|
myfile = File(f)
|
||||||
@ -432,11 +432,11 @@ def create_hls(friendly_token):
|
|||||||
output_dir = os.path.join(settings.HLS_DIR, p + produce_friendly_token())
|
output_dir = os.path.join(settings.HLS_DIR, p + produce_friendly_token())
|
||||||
files = " ".join([f.media_file.path for f in encodings if f.media_file])
|
files = " ".join([f.media_file.path for f in encodings if f.media_file])
|
||||||
cmd = "{0} --segment-duration=4 --output-dir={1} {2}".format(settings.MP4HLS_COMMAND, output_dir, files)
|
cmd = "{0} --segment-duration=4 --output-dir={1} {2}".format(settings.MP4HLS_COMMAND, output_dir, files)
|
||||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
|
subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
|
||||||
if existing_output_dir:
|
if existing_output_dir:
|
||||||
# override content with -T !
|
# override content with -T !
|
||||||
cmd = "cp -rT {0} {1}".format(output_dir, existing_output_dir)
|
cmd = "cp -rT {0} {1}".format(output_dir, existing_output_dir)
|
||||||
ret = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
|
subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
|
||||||
shutil.rmtree(output_dir)
|
shutil.rmtree(output_dir)
|
||||||
output_dir = existing_output_dir
|
output_dir = existing_output_dir
|
||||||
pp = os.path.join(output_dir, "master.m3u8")
|
pp = os.path.join(output_dir, "master.m3u8")
|
||||||
@ -626,7 +626,7 @@ def save_user_action(user_or_session, friendly_token=None, action="watch", extra
|
|||||||
rating_category_id=rating_category,
|
rating_category_id=rating_category,
|
||||||
score=score,
|
score=score,
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
# TODO: more specific handling, for errors in score, or
|
# TODO: more specific handling, for errors in score, or
|
||||||
# rating_category?
|
# rating_category?
|
||||||
return False
|
return False
|
||||||
|
@ -210,8 +210,6 @@ def embed_media(request):
|
|||||||
if not media:
|
if not media:
|
||||||
return HttpResponseRedirect("/")
|
return HttpResponseRedirect("/")
|
||||||
|
|
||||||
user_or_session = get_user_or_session(request)
|
|
||||||
|
|
||||||
context = {}
|
context = {}
|
||||||
context["media"] = friendly_token
|
context["media"] = friendly_token
|
||||||
return render(request, "cms/embed.html", context)
|
return render(request, "cms/embed.html", context)
|
||||||
|
Loading…
Reference in New Issue
Block a user