pull/1038/head
Louis Vézina 4 years ago
parent 487434c9fc
commit d0d3a0a3d9

@ -37,7 +37,7 @@ from filesystem import browse_bazarr_filesystem, browse_sonarr_filesystem, brows
from subliminal_patch.core import SUBTITLE_EXTENSIONS
from flask import Flask, jsonify, request, Response, Blueprint, url_for
from flask import Flask, jsonify, request, Response, Blueprint, url_for, make_response
from flask_restful import Resource, Api, abort
from functools import wraps
@ -1440,23 +1440,34 @@ class SyncSubtitles(Resource):
class BrowseBazarrFS(Resource):
@authenticate
def get(self):
path = request.args.get('path') or ''
path = request.args.get('id') or ''
data = []
result = browse_bazarr_filesystem(path)
return jsonify(result)
for item in result['directories']:
data.append({'id': item['name'], 'parent': result['parent'], 'children': True})
return jsonify(data=data)
class BrowseSonarrFS(Resource):
@authenticate
def get(self):
path = request.args.get('path') or ''
return jsonify(browse_sonarr_filesystem(path))
path = request.args.get('id') or ''
data = []
result = browse_sonarr_filesystem(path)
for item in result['directories']:
data.append({'id': item['name'], 'parent': result['parent'] if 'parent' in result else '#'})
return jsonify(data=data)
class BrowseRadarrFS(Resource):
@authenticate
def get(self):
path = request.args.get('path') or ''
return jsonify(browse_radarr_filesystem(path))
path = request.args.get('id') or ''
data = []
result = browse_radarr_filesystem(path)
for item in result['directories']:
data.append({'id': item['name'], 'parent': result['parent'] if 'parent' in result else '#'})
return jsonify(data=data)
api.add_resource(Shutdown, '/shutdown')

@ -6,8 +6,8 @@ import string
from config import settings, url_sonarr, url_radarr
def browse_bazarr_filesystem(path=''):
if path == '' or path == '/':
def browse_bazarr_filesystem(path='#'):
if path == '#' or path == '/' or path == '':
if os.name == 'nt':
dir_list = []
for drive in string.ascii_uppercase:
@ -32,13 +32,17 @@ def browse_bazarr_filesystem(path=''):
parent = os.path.dirname(path)
result = {'directories': data}
if parent != path:
if path == '#':
result.update({'parent': '#'})
else:
result.update({'parent': parent})
return result
def browse_sonarr_filesystem(path=''):
def browse_sonarr_filesystem(path='#'):
if path == '#':
path = ''
url_sonarr_api_filesystem = url_sonarr() + "/api/filesystem?path=" + path + \
"&allowFoldersWithoutTrailingSlashes=true&includeFiles=false&apikey=" + \
settings.sonarr.apikey
@ -61,7 +65,10 @@ def browse_sonarr_filesystem(path=''):
return r.json()
def browse_radarr_filesystem(path=''):
def browse_radarr_filesystem(path='#'):
if path == '#':
path = ''
url_radarr_api_filesystem = url_radarr() + "/api/filesystem?path=" + path + \
"&allowFoldersWithoutTrailingSlashes=true&includeFiles=false&apikey=" + \
settings.radarr.apikey

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -41,6 +41,7 @@
<link rel="stylesheet" href="{{ url_for('static',filename='css/bootstrap-slider.min.css') }}"/>
<link rel="stylesheet" href="{{ url_for('static',filename='css/jquery.typeahead.min.css') }}"/>
<link rel="stylesheet" href="{{ url_for('static',filename='css/Chart.min.css') }}"/>
<link rel="stylesheet" href="{{ url_for('static',filename='jstree/themes/default/style.min.css') }}"/>
{% endblock head_css %}
@ -332,6 +333,7 @@
<script src="{{ url_for('static',filename='moment/moment.js') }}"></script>
<script src="{{ url_for('static',filename='js/jquery.typeahead.min.js') }}"></script>
<script src="{{ url_for('static',filename='js/Chart.min.js') }}"></script>
<script src="{{ url_for('static',filename='jstree/jstree.min.js') }}"></script>
<script>
{% if not request.endpoint == 'login_page' %}

@ -171,6 +171,7 @@
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="add_path_sonarr" name="add_path_sonarr" value="">
<div id="sonarr_browser"></div>
</div>
</div>
<br>
@ -180,6 +181,7 @@
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="add_path_bazarr" name="add_path_bazarr" value="">
<div id="bazarr_browser"></div>
</div>
</div>
</div>
@ -411,6 +413,21 @@
form_changed = true;
$('#save_button').prop('disabled', false).css('cursor', 'auto');
})
$('#sonarr_browser').jstree({
'core' : {
'data' : {
'url' : '{{ url_for('api.browsesonarrfs') }}'
}
}
});
$('#bazarr_browser').jstree({
'core' : {
'data' : {
'url' : '{{ url_for('api.browsebazarrfs') }}'
}
}
});
});
</script>
{% endblock tail %}

Loading…
Cancel
Save