Skip to content

Commit

Permalink
fix!(parsing.tgraph): media upload to Telegraph no longer feasible
Browse files Browse the repository at this point in the history
Details: https://t.me/durov/343

This partially reverts "feat(parsing/tgraph): upload media to Telegraph"
(2968401) and "docs(README):
highlights: media upload to Telegraph"
(b2d3efc).

Signed-off-by: Rongrong <[email protected]>
  • Loading branch information
Rongronggg9 committed Sep 6, 2024
1 parent 01ee843 commit 160b89f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
- Automatically show the author-name (customizable)
- Automatically split too-long messages
- Messages can be sent as Telegraph posts (customizable)
- Most images and videos will be uploaded to Telegraph, so that Instant View will load rapidly
- [Various customizable formatting settings](docs/formatting-settings.md)
- Hashtags, custom title, etc.
- Individual proxy settings for Telegram and RSS feeds
Expand Down
1 change: 0 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
- 自动显示作者名 (可自定义)
- 自动切分超长消息
- 消息可作为 Telegraph 文章发送 (可自定义)
- 大部分图片和视频会被上传至 Telegraph,以便 Instant View 可迅速加载
- [丰富的自定义格式设定](docs/formatting-settings.md)
- Hashtag、自定义标题,等等
- 为 Telegram 和 RSS 源配置独立的代理设置
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### BREAKING CHANGES

Media (image and video) are no longer uploaded when generating Telegraph posts due to [Telegraph disabling media upload](https://t.me/durov/343). (first introduced in v2.6.0)

### Addition

- **Disable TLS certificate verification**: The environment variable `VERIFY_TLS` has been added to disable (when set to `0`) or enable (when set to `1`, default) TLS certificate verification. This is useful when subscribing to feeds with their TLS misconfigured. Note: Disabling TLS certificate verification is not recommended and should only be used as a last resort.
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 未发布

### 重大变更

由于 [Telegraph 禁用了媒体上传](https://t.me/durov/343),生成 Telegraph 文章时不再上传媒体 (图片与视频) 。(在 v2.6.0 中首次引入)

### 新增功能

- **关闭 TLS 证书验证**: 环境变量 `VERIFY_TLS` 已被添加以禁用 (设置为 `0` 时) 或启用 (设置为 `1` 时,默认) TLS 证书验证。当订阅 TLS 被错误配置的 feed 时,这很有用。注意:不建议禁用 TLS 证书验证,只应用作最后手段。
Expand Down
18 changes: 6 additions & 12 deletions src/parsing/tgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from .. import env, log
from .utils import is_emoticon, emojify, resolve_relative_link, isAbsoluteHttpLink
from ..web.media import construct_weserv_url, upload_to_telegraph
from ..web.media import construct_weserv_url
from ..aio_helper import run_async

convert_table_to_png: Optional[Awaitable]
Expand Down Expand Up @@ -309,18 +309,12 @@ async def generate_page(self):
if not isAbsoluteHttpLink(attr_content):
tag.replaceWithChildren()
continue
if (
tag.name in {'video', 'img'}
and not attr_content.startswith(env.IMG_RELAY_SERVER)
and not attr_content.startswith(env.IMAGES_WESERV_NL)
):
if uploaded_url := await upload_to_telegraph(attr_content):
attr_content = uploaded_url
elif tag.name == 'video':
if not attr_content.startswith(env.IMG_RELAY_SERVER):
if tag.name == 'video':
attr_content = env.IMG_RELAY_SERVER + attr_content
elif attr_content.split('.', 1)[1].split('/', 1)[0] == 'sinaimg.cn':
attr_content = env.IMG_RELAY_SERVER + attr_content
else: # other images
if tag.name == 'img' and not attr_content.startswith(env.IMAGES_WESERV_NL):
if attr_content.split('.', 1)[1].split('/', 1)[0] == 'sinaimg.cn':
attr_content = env.IMG_RELAY_SERVER + attr_content
attr_content = construct_weserv_url(attr_content)
tag.attrs = {attr_name: attr_content}

Expand Down

0 comments on commit 160b89f

Please sign in to comment.