added media files import to frontend and tasks

This commit is contained in:
simon 2021-09-14 18:24:02 +07:00
parent 6e9cdda07e
commit 297eb058cc
3 changed files with 26 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<div class="title-bar">
<h1>Settings</h1>
</div>
<form action="/settings/" method="POST">
<form action="/settings/" method="POST" name="settings-update">
{% csrf_token %}
<div class="settings-group">
<h2>Color scheme</h2>
@ -113,11 +113,14 @@
<h1>Actions</h1>
</div>
<div class="settings-group">
<p>Rescan filesystem.</p>
<i>Coming soon</i>
<h2>Manual media files import.</h2>
<p>Add files to the cache/import folder. Make sure to follow the instructions on Github.</p>
<div id="manual-import">
<button onclick="manualImport()">Start import</button>
</div>
</div>
<div class="settings-group">
<p>Manual media files import.</p>
<p>Rescan filesystem.</p>
<i>Coming soon</i>
</div>
<div class="settings-group">

View File

@ -30,7 +30,8 @@ from home.tasks import (
update_subscribed,
download_pending,
extrac_dl,
download_single
download_single,
run_manual_import
)
@ -428,7 +429,7 @@ class PostData:
VALID_KEYS = [
"watched", "rescan_pending", "ignore", "dl_pending",
"unsubscribe", "sort_order", "hide_watched", "show_subed_only",
"channel-search", "video-search", "dlnow"
"channel-search", "video-search", "dlnow", "manual-import"
]
def __init__(self, post_dict):
@ -497,6 +498,9 @@ class PostData:
youtube_id = item['status']
print('downloading: ' + youtube_id)
download_single(youtube_id)
elif task == 'manual-import':
print('starting manual import')
run_manual_import.delay()
return {'success': True}
def search_channels(self, search_query):

View File

@ -79,6 +79,19 @@ function downloadNow(button) {
}, 500);
}
// settings page buttons
function manualImport() {
var payload = JSON.stringify({'manual-import': true});
console.log(payload);
sendPost(payload);
// clear button
var message = document.createElement('p');
message.innerText = 'processing import';
var toReplace = document.getElementById('manual-import');
toReplace.innerHTML = '';
toReplace.appendChild(message);
}
// player
function createPlayer(button) {
var mediaUrl = button.getAttribute('data-src');