-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,051 additions
and
244 deletions.
There are no files selected for viewing
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,19 @@ | ||
# 使用 Alpine Linux 作为基础镜像 | ||
FROM python:3.8-alpine | ||
|
||
# 将工作目录设置为 /app | ||
WORKDIR /app | ||
|
||
# 将当前目录的内容复制到容器的 /app 目录中 | ||
COPY . /app | ||
|
||
# 安装需要的 Python 库 | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# 将启动脚本添加到镜像中 | ||
COPY start.sh /start.sh | ||
RUN chmod +x /start.sh | ||
|
||
# 设置容器的启动命令 | ||
ENTRYPOINT ["/start.sh"] | ||
CMD ["python", "plex-edition-manager.py"] |
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,11 @@ | ||
version: "2" | ||
services: | ||
pem-reset: | ||
image: x1ao4/plex-edition-manager:latest | ||
container_name: pem-reset | ||
command: python plex-edition-manager.py --reset | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- /自定义目录/plex-edition-manager/config:/app/config | ||
networks: {} |
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,36 @@ | ||
version: "2" | ||
services: | ||
pem-scheduler: | ||
image: mcuadros/ofelia:latest | ||
container_name: pem-scheduler | ||
depends_on: | ||
- pem-all | ||
command: daemon --docker -f label=com.docker.compose.project=${COMPOSE_PROJECT_NAME} | ||
labels: | ||
ofelia.job-run.pem-all.schedule: 0 30 22 * * * | ||
ofelia.job-run.pem-all.container: pem-all | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock:ro | ||
restart: unless-stopped | ||
pem-all: | ||
image: x1ao4/plex-edition-manager:latest | ||
container_name: pem-all | ||
command: python plex-edition-manager.py --all | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- /自定义目录/plex-edition-manager/config:/app/config | ||
pem-new: | ||
image: x1ao4/plex-edition-manager:latest | ||
container_name: pem-new | ||
command: python plex-edition-manager.py --new | ||
ports: | ||
- 8089:8089 | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- /自定义目录/plex-edition-manager/config:/app/config | ||
restart: unless-stopped | ||
networks: {} |
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,8 @@ | ||
[server] | ||
address = http://127.0.0.1:32400 | ||
token = | ||
skip_libraries = | ||
language = zh | ||
|
||
[modules] | ||
order = 片源版本;动态范围 |
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,35 @@ | ||
import requests | ||
|
||
def get_AudioCodec(server, token, movie_id, language): | ||
# 发送请求获取元数据 | ||
headers = {'X-Plex-Token': token, 'Accept': 'application/json'} | ||
response = requests.get(f'{server}/library/metadata/{movie_id}', headers=headers) | ||
data = response.json() | ||
|
||
# 从元数据中获取视频流的 title | ||
part = data['MediaContainer']['Metadata'][0]['Media'][0]['Part'][0] | ||
if 'Stream' in part: | ||
# 提取所有音频流 | ||
audio_streams = [stream for stream in part['Stream'] if stream['streamType'] == 2] | ||
if audio_streams: | ||
# 按照声道数排序,如果声道数相同,则按照比特率排序 | ||
audio_streams.sort(key=lambda x: (x.get('channels', 0), x.get('bitrate', 0)), reverse=True) | ||
|
||
audio_info = audio_streams[0]['displayTitle'] | ||
# 从 displayTitle 中提取最后一组括号内的部分作为音频信息 | ||
last_parenthesis_start = audio_info.rfind("(") | ||
last_parenthesis_end = audio_info.rfind(")") | ||
if last_parenthesis_start != -1 and last_parenthesis_end != -1: | ||
audio_info = audio_info[last_parenthesis_start+1:last_parenthesis_end] | ||
else: | ||
audio_info = audio_info | ||
|
||
# 如果语言是中文,将 "Mono" 和 "Stereo" 翻译为中文 | ||
if language == 'zh': | ||
audio_info = audio_info.replace('Mono', '单声道') | ||
audio_info = audio_info.replace('Stereo', '立体声') | ||
|
||
return audio_info | ||
|
||
# 如果没有找到任何音频流,就返回 None | ||
return None |
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,33 @@ | ||
import requests | ||
|
||
def get_Bitrate(server, token, movie_id): | ||
# 发送请求获取元数据 | ||
headers = {'X-Plex-Token': token, 'Accept': 'application/json'} | ||
response = requests.get(f'{server}/library/metadata/{movie_id}', headers=headers) | ||
data = response.json() | ||
|
||
# 初始化最大文件大小为0 | ||
max_size = 0 | ||
max_bitrate = None | ||
|
||
# 遍历每个 Media 对象 | ||
for media in data['MediaContainer']['Metadata'][0]['Media']: | ||
# 遍历每个 Part 对象 | ||
for part in media['Part']: | ||
# 如果这个 Part 的文件大小大于当前的最大文件大小,就更新最大文件大小和比特率 | ||
if part['size'] > max_size: | ||
max_size = part['size'] | ||
max_bitrate = media.get('bitrate') | ||
|
||
# 如果没有找到任何视频文件,返回 None | ||
if max_bitrate is None: | ||
return None | ||
|
||
# 将比特率从 Kbps 转换为 Mbps | ||
video_bitrate_mbps = max_bitrate / 1000 | ||
# 如果比特率小于 1 Mbps,则使用 Kbps 作为单位,并四舍五入到整数 | ||
if video_bitrate_mbps < 1: | ||
return f"{round(max_bitrate)} Kbps" | ||
else: | ||
# 四舍五入到小数点后一位,并使用 Mbps 作为单位 | ||
return f"{round(video_bitrate_mbps, 1)} Mbps" |
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,9 @@ | ||
def get_ContentRating(metadata): | ||
# 从元数据中获取内容分级信息 | ||
contentRating = metadata.get('contentRating', None) | ||
|
||
# 如果内容分级为 "Not Rated",将其转换为 "NR" | ||
if contentRating == 'Not Rated': | ||
contentRating = 'NR' | ||
|
||
return contentRating |
Oops, something went wrong.