develop #2
|
@ -29,9 +29,22 @@ def get_window_controller():
|
||||||
id = secrets.token_hex(16)
|
id = secrets.token_hex(16)
|
||||||
controller = WindowController()
|
controller = WindowController()
|
||||||
view = controller.get_window(1).get_view(0)
|
view = controller.get_window(1).get_view(0)
|
||||||
|
|
||||||
|
try:
|
||||||
view.ABS_THUMBS_PTH = app.config['ABS_THUMBS_PTH']
|
view.ABS_THUMBS_PTH = app.config['ABS_THUMBS_PTH']
|
||||||
|
except Exception as e:
|
||||||
|
...
|
||||||
|
|
||||||
|
try:
|
||||||
view.REMUX_FOLDER = app.config['REMUX_FOLDER']
|
view.REMUX_FOLDER = app.config['REMUX_FOLDER']
|
||||||
|
except Exception as e:
|
||||||
|
...
|
||||||
|
|
||||||
|
try:
|
||||||
view.FFMPG_THUMBNLR = app.config['FFMPG_THUMBNLR']
|
view.FFMPG_THUMBNLR = app.config['FFMPG_THUMBNLR']
|
||||||
|
except Exception as e:
|
||||||
|
...
|
||||||
|
|
||||||
view.logger = logger
|
view.logger = logger
|
||||||
|
|
||||||
session['win_controller_id'] = id
|
session['win_controller_id'] = id
|
||||||
|
@ -85,15 +98,30 @@ def listFiles(_hash = None):
|
||||||
|
|
||||||
sub_path = view.get_current_sub_path()
|
sub_path = view.get_current_sub_path()
|
||||||
current_directory = sub_path.split("/")[-1]
|
current_directory = sub_path.split("/")[-1]
|
||||||
|
trailer = None
|
||||||
if "(" in current_directory and ")" in current_directory:
|
if "(" in current_directory and ")" in current_directory:
|
||||||
title = current_directory.split("(")[0].strip()
|
title = current_directory.split("(")[0].strip()
|
||||||
startIndex = current_directory.index('(') + 1
|
startIndex = current_directory.index('(') + 1
|
||||||
endIndex = current_directory.index(')')
|
endIndex = current_directory.index(')')
|
||||||
date = current_directory[startIndex:endIndex]
|
date = current_directory[startIndex:endIndex]
|
||||||
video_data = tmdb.search(title, date)
|
video_data = tmdb.search(title, date)[0]
|
||||||
background_url = video_data[0]["backdrop_path"]
|
video_id = video_data["id"]
|
||||||
|
background_url = video_data["backdrop_path"]
|
||||||
background_pth = f"{view.get_current_directory()}/000.jpg"
|
background_pth = f"{view.get_current_directory()}/000.jpg"
|
||||||
|
|
||||||
|
try:
|
||||||
|
tmdb_videos = tmdb.tmdbapi.get_movie(str(video_id), append_to_response="videos")["videos"]["results"]
|
||||||
|
for tmdb_video in tmdb_videos:
|
||||||
|
if "YouTube" in tmdb_video["site"]:
|
||||||
|
trailer_key = tmdb_video["key"]
|
||||||
|
trailer = f"https://www.youtube-nocookie.com/embed/{trailer_key}?start=0&autoplay=1";
|
||||||
|
|
||||||
|
if not trailer:
|
||||||
|
raise Exception("No key found. Defering to none...")
|
||||||
|
except Exception as e:
|
||||||
|
print("No trailer found...")
|
||||||
|
trailer = None
|
||||||
|
|
||||||
if not os.path.isfile(background_pth):
|
if not os.path.isfile(background_pth):
|
||||||
r = requests.get(background_url, stream = True)
|
r = requests.get(background_url, stream = True)
|
||||||
|
|
||||||
|
@ -113,6 +141,7 @@ def listFiles(_hash = None):
|
||||||
in_fave = "true" if fave else "false"
|
in_fave = "true" if fave else "false"
|
||||||
|
|
||||||
files.update({'in_fave': in_fave})
|
files.update({'in_fave': in_fave})
|
||||||
|
files.update({'trailer': trailer})
|
||||||
return files
|
return files
|
||||||
else:
|
else:
|
||||||
msg = "Can't manage the request type..."
|
msg = "Can't manage the request type..."
|
||||||
|
|
|
@ -51,6 +51,18 @@ const updateHTMLDirList = async (data) => {
|
||||||
let isInFaves = data.in_fave;
|
let isInFaves = data.in_fave;
|
||||||
let background_image = (images[0]) ? images[0][0] : "";
|
let background_image = (images[0]) ? images[0][0] : "";
|
||||||
|
|
||||||
|
if (data.hasOwnProperty("trailer")) {
|
||||||
|
let trailerBttn = document.getElementById("trailer-btn");
|
||||||
|
let trailerLink = document.getElementById("trailer-link");
|
||||||
|
if (data.trailer !== null) {
|
||||||
|
trailerBttn.style.display = "";
|
||||||
|
trailerLink.href = `javascript: showFile( "Trailer", "${data.trailer}", "", "trailer" )`;
|
||||||
|
} else {
|
||||||
|
trailerBttn.style.display = "none";
|
||||||
|
trailerLink.href = "#";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById("path").innerText = data.path_head;
|
document.getElementById("path").innerText = data.path_head;
|
||||||
// Setup background if there is a 000.* in selection
|
// Setup background if there is a 000.* in selection
|
||||||
if (background_image.match(/000\.(jpg|png|gif)\b/) != null) {
|
if (background_image.match(/000\.(jpg|png|gif)\b/) != null) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ const scrollFilesToTop = () => {
|
||||||
|
|
||||||
const closeFile = () => {
|
const closeFile = () => {
|
||||||
const video = document.getElementById("video");
|
const video = document.getElementById("video");
|
||||||
|
const trailerPlayer = document.getElementById("trailerPlayer")
|
||||||
let title = document.getElementById("selectedFile");
|
let title = document.getElementById("selectedFile");
|
||||||
|
|
||||||
document.getElementById("image-viewer").style.display = "none";
|
document.getElementById("image-viewer").style.display = "none";
|
||||||
|
@ -61,6 +62,9 @@ const closeFile = () => {
|
||||||
video.style.display = "none";
|
video.style.display = "none";
|
||||||
video.style.cursor = '';
|
video.style.cursor = '';
|
||||||
video.pause();
|
video.pause();
|
||||||
|
|
||||||
|
trailerPlayer.src = "#";
|
||||||
|
trailerPlayer.style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
const showFile = async (title, hash, extension, type) => {
|
const showFile = async (title, hash, extension, type) => {
|
||||||
|
@ -68,6 +72,7 @@ const showFile = async (title, hash, extension, type) => {
|
||||||
document.getElementById("text-viewer").style.display = "none";
|
document.getElementById("text-viewer").style.display = "none";
|
||||||
document.getElementById("pdf-viewer").style.display = "none";
|
document.getElementById("pdf-viewer").style.display = "none";
|
||||||
document.getElementById("video").style.display = "none";
|
document.getElementById("video").style.display = "none";
|
||||||
|
document.getElementById("trailerPlayer").style.display = "none";
|
||||||
|
|
||||||
let titleElm = document.getElementById("selectedFile");
|
let titleElm = document.getElementById("selectedFile");
|
||||||
titleElm.innerText = title;
|
titleElm.innerText = title;
|
||||||
|
@ -78,15 +83,27 @@ const showFile = async (title, hash, extension, type) => {
|
||||||
if (type === "file") {
|
if (type === "file") {
|
||||||
setupFile(hash, extension);
|
setupFile(hash, extension);
|
||||||
}
|
}
|
||||||
|
if (type === "trailer") {
|
||||||
|
launchTrailer(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const launchTrailer = (link) => {
|
||||||
|
let modal = new bootstrap.Modal(document.getElementById('file-view-modal'), { keyboard: false });
|
||||||
|
let trailerPlayer = document.getElementById("trailerPlayer");
|
||||||
|
trailerPlayer.style.display = "";
|
||||||
|
trailerPlayer.src = link;
|
||||||
|
|
||||||
|
modal.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
const setupVideo = async (hash, extension) => {
|
const setupVideo = async (hash, extension) => {
|
||||||
|
let modal = new bootstrap.Modal(document.getElementById('file-view-modal'), { keyboard: false });
|
||||||
let video = document.getElementById("video");
|
let video = document.getElementById("video");
|
||||||
video.poster = "static/imgs/icons/loading.gif";
|
video.poster = "static/imgs/icons/loading.gif";
|
||||||
video.style.display = "";
|
video.style.display = "";
|
||||||
video.src = "#"
|
video.src = "#"
|
||||||
video_path = "api/file-manager-action/files/" + hash;
|
video_path = "api/file-manager-action/files/" + hash;
|
||||||
let modal = new bootstrap.Modal(document.getElementById('file-view-modal'), { keyboard: false });
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<div id="navbarTogglerHeader" class="row collapse navbar-collapse">
|
<div id="navbarTogglerHeader" class="row collapse navbar-collapse">
|
||||||
{% if current_directory %}
|
{% if current_directory %}
|
||||||
<div class="col">
|
<div class="col col-auto">
|
||||||
<!-- Left menues -->
|
<!-- Left menues -->
|
||||||
<ul class="navbar-nav col-auto">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item" data-bs-toggle="modal" data-bs-target="#file-view-modal">
|
<li class="nav-item" data-bs-toggle="modal" data-bs-target="#file-view-modal">
|
||||||
<i class="nav-link bi bi-projector-fill" aria-hidden="true" title="File viewer..." >
|
<i class="nav-link bi bi-projector-fill" aria-hidden="true" title="File viewer..." >
|
||||||
Media Viewer
|
Media Viewer
|
||||||
|
@ -38,6 +38,14 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<li class="nav-item mx-3">
|
||||||
|
<a id="trailer-link" href="#">
|
||||||
|
<span id="trailer-btn" class="btn btn-info btn-sm" style="display: none;" title="Trailer..." >Trailer</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col col-auto">
|
<div class="col col-auto">
|
||||||
<!-- Right menues -->
|
<!-- Right menues -->
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
|
|
|
@ -22,6 +22,18 @@
|
||||||
>
|
>
|
||||||
</video>
|
</video>
|
||||||
|
|
||||||
|
<iframe id="trailerPlayer"
|
||||||
|
width="560" height="315"
|
||||||
|
style="display: none;"
|
||||||
|
src=""
|
||||||
|
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
|
||||||
|
allowfullscreen="allowfullscreen"
|
||||||
|
mozallowfullscreen="mozallowfullscreen"
|
||||||
|
msallowfullscreen="msallowfullscreen"
|
||||||
|
oallowfullscreen="oallowfullscreen"
|
||||||
|
webkitallowfullscreen="webkitallowfullscreen">
|
||||||
|
</iframe>
|
||||||
|
|
||||||
<!-- For image -->
|
<!-- For image -->
|
||||||
<img id="image-viewer" class="card-img-top viewer"
|
<img id="image-viewer" class="card-img-top viewer"
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
|
|
Loading…
Reference in New Issue