Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Dec 19, 2022
1 parent 0e37a11 commit 1873726
Show file tree
Hide file tree
Showing 37 changed files with 69 additions and 66 deletions.
2 changes: 1 addition & 1 deletion app/brushtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from apscheduler.schedulers.background import BackgroundScheduler

import log
from app.downloader import Qbittorrent, Transmission
from app.downloader.client import Qbittorrent, Transmission
from app.filter import Filter
from app.helper import DbHelper, DictHelper
from app.message import Message
Expand Down
4 changes: 0 additions & 4 deletions app/downloader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
from .client.client115 import Client115
from .client.aria2 import Aria2
from .client.qbittorrent import Qbittorrent
from .client.transmission import Transmission
from .downloader import Downloader
4 changes: 4 additions & 0 deletions app/downloader/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .client115 import Client115
from .aria2 import Aria2
from .qbittorrent import Qbittorrent
from .transmission import Transmission
2 changes: 1 addition & 1 deletion app/downloader/client/aria2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from app.utils.exception_util import ExceptionUtils
from app.utils.types import DownloaderType
from config import Config
from app.downloader.client.client import IDownloadClient
from app.downloader.download_client import IDownloadClient
from app.downloader.client.pyaria2 import PyAria2


Expand Down
2 changes: 1 addition & 1 deletion app/downloader/client/client115.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import log
from app.utils.types import DownloaderType
from config import Config
from app.downloader.client.client import IDownloadClient
from app.downloader.download_client import IDownloadClient
from app.downloader.client.py115 import Py115


Expand Down
2 changes: 1 addition & 1 deletion app/downloader/client/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import log
import qbittorrentapi
from app.downloader.client.client import IDownloadClient
from app.downloader.download_client import IDownloadClient
from app.utils.exception_util import ExceptionUtils
from app.utils.types import DownloaderType
from config import Config
Expand Down
2 changes: 1 addition & 1 deletion app/downloader/client/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from app.utils.exception_util import ExceptionUtils
from app.utils.types import DownloaderType
from config import Config
from app.downloader.client.client import IDownloadClient
from app.downloader.download_client import IDownloadClient


class Transmission(IDownloadClient):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from threading import Lock

import log
from app.downloader import Aria2, Client115, Qbittorrent, Transmission
from app.downloader.client import Aria2, Client115, Qbittorrent, Transmission
from app.filetransfer import FileTransfer
from app.helper import DbHelper, ThreadHelper
from app.media import MetaInfo, Media
Expand Down
4 changes: 0 additions & 4 deletions app/indexer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .client.builtin import BuiltinIndexer
from .client.jackett import Jackett
from .client.prowlarr import Prowlarr
from .client.rarbg import Rarbg
4 changes: 4 additions & 0 deletions app/indexer/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .builtin import BuiltinIndexer
from .jackett import Jackett
from .prowlarr import Prowlarr
from .rarbg import Rarbg
3 changes: 0 additions & 3 deletions app/mediaserver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from .server.emby import Emby
from .server.jellyfin import Jellyfin
from .server.plex import Plex
from .media_server import MediaServer
from .webhook_event import WebhookEvent
3 changes: 3 additions & 0 deletions app/mediaserver/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .emby import Emby
from .jellyfin import Jellyfin
from .plex import Plex
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import log
from app.utils.exception_util import ExceptionUtils
from config import Config
from app.mediaserver.server.server import IMediaServer
from app.mediaserver.media_client import IMediaClient
from app.utils.commons import singleton
from app.utils import RequestUtils, SystemUtils
from app.utils.types import MediaType, MediaServerType


@singleton
class Emby(IMediaServer):
class Emby(IMediaClient):
_apikey = None
_host = None
_user = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from app.utils.exception_util import ExceptionUtils
from app.utils.types import MediaServerType
from config import Config
from app.mediaserver.server.server import IMediaServer
from app.mediaserver.media_client import IMediaClient
from app.utils.commons import singleton
from app.utils import RequestUtils, SystemUtils


@singleton
class Jellyfin(IMediaServer):
class Jellyfin(IMediaClient):
_apikey = None
_host = None
_user = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import log
from config import Config
from app.mediaserver.server.server import IMediaServer
from app.mediaserver.media_client import IMediaClient
from app.utils.commons import singleton
from plexapi.server import PlexServer


@singleton
class Plex(IMediaServer):
class Plex(IMediaClient):
_host = None
_token = None
_username = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABCMeta, abstractmethod


class IMediaServer(metaclass=ABCMeta):
class IMediaClient(metaclass=ABCMeta):

@abstractmethod
def get_status(self):
Expand Down
2 changes: 1 addition & 1 deletion app/mediaserver/media_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from app.helper import ProgressHelper
from app.utils.types import MediaServerType
from config import Config
from app.mediaserver import Emby, Jellyfin, Plex
from app.mediaserver.client import Emby, Jellyfin, Plex

lock = threading.Lock()
server_lock = threading.Lock()
Expand Down
Empty file removed app/mediaserver/server/__init__.py
Empty file.
File renamed without changes.
5 changes: 2 additions & 3 deletions app/message/channel/bark.py → app/message/client/bark.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from urllib.parse import quote_plus

import log
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils, StringUtils
from app.utils.exception_util import ExceptionUtils


class Bark(IMessageChannel):
class Bark(IMessageClient):
_server = None
_apikey = None
_client_config = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils, StringUtils
from app.utils.exception_util import ExceptionUtils


class Gotify(IMessageChannel):
class Gotify(IMessageClient):
_server = None
_token = None
_priority = None
Expand Down
5 changes: 2 additions & 3 deletions app/message/channel/iyuu.py → app/message/client/iyuu.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from urllib.parse import urlencode

import log
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils
from app.utils.exception_util import ExceptionUtils


class IyuuMsg(IMessageChannel):
class IyuuMsg(IMessageClient):
_token = None
_client_config = {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import time
from urllib.parse import urlencode

import log
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils
from app.utils.exception_util import ExceptionUtils


class PushPlus(IMessageChannel):
class PushPlus(IMessageClient):
_token = None
_topic = None
_channel = None
Expand All @@ -22,7 +21,7 @@ def init_config(self):
if self._client_config:
self._token = self._client_config.get('token')
self._topic = self._client_config.get('topic')
self._channel = self._client_config.get('channel')
self._channel = self._client_config.get('client')
self._webhook = self._client_config.get('webhook')

def send_msg(self, title, text="", image="", url="", user_id=""):
Expand All @@ -43,7 +42,7 @@ def send_msg(self, title, text="", image="", url="", user_id=""):
try:
values = {
"token": self._token,
"channel": self._channel,
"client": self._channel,
"topic": self._topic,
"webhook": self._webhook,
"title": title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from urllib.parse import urlencode

import log
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils
from app.utils.exception_util import ExceptionUtils


class ServerChan(IMessageChannel):
class ServerChan(IMessageClient):
_sckey = None
_client_config = {}

Expand Down
5 changes: 2 additions & 3 deletions app/message/channel/slack.py → app/message/client/slack.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import json
import re
from threading import Lock

import requests
from slack_sdk.errors import SlackApiError

import log
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils.exception_util import ExceptionUtils
from config import Config
from slack_bolt import App
Expand All @@ -15,7 +14,7 @@
lock = Lock()


class Slack(IMessageChannel):
class Slack(IMessageClient):
_client_config = {}
_interactive = False
_ds_url = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import log
from app.helper import ThreadHelper
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils
from app.utils.exception_util import ExceptionUtils
from config import Config
Expand All @@ -14,7 +14,7 @@
WEBHOOK_STATUS = False


class Telegram(IMessageChannel):
class Telegram(IMessageClient):
_telegram_token = None
_telegram_chat_id = None
_webhook = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
import threading
from datetime import datetime

import log
from app.message.channel.channel import IMessageChannel
from app.message.message_client import IMessageClient
from app.utils import RequestUtils
from app.utils.exception_util import ExceptionUtils
from config import DEFAULT_WECHAT_PROXY

lock = threading.Lock()


class WeChat(IMessageChannel):
class WeChat(IMessageClient):
_instance = None
_access_token = None
_expires_in = None
Expand Down
6 changes: 3 additions & 3 deletions app/message/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from app.utils.commons import singleton
from config import Config
from app.helper import DbHelper
from app.message.channel import Bark, IyuuMsg, PushPlus, ServerChan, Telegram, WeChat, Slack, Gotify
from app.message.client import Bark, IyuuMsg, PushPlus, ServerChan, Telegram, WeChat, Slack, Gotify
from app.utils import StringUtils
from app.message.message_center import MessageCenter
from app.utils.types import SearchType, MediaType
Expand All @@ -23,7 +23,7 @@ class Message:

# 消息通知类型
MESSAGE_DICT = {
"channel": {
"client": {
"telegram": {"name": "Telegram", "img_url": "../static/img/telegram.png", "search_type": SearchType.TG},
"wechat": {"name": "微信", "img_url": "../static/img/wechat.png", "search_type": SearchType.WX},
"serverchan": {"name": "Server酱", "img_url": "../static/img/serverchan.png"},
Expand Down Expand Up @@ -87,7 +87,7 @@ def init_config(self):
self._active_clients.append({
"name": name,
"type": ctype,
"search_type": self.MESSAGE_DICT.get('channel').get(ctype, {}).get('search_type'),
"search_type": self.MESSAGE_DICT.get('client').get(ctype, {}).get('search_type'),
"client": self.__build_client(ctype, config, interactive),
"config": config,
"switchs": switchs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from abc import ABCMeta, abstractmethod


class IMessageChannel(metaclass=ABCMeta):
class IMessageClient(metaclass=ABCMeta):

@abstractmethod
def init_config(self):
"""
初始化配置
"""
pass

@abstractmethod
def send_msg(self, title, text, image, url, user_id):
Expand Down
2 changes: 1 addition & 1 deletion app/rsschecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import traceback

import jsonpath
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from apscheduler.executors.pool import ThreadPoolExecutor
from apscheduler.schedulers.background import BackgroundScheduler
from lxml import etree

Expand Down
2 changes: 1 addition & 1 deletion app/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random
import traceback

from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from apscheduler.executors.pool import ThreadPoolExecutor
from apscheduler.schedulers.background import BackgroundScheduler

import log
Expand Down
2 changes: 1 addition & 1 deletion app/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from config import Config
from app.message import Message
from app.downloader import Downloader
from app.indexer import BuiltinIndexer, Jackett, Prowlarr
from app.indexer.client import BuiltinIndexer, Jackett, Prowlarr
from app.media import Media
from app.helper import ProgressHelper
from app.utils.types import SearchType, MediaType
Expand Down
1 change: 1 addition & 0 deletions log.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
LOG_QUEUE = deque(maxlen=200)
LOG_INDEX = 0


class Logger:
logger = None
__instance = {}
Expand Down
5 changes: 3 additions & 2 deletions web/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
import log
from app.brushtask import BrushTask
from app.doubansync import DoubanSync
from app.downloader import Qbittorrent, Transmission, Downloader
from app.downloader import Downloader
from app.downloader.client import Qbittorrent, Transmission
from app.filetransfer import FileTransfer
from app.filter import Filter
from app.helper import DbHelper, DictHelper, ChromeHelper, ProgressHelper, ThreadHelper, \
MetaHelper, DisplayHelper, WordsHelper
from app.indexer import BuiltinIndexer
from app.indexer.client import BuiltinIndexer
from app.media import Category, Media, MetaInfo, MetaBase
from app.media.bangumi import Bangumi
from app.media.douban import DouBan
Expand Down
Loading

0 comments on commit 1873726

Please sign in to comment.