Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cps/editbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ def move_mediafile(requested_files, current_user_name=None, shelf_title=None):
if shelf_title:
shelf.add_to_shelf_as_guest(shelf_id, book_id)

os.remove(requested_file.name)

if len(requested_files) < 2:
resp = {
"location": url_for(
Expand Down
41 changes: 41 additions & 0 deletions cps/templates/watchvideo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{{ entry.title }}</title>
<!-- Other meta tags -->
</head>

<body>

<div class="row" style="display: inline-block; width: 100%;">
<div class="col-sm-3 col-lg-3 col-xs-5">
</div>
<div class="col-sm-6 col-lg-6 book-meta" style="margin-bottom: 2%;">
<div class="video-container">
<!-- Native HTML5 video player with autoplay -->
<video
id="my-video"
controls
width="100%"
height="auto"
autoplay
preload="auto"
>
<!-- Actual video file path -->
<source src="{{ videofile }}" type="{{ videotype }}" />
Your browser does not support the video tag.
</video>
</div>

<!-- Book metadata and other information -->
<h2 id="title">{{entry.title}}</h2>

</div>
</div>

</body>

</html>
9 changes: 8 additions & 1 deletion cps/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import glob
import os
import json
import mimetypes
Expand Down Expand Up @@ -1568,7 +1569,13 @@ def read_book(book_id, book_format):
if book_format.lower() == fileExt:
entries = calibre_db.get_filtered_book(book_id)
log.debug("Start video watching for %d", book_id)
return serve_book.__closure__[0].cell_contents(book_id, book_format.lower(), anyname="")
video_path = os.path.join(config.config_calibre_dir, book.path)
video_file = glob.glob(os.path.join(video_path, "*." + book_format.lower()))
video_file = video_file[0]
video_type = "video/" + book_format.lower()
return render_title_template('watchvideo.html', videofile=video_file , videotype=video_type,
entry=entries, bookmark=bookmark)

for fileExt in ["cbr", "cbt", "cbz"]:
if book_format.lower() == fileExt:
all_name = str(book_id)
Expand Down
24 changes: 23 additions & 1 deletion scripts/calibre-web-nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,27 @@
# http://box/library/calibre-web/<author>/<title>/<webm_or_mp4_video_file>
location /library/calibre-web/ {
alias /library/www/html/calibre-web/;
fancyindex on; # autoindex on;
# fancyindex on;
# autoindex on;

location ~* \.(webm|mp4)$ {
# Configuration specific to video files
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
expires 30d;
add_header Cache-Control "public, max-age=2592000";
try_files $uri =404; # Ensure only existing files are served
}

# Default deny for other file types and directories
location ~* ^/library/calibre-web/.*\.(?!webm|mp4)[a-z0-9]+$ {
deny all;
access_log off;
log_not_found off;
}

location ~* ^/library/calibre-web/.*[^/]*$ {
deny all;
access_log off;
log_not_found off;
}
}
5 changes: 4 additions & 1 deletion scripts/omg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ runcmd:
admin_console_install: False
admin_console_enabled: False
EOF
- curl iiab.io/risky.txt | bash &
- curl iiab.io/risky.txt | bash
- curl https://raw.githubusercontent.com/iiab/calibre-web/master/scripts/calibre-web-nginx.conf > /etc/nginx/conf.d/calibre-web-nginx.conf
- ln -s /library/calibre-web /library/www/html/calibre-web
- nginx -s reload