render album title
This commit is contained in:
parent
d07e7caab2
commit
7eef48e341
@ -21,7 +21,7 @@ def get_timestamp_of_file(file):
|
|||||||
def album(id):
|
def album(id):
|
||||||
req = IMAGE_CACHE
|
req = IMAGE_CACHE
|
||||||
|
|
||||||
get("a/" + id, req)
|
title = get("a/" + id, req)
|
||||||
found_list_file = IMAGE_CACHE + ("a/" + id).replace('/', '_')
|
found_list_file = IMAGE_CACHE + ("a/" + id).replace('/', '_')
|
||||||
|
|
||||||
with open(found_list_file, 'r') as f:
|
with open(found_list_file, 'r') as f:
|
||||||
@ -40,7 +40,7 @@ def album(id):
|
|||||||
|
|
||||||
with open(f'{template_dir}gallery.html', 'r') as img_view:
|
with open(f'{template_dir}gallery.html', 'r') as img_view:
|
||||||
tpl = SimpleTemplate(img_view)
|
tpl = SimpleTemplate(img_view)
|
||||||
return tpl.render(imgs=imgs)
|
return tpl.render(imgs=imgs, title=title)
|
||||||
|
|
||||||
@route('/')
|
@route('/')
|
||||||
@route('')
|
@route('')
|
||||||
|
@ -41,12 +41,20 @@ def get(url: str, write_dir: str, delete=True):
|
|||||||
img.write(requests.get(url).content)
|
img.write(requests.get(url).content)
|
||||||
if delete:
|
if delete:
|
||||||
Thread(target=delete_file, args=[f"{write_dir}/{url[-11:]}"]).start()
|
Thread(target=delete_file, args=[f"{write_dir}/{url[-11:]}"]).start()
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
found_url = ''
|
found_url = ''
|
||||||
found_urls = []
|
found_urls = []
|
||||||
found_list_file = ''
|
found_list_file = ''
|
||||||
print('Detecting album/gallery images (contentUrl)', url)
|
print('Detecting album/gallery images (contentUrl)', url)
|
||||||
soup = bs4.BeautifulSoup(requests.get(url).text, 'html.parser')
|
soup = bs4.BeautifulSoup(requests.get(url).text, 'html.parser')
|
||||||
|
title = ''
|
||||||
|
try:
|
||||||
|
title = soup.select('meta[property="og:title"]')[0]['content']
|
||||||
|
if title == "Imgur":
|
||||||
|
title = ''
|
||||||
|
except (KeyError, IndexError):
|
||||||
|
title = ''
|
||||||
for count, el in enumerate(soup.select('.post-image-container'), start=1):
|
for count, el in enumerate(soup.select('.post-image-container'), start=1):
|
||||||
if el is None:
|
if el is None:
|
||||||
continue
|
continue
|
||||||
@ -78,3 +86,4 @@ def get(url: str, write_dir: str, delete=True):
|
|||||||
with open(found_list_file, 'w') as f:
|
with open(found_list_file, 'w') as f:
|
||||||
f.write(','.join(found_urls))
|
f.write(','.join(found_urls))
|
||||||
Thread(target=delete_file, args=[found_list_file]).start()
|
Thread(target=delete_file, args=[found_list_file]).start()
|
||||||
|
return title
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charself="utf-8">
|
<meta charself="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>imgin - minimal & private imgur proxy</title>
|
<title>{{title + " - imgin" if title else "imgin - minimal & private imgur proxy"}}</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📷</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📷</text></svg>">
|
||||||
<link rel="stylesheet" href="/static/theme.css">
|
<link rel="stylesheet" href="/static/theme.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
% if title != '':
|
||||||
|
<h1>{{title}}</h1>
|
||||||
|
% end
|
||||||
% for img in imgs:
|
% for img in imgs:
|
||||||
<a href="{{img}}"><img src="{{img}}" loading="lazy"></a>
|
<a href="{{img}}"><img src="{{img}}" loading="lazy"></a>
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
Reference in New Issue
Block a user