From 0af5def2706a43b0ef8f9d52c7656700fd1998ac Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:53:19 -0500 Subject: [PATCH 01/10] Remove original file Avoid duplication --- cps/editbooks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cps/editbooks.py b/cps/editbooks.py index cc4e44dde7..b50b3b39ac 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -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( From 7708d3f378b09e94823f8d9c76f152eca9d0ec4f Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Thu, 23 Nov 2023 01:02:48 -0500 Subject: [PATCH 02/10] Update omg.yml --- scripts/omg.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/omg.yml b/scripts/omg.yml index ae2aff8d1e..07bae376eb 100644 --- a/scripts/omg.yml +++ b/scripts/omg.yml @@ -27,4 +27,5 @@ 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 From d2fe87dd3156f02f2c7d0dcb6314bd52c8d34eb7 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Thu, 23 Nov 2023 01:06:46 -0500 Subject: [PATCH 03/10] Create watchvideo.html Use native HTML5 video player --- cps/templates/watchvideo.html | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cps/templates/watchvideo.html diff --git a/cps/templates/watchvideo.html b/cps/templates/watchvideo.html new file mode 100644 index 0000000000..bb22e4acb5 --- /dev/null +++ b/cps/templates/watchvideo.html @@ -0,0 +1,41 @@ + + + + + + + {{ entry.title }} + + + + + +
+
+
+
+
+ + +
+ + +

{{entry.title}}

+ +
+
+ + + + From 6f1363eb56c53b0abf6cc950f73f9966bdea71d6 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Thu, 23 Nov 2023 01:11:01 -0500 Subject: [PATCH 04/10] Update web.py Play video directly using native HTML5 player --- cps/web.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 485e42d43c..98e4d22ee7 100755 --- a/cps/web.py +++ b/cps/web.py @@ -18,6 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import glob import os import json import mimetypes @@ -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) From bd235e63491a209ff064199869c8ca7397e6d1e1 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Thu, 23 Nov 2023 06:52:42 -0500 Subject: [PATCH 05/10] Update scripts/omg.yml Co-authored-by: A Holt --- scripts/omg.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/omg.yml b/scripts/omg.yml index 07bae376eb..b973dcf347 100644 --- a/scripts/omg.yml +++ b/scripts/omg.yml @@ -29,3 +29,4 @@ runcmd: EOF - 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 + - nginx -s reload From 07ba82a1edbc7932b2de09553d73a9f0d17716de Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Fri, 24 Nov 2023 06:12:25 -0500 Subject: [PATCH 06/10] Update omg.yml --- scripts/omg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/omg.yml b/scripts/omg.yml index b973dcf347..0087770437 100644 --- a/scripts/omg.yml +++ b/scripts/omg.yml @@ -27,6 +27,6 @@ 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 - nginx -s reload From a0b909c44c43cdd94dc290087a6d50a186bd232d Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Mon, 27 Nov 2023 03:46:49 -0500 Subject: [PATCH 07/10] Symlink library --- scripts/omg.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/omg.yml b/scripts/omg.yml index 0087770437..c64fa00450 100644 --- a/scripts/omg.yml +++ b/scripts/omg.yml @@ -29,4 +29,5 @@ runcmd: EOF - 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/wwww/html/calibre-web - nginx -s reload From 8a3a90a227f83d0b48906f2cc393a3905a76434c Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:40:17 -0500 Subject: [PATCH 08/10] Update scripts/omg.yml Co-authored-by: A Holt --- scripts/omg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/omg.yml b/scripts/omg.yml index c64fa00450..d1933e21df 100644 --- a/scripts/omg.yml +++ b/scripts/omg.yml @@ -29,5 +29,5 @@ runcmd: EOF - 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/wwww/html/calibre-web + - ln -s /library/calibre-web /library/www/html/calibre-web - nginx -s reload From fa70213794cc7c70cb846c378d09964bbb5838d5 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:30:26 -0500 Subject: [PATCH 09/10] Remove "&" --- scripts/omg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/omg.yml b/scripts/omg.yml index d1933e21df..5915ff3929 100644 --- a/scripts/omg.yml +++ b/scripts/omg.yml @@ -27,7 +27,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 From e6d927377fec435e237f73e78f4ce693aaedd015 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:19:00 -0500 Subject: [PATCH 10/10] Restrict access This ensures that access is restricted to only video files with "webm" or "mp4" extensions within the /library/calibre-web/ path. Any other files or directories are denied access. --- scripts/calibre-web-nginx.conf | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/calibre-web-nginx.conf b/scripts/calibre-web-nginx.conf index 1187ee270d..e8d6bfaa29 100644 --- a/scripts/calibre-web-nginx.conf +++ b/scripts/calibre-web-nginx.conf @@ -3,5 +3,27 @@ # http://box/library/calibre-web///<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; + } }