knadh / tg-archive

A tool for exporting Telegram group chats into static websites like mailing list archives.
MIT License
829 stars 121 forks source link

add timezone in building progress #94

Closed Seele0oO closed 1 year ago

Seele0oO commented 1 year ago

The default TZ is utc+0. I think it would be more helpful to the visitors of the site if this feature is added.

Seele0oO commented 1 year ago
2023-02-27 10:20:21,264: building site
Traceback (most recent call last):
  File "/usr/local/bin/tg-archive", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/__init__.py", line 161, in main
    b.build()
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/build.py", line 87, in build
    self._render_page(messages, month, dayline,
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/build.py", line 116, in _render_page
    html = self.template.render(config=self.config,
  File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/dist-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 "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2019-10-25'

there is some error.

Seele0oO commented 1 year ago

same error in another tg-archive project

2023-02-27 10:24:18,143: building site
Traceback (most recent call last):
  File "/usr/local/bin/tg-archive", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/__init__.py", line 161, in main
    b.build()
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/build.py", line 87, in build
    self._render_page(messages, month, dayline,
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/build.py", line 116, in _render_page
    html = self.template.render(config=self.config,
  File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/dist-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 "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2020-06-01'
knadh commented 1 year ago

hmm, investigating this.

Seele0oO commented 1 year ago

Thank you for your attention.

knadh commented 1 year ago

Unable to reproduce this.

Seele0oO commented 1 year ago
  1. image
  2. no,I'm using the default.
knadh commented 1 year ago

Tried Asia/Shanghai and it works fine on a site with messages that span multiple years. Maybe there is one particular entry in your DB that's somehow being counted as UTC (in the get_timeline() method perhaps) and with a timezone when generating the message. I missed adding timezone support to get_timeline() and get_dayline(). Will add a push a fix.

knadh commented 1 year ago

Can you try v1.1.1?

Seele0oO commented 1 year ago
2023-02-27 12:19:00,746: building site
Traceback (most recent call last):
  File "/usr/local/bin/tg-archive", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/__init__.py", line 161, in main
    b.build()
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/build.py", line 87, in build
    self._render_page(messages, month, dayline,
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/build.py", line 116, in _render_page
    html = self.template.render(config=self.config,
  File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/dist-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 "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2019-10-25'
tg-archive -v
v1.1.1

it's a bad news.

Seele0oO commented 11 months ago

@knadh I noticed this again as I have in trying to update all the packages, currently removing the softlinks in the build parameter, I think it may work, due to the number of media files in the message it may take a few hours to know the exact result. If it still fails, I will try to do some testing in github action.

Seele0oO commented 11 months ago

It doesn't seem feasible, but I made a github action to do automatic testing.

scarlion1 commented 10 months ago

Hi @Seele0oO have you figured anything yet? It is caused by using --symlinks option? Anything I can to do help fix?

Seele0oO commented 10 months ago

@scarlion1 I apologize for the long delay in responding. It may not have been a problem with my judgment, now I have to go back to version 1.0.0.

scarlion1 commented 10 months ago

@Seele0oO No worries, we are still working on it over on #99