forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.php
162 lines (144 loc) · 7.31 KB
/
import.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
if (!User::canUpload() || !empty($advancedCustom->doNotShowImportMP4Button)) {
return false;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>">
<head>
<title><?php echo __("Import") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">Import Local Videos</div>
<div class="panel-body">
<div class="alert alert-info">
<i class="fas fa-question-circle"></i>
Here you can direct import multiple videos stored on your hard drive.<br>
If there is a file (html or htm or txt) we will import it's content as a description, and the first
<input type="number" id="length" value="100" style="width: 70px;" /> characteres will be the file title. (choose 0 to use the file name as the title)
</div>
<div class="form-group">
<div class="checkbox">
<label><input type="checkbox" value="delete" id="delete" checked="true"> <?php echo __("Delete files after submit"); ?></label>
</div>
</div>
<div class="form-group">
<div class="input-group">
<input type="text" id="path" class="form-control" placeholder="Local Path of videos i.e. /media/videos"/>
<span class="input-group-btn">
<button class="btn btn-default" id="pathBtn">
<span class="glyphicon glyphicon-list"></span> <?php echo __("List Files"); ?>
</button>
</span>
<span class="input-group-btn">
<button class="btn btn-default" id="checkBtn">
<i class="far fa-check-square" aria-hidden="true"></i>
</button>
</span>
<span class="input-group-btn">
<button class="btn btn-default" id="uncheckBtn">
<i class="far fa-square" aria-hidden="true"></i>
</button>
</span>
</div>
</div>
<div class="form-group">
<select class="form-control" id="bulk_categories_id" name="bulk_categories_id">
<option value="0">Category - Use site default</option>
<?php
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->name . '</option>';
}
?>
</select>
</div>
<ul class="list-group" id="files">
</ul>
<button class="btn btn-block btn-primary" id="addQueueBtn"><?php echo __("Direct Import all"); ?></button>
</div>
</div>
</div><!--/.container-->
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script>
function checkFiles() {
var path = $('#path').val();
if (!path) {
return false;
}
$.ajax({
url: webSiteRootURL + 'objects/listFiles.json.php',
data: {"path": path},
type: 'post',
success: function (response) {
$('#files').empty();
if (response) {
for (i = 0; i < response.length; i++) {
if (!response[i])
continue;
$('#files').append('<li class="list-group-item" path="' + response[i].path + '" id="li' + i + '"><span class="label label-success" style="display: none;"><span class="glyphicon glyphicon-ok"></span> Added on queue.. </span> ' + response[i].name + '<div class="material-switch pull-right"><input id="someSwitchOption' + response[i].id + '" class="someSwitchOption" type="checkbox"/><label for="someSwitchOption' + response[i].id + '" class="label-primary"></label></div></li>');
}
}
}
});
}
var importing = 0;
$(document).ready(function () {
$("#checkBtn").click(function () {
$('#files').find('input:checkbox').prop('checked', true);
});
$("#uncheckBtn").click(function () {
$('#files').find('input:checkbox').prop('checked', false);
});
$("#pathBtn").click(function () {
checkFiles();
});
$("#addQueueBtn").click(function () {
importing = 0;
modal.showPleaseWait();
$('#files li').each(function () {
if ($(this).find('.someSwitchOption').is(":checked")) {
importing++;
console.log("+ "+importing);
var id = $(this).attr('id');
$.ajax({
url: webSiteRootURL + 'objects/import.json.php',
data: {
"fileURI": $(this).attr('path'),
"categories_id": $('#bulk_categories_id').val(),
"length": $('#length').val(),
"delete": $('#delete').is(":checked")
},
type: 'post',
success: function (response) {
importing--;
console.log("- "+importing);
$('#' + id).find('.label').fadeIn();
if (!importing) {
modal.hidePleaseWait();
}
}
});
}
});
if(!importing){
modal.hidePleaseWait();
}
});
});
</script>
</body>
</html>