diff --git a/web/SimpleWebPage.py b/web/SimpleWebPage.py
index 2ab1c9d..95fa8aa 100755
--- a/web/SimpleWebPage.py
+++ b/web/SimpleWebPage.py
@@ -12,8 +12,10 @@ from glob import fnmatch
import base64
import random
-VERSION = "20200619"
+VERSION = "20210128"
IMAGE_EXTENSIONS = ["png", "gif", "jpg", "jpeg", "tif", "tiff"]
+AUDIO_EXTENSIONS = ["wav", "mp3", "ogg"]
+VIDEO_EXTENSIONS = ["mp4", "ogg", "webm"]
def setup():
@@ -79,6 +81,14 @@ def setup():
default=False,
help="Show images with tags",
)
+ parser.add_argument(
+ "--media",
+ action="store_true",
+ dest="media",
+ default=False,
+ help="Make media playable",
+ )
+
parser.add_argument(
"--include",
"-i",
@@ -112,6 +122,7 @@ def setup2HTML(opts):
"parent=%s" % opts.parent,
"title=%s" % urllib.parse.quote(opts.title),
"images=%s" % opts.images,
+ "media=%s" % opts.media,
]
)
@@ -134,6 +145,8 @@ def HTML2setup(opts):
opts.title = urllib.parse.unquote(v)
if k == "images":
opts.images = v == "True"
+ if k == "media":
+ opts.media = v == "True"
read_config = True
print("Reading options from existing " + opts.filename)
break
@@ -196,7 +209,7 @@ def generate_index(opts):
for di in dirs:
f.write(get_pathlink(path, di))
for fi in files:
- f.write(get_filelink(path, fi, opts.images))
+ f.write(get_filelink(path, fi, opts.images, opts.media))
f.write(get_footer())
f.write(get_wget_lines(files))
f.close()
@@ -238,7 +251,7 @@ def generate_password_page(path, password_file, password):
return "{}.{}{}".format(target_base, target_middle, target_ext)
-def get_filelink(path, fname, images=False):
+def get_filelink(path, fname, images=False, media=False):
if os.path.islink(os.path.join(path, fname)) and not os.path.exists(
os.path.join(path, fname)
):
@@ -249,10 +262,13 @@ def get_filelink(path, fname, images=False):
fsstrb = str(fsize)
fdate = time.localtime(os.path.getmtime(os.path.join(path, fname)))
fdstr = time.strftime("%Y/%m/%d %H:%M:%S", fdate)
+ fname_str = fname
if images and is_imagefile(fname):
fname_str = get_imagestr(fname)
- else:
- fname_str = fname
+ if media and is_audiofile(fname):
+ fname_str = get_audiostr(fname)
+ if media and is_videofile(fname):
+ fname_str = get_videostr(fname)
return (
'