Skip to content

Commit

Permalink
增加功能
Browse files Browse the repository at this point in the history
替换豆瓣评分
过滤指定媒体
开关媒体名称同步
  • Loading branch information
sleikang committed Jun 16, 2024
1 parent 7bbc0c5 commit 9e600a5
Show file tree
Hide file tree
Showing 14 changed files with 891 additions and 681 deletions.
22 changes: 22 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
- docker:dind

stages:
- build-and_push

variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/ # 设置DOCKER_HOST指向docker服务
DOCKER_TLS_CERTDIR: "" # 禁用TLS验证(仅在安全环境下使用)

before_script:
- docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD

build-and_push:
stage: build-and_push
script:
- docker build -t media_server_tools .
- docker tag media_server_tools $DOCKER_HUB_USERNAME/media_server_tools:latest
- docker push $DOCKER_HUB_USERNAME/media_server_tools:latest
only:
- main
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ WORKDIR /app
COPY . /app

RUN pip install -r requirements.txt
RUN pip install --index-url https://nexus3.smwap.top:88/repository/python/simple network
RUN pip install --index-url https://nexus3.smwap.top:88/repository/python/simple system

CMD ["python", "main.py"]
667 changes: 367 additions & 300 deletions media.py → api/media.py

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions system/config.py → api/media_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
import os


class config:
path = None
configdata = None
defaultconfig = None
apidata = None
systemdata = None

def __init__(self, path: str) -> None:
class MediaConfig:
def __init__(self) -> None:
try:
# 打开文件
self.defaultconfig = yaml.load(
open("config.default.yaml", "r", encoding="utf-8"),
Loader=yaml.FullLoader,
)
self.path = path
self.configdata = yaml.load(
open(self.path, "r", encoding="utf-8"), Loader=yaml.FullLoader
open(
os.path.join(os.getcwd(), "config", "config.yaml"),
"r",
encoding="utf-8",
),
Loader=yaml.FullLoader,
)

# 递归检查配置文件是否包含默认配置文件的所有配置项
for key in self.defaultconfig:
self.__config_check__(self.configdata, key, self.defaultconfig[key])

self.systemdata = self.configdata["system"]
self.apidata = self.configdata["api"]

except Exception as result:
log().logger.info("配置异常错误, {}".format(result))

Expand Down
593 changes: 443 additions & 150 deletions api/mediasql.py

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,20 @@ system:
# - "xxx"
excludepath:
- "合集"
#排除媒体
#例如
#excludemedia:
# - "xxx"
excludemedia:
- "进击的巨人"
#使用媒体服务器 Emby Jellyfin Plex
mediaserver: "Emby"
#线程数量 豆瓣API有请求频率限制建议线程数量不要过多
threadnum: 10
#是否更新豆瓣评分
updatescore: False
#是否更新标题
updatetitle: True
#是否刷新人名
updatepeople: False
#是否更新概述
Expand Down
19 changes: 19 additions & 0 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
api:
nastools:
#授权码
authorization: ""
#域名 包含http(s)和端口号后面不带/
#例如http://xxx.xxx.xxx:3000
host: "http://127.0.0.1:3000"
Expand Down Expand Up @@ -51,10 +53,27 @@ api:
peoplecachefailtime: 120

system:
#排除媒体文件夹
#例如
#excludepath:
# - "AV"
# - "xxx"
excludepath:
- "合集"
#排除媒体
#例如
#excludemedia:
# - "xxx"
excludemedia:
- "进击的巨人"
#使用媒体服务器 Emby Jellyfin Plex
mediaserver: "Emby"
#线程数量 豆瓣API有请求频率限制建议线程数量不要过多
threadnum: 10
#是否更新豆瓣评分
updatescore: False
#是否更新标题
updatetitle: True
#是否刷新人名
updatepeople: False
#是否更新概述
Expand Down
14 changes: 13 additions & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,22 @@ system:
# - "xxx"
excludepath:
- "合集"
excludepath:
- "合集"
#排除媒体
#例如
#excludemedia:
# - "xxx"
excludemedia:
- "进击的巨人"
#使用媒体服务器 Emby Jellyfin Plex
mediaserver: "Emby"
#线程数量 豆瓣API有请求频率限制建议线程数量不要过多
threadnum: 10
threadnum: 1
#是否更新豆瓣评分
updatescore: True
#是否更新标题
updatetitle: True
#是否刷新人名
updatepeople: False
#是否更新概述
Expand Down
14 changes: 7 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import time
import shutil
from media import media
from system.config import config
from api.media import media
from system.log import log
from api.media_config import MediaConfig
from system.config import Config

if __name__ == "__main__":
try:
Expand All @@ -20,16 +21,15 @@
"默认配置文件不存在, 拷贝默认配置文件[config.default.yaml]->[/config/config.default.yaml]"
)
shutil.copy("config.default.yaml", "config/config.default.yaml")

path = os.path.join(os.getcwd(), "config", "config.yaml")
configinfo = config(path=path)
mediaclient = media(configinfo=configinfo)
_ = MediaConfig()
config = Config().get_config()
mediaclient = media()
while True:
try:
log().logger.info("开始刷新媒体库元数据")
mediaclient.start_scan_media()
log().logger.info("刷新媒体库元数据完成")
time.sleep(configinfo.systemdata["updatetime"] * 3600)
time.sleep(config["system"]["updatetime"] * 3600)
except Exception as result:
log().logger.info(result)
except Exception as result:
Expand Down
Empty file removed network/__init__.py
Empty file.
51 changes: 0 additions & 51 deletions network/client_data.py

This file was deleted.

101 changes: 0 additions & 101 deletions network/network.py

This file was deleted.

36 changes: 0 additions & 36 deletions system/log.py

This file was deleted.

Loading

0 comments on commit 9e600a5

Please sign in to comment.