Browse Source

add indication if path is stored in db

master
cinnaboot 7 years ago
parent
commit
9b02be1ebd
  1. 5
      video_metadata/static/file_listing.js
  2. 1
      video_metadata/static/style.css
  3. 11
      video_metadata/views/file_listing.py

5
video_metadata/static/file_listing.js

@ -17,7 +17,10 @@ function addContents(node, json) {
if (json.is_dir)
a.classList.add('folder');
else
a.classList.add('file');
if (json.in_db)
a.classList.add('file_stored');
else
a.classList.add('file');
a.appendChild(document.createTextNode(json.base_name));
li.appendChild(a);

1
video_metadata/static/style.css

@ -25,3 +25,4 @@ input.danger { color: #cc2f2e; }
.content li { list-style: ' - '; }
.folder { background: lightblue; }
.file { background: orange; }
.file_stored { background: lightgreen; }

11
video_metadata/views/file_listing.py

@ -5,7 +5,7 @@ import re
from flask import Blueprint, current_app, escape, flash, render_template
from flask import jsonify
from .. import util
from .. import db, util
VIDEO_EXTENSIONS = ['.avi', '.m4v', '.mkv', '.mp4', '.mpg']
@ -18,6 +18,7 @@ class path_entry:
rel_path = '' # NOTE: fs path relative to config['MOVIE_DIR']
file_extension = ''
is_dir = False
in_db = False
@bp.route('/folder_contents/')
@ -52,6 +53,7 @@ def getFolderJSON(subpath = ''):
'rel_path': pe.rel_path,
'file_extension': pe.file_extension,
'is_dir': pe.is_dir,
'in_db': pe.in_db,
})
return jsonify(errors=errors, paths=paths)
@ -70,7 +72,14 @@ def getPathInfo(entry):
if ext in VIDEO_EXTENSIONS:
pe.file_extension = ext
# check if the path is already stored in db
cur = db.get_db().cursor()
cur.execute('SELECT COUNT(*) FROM movie_paths WHERE movie_path = ?',
(pe.rel_path, )
)
pe.in_db = cur.fetchone()[0] > 0
else:
return None
return pe
return None

Loading…
Cancel
Save