diff --git a/tubearchivist/home/templates/home/channel_id_about.html b/tubearchivist/home/templates/home/channel_id_about.html index 5c6ac892..9f227b0a 100644 --- a/tubearchivist/home/templates/home/channel_id_about.html +++ b/tubearchivist/home/templates/home/channel_id_about.html @@ -47,10 +47,20 @@ {% elif channel_info.channel_views > 0 %}

Channel views: {{ channel_info.channel_views|intcomma }}

{% endif %} - -
- Delete {{ channel_info.channel_name }} including all videos? +
+ +
+ Delete {{ channel_info.channel_name }} including all videos? +
+ {% if reindex %} +

Reindex scheduled

+ {% else %} +
+ + +
+ {% endif %}
diff --git a/tubearchivist/home/templates/home/playlist_id.html b/tubearchivist/home/templates/home/playlist_id.html index ca7a6c00..92a450dd 100644 --- a/tubearchivist/home/templates/home/playlist_id.html +++ b/tubearchivist/home/templates/home/playlist_id.html @@ -52,6 +52,14 @@

Total Videos archived: {{ max_hits }}/{{ playlist_info.playlist_entries|length }}

Watched:

{% endif %} + {% if reindex %} +

Reindex scheduled

+ {% else %} +
+ + +
+ {% endif %} diff --git a/tubearchivist/home/templates/home/video.html b/tubearchivist/home/templates/home/video.html index a5784231..904f8a34 100644 --- a/tubearchivist/home/templates/home/video.html +++ b/tubearchivist/home/templates/home/video.html @@ -56,10 +56,19 @@ {% else %}

Youtube: Deactivated

{% endif %} - - -
- Are you sure? + {% if reindex %} +

Reindex scheduled

+ {% else %} +
+ +
+ {% endif %} +
+ + +
+ Are you sure? +
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 18810ad9..a305bbe2 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -35,6 +35,7 @@ from home.src.frontend.searching import SearchHandler from home.src.index.channel import YoutubeChannel, channel_overwrites from home.src.index.generic import Pagination from home.src.index.playlist import YoutubePlaylist +from home.src.index.reindex import ReindexProgress from home.src.ta.config import AppConfig, ScheduleBuilder from home.src.ta.helper import UrlListParser, time_parser from home.src.ta.ta_redis import RedisArchivist @@ -569,17 +570,18 @@ class ChannelIdAboutView(ChannelIdBaseView): self.initiate_vars(request) self.channel_has_pending(channel_id) - path = f"ta_channel/_doc/{channel_id}" - response, _ = ElasticWrap(path).get() - + response, _ = ElasticWrap(f"ta_channel/_doc/{channel_id}").get() channel_info = SearchProcess(response).process() - channel_name = channel_info["channel_name"] + reindex = ReindexProgress( + request_type="channel", request_id=channel_id + ).get_progress() self.context.update( { - "title": "Channel: About " + channel_name, + "title": "Channel: About " + channel_info["channel_name"], "channel_info": channel_info, "channel_overwrite_form": ChannelOverwriteForm, + "reindex": reindex.get("state"), } ) @@ -706,12 +708,17 @@ class PlaylistIdView(ArchivistResultsView): self._update_view_data(playlist_id, playlist_info) self.find_results() self.match_progress() + reindex = ReindexProgress( + request_type="playlist", request_id=playlist_id + ).get_progress() + self.context.update( { "title": "Playlist: " + playlist_name, "playlist_info": playlist_info, "playlist_name": playlist_name, "channel_info": channel_info, + "reindex": reindex.get("state"), } ) return render(request, "home/playlist_id.html", self.context) @@ -844,11 +851,8 @@ class VideoView(View): def get(self, request, video_id): """get single video""" config_handler = AppConfig(request.user.id) - position = time_parser(request.GET.get("t")) - path = f"ta_video/_doc/{video_id}" - look_up = SearchHandler(path, config=False) - video_hit = look_up.get_data() - video_data = video_hit[0]["source"] + look_up = SearchHandler(f"ta_video/_doc/{video_id}", config=False) + video_data = look_up.get_data()[0]["source"] try: rating = video_data["stats"]["average_rating"] video_data["stats"]["average_rating"] = self.star_creator(rating) @@ -861,16 +865,20 @@ class VideoView(View): else: playlist_nav = False - video_title = video_data["title"] + reindex = ReindexProgress( + request_type="video", request_id=video_id + ).get_progress() + context = { "video": video_data, "playlist_nav": playlist_nav, - "title": video_title, + "title": video_data.get("title"), "colors": config_handler.colors, "cast": config_handler.config["application"]["enable_cast"], "version": settings.TA_VERSION, "config": config_handler.config, - "position": position, + "position": time_parser(request.GET.get("t")), + "reindex": reindex.get("state"), } return render(request, "home/video.html", context) diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index 1e4763bf..4e747951 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -119,6 +119,10 @@ button:hover { color: var(--main-bg); } +.button-box { + padding: 5px 0; +} + .unsubscribe { background-color: var(--accent-font-light); } diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index aec85661..09a8580c 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -147,6 +147,24 @@ function toggleCheckbox(checkbox) { }, 500); } +// start reindex task +function reindex(button) { + let apiEndpoint = '/api/refresh/'; + if (button.getAttribute('data-extract-videos')) { + apiEndpoint += '?extract_videos=true'; + } + let type = button.getAttribute('data-type'); + let id = button.getAttribute('data-id'); + + let data = {}; + data[type] = [id]; + + apiRequest(apiEndpoint, 'POST', data); + let message = document.createElement('p'); + message.innerText = 'Reindex scheduled'; + document.getElementById('reindex-button').replaceWith(message); +} + // download page buttons function rescanPending() { let payload = JSON.stringify({ rescan_pending: true });