develop #2
|
@ -29,9 +29,22 @@ def get_window_controller():
|
|||
id = secrets.token_hex(16)
|
||||
controller = WindowController()
|
||||
view = controller.get_window(1).get_view(0)
|
||||
|
||||
try:
|
||||
view.ABS_THUMBS_PTH = app.config['ABS_THUMBS_PTH']
|
||||
except Exception as e:
|
||||
...
|
||||
|
||||
try:
|
||||
view.REMUX_FOLDER = app.config['REMUX_FOLDER']
|
||||
except Exception as e:
|
||||
...
|
||||
|
||||
try:
|
||||
view.FFMPG_THUMBNLR = app.config['FFMPG_THUMBNLR']
|
||||
except Exception as e:
|
||||
...
|
||||
|
||||
view.logger = logger
|
||||
|
||||
session['win_controller_id'] = id
|
||||
|
@ -85,15 +98,30 @@ def listFiles(_hash = None):
|
|||
|
||||
sub_path = view.get_current_sub_path()
|
||||
current_directory = sub_path.split("/")[-1]
|
||||
trailer = None
|
||||
if "(" in current_directory and ")" in current_directory:
|
||||
title = current_directory.split("(")[0].strip()
|
||||
startIndex = current_directory.index('(') + 1
|
||||
endIndex = current_directory.index(')')
|
||||
date = current_directory[startIndex:endIndex]
|
||||
video_data = tmdb.search(title, date)
|
||||
background_url = video_data[0]["backdrop_path"]
|
||||
video_data = tmdb.search(title, date)[0]
|
||||
video_id = video_data["id"]
|
||||
background_url = video_data["backdrop_path"]
|
||||
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):
|
||||
r = requests.get(background_url, stream = True)
|
||||
|
||||
|
@ -113,6 +141,7 @@ def listFiles(_hash = None):
|
|||
in_fave = "true" if fave else "false"
|
||||
|
||||
files.update({'in_fave': in_fave})
|
||||
files.update({'trailer': trailer})
|
||||
return files
|
||||
else:
|
||||
msg = "Can't manage the request type..."
|
||||
|
|
|
@ -51,6 +51,18 @@ const updateHTMLDirList = async (data) => {
|
|||
let isInFaves = data.in_fave;
|
||||
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;
|
||||
// Setup background if there is a 000.* in selection
|
||||
if (background_image.match(/000\.(jpg|png|gif)\b/) != null) {
|
||||
|
|
|
@ -51,6 +51,7 @@ const scrollFilesToTop = () => {
|
|||
|
||||
const closeFile = () => {
|
||||
const video = document.getElementById("video");
|
||||
const trailerPlayer = document.getElementById("trailerPlayer")
|
||||
let title = document.getElementById("selectedFile");
|
||||
|
||||
document.getElementById("image-viewer").style.display = "none";
|
||||
|
@ -61,6 +62,9 @@ const closeFile = () => {
|
|||
video.style.display = "none";
|
||||
video.style.cursor = '';
|
||||
video.pause();
|
||||
|
||||
trailerPlayer.src = "#";
|
||||
trailerPlayer.style.display = "none";
|
||||
}
|
||||
|
||||
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("pdf-viewer").style.display = "none";
|
||||
document.getElementById("video").style.display = "none";
|
||||
document.getElementById("trailerPlayer").style.display = "none";
|
||||
|
||||
let titleElm = document.getElementById("selectedFile");
|
||||
titleElm.innerText = title;
|
||||
|
@ -78,15 +83,27 @@ const showFile = async (title, hash, extension, type) => {
|
|||
if (type === "file") {
|
||||
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) => {
|
||||
let modal = new bootstrap.Modal(document.getElementById('file-view-modal'), { keyboard: false });
|
||||
let video = document.getElementById("video");
|
||||
video.poster = "static/imgs/icons/loading.gif";
|
||||
video.style.display = "";
|
||||
video.src = "#"
|
||||
video_path = "api/file-manager-action/files/" + hash;
|
||||
let modal = new bootstrap.Modal(document.getElementById('file-view-modal'), { keyboard: false });
|
||||
|
||||
|
||||
try {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
<div id="navbarTogglerHeader" class="row collapse navbar-collapse">
|
||||
{% if current_directory %}
|
||||
<div class="col">
|
||||
<div class="col col-auto">
|
||||
<!-- 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">
|
||||
<i class="nav-link bi bi-projector-fill" aria-hidden="true" title="File viewer..." >
|
||||
Media Viewer
|
||||
|
@ -38,6 +38,14 @@
|
|||
</div>
|
||||
{% 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">
|
||||
<!-- Right menues -->
|
||||
<ul class="navbar-nav">
|
||||
|
|
|
@ -22,6 +22,18 @@
|
|||
>
|
||||
</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 -->
|
||||
<img id="image-viewer" class="card-img-top viewer"
|
||||
style="display: none;"
|
||||
|
|
Loading…
Reference in New Issue