Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workaround for] OOM / memory "502 Bad Gateway" crashes w/ large videos' playback or download-to-client [SEE ALSO #37 & #53] #51

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion scripts/omg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +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