Open KingOfGerrit opened 1 year ago
Have you solved it yet? I have the same problem
Have you solved it yet? I have the same problem
# Timezone to apply on timestamps when building the site. If no value
# is specified, all timestamps are in UTC:
# Eg: US/Eastern Asia/Kolkata
timezone: ""
Leave time zone blank
With timezone
blank, the site builds, but timestamps are all in UTC time. Is it an issue with newer python? I see OP using 3.10 and I have 3.11.2, but tg-archive
only tested with 3.8.6...
With
timezone
blank, the site builds, but timestamps are all in UTC time. Is it an issue with newer python? I see OP using 3.10 and I have 3.11.2, buttg-archive
only tested with 3.8.6...
I'm using python 3.8.6 (Windows 10) and got this issue too
tg-archive --build
2023-10-05 07:02:59,918: building site
Traceback (most recent call last):
File "C:\Python38\Scripts\tg-archive-script.py", line 33, in <module>
sys.exit(load_entry_point('tg-archive==1.1.3', 'console_scripts', 'tg-archive')())
File "c:\python38\lib\site-packages\tgarchive\__init__.py", line 161, in main
b.build()
File "c:\python38\lib\site-packages\tgarchive\build.py", line 87, in build
self._render_page(messages, month, dayline,
File "c:\python38\lib\site-packages\tgarchive\build.py", line 116, in _render_page
html = self.template.render(config=self.config,
File "c:\python38\lib\site-packages\jinja2\environment.py", line 1301, in render
self.environment.handle_exception()
File "c:\python38\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 90, in top-level template code
File "c:\python38\lib\site-packages\jinja2\environment.py", line 485, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2020-03-08'
The problem seems to be the date
stored in the database is in UTC, but when tg-archive pulls it out (such as in File "\<template>", line 90), it is corrected by the timezone
setting, creating a discrepancy that causes the crash. For me, it appears to happen in the beginning of the database when the day changes from 1/31 to 2/1. I think tg-archive pulls a message from early 2/1 which turns to 1/31 when timezone is applied and freaks it out. Maybe if you are lucky and all your messages at the beginning of all your months are more than timezone
hours from UTC midnight, then you might get a successful build?
By changing line 90 to get rid of the counting,
<span class="title">{{ day }} <span class="count">(X messages)</span></span>
the --build
command completes (using --symlink
here too), but there are still problems:
2023-10.html
actually starts with messages from the end of Sep within timezone
offset hours of midnight Oct 1, corresponding to messages in the database that begin on/after Oct 1 midnight UTC. All months begin like this as long as you have messages within the time frame of your timezone
offset.title
for all media has already been saved in the database with a UTC date + time. For example, a photo sent at HH:MM local time has already been saved to the database with a title
of photo_YYYY-MM-DD_(HH+tz offset)-mm-ss.jpg
. If media is sent around the end of the month or year then MM-DD or YYYY-MM-DD could also be different from the local time stamp.Maybe by adding timezone
offset hours to the day
variable or elsewhere in the template.html
could fix all of this? I tried for too long and couldn't figure out, apparently there is a datetime.timedelta(hours=H)
that could be used but could not figure out how, kept getting different errors such as jinja2.exceptions.UndefinedError: 'datetime.datetime object' has no attribute 'timedelta'
or jinja2.exceptions.UndefinedError: 'datetime' is undefined
even though I put import datetime
all over the place and m.date
is already a datetime
object. 🤬
I found another workaround using JavaScript. This will adjust the time/date stamps of the site to the timezone corresponding to the viewer's locale setting. It has some of the same issues from my previous findings, but not as bad. E.g. the messages at the beginning/ending of each day/month remain under their original date, but all messages from the database up to the present are shown now, at least.
Starting on line 2 of main.js, I inserted this code (had some fun with the box drawing chars with my comments, sorry in advance!):
is it issue is still not solved anyway? try to fix some code with get_timeline and cannot find working solution... how to fix this just using utc shift in config.yaml? without any timezone descriptor...
Looks like this hasn't been resolved yet. If somebody can debug this and send a PR, will be happy to merge.
Can someone provide some replication for this issue? I am not able to replicate this issue, I think for some specific dates it is acting weird. A dump of sqllite db with anonymised values should help.
Have issue when run
tg-archive --build
Error:Config: