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"> <div class="title-bar">
<h1>Settings</h1> <h1>Settings</h1>
</div> </div>
<form action="/settings/" method="POST"> <form action="/settings/" method="POST" name="settings-update">
{% csrf_token %} {% csrf_token %}
<div class="settings-group"> <div class="settings-group">
<h2>Color scheme</h2> <h2>Color scheme</h2>
@ -113,11 +113,14 @@
<h1>Actions</h1> <h1>Actions</h1>
</div> </div>
<div class="settings-group"> <div class="settings-group">
<p>Rescan filesystem.</p> <h2>Manual media files import.</h2>
<i>Coming soon</i> <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>
<div class="settings-group"> <div class="settings-group">
<p>Manual media files import.</p> <p>Rescan filesystem.</p>
<i>Coming soon</i> <i>Coming soon</i>
</div> </div>
<div class="settings-group"> <div class="settings-group">

View File

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

View File

@ -79,6 +79,19 @@ function downloadNow(button) {
}, 500); }, 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 // player
function createPlayer(button) { function createPlayer(button) {
var mediaUrl = button.getAttribute('data-src'); var mediaUrl = button.getAttribute('data-src');