home · contact · privacy
Allow YouTube links, but make them optional via config. master
authorChristian Heller <c.heller@plomlompom.de>
Sun, 13 Apr 2025 21:56:49 +0000 (23:56 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 13 Apr 2025 21:56:49 +0000 (23:56 +0200)
src/templates/yt_result.tmpl
src/ytplom/http.py
src/ytplom/misc.py

index 9a7ca49d30e995cb6c22b62ae31e1ecf661b3bd4..2aa3737a130ca6bc593d2ad310a506ba18525ed3 100644 (file)
@@ -24,7 +24,7 @@ event_handlers.download = function(data) {
 <tr><th>description:</th><td>{{video_data.description}}</td></tr>
 <tr><th>duration:</th><td>{{video_data.duration}}</td></tr>
 <tr><th>definition:</th><td>{{video_data.definition}}</td></tr>
-<tr><th>YouTube ID:</th><td>{{video_data.id_}}</td></tr>
+<tr><th>YouTube ID:</th><td>{% if youtube_prefix|length > 0 %}<a href="{{youtube_prefix}}{{video_data.id_}}">{{video_data.id_}}{% else %}{{video_data.id_}}{% endif %}</td></tr>
 <tr><th>download:</th><td id="status"></td></tr>
 <tr>
 <th>linked queries:</th>
index 0c98d2b12a4ac02d756766a882101c595f3f44f9..e1105a68f6746be8e87bbaba4de0870429caa044 100644 (file)
@@ -13,10 +13,9 @@ from plomlib.web import (
         PlomHttpHandler, PlomHttpServer, PlomQueryMap, MIME_APP_JSON)
 from ytplom.db import Hash, DbConn
 from ytplom.misc import (
-        FilterStr, FlagName, QueryId, QueryText, TagSet, YoutubeId,
-        FILE_FLAGS, PATH_THUMBNAILS, ensure_expected_dirs,
-        Config, DownloadsManager, Player, QuotaLog, VideoFile, YoutubeQuery,
-        YoutubeVideo
+    FILE_FLAGS, PATH_THUMBNAILS, YOUTUBE_URL_PREFIX, ensure_expected_dirs,
+    Config, DownloadsManager, FilterStr, FlagName, Player, QueryId, QueryText,
+    QuotaLog, TagSet, VideoFile, YoutubeId, YoutubeQuery, YoutubeVideo
 )
 from ytplom.primitives import NotFoundException, PATH_APP_DATA
 
@@ -406,7 +405,10 @@ class _TaskHandler(PlomHttpHandler):
                  'is_temp': video_id in self.server.downloads.ids_unfinished,
                  'file_digest': file_digest,
                  'file_path': file_path,
-                 'queries': linked_queries})
+                 'queries': linked_queries,
+                 'youtube_prefix': (
+                     YOUTUBE_URL_PREFIX if self.server.config.link_originals
+                     else '')})
 
     def _send_yt_queries_index_and_search(self) -> None:
         with DbConn() as conn:
index ade627e9e2cab2dcd92478912cfe8071e6611e9b..a3f337bdc336cd84eff62cb45e31451d36778415 100644 (file)
@@ -34,7 +34,8 @@ DEFAULTS = {
     'tags_prefilter_needed': [],
     'tags_display_whitelist': [],
     'tags_default': ['new'],
-    'allow_file_edit': True
+    'allow_file_edit': True,
+    'link_originals': True
 }
 
 # type definitions for mypy
@@ -183,6 +184,7 @@ class Config:
     tags_prefilter_whitelist: TagSet
     tags_display_whitelist: TagSet
     tags_default: TagSet
+    link_originals: bool
 
     def __init__(self):
         def set_attrs_from_dict(d):