Commit acaa942b authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

merged allmedia from sound.constant

parents 8da482d8 8d3f13e0
......@@ -14,8 +14,8 @@
--output $@
.index/%.{{ext}}/play.mp3: %.{{ext}}
mkdir -p .index/$*.{{ext}}
ffmpeg-loudnorm $< --output $@
mkdir -p '.index/$*.{{ext}}'
TMP=/home/videos/tmp ffmpeg-normalize $< -o $@ -t -16 -tp -1.5 -lrt 11 -c:a mp3
{% endfor %}
#############################
......@@ -28,19 +28,19 @@
# {{pdf}}_all=$({{pdf}}_meta) $({{pdf}}_poster) $({{pdf}}_thumb)
.index/%.{{pdf}}/metadata.json: %.{{pdf}} .index/%.{{pdf}}/poster.png .index/%.{{pdf}}/thumb.png
indexalist pdfinfo $< | \
indexalist pdfinfo '$<' | \
indexalist jsonaddkeyvalue \
--keyvalue "id" "$$(indexalist urlencode $<)" \
--keyvalue "poster" .index/$*.{{pdf}}/poster.png \
--keyvalue "thumbnail" .index/$*.{{pdf}}/thumb.png \
--output $@
--output '$@'
.index/%.{{pdf}}/poster.png: %.{{pdf}}
mkdir -p .index/$*.{{pdf}}
convert $<[0] -background white -flatten $@
mkdir -p '.index/$*.{{pdf}}'
MAGICK_TMPDIR=/home/videos/tmp convert $<[0] -background white -flatten $@
.index/%.{{pdf}}/thumb.png: .index/%.{{pdf}}/poster.png
convert $< -resize 200x200 $@
MAGICK_TMPDIR=/home/videos/tmp convert $< -resize 200x200 $@
{% endfor %}
......@@ -52,19 +52,19 @@
{{jpg}}_meta=$({{jpg}}:%.{{jpg}}=.index/%.{{jpg}}/metadata.json)
.index/%.{{jpg}}/metadata.json: %.{{jpg}} .index/%.{{jpg}}/poster.jpg .index/%.{{jpg}}/thumb.jpg
indexalist imageinfo $< | \
indexalist imageinfo "$<" | \
indexalist jsonaddkeyvalue \
--keyvalue "id" "$$(indexalist urlencode $<)" \
--keyvalue "poster" .index/$*.{{jpg}}/poster.jpg \
--keyvalue "thumbnail" .index/$*.{{jpg}}/thumb.jpg \
--output $@
--keyvalue "id" "$$(indexalist urlencode '$<')" \
--keyvalue "poster" ".index/$*.{{jpg}}/poster.jpg" \
--keyvalue "thumbnail" ".index/$*.{{jpg}}/thumb.jpg" \
--output "$@"
.index/%.{{jpg}}/poster.jpg: %.{{jpg}}
mkdir -p .index/$*.{{jpg}}
convert $< -auto-orient -resize 640x640 $@
mkdir -p '.index/$*.{{jpg}}'
MAGICK_TMPDIR=/home/videos/tmp convert $<[0] -auto-orient -resize 640x640 $@
.index/%.{{jpg}}/thumb.jpg: .index/%.{{jpg}}/poster.jpg
convert $< -resize 200x200 $@
MAGICK_TMPDIR=/home/videos/tmp convert $< -resize 200x200 $@
{% endfor %}
......@@ -89,14 +89,15 @@
.index/%.{{mp4}}/play.mp4: %.{{mp4}}
mkdir -p .index/$*.{{mp4}}
ffmpeg-loudnorm-240p $< --output $@
TMP=/home/videos/tmp ffmpeg-normalize $< -o $@ -t -16 -tp -1.5 -lrt 11 -c:a aac -c:v h264 -e="-vf scale=-2:240" || \
ffmpeg -i $< -vf scale=-2:240 $@
.index/%.{{mp4}}/poster.png: %.{{mp4}}
mkdir -p .index/$*.{{mp4}}
ffmpeg -i $< -ss 6 -vframes 1 $@
mkdir -p '.index/$*.{{mp4}}'
ffmpeg -i $< -ss {{video_poster_time|default(0)}} -vframes 1 $@
.index/%.{{mp4}}/thumb.png: .index/%.{{mp4}}/poster.png
convert $< -resize 200x200 $@
MAGICK_TMPDIR=/home/videos/tmp convert $< -resize 200x200 $@
{% endfor %}
#############################
......@@ -116,6 +117,8 @@ all: index.html
# replace spaces
fixnames:
rename "s/ /_/g" *
rename "s/'//g" *
rename "s/\"//g" *
# special rule for debugging variables
print-%:
@echo '$*=$($*)'
......@@ -135,5 +138,5 @@ index.json: .index/index.json description.json $(all_meta)
index.html: index.json
indexalist template --data $< \
~/indexalist/cookbook/index-template.html \
/home/murtaugh/indexalist/cookbook/index-template.html \
--output $@
{
"audio_extensions": ["mp3", "MP3", "wav", "WAV", "ogg", "OGG", "oga", "OGA", "m4a", "M4A"],
"pdf_extensions": ["pdf", "PDF"],
"video_extensions": ["mp4", "MP4", "m4v", "ogv", "OGV", "mpeg", "MPEG", "webm", "WEBM", "mkv", "MKV"],
"image_extensions": ["jpg", "JPG", "tiff", "TIFF", "png", "PNG"]
"video_extensions": ["mp4", "MP4", "m4v", "ogv", "OGV", "mpeg", "MPEG", "webm", "WEBM", "mkv", "MKV", "avi", "AVI", "mov", "MOV", "flv", "FLV"],
"image_extensions": ["jpg", "JPG", "tiff", "TIFF", "png", "PNG", "gif", "GIF", "svg", "SVG"]
}
\ No newline at end of file
}
......@@ -37,7 +37,7 @@
<!-- DIRECTORY -->
{% set d = i %}
<tr class="folder" property="dcterms:hasPart" resource="{{d.id}}/" typeof="mediafolder">
<td class="icon" valign="top"><img src="/icons/folder.gif" alt="[FOLDER]"></td>
<td class="icon" valign="top"><img src="/lib/icons/folder.gif" alt="[FOLDER]"></td>
<td class="name"><a href="{{d.id}}/">{{d.filename}}/</a></td>
<td class="lastmod" align="right">{% if d.mtime %}{{d.mtime|strftime}}{%else%}&mdash;{%endif%}</td>
<td class="size" align="right" content="{{d.size}}">{{d.size|filesizeformat}}</td>
......@@ -61,11 +61,11 @@
{% if f.thumbnail %}
<img src="{{f.thumbnail|urlencode}}" class="icon" alt="[FILE]">
{% elif f.mime.startswith("image/") %}
<img src="/icons/image1.gif" alt="[IMAGE]">
<img src="/lib/icons/image1.gif" alt="[IMAGE]">
{% elif f.mime.startswith("audio/") or f.mime.startswith("video/") %}
{% if f.video %}<img src="/icons/video.gif" alt="[IMAGE]">{% else %}<img src="/icons/sound2.gif" alt="[IMAGE]">{%endif%}
{% if f.video %}<img src="/lib/icons/video.gif" alt="[IMAGE]">{% else %}<img src="/lib/icons/sound2.gif" alt="[IMAGE]">{%endif%}
{% else %}
<img src="/icons/generic.gif" alt="[IMAGE]">
<img src="/lib/icons/generic.gif" alt="[IMAGE]">
{% endif %}
</a>
{% if f.thumbnail %}
......
{
"audio_extensions": ["mp3", "MP3", "wav", "WAV", "oga", "OGA", "m4a", "M4A"],
"pdf_extensions": ["pdf", "PDF"],
"video_extensions": ["mp4", "MP4", "m4v", "ogg", "OGG", "ogv", "OGV", "mpeg", "MPEG", "webm", "WEBM", "mkv", "avi", "AVI", "mov", "MOV"],
"image_extensions": ["jpg", "JPG", "tiff", "TIFF", "png", "PNG"]
}
......@@ -19,7 +19,7 @@ from gitignore_parser import parse_gitignore
# return data
def joiniter (set1, set2, key):
# print ("join", set1, set2)
# print ("join", [key(x) for x in set1], [key(x) for x in set2])
index1 = {key(item): item for item in set1}
index2 = {key(item): item for item in set2}
enter, update = [], []
......@@ -121,6 +121,8 @@ class FileWalker (object):
curpath = os.path.join(curpath, dirname)
indexignore = os.path.join(curpath, ".indexignore")
if os.path.exists(indexignore):
if self.verbose:
print ("parse_gitignore", indexignore, file=sys.stderr)
ignores.append(parse_gitignore(indexignore))
if self.verbose:
print ("Using", os.path.relpath(indexignore, self.path), file=sys.stderr)
......@@ -142,7 +144,7 @@ class FileWalker (object):
child_dirs = []
indexignore = os.path.join(path, ".indexignore")
if os.path.exists(indexignore):
ignores = ignores + [parse_gitignore(indexignore)]
ignores = ignores + [parse_gitignore(os.path.abspath(indexignore))]
# don't alter ignores
# ignores.append(parse_gitignore(indexignore))
if self.verbose:
......@@ -153,6 +155,8 @@ class FileWalker (object):
ignore_item = False
for ignore in ignores:
if ignore(os.path.abspath(item_fp)):
if self.verbose:
print ("Ignoring {} based on {}".format(os.path.abspath(item_fp), ignore), file=sys.stderr)
ignore_item = True
break
if not ignore_item:
......@@ -268,8 +272,10 @@ class FileWalker (object):
# put back the filenames
# for n, d in zip(dirnodes, dirs):
# n['filename'] = d
for jdir, oldnode, newnode in joiniter(n['dirs'], dirnodes, lambda d: d['id']):
# print ("dirnodes", dirnodes)
# print ("n[dirs]", n['dirs'])
# important to join on filename ... as directory nodes have blank ids
for jdir, oldnode, newnode in joiniter(n['dirs'], dirnodes, lambda d: d['filename']):
if jdir == 'exit':
index_changed = True
yield ('exit', 'd', os.path.join(path, oldnode['filename']))
......@@ -380,8 +386,9 @@ class FileWalker (object):
cmdargs.append(makefile)
if self.verbose:
print ("Using {}".format(os.path.relpath(makefile, self.path)), file=sys.stderr)
p = subprocess.run(cmdargs, cwd = path)
print ("make returned {}".format(p.returncode))
p = subprocess.run(cmdargs, cwd = path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if p.returncode != 0:
print ("make returned {}: {}".format(p.returncode, p.stdout.decode("utf-8")))
def make (self, target=None, force=False):
# sync first
......@@ -389,6 +396,7 @@ class FileWalker (object):
pass
# Call make on ALL directories in walk (bottom up) order
for base,dirs,files in self.walk(self.path):
print (base, file=sys.stderr)
self._make(base, target=target, force=force)
# # Combine make with sync -- calling only on changed dirs
......
......@@ -91,6 +91,11 @@ def main (args):
data = {
args.listkey: data
}
if args.set:
for key, value in args.set:
print ("Setting {0}={1}".format(key, value), file=sys.stderr)
data[key] = value
# data['allkeys'] = allkeys
print (template.render(**data), file=args.output)
......@@ -100,6 +105,7 @@ def add_subparser (subparsers):
p.add_argument("template")
p.add_argument("--data", type=argparse.FileType('r'), default=sys.stdin)
p.add_argument("--listkey", default="items", help="if incoming data is a list, give it this name for the template, default: items")
p.add_argument("--set", nargs=2, default=None, action="append")
# p.add_argument("--meta", help="Mixin this metadata", action="append")
p.set_defaults(func=main)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment