|
|
|
@ -5,7 +5,7 @@ import re |
|
|
|
from flask import Blueprint, current_app, escape, flash, render_template |
|
|
|
from flask import Blueprint, current_app, escape, flash, render_template |
|
|
|
from flask import jsonify |
|
|
|
from flask import jsonify |
|
|
|
|
|
|
|
|
|
|
|
from .. import util |
|
|
|
from .. import db, util |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VIDEO_EXTENSIONS = ['.avi', '.m4v', '.mkv', '.mp4', '.mpg'] |
|
|
|
VIDEO_EXTENSIONS = ['.avi', '.m4v', '.mkv', '.mp4', '.mpg'] |
|
|
|
@ -18,6 +18,7 @@ class path_entry: |
|
|
|
rel_path = '' # NOTE: fs path relative to config['MOVIE_DIR'] |
|
|
|
rel_path = '' # NOTE: fs path relative to config['MOVIE_DIR'] |
|
|
|
file_extension = '' |
|
|
|
file_extension = '' |
|
|
|
is_dir = False |
|
|
|
is_dir = False |
|
|
|
|
|
|
|
in_db = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/folder_contents/') |
|
|
|
@bp.route('/folder_contents/') |
|
|
|
@ -52,6 +53,7 @@ def getFolderJSON(subpath = ''): |
|
|
|
'rel_path': pe.rel_path, |
|
|
|
'rel_path': pe.rel_path, |
|
|
|
'file_extension': pe.file_extension, |
|
|
|
'file_extension': pe.file_extension, |
|
|
|
'is_dir': pe.is_dir, |
|
|
|
'is_dir': pe.is_dir, |
|
|
|
|
|
|
|
'in_db': pe.in_db, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return jsonify(errors=errors, paths=paths) |
|
|
|
return jsonify(errors=errors, paths=paths) |
|
|
|
@ -70,7 +72,14 @@ def getPathInfo(entry): |
|
|
|
|
|
|
|
|
|
|
|
if ext in VIDEO_EXTENSIONS: |
|
|
|
if ext in VIDEO_EXTENSIONS: |
|
|
|
pe.file_extension = ext |
|
|
|
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: |
|
|
|
else: |
|
|
|
return None |
|
|
|
return None |
|
|
|
return pe |
|
|
|
return pe |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|