|
|
|
@ -36,7 +36,7 @@ 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.config import AppConfig, ReleaseVersion, ScheduleBuilder
|
|
|
|
|
from home.src.ta.helper import UrlListParser, time_parser
|
|
|
|
|
from home.src.ta.ta_redis import RedisArchivist
|
|
|
|
|
from home.tasks import extrac_dl, index_channel_playlists, subscribe_to
|
|
|
|
@ -138,6 +138,7 @@ class ArchivistViewConfig(View):
|
|
|
|
|
"show_ignored_only": self._get_show_ignore_only(),
|
|
|
|
|
"show_subed_only": self._get_show_subed_only(),
|
|
|
|
|
"version": settings.TA_VERSION,
|
|
|
|
|
"ta_update": ReleaseVersion().get_update(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -257,6 +258,19 @@ class ArchivistResultsView(ArchivistViewConfig):
|
|
|
|
|
self.context["pagination"] = self.pagination_handler.pagination
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MinView(View):
|
|
|
|
|
"""to inherit from for minimal config vars"""
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get_min_context(request):
|
|
|
|
|
"""build minimal vars for context"""
|
|
|
|
|
return {
|
|
|
|
|
"colors": AppConfig(request.user.id).colors,
|
|
|
|
|
"version": settings.TA_VERSION,
|
|
|
|
|
"ta_update": ReleaseVersion().get_update(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HomeView(ArchivistResultsView):
|
|
|
|
|
"""resolves to /
|
|
|
|
|
handle home page and video search post functionality
|
|
|
|
@ -298,20 +312,23 @@ class HomeView(ArchivistResultsView):
|
|
|
|
|
self.data["query"] = query
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LoginView(View):
|
|
|
|
|
class LoginView(MinView):
|
|
|
|
|
"""resolves to /login/
|
|
|
|
|
Greeting and login page
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
SEC_IN_DAY = 60 * 60 * 24
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get(request):
|
|
|
|
|
def get(self, request):
|
|
|
|
|
"""handle get requests"""
|
|
|
|
|
failed = bool(request.GET.get("failed"))
|
|
|
|
|
colors = AppConfig(request.user.id).colors
|
|
|
|
|
form = CustomAuthForm()
|
|
|
|
|
context = {"colors": colors, "form": form, "form_error": failed}
|
|
|
|
|
context = self.get_min_context(request)
|
|
|
|
|
context.update(
|
|
|
|
|
{
|
|
|
|
|
"form": CustomAuthForm(),
|
|
|
|
|
"form_error": bool(request.GET.get("failed")),
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return render(request, "home/login.html", context)
|
|
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
@ -333,19 +350,15 @@ class LoginView(View):
|
|
|
|
|
return redirect("/login?failed=true")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AboutView(View):
|
|
|
|
|
class AboutView(MinView):
|
|
|
|
|
"""resolves to /about/
|
|
|
|
|
show helpful how to information
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get(request):
|
|
|
|
|
def get(self, request):
|
|
|
|
|
"""handle http get"""
|
|
|
|
|
context = {
|
|
|
|
|
"title": "About",
|
|
|
|
|
"colors": AppConfig(request.user.id).colors,
|
|
|
|
|
"version": settings.TA_VERSION,
|
|
|
|
|
}
|
|
|
|
|
context = self.get_min_context(request)
|
|
|
|
|
context.update({"title": "About"})
|
|
|
|
|
return render(request, "home/about.html", context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -843,7 +856,7 @@ class PlaylistView(ArchivistResultsView):
|
|
|
|
|
return redirect("playlist")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VideoView(View):
|
|
|
|
|
class VideoView(MinView):
|
|
|
|
|
"""resolves to /video/<video-id>/
|
|
|
|
|
display details about a single video
|
|
|
|
|
"""
|
|
|
|
@ -869,17 +882,18 @@ class VideoView(View):
|
|
|
|
|
request_type="video", request_id=video_id
|
|
|
|
|
).get_progress()
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
|
context = self.get_min_context(request)
|
|
|
|
|
context.update(
|
|
|
|
|
{
|
|
|
|
|
"video": video_data,
|
|
|
|
|
"playlist_nav": playlist_nav,
|
|
|
|
|
"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": time_parser(request.GET.get("t")),
|
|
|
|
|
"reindex": reindex.get("state"),
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
return render(request, "home/video.html", context)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@ -936,7 +950,7 @@ class SearchView(ArchivistResultsView):
|
|
|
|
|
return render(request, "home/search.html", self.context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsView(View):
|
|
|
|
|
class SettingsView(MinView):
|
|
|
|
|
"""resolves to /settings/
|
|
|
|
|
handle the settings page, display current settings,
|
|
|
|
|
take post request from the form to update settings
|
|
|
|
@ -944,28 +958,19 @@ class SettingsView(View):
|
|
|
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
|
"""read and display current settings"""
|
|
|
|
|
config_handler = AppConfig(request.user.id)
|
|
|
|
|
colors = config_handler.colors
|
|
|
|
|
|
|
|
|
|
available_backups = ElasticBackup().get_all_backup_files()
|
|
|
|
|
user_form = UserSettingsForm()
|
|
|
|
|
app_form = ApplicationSettingsForm()
|
|
|
|
|
scheduler_form = SchedulerSettingsForm()
|
|
|
|
|
snapshots = ElasticSnapshot().get_snapshot_stats()
|
|
|
|
|
token = self.get_token(request)
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
|
context = self.get_min_context(request)
|
|
|
|
|
context.update(
|
|
|
|
|
{
|
|
|
|
|
"title": "Settings",
|
|
|
|
|
"config": config_handler.config,
|
|
|
|
|
"api_token": token,
|
|
|
|
|
"colors": colors,
|
|
|
|
|
"available_backups": available_backups,
|
|
|
|
|
"user_form": user_form,
|
|
|
|
|
"app_form": app_form,
|
|
|
|
|
"scheduler_form": scheduler_form,
|
|
|
|
|
"snapshots": snapshots,
|
|
|
|
|
"version": settings.TA_VERSION,
|
|
|
|
|
"config": AppConfig(request.user.id).config,
|
|
|
|
|
"api_token": self.get_token(request),
|
|
|
|
|
"available_backups": ElasticBackup().get_all_backup_files(),
|
|
|
|
|
"user_form": UserSettingsForm(),
|
|
|
|
|
"app_form": ApplicationSettingsForm(),
|
|
|
|
|
"scheduler_form": SchedulerSettingsForm(),
|
|
|
|
|
"snapshots": ElasticSnapshot().get_snapshot_stats(),
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return render(request, "home/settings.html", context)
|
|
|
|
|
|
|
|
|
|