commit d7b4764bd6903c56612b6f83226ceccd993f89f8
parent 6d273a754391a93082654b62d4d6bd73334a90d1
Author: rbckman <rob@tarina.org>
Date: Thu, 14 Dec 2023 13:41:41 +0000
filmfolder usb srv
Diffstat:
2 files changed, 59 insertions(+), 18 deletions(-)
diff --git a/srv/gonzopiserver.py b/srv/gonzopiserver.py
@@ -8,20 +8,61 @@ import sys
import time
import random
import hashlib
+import configparser
# Get path of the current dir, then use it as working directory:
rundir = os.path.dirname(__file__)
if rundir != '':
os.chdir(rundir)
-filmfolder = '/home/pi/Videos/'
+#--------------USB filmfolder-------------------
-basedir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(basedir)
+def usbfilmfolder():
+ usbmount = 0
+ while True:
+ usbconnected = os.path.ismount('/media/usb'+str(usbmount))
+ time.sleep(0.02)
+ if usbconnected == True:
+ try:
+ os.makedirs('/media/usb'+str(usbmount)+'/gonzopifilms/')
+ except:
+ pass
+ try:
+ p = subprocess.check_output('stat -f -c %T /media/usb'+str(usbmount), shell=True)
+ filesystem = p.decode()
+ print('filesystem info: ' + filesystem)
+ except:
+ print('Oh-no! dont know your filesystem')
+ filmfolder = '/media/usb'+str(usbmount)+'/gonzopifilms/'
+ return filmfolder
+ else:
+ usbmount = usbmount + 1
+ if usbmount > 20:
+ break
+
+home = os.path.expanduser('~')
+configfile = home + '/.gonzopi/config.ini'
+configdir = os.path.dirname(configfile)
+config = configparser.ConfigParser()
+if config.read(configfile):
+ filmfolder = config['USER']['filmfolder']+'/'
-# Link video directory to static dir
-if os.path.isfile('static/Videos') == False:
+
+os.system("unlink static/*")
+#CHECK IF FILMING TO USB STORAGE
+filmfolderusb=usbfilmfolder()
+if filmfolderusb:
+ filmfolder=filmfolderusb
+ # Link video directory to static dir
+ os.system("ln -s -t static/ " + filmfolder)
+ filmfolder='static/gonzopifilms/'
+else:
os.system("ln -s -t static/ " + filmfolder)
+ filmfolder='static/Videos/'
+ #fix filmfolder root to Videos/gonzopifilms
+
+basedir = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(basedir)
films = []
@@ -153,7 +194,7 @@ class index:
renderedfilms = []
unrenderedfilms = []
for f in films:
- if os.path.isfile('static/Videos/' + f[0] + '/' + f[0] + '.mp4') == True:
+ if os.path.isfile(filmfolder + f[0] + '/' + f[0] + '.mp4') == True:
renderedfilms.append(f[0])
else:
unrenderedfilms.append(f[0])
@@ -216,7 +257,7 @@ class index:
take=1
session.reload = 0
if i.func == 'retake':
- print(i.func+'fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuiccccccccccccccccccccccccccccccccccccccccckkkkkkkkkkkkkkkkkkkkkkkkkk')
+ print(i.func)
if recording == False:
sendtocamera(ip,port,'RETAKE:'+shot)
recording = True
@@ -227,12 +268,12 @@ class index:
time.sleep(1)
session.reload = 1
raise web.seeother('/')
- thumb="/static/Videos/"+name+"/scene"+str(scene).zfill(3)+"/shot"+str(shot).zfill(3)+"/picture"+str(take).zfill(3)+".jpeg"
+ thumb=filmfolder+name+"/scene"+str(scene).zfill(3)+"/shot"+str(shot).zfill(3)+"/picture"+str(take).zfill(3)+".jpeg"
print(thumb)
if os.path.isfile(basedir+thumb) == False:
print(basedir+thumb)
thumb=''
- return render.index(renderedfilms, unrenderedfilms, session.cameras, menu, selected,name,scene,shot,take,str,session.randhash,thumb,vumetermessage,i.func)
+ return render.index(renderedfilms, unrenderedfilms, session.cameras, menu, selected,name,scene,shot,take,str,session.randhash,thumb,vumetermessage,i.func,filmfolder)
class films:
def GET(self, film):
diff --git a/srv/templates/index.html b/srv/templates/index.html
@@ -1,4 +1,4 @@
-$def with (renderedfilms, unrenderedfilms, cameras, menu, selected,name,scene,shot,take,str,randhash,thumb,vumetermessage,func)
+$def with (renderedfilms, unrenderedfilms, cameras, menu, selected,name,scene,shot,take,str,randhash,thumb,vumetermessage,func,filmfolder)
$var renderedfilms = renderedfilms
$var unrenderedfilms = unrenderedfilms
<script>
@@ -50,14 +50,14 @@ $for m in menu[3:]:
<br>
</div>
$if thumb != '':
- $ picture="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/picture" + str(take).zfill(3) + ".jpeg"
+ $ picture=filmfolder + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/picture" + str(take).zfill(3) + ".jpeg"
$else:
- $ picture="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".jpeg"
+ $ picture=filmfolder + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".jpeg"
-$ take_link="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".mp4"
-$ scene_link="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/scene.mp4"
-$ film_link="static/Videos/" + name + "/" +name+ ".mp4"
+$ take_link=filmfolder + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".mp4"
+$ scene_link=filmfolder + name + "/scene" + str(scene).zfill(3) + "/scene.mp4"
+$ film_link=filmfolder + name + "/" +name+ ".mp4"
$if selected == 0:
<a href='$film_link'><img width="80%" src="$picture?$randhash"/></a><br>
$elif selected == 1:
@@ -71,15 +71,15 @@ $if func=='show_all_films':
$for i in renderedfilms:
<p>--------------------------------------------------------------</p>
<h2>$i</h2>
- <a href="static/Videos/$i/${i}.mp4"><img width="80%" src="static/Videos/$i/scene001/shot001/take001.jpeg?$randhash"/></a><br>
+ <a href="$filmfolder$i/${i}.mp4"><img width="80%" src="$filmfolder$i/scene001/shot001/take001.jpeg?$randhash"/></a><br>
<p>Copy project to your destination:</p>
- <pre>scp -r pi@tarina.local:~/Videos/$i ~/films/$i</pre>
+ <pre>scp -r pi@tarina.local:~$filmfolder$i ~/films/$i</pre>
<h1>Films unrendered</h1>
$for i in unrenderedfilms:
<h2>$i </h2>
<p>Copy project to your destination:</p>
- <pre>scp -r pi@tarina.local:~/Videos/$i ~/films/$i</pre>
+ <pre>scp -r pi@tarina.local:$filmfolder$i ~/films/$i</pre>
<script>
$$('#LEFT').on('click', function () { window.open('?func=left',"_self");return false; });