mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
show ignored videos, forget or download ids
This commit is contained in:
parent
f5a56fca86
commit
2905a67ab9
@ -23,6 +23,8 @@ def sync_redis_state():
|
||||
redis_archivist.set_message(
|
||||
"show_subed_only", show_subed_only, expire=False
|
||||
)
|
||||
filter_view = config["archive"]["filter_view"]
|
||||
redis_archivist.set_message("filter_view", filter_view, expire=False)
|
||||
|
||||
|
||||
def make_folders():
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"archive": {
|
||||
"sort": "published",
|
||||
"filter_view": "pending",
|
||||
"hide_watched": false,
|
||||
"show_subed_only": false,
|
||||
"page_size": 12
|
||||
|
@ -27,30 +27,51 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="padding-box">
|
||||
<span>Change show / hide ignored only </span><span class="settings-current">{{ filter_view }}</span>
|
||||
<select name="showIgnoredOnly" id="showIgnoredOnly" onchange="showIgnoredOnly(this.value)">
|
||||
<option value="" disabled selected> -- change -- </option>
|
||||
<option value="ignore">show ignored only</option>
|
||||
<option value="pending">show download queue</option>
|
||||
</select>
|
||||
</div>
|
||||
{% if filter_view == "ignore" %}
|
||||
<h2>Ignored from download</h2>
|
||||
{% else %}
|
||||
<h2>Download queue</h2>
|
||||
{% endif %}
|
||||
<div>
|
||||
{% if pending %}
|
||||
<h3>Total pending downloads: {{ max_hits }}</h3>
|
||||
{% for video in pending %}
|
||||
{% if all_video_hits %}
|
||||
<h3>Total videos found: {{ max_hits }}</h3>
|
||||
{% for video in all_video_hits %}
|
||||
<div class="dl-item" id="dl-{{ video.youtube_id }}">
|
||||
<div class="dl-thumb">
|
||||
<img src="{{ video.vid_thumb_url }}" alt="video_thumb">
|
||||
</div>
|
||||
<div class="dl-desc">
|
||||
<h3>{{ video.title }}</h3>
|
||||
{% if filter_view == "ignore" %}
|
||||
<h3>Ignore: {{ video.title }}</h3>
|
||||
{% else %}
|
||||
<h3>Download: {{ video.title }}</h3>
|
||||
{% endif %}
|
||||
{% if video.channel_indexed %}
|
||||
<a href="{% url 'channel_id' video.channel_id %}">{{ video.channel_name }}</a>
|
||||
{% else %}
|
||||
<span>{{ video.channel_name }}</span>
|
||||
{% endif %}
|
||||
<p>Published: {{ video.published }} | Duration: {{ video.duration }} | {{ video.youtube_id }}</p>
|
||||
{% if filter_view == "ignore" %}
|
||||
<button data-id="{{ video.youtube_id }}" onclick="forgetIgnore(this)">Forget</button>
|
||||
<button data-id="{{ video.youtube_id }}" onclick="addSingle(this)">Add to queue</button>
|
||||
{% else %}
|
||||
<button data-id="{{ video.youtube_id }}" onclick="toIgnore(this)">Ignore</button>
|
||||
<button id="{{ video.youtube_id }}" data-id="{{ video.youtube_id }}" onclick="downloadNow(this)">Download now</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<h3>No pending downloads</h3>
|
||||
<h3>No videos found</h3>
|
||||
{% endif %}
|
||||
</div>
|
||||
<script type="text/javascript" src="{% static 'progress.js' %}"></script>
|
||||
|
@ -144,43 +144,45 @@ class DownloadView(View):
|
||||
"""handle get requests"""
|
||||
config = AppConfig().config
|
||||
colors = config["application"]["colors"]
|
||||
filter_view = RedisArchivist().get_message("filter_view")
|
||||
|
||||
page_get = int(request.GET.get("page", 0))
|
||||
pagination_handler = Pagination(page_get)
|
||||
|
||||
url = config["application"]["es_url"] + "/ta_download/_search"
|
||||
data = self.build_data(pagination_handler)
|
||||
data = self.build_data(pagination_handler, filter_view)
|
||||
search = SearchHandler(url, data, cache=False)
|
||||
|
||||
videos_hits = search.get_data()
|
||||
max_hits = search.max_hits
|
||||
|
||||
if videos_hits:
|
||||
all_pending = [i["source"] for i in videos_hits]
|
||||
all_video_hits = [i["source"] for i in videos_hits]
|
||||
pagination_handler.validate(max_hits)
|
||||
pagination = pagination_handler.pagination
|
||||
else:
|
||||
all_pending = False
|
||||
all_video_hits = False
|
||||
pagination = False
|
||||
|
||||
context = {
|
||||
"pending": all_pending,
|
||||
"all_video_hits": all_video_hits,
|
||||
"max_hits": max_hits,
|
||||
"pagination": pagination,
|
||||
"title": "Downloads",
|
||||
"colors": colors,
|
||||
"filter_view": filter_view,
|
||||
}
|
||||
return render(request, "home/downloads.html", context)
|
||||
|
||||
@staticmethod
|
||||
def build_data(pagination_handler):
|
||||
def build_data(pagination_handler, filter_view):
|
||||
"""build data dict for search"""
|
||||
page_size = pagination_handler.pagination["page_size"]
|
||||
page_from = pagination_handler.pagination["page_from"]
|
||||
data = {
|
||||
"size": page_size,
|
||||
"from": page_from,
|
||||
"query": {"term": {"status": {"value": "pending"}}},
|
||||
"query": {"term": {"status": {"value": filter_view}}},
|
||||
"sort": [{"timestamp": {"order": "asc"}}],
|
||||
}
|
||||
return data
|
||||
@ -481,6 +483,9 @@ class PostData:
|
||||
"hide_watched": self.hide_watched,
|
||||
"show_subed_only": self.show_subed_only,
|
||||
"dlnow": self.dlnow,
|
||||
"show_ignored_only": self.show_ignored_only,
|
||||
"forgetIgnore": self.forget_ignore,
|
||||
"addSingle": self.add_single,
|
||||
"manual-import": self.manual_import,
|
||||
"db-backup": self.db_backup,
|
||||
"db-restore": self.db_restore,
|
||||
@ -577,6 +582,29 @@ class PostData:
|
||||
RedisArchivist().set_message("dl_queue_id", task_id, expire=False)
|
||||
return {"success": True}
|
||||
|
||||
def show_ignored_only(self):
|
||||
"""switch view on /downloads/ to show ignored only"""
|
||||
show_value = self.exec_val
|
||||
print("Download view: " + show_value)
|
||||
RedisArchivist().set_message("filter_view", show_value, expire=False)
|
||||
return {"success": True}
|
||||
|
||||
def forget_ignore(self):
|
||||
"""delete from ta_download index"""
|
||||
youtube_id = self.exec_val
|
||||
print("forgetting from download index: " + youtube_id)
|
||||
PendingList().delete_from_pending(youtube_id)
|
||||
return {"success": True}
|
||||
|
||||
def add_single(self):
|
||||
"""add single youtube_id to download queue"""
|
||||
youtube_id = self.exec_val
|
||||
print("add vid to dl queue: " + youtube_id)
|
||||
PendingList().delete_from_pending(youtube_id)
|
||||
youtube_ids = process_url_list([youtube_id])
|
||||
extrac_dl.delay(youtube_ids)
|
||||
return {"success": True}
|
||||
|
||||
@staticmethod
|
||||
def manual_import():
|
||||
"""run manual import from settings page"""
|
||||
|
@ -79,6 +79,35 @@ function downloadNow(button) {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function showIgnoredOnly(showValue) {
|
||||
var payload = JSON.stringify({'show_ignored_only': showValue});
|
||||
console.log(payload);
|
||||
sendPost(payload);
|
||||
setTimeout(function(){
|
||||
window.location.replace("/downloads/");
|
||||
return false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function forgetIgnore(button) {
|
||||
var youtube_id = button.getAttribute('data-id');
|
||||
var payload = JSON.stringify({'forgetIgnore': youtube_id});
|
||||
console.log(payload);
|
||||
sendPost(payload);
|
||||
document.getElementById("dl-" + youtube_id).remove();
|
||||
}
|
||||
|
||||
function addSingle(button) {
|
||||
var youtube_id = button.getAttribute('data-id');
|
||||
var payload = JSON.stringify({'addSingle': youtube_id});
|
||||
console.log(payload);
|
||||
sendPost(payload);
|
||||
document.getElementById("dl-" + youtube_id).remove();
|
||||
setTimeout(function(){
|
||||
handleInterval();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function stopQueue() {
|
||||
var payload = JSON.stringify({'queue': 'stop'});
|
||||
sendPost(payload);
|
||||
|
Loading…
Reference in New Issue
Block a user