Update webinterface

This commit is contained in:
Arti Zirk 2016-11-02 00:06:44 +02:00
parent 5700749105
commit d82f7f0bb2
3 changed files with 33 additions and 7 deletions

View File

@ -1,3 +1,7 @@
body {
padding-top: 70px;
}
.thumbnail>img {
box-shadow: 0px 2px 10px #000;
}

View File

@ -19,7 +19,7 @@
<div class="form-group" style="display:inline;">
<div class="input-group" style="display:table;padding-right:10px;padding-left: 10px;">
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
<input class="form-control" name="search" placeholder="Otsi filme" autocomplete="on" autofocus="autofocus" type="text" value="{{search}}">
<input class="form-control" name="search" placeholder="Otsi filme" autocomplete="on" type="text" value="{{search}}">
</div>
</div>

View File

@ -1,4 +1,5 @@
import os
import re
import json
from flask import Flask
from flask import render_template
@ -19,13 +20,13 @@ def gen_play_movie_url(movie_type, movie_name):
for movie_file in movie_files:
sizes.append((os.path.getsize(movie_dir+'/'+movie_name+'/'+movie_file), movie_file))
file_name = sorted(sizes)[-1][1]
return 'http://karu/kraam/Filmid/Nimed/{}/{}'.format(movie_name.replace(" ", "%20"),
return 'https://media.arti.ee/Filmid/{}/{}'.format(movie_name.replace(" ", "%20"),
file_name.replace(" ", "%20")), 200, {'Content-Type': 'audio/mpegurl; charset=utf-8'}
#@app.route('/')
@app.route('/')
@app.route('/movies/')
def show_movies():
key = request.args.get("sort", "Viimati lisatud")
key = request.args.get("sort", "")
if key.startswith("-"):
reverse = True
key = key[1:]
@ -33,8 +34,29 @@ def show_movies():
reverse = False
if key == "Aastad":
reverse = not reverse
movies = sorted(os.listdir(movie_base+"/"+key), reverse=reverse)
movies = (os.path.realpath(movie_base+"/"+key+"/"+movie).split("/")[-1] for movie in movies)
movies = []
if key == "Aastad":
movies = sorted(((year, movie) for movie, year in (g.groups() for g in (re.search("(.*)\((\d{4})\)", movie_full) for movie_full in os.listdir(movie_base)) if g)), reverse=reverse)
movies = ["{} ({})".format(movie[1].strip(), movie[0].strip()) for movie in movies]
elif key == "Viimati lisatud":
movies = []
movies_to_sort = []
for movie in os.listdir(movie_base):
movie_files = os.listdir(movie_base+'/'+movie)
sizes = []
for movie_file in movie_files:
sizes.append((os.path.getsize(movie_base+'/'+movie+'/'+movie_file), movie_file))
file_name = sorted(sizes)[-1][1]
stat = os.stat(movie_base+"/"+movie+"/"+file_name)
st_atime = stat.st_atime
st_mtime = stat.st_mtime
st_ctime = stat.st_ctime
#print(st_atime, "\t", st_mtime, "\t", st_ctime)
movies_to_sort.append((int(st_atime), movie))
movies = (movie for atime, movie in sorted(movies_to_sort, reverse=reverse))
else:
movies = sorted(os.listdir(movie_base), reverse=reverse)
movies = (os.path.realpath(movie_base+"/"+movie).split("/")[-1] for movie in movies)
search = ""
if request.args.get("search"):
search = str(request.args.get("search").lower())