From fcc1c2a6485284200a2176203fee84fc199e0c00 Mon Sep 17 00:00:00 2001 From: Clark <104835586+anonamouslyginger@users.noreply.github.com> Date: Thu, 31 Aug 2023 04:11:31 +0000 Subject: [PATCH] Split the settings page (#528) * Split the settings page * Add a dashboard page for future use Create a settings base to keep all the settings pages consistent * Correct Python formatting * Fix snapshots not showing in new view --- .../home/templates/home/base_settings.html | 17 + .../home/templates/home/channel_id.html | 2 +- .../home/templates/home/channel_id_about.html | 2 +- .../templates/home/channel_id_playlist.html | 2 +- .../home/templates/home/settings.html | 448 +----------------- .../home/templates/home/settings_actions.html | 66 +++ .../templates/home/settings_application.html | 192 ++++++++ .../templates/home/settings_scheduling.html | 154 ++++++ .../home/templates/home/settings_user.html | 37 ++ tubearchivist/home/urls.py | 20 + tubearchivist/home/views.py | 120 ++++- tubearchivist/static/css/style.css | 6 +- 12 files changed, 602 insertions(+), 464 deletions(-) create mode 100644 tubearchivist/home/templates/home/base_settings.html create mode 100644 tubearchivist/home/templates/home/settings_actions.html create mode 100644 tubearchivist/home/templates/home/settings_application.html create mode 100644 tubearchivist/home/templates/home/settings_scheduling.html create mode 100644 tubearchivist/home/templates/home/settings_user.html diff --git a/tubearchivist/home/templates/home/base_settings.html b/tubearchivist/home/templates/home/base_settings.html new file mode 100644 index 0000000..885cbe9 --- /dev/null +++ b/tubearchivist/home/templates/home/base_settings.html @@ -0,0 +1,17 @@ +{# Base file for all of the settings pages to ensure a common menu #} +{% extends "home/base.html" %} +{% load static %} +{% block content %} +
+
+

Dashboard

+

User

+

Application

+

Scheduling

+

Actions

+
+
+ {% block settings_content %}{% endblock %} +
+ +{% endblock content %} diff --git a/tubearchivist/home/templates/home/channel_id.html b/tubearchivist/home/templates/home/channel_id.html index 7c09888..dcc935c 100644 --- a/tubearchivist/home/templates/home/channel_id.html +++ b/tubearchivist/home/templates/home/channel_id.html @@ -6,7 +6,7 @@
channel_banner
-
+

Videos

{% if has_streams %}

Streams

diff --git a/tubearchivist/home/templates/home/channel_id_about.html b/tubearchivist/home/templates/home/channel_id_about.html index fb55e0d..d4afcbc 100644 --- a/tubearchivist/home/templates/home/channel_id_about.html +++ b/tubearchivist/home/templates/home/channel_id_about.html @@ -6,7 +6,7 @@
channel_banner
-
+

Videos

{% if has_streams %}

Streams

diff --git a/tubearchivist/home/templates/home/channel_id_playlist.html b/tubearchivist/home/templates/home/channel_id_playlist.html index c40a121..86d635d 100644 --- a/tubearchivist/home/templates/home/channel_id_playlist.html +++ b/tubearchivist/home/templates/home/channel_id_playlist.html @@ -6,7 +6,7 @@
channel_banner
-
+

Videos

{% if has_streams %}

Streams

diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index e9c2311..d9e1860 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -1,441 +1,11 @@ -{% extends "home/base.html" %} +{% extends "home/base_settings.html" %} {% load static %} -{% block content %} -
-
-
-

User Configurations

-
-
- {% csrf_token %} -
-

Color scheme

-
-

Current color scheme: {{ config.application.colors }}

- Select your preferred color scheme between dark and light mode.
- {{ user_form.colors }} -
-
-
-

Archive View

-
-

Current page size: {{ config.archive.page_size }}

- Result of videos showing in archive page
- {{ user_form.page_size }} -
-
- -
-
-

Application Configurations

-
-
- {% csrf_token %} -
-

Subscriptions

-

Disable shorts or streams by setting their page size to 0 (zero).

-
-

YouTube page size: {{ config.subscriptions.channel_size }}

- Videos to scan to find new items for the Rescan subscriptions task, max recommended 50.
- {{ app_form.subscriptions_channel_size }} -
-
-

YouTube Live page size: {{ config.subscriptions.live_channel_size }}

- Live Videos to scan to find new items for the Rescan subscriptions task, max recommended 50.
- {{ app_form.subscriptions_live_channel_size }} -
-
-

YouTube Shorts page size: {{ config.subscriptions.shorts_channel_size }}

- Shorts Videos to scan to find new items for the Rescan subscriptions task, max recommended 50.
- {{ app_form.subscriptions_shorts_channel_size }} -
-
-

Auto start download from your subscriptions: {{ config.subscriptions.auto_start}}

- Enable this will automatically start and prioritize videos from your subscriptions.
- {{ app_form.subscriptions_auto_start }} -
-
-
-

Downloads

-
-

Current download speed limit in KB/s: {{ config.downloads.limit_speed }}

- Limit download speed. 0 (zero) to deactivate, e.g. 1000 (1MB/s). Speeds are in KB/s. Setting takes effect on new download jobs or application restart.
- {{ app_form.downloads_limit_speed }} -
-
-

Current throttled rate limit in KB/s: {{ config.downloads.throttledratelimit }}

- Download will restart if speeds drop below specified amount. 0 (zero) to deactivate, e.g. 100. Speeds are in KB/s.
- {{ app_form.downloads_throttledratelimit }} -
-
-

Current scraping sleep interval: {{ config.downloads.sleep_interval }}

- Seconds to sleep between calls to YouTube. Might be necessary to avoid throttling. Recommended 3.
- {{ app_form.downloads_sleep_interval }} -
-
-

Danger Zone: Current auto delete watched videos: {{ config.downloads.autodelete_days }}

- Auto delete watched videos after x days, 0 (zero) to deactivate:
- {{ app_form.downloads_autodelete_days }} -
-
-
-

Download Format

-
-

Limit video and audio quality format for yt-dlp.
- Currently: {{ config.downloads.format }} -

-

Example configurations:

-
    -
  • bestvideo[height<=720]+bestaudio/best[height<=720]: best audio and max video height of 720p.
  • -
  • bestvideo[height<=1080]+bestaudio/best[height<=1080]: best audio and max video height of 1080p.
  • -
  • bestvideo[height<=1080][vcodec*=avc1]+bestaudio[acodec*=mp4a]/mp4: Max 1080p video height with iOS compatible video and audio codecs.
  • -
  • 0: deactivate and download the best quality possible as decided by yt-dlp.
  • -
- Make sure your custom format gets merged into a single file. Check out the documentation for valid configurations.
- {{ app_form.downloads_format }} -
-
-
-

Force sort order to have precedence over all yt-dlp fields.
- Currently: {{ config.downloads.format_sort }} -

-

Example configurations:

-
    -
  • res,codec:av1: prefer AV1 over all other video codecs.
  • -
  • 0: deactivate and keep the default as decided by yt-dlp.
  • -
- Not all codecs are supported by all browsers. The default value ensures best compatibility. Check out the documentation for valid configurations.
- {{ app_form.downloads_format_sort }} -
-
-
-

Prefer translated metadata language: {{ config.downloads.extractor_lang }}

- This will change the language this video gets indexed as. That will only be available if the uploader provides translations. Add as two letter ISO language code, check the documentation which languages are available.
- {{ app_form.downloads_extractor_lang}} -
-
-

Current metadata embed setting: {{ config.downloads.add_metadata }}

- Metadata is not embedded into the downloaded files by default.
- {{ app_form.downloads_add_metadata }} -
-
-

Current thumbnail embed setting: {{ config.downloads.add_thumbnail }}

- Embed thumbnail into the mediafile.
- {{ app_form.downloads_add_thumbnail }} -
-
-
-

Subtitles

-
-

Subtitles download setting: {{ config.downloads.subtitle }}
- Choose which subtitles to download, add comma separated language codes,
- e.g. en, de, zh-Hans

- {{ app_form.downloads_subtitle }}

-
-
-

Subtitle source settings: {{ config.downloads.subtitle_source }}

- Download only user generated, or also less accurate auto generated subtitles.
- {{ app_form.downloads_subtitle_source }} -
-
-

Index and make subtitles searchable: {{ config.downloads.subtitle_index }}

- Store subtitle lines in Elasticsearch. Not recommended for low-end hardware.
- {{ app_form.downloads_subtitle_index }} -
-
-
-

Comments

-
-

Download and index comments: {{ config.downloads.comment_max }}
- Follow the yt-dlp max_comments documentation, max-comments,max-parents,max-replies,max-replies-per-thread:
-

Example configurations:

-
    -
  • all,100,all,30: Get 100 max-parents and 30 max-replies-per-thread.
  • -
  • 1000,all,all,50: Get a total of 1000 comments over all, 50 replies per thread.
  • -
- {{ app_form.downloads_comment_max }}

-
-
-

Selected comment sort method: {{ config.downloads.comment_sort }}
- Select how many comments and threads to download:
- {{ app_form.downloads_comment_sort }}

-
-
-
-

Cookie

-
-

Import YouTube cookie: {{ config.downloads.cookie_import }}

-

For automatic cookie import use Tube Archivist Companion browser extension.

- For manual cookie import, place your cookie file named cookies.google.txt in cache/import before enabling. Instructions in the Wiki.
- {{ app_form.downloads_cookie_import }}
- {% if config.downloads.cookie_import %} -
- -
- {% endif %} -
-
-
-

Integrations

-
-

API token:

-
-

{{ api_token }}

- -
-
-
-

Integrate with returnyoutubedislike.com to get dislikes and average ratings back: {{ config.downloads.integrate_ryd }}

- Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.
- {{ app_form.downloads_integrate_ryd }} -
-
-

Integrate with SponsorBlock to get sponsored timestamps: {{ config.downloads.integrate_sponsorblock }}

- Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.
- {{ app_form.downloads_integrate_sponsorblock }} -
-
-
-

Snapshots

-
-

Current system snapshot: {{ config.application.enable_snapshot }}

- Automatically create daily deduplicated snapshots of the index, stored in Elasticsearch. Read first before activating: Wiki.
- {{ app_form.application_enable_snapshot }} -
-
- {% if snapshots %} -

Create next snapshot: {{ snapshots.next_exec_str }}, snapshots expire after {{ snapshots.expire_after }}.

-
- {% for snapshot in snapshots.snapshots %} -

Snapshot created on: {{ snapshot.start_date }}, took {{ snapshot.duration_s }}s to create. State: {{ snapshot.state }}

- {% endfor %} - {% endif %} -
-
- -
-
-

Scheduler Setup

-
-

Schedule settings expect a cron like format, where the first value is minute, second is hour and third is day of the week.

-

Examples:

-
    -
  • 0 15 *: Run task every day at 15:00 in the afternoon.
  • -
  • 30 8 */2: Run task every second day of the week (Sun, Tue, Thu, Sat) at 08:30 in the morning.
  • -
  • auto: Sensible default.
  • -
  • 0: (zero), deactivate that task.
  • -
-

Note:

-
    -
  • Changes in the scheduler settings require a container restart to take effect.
  • -
  • Avoid an unnecessary frequent schedule to not get blocked by YouTube. For that reason, the scheduler doesn't support schedules that trigger more than once per hour.
  • -
-
-
-
- {% csrf_token %} -
-

Rescan Subscriptions

-
-

Current rescan schedule: - {% if config.scheduler.update_subscribed %} - {% for key, value in config.scheduler.update_subscribed.items %} - {{ value }} - {% endfor %} - {% else %} - False - {% endif %} -

-

Become a sponsor and join members.tubearchivist.com to get access to real time notifications for new videos uploaded by your favorite channels.

-

Periodically rescan your subscriptions:

- {{ scheduler_form.update_subscribed }} -
-
-

Send notification on task completed:

- {% if config.scheduler.update_subscribed_notify %} -

stored notification links

-
-

{{ config.scheduler.update_subscribed_notify|linebreaks }}

-
- {% else %} -

Current notification urls: {{ config.scheduler.update_subscribed_notify }}

- {% endif %} - {{ scheduler_form.update_subscribed_notify }} -
-
-
-

Start download

-
-

Current Download schedule: - {% if config.scheduler.download_pending %} - {% for key, value in config.scheduler.download_pending.items %} - {{ value }} - {% endfor %} - {% else %} - False - {% endif %} -

-

Automatic video download schedule:

- {{ scheduler_form.download_pending }} -
-
-

Send notification on task completed:

- {% if config.scheduler.download_pending_notify %} -

stored notification links

-
-

{{ config.scheduler.download_pending_notify|linebreaks }}

-
- {% else %} -

Current notification urls: {{ config.scheduler.download_pending_notify }}

- {% endif %} - {{ scheduler_form.download_pending_notify }} -
-
-
-

Refresh Metadata

-
-

Current Metadata refresh schedule: - {% if config.scheduler.check_reindex %} - {% for key, value in config.scheduler.check_reindex.items %} - {{ value }} - {% endfor %} - {% else %} - False - {% endif %} -

-

Daily schedule to refresh metadata from YouTube:

- {{ scheduler_form.check_reindex }} -
-
-

Current refresh for metadata older than x days: {{ config.scheduler.check_reindex_days }}

-

Refresh older than x days, recommended 90:

- {{ scheduler_form.check_reindex_days }} -
-
-

Send notification on task completed:

- {% if config.scheduler.check_reindex_notify %} -

stored notification links

-
-

{{ config.scheduler.check_reindex_notify|linebreaks }}

-
- {% else %} -

Current notification urls: {{ config.scheduler.check_reindex_notify }}

- {% endif %} - {{ scheduler_form.check_reindex_notify }} -
-
-
-

Thumbnail check

-
-

Current thumbnail check schedule: - {% if config.scheduler.thumbnail_check %} - {% for key, value in config.scheduler.thumbnail_check.items %} - {{ value }} - {% endfor %} - {% else %} - False - {% endif %} -

-

Periodically check and cleanup thumbnails:

- {{ scheduler_form.thumbnail_check }} -
-
-
-

ZIP file index backup

-
-

Zip file backups are very slow for large archives and consistency is not guaranteed, use snapshots instead. Make sure no other tasks are running when creating a Zip file backup.

-

Current index backup schedule: - {% if config.scheduler.run_backup %} - {% for key, value in config.scheduler.run_backup.items %} - {{ value }} - {% endfor %} - {% else %} - False - {% endif %} -

-

Automatically backup metadata to a zip file:

- {{ scheduler_form.run_backup }} -
-
-

Current backup files to keep: {{ config.scheduler.run_backup_rotate }}

-

Max auto backups to keep:

- {{ scheduler_form.run_backup_rotate }} -
-
- -
-
-

Actions

-
-
-

Delete download queue

-

Delete your pending or previously ignored videos from your download queue.

- - -

-
-

Manual media files import.

-

Add files to the cache/import folder. Make sure to follow the instructions in the Github Wiki.

-
- -
-
-
-

Embed thumbnails into media file.

-

Set extracted youtube thumbnail as cover art of the media file.

-
- -
-
-
-

ZIP file index backup

-

Export your database to a zip file stored at cache/backup.

-

Zip file backups are very slow for large archives and consistency is not guaranteed, use snapshots instead. Make sure no other tasks are running when creating a Zip file backup.

-
- -
-
-
-

Restore from backup

-

Danger Zone: This will replace your existing index with the backup.

-

Restore from available backup files from cache/backup.

- {% if available_backups %} -
- - Timestamp - Source - Filename -
- {% for backup in available_backups %} -
- - {{ backup.timestamp }} - {{ backup.reason }} - {{ backup.filename }} -
- {% endfor %} - {% else %} -

No backups found.

- {% endif %} -
-
-

Rescan filesystem

-

Danger Zone: This will delete the metadata of deleted videos from the filesystem.

-

Rescan your media folder looking for missing videos and clean up index. More infos on the Github Wiki.

-
- -
-
- {% if request.user.is_superuser %} -
-

Users

-
-
-

User Management

-

Access the admin interface for basic user management functionality like adding and deleting users, changing passwords and more.

- -
- {% endif %} +{% block settings_content %} +
+

Dashboard Coming Soon

- -{% endblock content %} +
+

Tube Archivist settings have been moved to their own pages!

+

You can now find them by selecting an item from the sub-menu at the top of the page.

+
+{% endblock settings_content %} diff --git a/tubearchivist/home/templates/home/settings_actions.html b/tubearchivist/home/templates/home/settings_actions.html new file mode 100644 index 0000000..74405f7 --- /dev/null +++ b/tubearchivist/home/templates/home/settings_actions.html @@ -0,0 +1,66 @@ +{% extends "home/base_settings.html" %} +{% load static %} +{% block settings_content %} +
+

Actions

+
+
+

Delete download queue

+

Delete your pending or previously ignored videos from your download queue.

+ + +

+
+

Manual media files import.

+

Add files to the cache/import folder. Make sure to follow the instructions in the Github Wiki.

+
+ +
+
+
+

Embed thumbnails into media file.

+

Set extracted youtube thumbnail as cover art of the media file.

+
+ +
+
+
+

ZIP file index backup

+

Export your database to a zip file stored at cache/backup.

+

Zip file backups are very slow for large archives and consistency is not guaranteed, use snapshots instead. Make sure no other tasks are running when creating a Zip file backup.

+
+ +
+
+
+

Restore from backup

+

Danger Zone: This will replace your existing index with the backup.

+

Restore from available backup files from cache/backup.

+ {% if available_backups %} +
+ + Timestamp + Source + Filename +
+ {% for backup in available_backups %} +
+ + {{ backup.timestamp }} + {{ backup.reason }} + {{ backup.filename }} +
+ {% endfor %} + {% else %} +

No backups found.

+ {% endif %} +
+
+

Rescan filesystem

+

Danger Zone: This will delete the metadata of deleted videos from the filesystem.

+

Rescan your media folder looking for missing videos and clean up index. More infos on the Github Wiki.

+
+ +
+
+{% endblock settings_content %} diff --git a/tubearchivist/home/templates/home/settings_application.html b/tubearchivist/home/templates/home/settings_application.html new file mode 100644 index 0000000..12f7cdb --- /dev/null +++ b/tubearchivist/home/templates/home/settings_application.html @@ -0,0 +1,192 @@ +{% extends "home/base_settings.html" %} +{% load static %} +{% block settings_content %} +
+

Application Configurations

+
+
+ {% csrf_token %} +
+

Subscriptions

+

Disable shorts or streams by setting their page size to 0 (zero).

+
+

YouTube page size: {{ config.subscriptions.channel_size }}

+ Videos to scan to find new items for the Rescan subscriptions task, max recommended 50.
+ {{ app_form.subscriptions_channel_size }} +
+
+

YouTube Live page size: {{ config.subscriptions.live_channel_size }}

+ Live Videos to scan to find new items for the Rescan subscriptions task, max recommended 50.
+ {{ app_form.subscriptions_live_channel_size }} +
+
+

YouTube Shorts page size: {{ config.subscriptions.shorts_channel_size }}

+ Shorts Videos to scan to find new items for the Rescan subscriptions task, max recommended 50.
+ {{ app_form.subscriptions_shorts_channel_size }} +
+
+

Auto start download from your subscriptions: {{ config.subscriptions.auto_start}}

+ Enable this will automatically start and prioritize videos from your subscriptions.
+ {{ app_form.subscriptions_auto_start }} +
+
+
+

Downloads

+
+

Current download speed limit in KB/s: {{ config.downloads.limit_speed }}

+ Limit download speed. 0 (zero) to deactivate, e.g. 1000 (1MB/s). Speeds are in KB/s. Setting takes effect on new download jobs or application restart.
+ {{ app_form.downloads_limit_speed }} +
+
+

Current throttled rate limit in KB/s: {{ config.downloads.throttledratelimit }}

+ Download will restart if speeds drop below specified amount. 0 (zero) to deactivate, e.g. 100. Speeds are in KB/s.
+ {{ app_form.downloads_throttledratelimit }} +
+
+

Current scraping sleep interval: {{ config.downloads.sleep_interval }}

+ Seconds to sleep between calls to YouTube. Might be necessary to avoid throttling. Recommended 3.
+ {{ app_form.downloads_sleep_interval }} +
+
+

Danger Zone: Current auto delete watched videos: {{ config.downloads.autodelete_days }}

+ Auto delete watched videos after x days, 0 (zero) to deactivate:
+ {{ app_form.downloads_autodelete_days }} +
+
+
+

Download Format

+
+

Limit video and audio quality format for yt-dlp.
+ Currently: {{ config.downloads.format }} +

+

Example configurations:

+
    +
  • bestvideo[height<=720]+bestaudio/best[height<=720]: best audio and max video height of 720p.
  • +
  • bestvideo[height<=1080]+bestaudio/best[height<=1080]: best audio and max video height of 1080p.
  • +
  • bestvideo[height<=1080][vcodec*=avc1]+bestaudio[acodec*=mp4a]/mp4: Max 1080p video height with iOS compatible video and audio codecs.
  • +
  • 0: deactivate and download the best quality possible as decided by yt-dlp.
  • +
+ Make sure your custom format gets merged into a single file. Check out the documentation for valid configurations.
+ {{ app_form.downloads_format }} +
+
+
+

Force sort order to have precedence over all yt-dlp fields.
+ Currently: {{ config.downloads.format_sort }} +

+

Example configurations:

+
    +
  • res,codec:av1: prefer AV1 over all other video codecs.
  • +
  • 0: deactivate and keep the default as decided by yt-dlp.
  • +
+ Not all codecs are supported by all browsers. The default value ensures best compatibility. Check out the documentation for valid configurations.
+ {{ app_form.downloads_format_sort }} +
+
+
+

Prefer translated metadata language: {{ config.downloads.extractor_lang }}

+ This will change the language this video gets indexed as. That will only be available if the uploader provides translations. Add as two letter ISO language code, check the documentation which languages are available.
+ {{ app_form.downloads_extractor_lang}} +
+
+

Current metadata embed setting: {{ config.downloads.add_metadata }}

+ Metadata is not embedded into the downloaded files by default.
+ {{ app_form.downloads_add_metadata }} +
+
+

Current thumbnail embed setting: {{ config.downloads.add_thumbnail }}

+ Embed thumbnail into the mediafile.
+ {{ app_form.downloads_add_thumbnail }} +
+
+
+

Subtitles

+
+

Subtitles download setting: {{ config.downloads.subtitle }}
+ Choose which subtitles to download, add comma separated language codes,
+ e.g. en, de, zh-Hans

+ {{ app_form.downloads_subtitle }}

+
+
+

Subtitle source settings: {{ config.downloads.subtitle_source }}

+ Download only user generated, or also less accurate auto generated subtitles.
+ {{ app_form.downloads_subtitle_source }} +
+
+

Index and make subtitles searchable: {{ config.downloads.subtitle_index }}

+ Store subtitle lines in Elasticsearch. Not recommended for low-end hardware.
+ {{ app_form.downloads_subtitle_index }} +
+
+
+

Comments

+
+

Download and index comments: {{ config.downloads.comment_max }}
+ Follow the yt-dlp max_comments documentation, max-comments,max-parents,max-replies,max-replies-per-thread:
+

Example configurations:

+
    +
  • all,100,all,30: Get 100 max-parents and 30 max-replies-per-thread.
  • +
  • 1000,all,all,50: Get a total of 1000 comments over all, 50 replies per thread.
  • +
+ {{ app_form.downloads_comment_max }}

+
+
+

Selected comment sort method: {{ config.downloads.comment_sort }}
+ Select how many comments and threads to download:
+ {{ app_form.downloads_comment_sort }}

+
+
+
+

Cookie

+
+

Import YouTube cookie: {{ config.downloads.cookie_import }}

+

For automatic cookie import use Tube Archivist Companion browser extension.

+ For manual cookie import, place your cookie file named cookies.google.txt in cache/import before enabling. Instructions in the Wiki.
+ {{ app_form.downloads_cookie_import }}
+ {% if config.downloads.cookie_import %} +
+ +
+ {% endif %} +
+
+
+

Integrations

+
+

API token:

+
+

{{ api_token }}

+ +
+
+
+

Integrate with returnyoutubedislike.com to get dislikes and average ratings back: {{ config.downloads.integrate_ryd }}

+ Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.
+ {{ app_form.downloads_integrate_ryd }} +
+
+

Integrate with SponsorBlock to get sponsored timestamps: {{ config.downloads.integrate_sponsorblock }}

+ Before activating that, make sure you have a scraping sleep interval of at least 3 secs set to avoid ratelimiting issues.
+ {{ app_form.downloads_integrate_sponsorblock }} +
+
+
+

Snapshots

+
+

Current system snapshot: {{ config.application.enable_snapshot }}

+ Automatically create daily deduplicated snapshots of the index, stored in Elasticsearch. Read first before activating: Wiki.
+ {{ app_form.application_enable_snapshot }} +
+
+ {% if snapshots %} +

Create next snapshot: {{ snapshots.next_exec_str }}, snapshots expire after {{ snapshots.expire_after }}.

+
+ {% for snapshot in snapshots.snapshots %} +

Snapshot created on: {{ snapshot.start_date }}, took {{ snapshot.duration_s }}s to create. State: {{ snapshot.state }}

+ {% endfor %} + {% endif %} +
+
+ +
+{% endblock settings_content %} diff --git a/tubearchivist/home/templates/home/settings_scheduling.html b/tubearchivist/home/templates/home/settings_scheduling.html new file mode 100644 index 0000000..b3b57a3 --- /dev/null +++ b/tubearchivist/home/templates/home/settings_scheduling.html @@ -0,0 +1,154 @@ +{% extends "home/base_settings.html" %} +{% load static %} +{% block settings_content %} +
+

Scheduler Setup

+
+

Schedule settings expect a cron like format, where the first value is minute, second is hour and third is day of the week.

+

Examples:

+
    +
  • 0 15 *: Run task every day at 15:00 in the afternoon.
  • +
  • 30 8 */2: Run task every second day of the week (Sun, Tue, Thu, Sat) at 08:30 in the morning.
  • +
  • auto: Sensible default.
  • +
  • 0: (zero), deactivate that task.
  • +
+

Note:

+
    +
  • Changes in the scheduler settings require a container restart to take effect.
  • +
  • Avoid an unnecessary frequent schedule to not get blocked by YouTube. For that reason, the scheduler doesn't support schedules that trigger more than once per hour.
  • +
+
+
+
+ {% csrf_token %} +
+

Rescan Subscriptions

+
+

Current rescan schedule: + {% if config.scheduler.update_subscribed %} + {% for key, value in config.scheduler.update_subscribed.items %} + {{ value }} + {% endfor %} + {% else %} + False + {% endif %} +

+

Become a sponsor and join members.tubearchivist.com to get access to real time notifications for new videos uploaded by your favorite channels.

+

Periodically rescan your subscriptions:

+ {{ scheduler_form.update_subscribed }} +
+
+

Send notification on task completed:

+ {% if config.scheduler.update_subscribed_notify %} +

stored notification links

+
+

{{ config.scheduler.update_subscribed_notify|linebreaks }}

+
+ {% else %} +

Current notification urls: {{ config.scheduler.update_subscribed_notify }}

+ {% endif %} + {{ scheduler_form.update_subscribed_notify }} +
+
+
+

Start download

+
+

Current Download schedule: + {% if config.scheduler.download_pending %} + {% for key, value in config.scheduler.download_pending.items %} + {{ value }} + {% endfor %} + {% else %} + False + {% endif %} +

+

Automatic video download schedule:

+ {{ scheduler_form.download_pending }} +
+
+

Send notification on task completed:

+ {% if config.scheduler.download_pending_notify %} +

stored notification links

+
+

{{ config.scheduler.download_pending_notify|linebreaks }}

+
+ {% else %} +

Current notification urls: {{ config.scheduler.download_pending_notify }}

+ {% endif %} + {{ scheduler_form.download_pending_notify }} +
+
+
+

Refresh Metadata

+
+

Current Metadata refresh schedule: + {% if config.scheduler.check_reindex %} + {% for key, value in config.scheduler.check_reindex.items %} + {{ value }} + {% endfor %} + {% else %} + False + {% endif %} +

+

Daily schedule to refresh metadata from YouTube:

+ {{ scheduler_form.check_reindex }} +
+
+

Current refresh for metadata older than x days: {{ config.scheduler.check_reindex_days }}

+

Refresh older than x days, recommended 90:

+ {{ scheduler_form.check_reindex_days }} +
+
+

Send notification on task completed:

+ {% if config.scheduler.check_reindex_notify %} +

stored notification links

+
+

{{ config.scheduler.check_reindex_notify|linebreaks }}

+
+ {% else %} +

Current notification urls: {{ config.scheduler.check_reindex_notify }}

+ {% endif %} + {{ scheduler_form.check_reindex_notify }} +
+
+
+

Thumbnail check

+
+

Current thumbnail check schedule: + {% if config.scheduler.thumbnail_check %} + {% for key, value in config.scheduler.thumbnail_check.items %} + {{ value }} + {% endfor %} + {% else %} + False + {% endif %} +

+

Periodically check and cleanup thumbnails:

+ {{ scheduler_form.thumbnail_check }} +
+
+
+

ZIP file index backup

+
+

Zip file backups are very slow for large archives and consistency is not guaranteed, use snapshots instead. Make sure no other tasks are running when creating a Zip file backup.

+

Current index backup schedule: + {% if config.scheduler.run_backup %} + {% for key, value in config.scheduler.run_backup.items %} + {{ value }} + {% endfor %} + {% else %} + False + {% endif %} +

+

Automatically backup metadata to a zip file:

+ {{ scheduler_form.run_backup }} +
+
+

Current backup files to keep: {{ config.scheduler.run_backup_rotate }}

+

Max auto backups to keep:

+ {{ scheduler_form.run_backup_rotate }} +
+
+ +
+{% endblock settings_content %} diff --git a/tubearchivist/home/templates/home/settings_user.html b/tubearchivist/home/templates/home/settings_user.html new file mode 100644 index 0000000..a12fc75 --- /dev/null +++ b/tubearchivist/home/templates/home/settings_user.html @@ -0,0 +1,37 @@ +{% extends "home/base_settings.html" %} +{% load static %} +{% block settings_content %} +
+

User Configurations

+
+
+ {% csrf_token %} +
+

Color scheme

+
+

Current color scheme: {{ config.application.colors }}

+ Select your preferred color scheme between dark and light mode.
+ {{ user_form.colors }} +
+
+
+

Archive View

+
+

Current page size: {{ config.archive.page_size }}

+ Result of videos showing in archive page
+ {{ user_form.page_size }} +
+
+ +
+{% if request.user.is_superuser %} +
+

Users

+
+
+

User Management

+

Access the admin interface for basic user management functionality like adding and deleting users, changing passwords and more.

+ +
+{% endif %} +{% endblock settings_content %} diff --git a/tubearchivist/home/urls.py b/tubearchivist/home/urls.py index 14e851b..614c29b 100644 --- a/tubearchivist/home/urls.py +++ b/tubearchivist/home/urls.py @@ -26,6 +26,26 @@ urlpatterns = [ login_required(views.SettingsView.as_view()), name="settings", ), + path( + "settings/user/", + login_required(views.SettingsUserView.as_view()), + name="settings_user", + ), + path( + "settings/application/", + login_required(views.SettingsApplicationView.as_view()), + name="settings_application", + ), + path( + "settings/scheduling/", + login_required(views.SettingsSchedulingView.as_view()), + name="settings_scheduling", + ), + path( + "settings/actions/", + login_required(views.SettingsActionsView.as_view()), + name="settings_actions", + ), path("process/", login_required(views.process), name="process"), path( "channel/", diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 507c933..8e9f89d 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -981,7 +981,21 @@ class SearchView(ArchivistResultsView): class SettingsView(MinView): """resolves to /settings/ - handle the settings page, display current settings, + handle the settings dashboard + """ + + def get(self, request): + """read and display the dashboard""" + context = self.get_min_context(request) + context.update({"title": "Settings Dashboard"}) + + return render(request, "home/settings.html", context) + + +class SettingsUserView(MinView): + """resolves to /settings/user/ + handle the settings sub-page for user settings, + display current settings, take post request from the form to update settings """ @@ -990,18 +1004,47 @@ class SettingsView(MinView): context = self.get_min_context(request) context.update( { - "title": "Settings", + "title": "User Settings", + "config": AppConfig(request.user.id).config, + "user_form": UserSettingsForm(), + } + ) + + return render(request, "home/settings_user.html", context) + + def post(self, request): + """handle form post to update settings""" + user_form = UserSettingsForm(request.POST) + if user_form.is_valid(): + user_form_post = user_form.cleaned_data + if any(user_form_post.values()): + AppConfig().set_user_config(user_form_post, request.user.id) + + sleep(1) + return redirect("settings_user", permanent=True) + + +class SettingsApplicationView(MinView): + """resolves to /settings/application/ + handle the settings sub-page for application configuration, + display current settings, + take post request from the form to update settings + """ + + def get(self, request): + """read and display current application settings""" + context = self.get_min_context(request) + context.update( + { + "title": "Application Settings", "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) + return render(request, "home/settings_application.html", context) @staticmethod def get_token(request): @@ -1012,12 +1055,7 @@ class SettingsView(MinView): def post(self, request): """handle form post to update settings""" - user_form = UserSettingsForm(request.POST) config_handler = AppConfig() - if user_form.is_valid(): - user_form_post = user_form.cleaned_data - if any(user_form_post.values()): - config_handler.set_user_config(user_form_post, request.user.id) app_form = ApplicationSettingsForm(request.POST) if app_form.is_valid(): @@ -1027,15 +1065,8 @@ class SettingsView(MinView): updated = config_handler.update_config(app_form_post) self.post_process_updated(updated, config_handler.config) - scheduler_form = SchedulerSettingsForm(request.POST) - if scheduler_form.is_valid(): - scheduler_form_post = scheduler_form.cleaned_data - if any(scheduler_form_post.values()): - print(scheduler_form_post) - ScheduleBuilder().update_schedule_conf(scheduler_form_post) - sleep(1) - return redirect("settings", permanent=True) + return redirect("settings_application", permanent=True) def post_process_updated(self, updated, config): """apply changes for config""" @@ -1080,6 +1111,57 @@ class SettingsView(MinView): RedisArchivist().set_message(key, message=message, expire=True) +class SettingsSchedulingView(MinView): + """resolves to /settings/scheduling/ + handle the settings sub-page for scheduling settings, + display current settings, + take post request from the form to update settings + """ + + def get(self, request): + """read and display current settings""" + context = self.get_min_context(request) + context.update( + { + "title": "Scheduling Settings", + "config": AppConfig(request.user.id).config, + "scheduler_form": SchedulerSettingsForm(), + } + ) + + return render(request, "home/settings_scheduling.html", context) + + def post(self, request): + """handle form post to update settings""" + scheduler_form = SchedulerSettingsForm(request.POST) + if scheduler_form.is_valid(): + scheduler_form_post = scheduler_form.cleaned_data + if any(scheduler_form_post.values()): + print(scheduler_form_post) + ScheduleBuilder().update_schedule_conf(scheduler_form_post) + + sleep(1) + return redirect("settings_scheduling", permanent=True) + + +class SettingsActionsView(MinView): + """resolves to /settings/actions/ + handle the settings actions sub-page + """ + + def get(self, request): + """read and display current settings""" + context = self.get_min_context(request) + context.update( + { + "title": "Actions", + "available_backups": ElasticBackup().get_all_backup_files(), + } + ) + + return render(request, "home/settings_actions.html", context) + + def process(request): """handle all the buttons calls via POST ajax""" if request.method == "POST": diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index 9ece987..74b3285 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -960,15 +960,15 @@ video:-webkit-full-screen { transform: translateX(-30%); } -.info-box-item.channel-nav { +.info-box-item.child-page-nav { justify-content: center; } -.info-box-item.channel-nav a { +.info-box-item.child-page-nav a { padding: 0 1rem; } -.info-box-item.channel-nav a:hover { +.info-box-item.child-page-nav a:hover { text-decoration: underline; }