From cd933fff03c21ecfa4dc67b42baa155a2bc165ae Mon Sep 17 00:00:00 2001
From: John Xina <bingchilling@riseup.net>
Date: Fri, 21 Jul 2023 18:03:53 +0800
Subject: [PATCH] add title to articles, and fix rare crashes with
 preprocessing

---
 extra.py                           | 18 ++++++++++++------
 templates/themes/wayback/read.html |  2 +-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/extra.py b/extra.py
index da588e8..3b17bb4 100644
--- a/extra.py
+++ b/extra.py
@@ -47,15 +47,21 @@ def article_to_html(article_text):
             continue
 
         if child.name == 'a':
+            if 'href' not in child:
+                continue
+            
             child['href'] = child['href'].split('//')[1].strip('www.bilibili.com')
             continue
         elif child.name == 'img':
-            if appconf['proxy']['image']:
-                child['src'] = '/proxy/pic/' + child['data-src'].split('//')[1]
-            else:
-                child['src'] = child['data-src']
-            del child['data-src']
-            del child['data-size']
+            try:
+                if appconf['proxy']['image']:
+                    child['src'] = '/proxy/pic/' + child['data-src'].split('//')[1]
+                else:
+                    child['src'] = child['data-src']
+                    del child['data-src']
+                    del child['data-size']
+            except:
+                pass
             continue
         elif child.name == 'span' and not child.parent in purge_elems:
             purge_elems.append(child.parent)
diff --git a/templates/themes/wayback/read.html b/templates/themes/wayback/read.html
index 2a6c551..d2edf4b 100644
--- a/templates/themes/wayback/read.html
+++ b/templates/themes/wayback/read.html
@@ -3,7 +3,7 @@
 {% block head %}
   <link rel="alternate" href="https://www.bilibili.com/read/{{ cid }}">
   <meta name="referrer" content="never">
-  <title>专栏 - MikuInvidious</title>
+  <title>{{ arinfo['title'] }} - 专栏 - MikuInvidious</title>
   <style>
     @media only screen and (min-width: 600px) {
 	figure > img {
-- 
GitLab