social media crossposting tool. 3rd time's the charm
mastodon misskey crossposting bluesky

this is so ruff

zenfyr.dev 49f701f6 eef826f3

verified
+7 -12
+1 -3
cross/media.py
··· 148 148 "json", 149 149 "pipe:0", 150 150 ] 151 - proc = subprocess.run( 152 - cmd, input=bytes, stdout=subprocess.PIPE, stderr=subprocess.PIPE 153 - ) 151 + proc = subprocess.run(cmd, input=bytes, capture_output=True) 154 152 155 153 if proc.returncode != 0: 156 154 raise RuntimeError(f"ffprobe failed: {proc.stderr.decode()}")
+2 -2
mastodon/parser.py
··· 7 7 class StatusParser(HTMLToTokensParser): 8 8 def __init__(self, status: dict[str, Any]) -> None: 9 9 super().__init__() 10 - self.tags: set[str] = set(tag["url"] for tag in status.get("tags", [])) 11 - self.mentions: set[str] = set(m["url"] for m in status.get("mentions", [])) 10 + self.tags: set[str] = {tag["url"] for tag in status.get("tags", [])} 11 + self.mentions: set[str] = {m["url"] for m in status.get("mentions", [])} 12 12 13 13 @override 14 14 def handle_a_endtag(self):
+2 -2
misskey/input.py
··· 109 109 tags: list[str] = note.get("tags") or [] 110 110 111 111 handles: list[tuple[str, str]] = [] 112 - for key, value in mention_handles.items(): 112 + for _key, value in mention_handles.items(): 113 113 handles.append((value, value)) 114 114 115 115 parser = MarkdownParser() # TODO MFM parser ··· 119 119 post.attachments.put(RemoteUrlAttachment(url=self.url + "/notes/" + note["id"])) 120 120 if renote: 121 121 post.attachments.put(QuoteAttachment(quoted_id=renote['id'], quoted_user=self.user_id)) 122 - if any([a.get("isSensitive", False) for a in note.get("files", [])]): 122 + if any(a.get("isSensitive", False) for a in note.get("files", [])): 123 123 post.attachments.put(SensitiveAttachment(sensitive=True)) 124 124 if note.get("cw"): 125 125 post.attachments.put(LabelsAttachment(labels=[note["cw"]]))
+2 -5
util/cache.py
··· 2 2 import time 3 3 from abc import ABC, abstractmethod 4 4 from pathlib import Path 5 - from typing import Generic, TypeVar, override 6 - 5 + from typing import override 7 6 8 - K = TypeVar("K") 9 - V = TypeVar("V") 10 7 11 8 class Cacheable(ABC): 12 9 @abstractmethod ··· 17 14 def load_cache(self, path: Path): 18 15 pass 19 16 20 - class TTLCache(Generic[K, V], Cacheable): 17 + class TTLCache[K, V](Cacheable): 21 18 def __init__(self, ttl_seconds: int = 3600) -> None: 22 19 self.ttl: int = ttl_seconds 23 20 self.__cache: dict[K, tuple[V, float]] = {}