Skip to content

Commit

Permalink
Changes and improvements
Browse files Browse the repository at this point in the history
Added loading animation
Option to drag player controls panel
StashApp support
Other changes and improvements
  • Loading branch information
michal-repo committed Jun 25, 2023
1 parent 38b3d75 commit 4a0c14d
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 205 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

## Setup

### Using JSON solution and provided Python scripts

- Edit `config.ini` providing correct paths

`videos_location` => absolute path to folder containing videos folder and thumbnails folder (eg. for `/media/videos` set this to `videos_location=/media/videos`)
Expand All @@ -35,6 +37,16 @@
- If you don't have Thumbnails generated for your videos and want to use them run `generate_thumbnails.sh` script
- Finally run `generate_files_json.sh` script to generate `files.json` containing list of VR files for player

Script can set screen type based on file name. Add one of following at the end of file name: `_TB` (Top-Bottom), `_SCREEN`. Default screen type is Side-by-Side.

### Stashapp

For stashapp comment json span in index and uncomment stashapp span, then provide url to app (it must be configured with SSL, browser will blocking mixed content if you use http)

Tag your videos with one of these tags: `SBS`, `VR` (screen type is SBS), `TB`, `SCREEN`

Videos are organized by Studios.

## Generating your own JSON file with video sources
Player is using locally stored JSON file with video sources. It's configured in `index.html`, where you can provide your JSON file name:
```
Expand Down Expand Up @@ -119,6 +131,8 @@ Player is using locally stored JSON file with video sources. It's configured in
"src": "../videos/Movies/The%20Good%20the%20Bad%20and%20the%20Ugly.mp4",
"thumbnail": "../videos/Thumbnails/Movies/The%20Good%20the%20Bad%20and%20the%20Ugly.jpg",
"screen_type": "screen",
"frame_height": "720",
"frame_width": "1280",
"date": "2023-01-10 15:05:50",
"epoch": "1673359550.854825"
},
Expand Down
Binary file added dist/0c33216c2b6f8e86c510de53dc7690d2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<source id="video_src" src="" type="video/mp4">
</video>
<span id="json_file" hidden>files.json</span>
<!-- StashApp must be configured with SSL -->
<!-- <span id="stashapp" hidden>https://192.168.1.100:9999/</span> -->



<footer>
<p>
Icons made by
Expand Down
76 changes: 66 additions & 10 deletions scripts/generate_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import sys
import urllib.parse
from datetime import datetime
import sqlite3
import subprocess
import pipes

connection = sqlite3.connect("videos.db")
cursor = connection.cursor()

cursor.execute("CREATE TABLE IF NOT EXISTS videos(id INTEGER PRIMARY KEY AUTOINCREMENT, fullfile, title, extension, codec_name, frame_height, frame_width, framerate)")

if not len(sys.argv) > 1:
print("Usage: pass config ini file as first parameter, you can force metadata rescan by setting second parameter to true (false by default)\neg.\npython3 generateJson.py config.ini\npython3 generateJson.py config.ini true")
Expand Down Expand Up @@ -38,7 +46,42 @@
extension = file[-4:]

fullfile = (os.path.join(root, file))
date = os.path.getmtime(fullfile)
date = os.path.getmtime(fullfile)

if "_SCREEN" in title[-7:]:
# DB
codec_name = ""
frame_height = ""
frame_width = ""
framerate = ""
existing_entry_query = cursor.execute(
"SELECT frame_height, frame_width FROM videos WHERE fullfile = :fullfile", {
"fullfile": fullfile,
})
existing_entry = existing_entry_query.fetchone()
if existing_entry is None:
cmd = [
"ffprobe -v quiet -print_format json -show_format -show_streams " + pipes.quote(fullfile)]
result = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
metadataJson = result.stdout
d = json.loads(metadataJson)
streams = d.get("streams", [])
for stream in streams:
if "codec_type" in stream:
if stream["codec_type"] == "video":
codec_name = stream["codec_name"]
framerate = round(
eval(stream["avg_frame_rate"]))
frame_height = stream["height"]
frame_width = stream["width"]
cursor.execute("insert into videos(fullfile, title, extension, codec_name, frame_height, frame_width, framerate) values (?, ?, ?, ?, ?, ?, ?)", (
fullfile, title, extension, codec_name, frame_height, frame_width, framerate))
connection.commit()
else:
frame_height = existing_entry[0]
frame_width = existing_entry[1]
##

entry = fullfile.replace(
config['videos']['videos_relative_path'], "")
Expand All @@ -60,15 +103,28 @@
else:
screen_type = "sbs"

out_files[subDir]["list"].append(
{"name": title,
"src": urllib.parse.quote(fullfile),
"thumbnail": urllib.parse.quote(img),
"screen_type": screen_type,
"date": datetime.fromtimestamp(date).strftime('%Y-%m-%d %H:%M:%S'),
"epoch": date
})

if screen_type == "screen":
out_files[subDir]["list"].append(
{"name": title,
"src": urllib.parse.quote(fullfile),
"thumbnail": urllib.parse.quote(img),
"screen_type": screen_type,
"frame_height": frame_height,
"frame_width": frame_width,
"date": datetime.fromtimestamp(date).strftime('%Y-%m-%d %H:%M:%S'),
"epoch": date
})
else:
out_files[subDir]["list"].append(
{"name": title,
"src": urllib.parse.quote(fullfile),
"thumbnail": urllib.parse.quote(img),
"screen_type": screen_type,
"date": datetime.fromtimestamp(date).strftime('%Y-%m-%d %H:%M:%S'),
"epoch": date
})

cursor.close()
out_json = []
for entry in out_files:
if len(out_files[entry]["list"]) > 0:
Expand Down
Loading

0 comments on commit 4a0c14d

Please sign in to comment.