-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #798 from Wolfy76700/feature/bsky-post
Added Bluesky posting feature
- Loading branch information
Showing
18 changed files
with
1,131 additions
and
306 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import json | ||
import math | ||
import textwrap | ||
from qtpy.QtGui import * | ||
from qtpy.QtWidgets import * | ||
from qtpy.QtCore import * | ||
from .TSHAltTextHelper import generate_bsky_text, generate_youtube | ||
from .TSHLocaleHelper import TSHLocaleHelper | ||
from src.SettingsManager import SettingsManager | ||
from atproto import Client | ||
from atproto_client.models.app.bsky.embed.defs import AspectRatio | ||
|
||
def post_to_bsky(scoreboardNumber=1, image_path=None): | ||
locale = TSHLocaleHelper.programLocale | ||
bsky_account = SettingsManager.Get("bsky_account", {}) | ||
if not bsky_account or not bsky_account.get("username") or not bsky_account.get("host") or not bsky_account.get("app_password"): | ||
raise ValueError(QApplication.translate("app", "Bluesky account not correctly set")) | ||
client = Client(bsky_account.get("host", "https://bsky.social")) | ||
client.login(bsky_account["username"].lstrip("@"), bsky_account["app_password"]) | ||
|
||
raw_text, builder = generate_bsky_text(scoreboard_id = scoreboardNumber) | ||
yt_title, yt_description = generate_youtube(scoreboard_id = scoreboardNumber) # Use YouTube Description as Alt Text | ||
|
||
pixmap = QPixmap(image_path, "RGBA") | ||
aspect_ratio = AspectRatio(width=pixmap.width(), height=pixmap.height()) | ||
|
||
with open(image_path, "rb") as image: | ||
post = client.send_images(builder, images=[image.read()], image_alts=[yt_description], langs=[locale], image_aspect_ratios=[aspect_ratio]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.