3402-always-update-page-title
dgtlmoon 2025-09-09 18:04:43 +02:00
rodzic a7c21c566c
commit 359168f40a
5 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -352,7 +352,7 @@ async def async_update_worker(worker_id, q, notification_q, app, datastore):
try:
page_title = html_tools.extract_title(data=update_handler.fetcher.content)
logger.info(f"UUID: {uuid} Page <title> is '{page_title}")
datastore.update_watch(uuid=uuid, update_obj={'title': page_title})
datastore.update_watch(uuid=uuid, update_obj={'page_title': page_title})
except Exception as e:
logger.warning(f"UUID: {uuid} Exception when extracting <title> - {str(e)}")

Wyświetl plik

@ -548,7 +548,9 @@ def extract_title(data: bytes | str, sniff_bytes: int = 2048, scan_chars: int =
# Search only in the prefix
if m := TITLE_RE.search(prefix):
return html.unescape(" ".join(m.group(1).split())).strip()
title = html.unescape(" ".join(m.group(1).split())).strip()
# Some safe limit
return title[:2000]
return None
except Exception as e:

Wyświetl plik

@ -169,8 +169,8 @@ class model(watch_base):
@property
def label(self):
# Used for sorting
return self.get('title') if self.get('title') else self.get('url')
# Used for sorting, display, etc
return self.get('title') or self.get('page_title') or self.get('url')
@property
def last_changed(self):

Wyświetl plik

@ -48,6 +48,7 @@ class watch_base(dict):
'notification_screenshot': False, # Include the latest screenshot if available and supported by the apprise URL
'notification_title': None,
'notification_urls': [], # List of URLs to add to the notification Queue (Usually AppRise)
'page_title': None, # <title> from the page
'paused': False,
'previous_md5': False,
'previous_md5_before_filters': False, # Used for skipping changedetection entirely
@ -121,7 +122,7 @@ class watch_base(dict):
}
},
},
'title': None,
'title': None, # An arbitrary field that overrides 'page_title'
'track_ldjson_price_data': None,
'trim_text_whitespace': False,
'remove_duplicate_lines': False,

Wyświetl plik

@ -70,7 +70,7 @@
</tr>
<tr>
<td><code>{{ '{{watch_title}}' }}</code></td>
<td>The page title of the watch.</td>
<td>The page title of the watch, uses &lt;title&gt; if not set.</td>
</tr>
<tr>
<td><code>{{ '{{watch_tag}}' }}</code></td>