Remove subscription save file

This commit is contained in:
BreadTube 2026-01-09 00:56:48 +09:00
commit 3d7ec85a55

View file

@ -3,7 +3,6 @@ from __future__ import annotations
from enum import Enum
import html
import http.client
import json
import logging
import operator
from pathlib import Path
@ -14,7 +13,7 @@ from typing import Any
import traceback
from .config import Config
from .discord_manager import ApiEncoder, DiscordManager
from .discord_manager import DiscordManager
from .logger import create_logger
from .objects import (ChannelCategory, FileMime, Message, MessageReference, MessageReferenceType, Overwrite,
OverwriteType, Permissions, Role, TextChannel)
@ -29,7 +28,6 @@ class Bot:
INIT_MESSAGE: str = ('Bot initialized.\nThis is the current configuration used.\n'
'You can upload a new one to update the configuration.')
MAX_DOWNLOAD_SIZE: int = 50_000
SUBS_SAVE_PATH: Path = Path('/tmp/breadtube-bot_subs.json')
class Task(Enum):
DELETE_MESSAGES = 1
@ -90,14 +88,6 @@ class Bot:
self.yt_manager = YoutubeManager(logger=self.logger)
self._yt_subscriptions: Subscriptions = {}
if self.SUBS_SAVE_PATH.exists():
try:
self._yt_subscriptions = {
name: SubscriptionInfo.from_dict(info) for name, info in json.loads(
self.SUBS_SAVE_PATH.read_text(encoding='utf-8')).items()}
except Exception:
self.logger.error('Cannot load saved subscriptions at path "%s" -> deleting', self.SUBS_SAVE_PATH)
self.SUBS_SAVE_PATH.unlink()
self._scan_bot_channel()
self.tasks.append((
self.Task.SCAN_BOT_CHANNEL, time.time() + self.config.bot_channel_scan_interval, None))
@ -483,8 +473,6 @@ class Bot:
except Exception as error:
self.logger.error('Error initializing subscriptions : %s -> %s',
error, traceback.format_exc().replace('\n', ' | '))
self.SUBS_SAVE_PATH.write_text(
json.dumps(self._yt_subscriptions, cls=ApiEncoder, ensure_ascii=False), encoding='utf-8')
self.tasks = list(filter(lambda t: t[0] != Bot.Task.REFRESH_SUBS, self.tasks))
self.tasks.append((
self.Task.REFRESH_SUBS, time.time() + self.config.youtube_channel_refresh_interval, None))