Skip to content

Commit

Permalink
better in-app video preview
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaaoBlues committed Jun 26, 2022
1 parent 21bceb3 commit 9dc2418
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 4 deletions.
12 changes: 9 additions & 3 deletions copypasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,16 @@ def process(process_id):


if process_id == "[OPEN VIDEO]":

ret = f"<head><title>CopyPasta/Video</title><head><body>"+f"<link rel=\"icon\" href=\"/static/favicon.ico\" type=\"image/x-icon\"/>"+f"<video controls> <source src=\"/{request.args.get('file_path')}\"></video></body>"
file_path = request.args.get('file_path')

return ret

# try to secure the file path
# if suspicious path, just go home
if (not path.exists(file_path)) or (not file_path.startswith("static/files_hist/")) or (".." in file_path):
return redirect("/")


return render_template("video_preview.html",file_path=file_path)
else:
return abort(403)

Expand Down
2 changes: 1 addition & 1 deletion templates/scan_preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% endif %}
{% endwith %}

<title translate="no">CopyPasta/scan preview</title>
<title translate="no">CopyPasta/Scan preview</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
Expand Down
78 changes: 78 additions & 0 deletions templates/video_preview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="fr">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title translate="no">CopyPasta/Video</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-eoTu3+HydHRBIjnCVwsFyCpUDZHZSFKEJD0mc3ZqSBSb6YhZzRHeiomAUWCstIWo" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</head>

<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">

<div class="container-fluid">
<a class="navbar-brand" href="/" translate="no">CopyPasta</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link active" name="over" href="/process/[HOME]">Main menu</a>
</li>
<li>
<div id="google_translate_element"></div>
</li>
</ul>
</div>
</div>

</nav>


<div class="text-center">
<video controls width="800" height="600"> <source src="/{{file_path}}"></video>
</div>







<style>
.btn-primary, .btn-primary:hover, .btn-primary:active, .btn-primary:visited, .btn-outline-primary {
background-color: #009c74 !important;
border-color: #009c74;
color: white;
}

.bg-primary{
background-color: #009c74 !important;
border-color: #009c74;
color: #009c74;
}


.sep_left{
border-left: 1px solid #ffffff;
margin-left: 10px;
}

</style>


<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
document.getElementsByTagName("body")[0].style = "";

}
</script>
</body>
4 changes: 4 additions & 0 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def download_templates():
r = get(f"https://raw.githubusercontent.com/copypastaofficial/copypasta/master/templates/img_preview.html",allow_redirects=True)
with open("templates/img_preview.html","wb") as f:
f.write(r.content)

r = get(f"https://raw.githubusercontent.com/copypastaofficial/copypasta/master/templates/video_preview.html",allow_redirects=True)
with open("templates/img_preview.html","wb") as f:
f.write(r.content)

r = get(f"https://raw.githubusercontent.com/copypastaofficial/copypasta/master/templates/favicon.ico",allow_redirects=True)
with open("static/favicon.ico","wb") as f:
Expand Down

0 comments on commit 9dc2418

Please sign in to comment.