|
|
@@ -32,9 +32,8 @@ def eink_quote_qr(args):
|
|
|
# args.text = q["data"]["title"]
|
|
|
# eink_text(args)
|
|
|
text = q["data"]["title"]
|
|
|
- url = simpilib.short_url(q["data"]["url"])
|
|
|
|
|
|
- smalltext = None
|
|
|
+ author = None
|
|
|
import re
|
|
|
dashes = r"(.*)[\u002D\u058A\u05BE\u1400\u1806\u2010-\u2015\u2E17\u2E1A\u2E3A\u2E3B\u2E40\u301C\u3030\u30A0\uFE31\uFE32\uFE58\uFE63\uFF0D](.*)"
|
|
|
matches = re.match(dashes, text)
|
|
|
@@ -42,20 +41,31 @@ def eink_quote_qr(args):
|
|
|
groups = matches.groups()
|
|
|
if len(groups[1]) < 30:
|
|
|
text = groups[0]
|
|
|
- smalltext = groups[1]
|
|
|
+ author = groups[1]
|
|
|
|
|
|
- if not smalltext:
|
|
|
+ if not author:
|
|
|
qt = r"(.*)\"(.*)\"(.*)"
|
|
|
matches = re.match(qt, text)
|
|
|
if matches:
|
|
|
groups = matches.groups()
|
|
|
if len(groups[0]) < 10 and len(groups[1]) > 10:
|
|
|
text = groups[1]
|
|
|
- smalltext = groups[2].strip()
|
|
|
+ author = groups[2]
|
|
|
+
|
|
|
+ if author:
|
|
|
+ author = re.sub(r"[^a-zA-Z0-9 ]","", author).strip()
|
|
|
+ from urllib.parse import urlencode
|
|
|
+ args = urlencode({
|
|
|
+ "search": author,
|
|
|
+ "title": "Special:Search",
|
|
|
+ })
|
|
|
+ url = simpilib.short_url("https://wikipedia.org/w/index.php?" + args)
|
|
|
+ else:
|
|
|
+ url = simpilib.short_url(q["data"]["url"])
|
|
|
|
|
|
print(text)
|
|
|
- print(smalltext)
|
|
|
- eink_text_qr(text, url, smalltext)
|
|
|
+ print(author)
|
|
|
+ eink_text_qr(text, url, author)
|
|
|
|
|
|
def eink_text_qr(text, qrdata, smalltext=None):
|
|
|
import simpilib
|