podflow 20250212__py3-none-any.whl → 20250301__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Podflow/__init__.py +2 -2
- Podflow/basic/http_client.py +10 -2
- Podflow/bilibili/build.py +8 -6
- Podflow/bilibili/login.py +3 -3
- Podflow/download/youtube_and_bilibili_download.py +2 -1
- Podflow/download_and_build.py +24 -0
- Podflow/httpfs/port_judge.py +5 -12
- Podflow/main.py +2 -240
- Podflow/main_podcast.py +214 -0
- Podflow/main_upload.py +28 -0
- Podflow/makeup/{del_makeup_yt_format_fail.py → del_makeup_format_fail.py} +4 -5
- Podflow/makeup/make_up_file_format_mod.py +8 -8
- Podflow/message/create_main_rss.py +57 -32
- Podflow/message/display_qrcode_and_url.py +9 -11
- Podflow/message/fail_message_initialize.py +5 -0
- Podflow/message/get_media_name.py +26 -0
- Podflow/message/save_rss.py +85 -0
- Podflow/remove/remove_file.py +1 -0
- Podflow/upload/add_upload.py +36 -0
- Podflow/upload/get_upload_original.py +22 -23
- Podflow/upload/linked_client.py +74 -0
- Podflow/upload/linked_server.py +32 -0
- Podflow/upload/update_upload.py +74 -0
- Podflow/upload/upload_print.py +8 -0
- Podflow/youtube/build.py +36 -16
- {podflow-20250212.dist-info → podflow-20250301.dist-info}/METADATA +2 -2
- {podflow-20250212.dist-info → podflow-20250301.dist-info}/RECORD +30 -20
- {podflow-20250212.dist-info → podflow-20250301.dist-info}/WHEEL +0 -0
- {podflow-20250212.dist-info → podflow-20250301.dist-info}/entry_points.txt +0 -0
- {podflow-20250212.dist-info → podflow-20250301.dist-info}/top_level.txt +0 -0
Podflow/__init__.py
CHANGED
@@ -110,12 +110,12 @@ class Application_gVar:
|
|
110
110
|
self.youtube_xml_get_tree = {} # YouTube频道简介和图标字典
|
111
111
|
self.all_youtube_content_ytid = {} # 所有YouTube视频id字典
|
112
112
|
self.all_bilibili_content_bvid = {} # 所有哔哩哔哩视频id字典
|
113
|
-
self.all_items =
|
113
|
+
self.all_items = {} # 更新后所有item明细字典
|
114
114
|
self.overall_rss = "" # 更新后的rss文本
|
115
115
|
self.make_up_file_format = {} # 补全缺失媒体字典
|
116
116
|
self.make_up_file_format_fail = {} # 补全缺失媒体失败字典
|
117
117
|
|
118
|
-
self.upload_original =
|
118
|
+
self.upload_original = [] # 原始上传信息字典
|
119
119
|
|
120
120
|
self.shortcuts_url = {} # 输出至shortcut的url字典
|
121
121
|
|
Podflow/basic/http_client.py
CHANGED
@@ -16,6 +16,7 @@ def http_client(
|
|
16
16
|
cookies=None,
|
17
17
|
data=None,
|
18
18
|
mode="get",
|
19
|
+
filename=None,
|
19
20
|
):
|
20
21
|
user_agent = {
|
21
22
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
|
@@ -52,8 +53,12 @@ def http_client(
|
|
52
53
|
session.params.update(data)
|
53
54
|
for num in range(max_retries):
|
54
55
|
try:
|
55
|
-
if mode != "post":
|
56
|
+
if mode.lower() != "post":
|
56
57
|
response = session.get(url, timeout=8)
|
58
|
+
elif filename:
|
59
|
+
with open(filename, "rb") as f:
|
60
|
+
files = {"file": f} # 这里 "file" 对应服务器端接收文件的字段名称
|
61
|
+
response = session.post(url, files=files, timeout=8)
|
57
62
|
else:
|
58
63
|
response = session.post(url, timeout=8)
|
59
64
|
response.raise_for_status()
|
@@ -64,7 +69,10 @@ def http_client(
|
|
64
69
|
print(
|
65
70
|
f"{datetime.now().strftime('%H:%M:%S')}|{name}|\033[31m连接异常重试中...\033[97m{num + 1}\033[0m"
|
66
71
|
)
|
67
|
-
|
72
|
+
if err:
|
73
|
+
err = f"{err}\n{str(http_get_error)}"
|
74
|
+
else:
|
75
|
+
err = f":\n{str(http_get_error)}"
|
68
76
|
else:
|
69
77
|
return response
|
70
78
|
time.sleep(retry_delay)
|
Podflow/bilibili/build.py
CHANGED
@@ -193,9 +193,11 @@ def bilibili_xml_items(output_dir):
|
|
193
193
|
items = f"""<!-- {{{output_dir}}} -->
|
194
194
|
{items}
|
195
195
|
<!-- {{{output_dir}}} -->"""
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
"
|
200
|
-
|
201
|
-
|
196
|
+
return {
|
197
|
+
"title": title,
|
198
|
+
"link": link,
|
199
|
+
"description": description,
|
200
|
+
"category": category,
|
201
|
+
"icon": icon,
|
202
|
+
"items": items,
|
203
|
+
}
|
Podflow/bilibili/login.py
CHANGED
@@ -8,9 +8,9 @@ import re
|
|
8
8
|
import time
|
9
9
|
from datetime import datetime
|
10
10
|
import requests
|
11
|
-
from
|
12
|
-
from
|
13
|
-
from
|
11
|
+
from Crypto.Cipher import PKCS1_OAEP
|
12
|
+
from Crypto.Hash import SHA256
|
13
|
+
from Crypto.PublicKey import RSA
|
14
14
|
from Podflow.basic.file_save import file_save
|
15
15
|
from Podflow.basic.http_client import http_client
|
16
16
|
from Podflow.basic.qr_code import qr_code
|
@@ -8,7 +8,7 @@ from Podflow.download.dl_aideo_video import dl_aideo_video
|
|
8
8
|
|
9
9
|
# 下载YouTube和哔哩哔哩视频
|
10
10
|
def youtube_and_bilibili_download():
|
11
|
-
for video_id, format_value in gVar.video_id_update_format.items():
|
11
|
+
for video_id, format_value in gVar.video_id_update_format.copy().items():
|
12
12
|
if isinstance(format_value, dict) and format_value["main"] not in gVar.video_id_failed:
|
13
13
|
output_dir_name = format_value["name"]
|
14
14
|
display_color = "\033[35m" if format_value["backward_update"] else "\033[95m"
|
@@ -28,3 +28,4 @@ def youtube_and_bilibili_download():
|
|
28
28
|
write_log(
|
29
29
|
f"{display_color}{output_dir_name}\033[0m|{video_id} \033[31m无法下载\033[0m"
|
30
30
|
)
|
31
|
+
del gVar.video_id_update_format[video_id]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Podflow/download_and_build.py
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
import threading
|
5
|
+
from Podflow.youtube.build import get_youtube_introduction
|
6
|
+
from Podflow.message.create_main_rss import create_main_rss
|
7
|
+
from Podflow.download.youtube_and_bilibili_download import youtube_and_bilibili_download
|
8
|
+
|
9
|
+
|
10
|
+
def get_and_duild():
|
11
|
+
get_youtube_introduction()
|
12
|
+
create_main_rss()
|
13
|
+
|
14
|
+
|
15
|
+
# 下载并构建YouTube和哔哩哔哩视频模块
|
16
|
+
def download_and_build():
|
17
|
+
thread_download = threading.Thread(target=youtube_and_bilibili_download)
|
18
|
+
thread_build = threading.Thread(target=get_and_duild)
|
19
|
+
|
20
|
+
thread_download.start()
|
21
|
+
thread_build.start()
|
22
|
+
|
23
|
+
thread_download.join()
|
24
|
+
thread_build.join()
|
Podflow/httpfs/port_judge.py
CHANGED
@@ -4,18 +4,11 @@
|
|
4
4
|
import socket
|
5
5
|
|
6
6
|
|
7
|
-
def port_judge(
|
8
|
-
# 创建一个新的 socket
|
9
|
-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
10
|
-
# 设置 socket 为可重用
|
11
|
-
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
7
|
+
def port_judge(hostip, port):
|
12
8
|
try:
|
13
|
-
|
14
|
-
|
9
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
10
|
+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
11
|
+
sock.bind((hostip, port))
|
12
|
+
return True
|
15
13
|
except OSError:
|
16
|
-
# 如果绑定失败,说明端口被占用
|
17
14
|
return False
|
18
|
-
else:
|
19
|
-
# 如果绑定成功,端口可用,关闭 socket
|
20
|
-
sock.close()
|
21
|
-
return True
|
Podflow/main.py
CHANGED
@@ -1,65 +1,10 @@
|
|
1
1
|
# Podflow/main.py
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
-
import sys
|
5
|
-
import json
|
6
|
-
import time
|
7
|
-
import urllib
|
8
|
-
import subprocess
|
9
4
|
from datetime import datetime
|
10
5
|
from importlib.metadata import version
|
11
|
-
import
|
12
|
-
|
13
|
-
# 基本功能模块
|
14
|
-
from Podflow import gVar, parse
|
6
|
+
from Podflow.main_podcast import main_podcast
|
15
7
|
from Podflow.parse_arguments import parse_arguments
|
16
|
-
from Podflow.basic.file_save import file_save
|
17
|
-
from Podflow.basic.qr_code import qr_code
|
18
|
-
from Podflow.basic.write_log import write_log
|
19
|
-
from Podflow.basic.split_dict import split_dict
|
20
|
-
|
21
|
-
# 网络和 HTTP 模块
|
22
|
-
from Podflow.httpfs.port_judge import port_judge
|
23
|
-
from Podflow.httpfs.app_bottle import bottle_app_instance
|
24
|
-
|
25
|
-
# 下载和视频处理模块
|
26
|
-
from Podflow.download.delete_part import delete_part
|
27
|
-
from Podflow.download.youtube_and_bilibili_download import youtube_and_bilibili_download
|
28
|
-
from Podflow.ffmpeg_judge import ffmpeg_judge
|
29
|
-
|
30
|
-
# RSS 和消息处理模块
|
31
|
-
from Podflow.message.xml_rss import xml_rss
|
32
|
-
from Podflow.message.backup_zip_save import backup_zip_save
|
33
|
-
from Podflow.message.create_main_rss import create_main_rss
|
34
|
-
from Podflow.message.get_original_rss import get_original_rss
|
35
|
-
from Podflow.message.original_rss_fail_print import original_rss_fail_print
|
36
|
-
from Podflow.message.update_information_display import update_information_display
|
37
|
-
from Podflow.message.update_youtube_bilibili_rss import update_youtube_bilibili_rss
|
38
|
-
from Podflow.message.get_video_format import get_video_format
|
39
|
-
|
40
|
-
# 登录模块
|
41
|
-
from Podflow.bilibili.login import get_bilibili_data
|
42
|
-
from Podflow.youtube.login import get_youtube_cookie
|
43
|
-
|
44
|
-
# 配置和图标模块
|
45
|
-
from Podflow.config.channge_icon import channge_icon
|
46
|
-
from Podflow.config.build_original import build_original
|
47
|
-
|
48
|
-
# 制作和修改文件模块
|
49
|
-
from Podflow.makeup.make_up_file import make_up_file
|
50
|
-
from Podflow.makeup.make_up_file_mod import make_up_file_mod
|
51
|
-
from Podflow.makeup.make_up_file_format_mod import make_up_file_format_mod
|
52
|
-
from Podflow.makeup.del_makeup_yt_format_fail import del_makeup_yt_format_fail
|
53
|
-
|
54
|
-
# 移除模块
|
55
|
-
from Podflow.remove.remove_file import remove_file
|
56
|
-
from Podflow.remove.remove_dir import remove_dir
|
57
|
-
|
58
|
-
# 处理 YouTube 信息模块
|
59
|
-
from Podflow.youtube.build import get_youtube_introduction
|
60
|
-
|
61
|
-
# 长期媒体进行上传模块
|
62
|
-
from Podflow.upload.get_upload_original import get_upload_original
|
63
8
|
|
64
9
|
|
65
10
|
def main():
|
@@ -69,190 +14,7 @@ def main():
|
|
69
14
|
print(
|
70
15
|
f"{datetime.now().strftime('%H:%M:%S')}|Podflow|{version('Podflow')}开始运行....."
|
71
16
|
)
|
72
|
-
|
73
|
-
ffmpeg_judge()
|
74
|
-
# 初始化
|
75
|
-
build_original()
|
76
|
-
# http共享
|
77
|
-
port = gVar.config["port"]
|
78
|
-
host = "0.0.0.0"
|
79
|
-
if port_judge(host, port):
|
80
|
-
# 启动 CherryPy 服务器
|
81
|
-
cherrypy.tree.graft(
|
82
|
-
bottle_app_instance.app_bottle
|
83
|
-
) # 将 Bottle 应用嵌入到 CherryPy 中
|
84
|
-
cherrypy.config.update(
|
85
|
-
{
|
86
|
-
"global": {
|
87
|
-
"tools.sessions.on": True, # 启用会话支持
|
88
|
-
"server.socket_host": host, # 监听所有 IP 地址
|
89
|
-
"server.socket_port": port, # 设置监听端口
|
90
|
-
"log.screen": False, # 禁用屏幕日志输出
|
91
|
-
"log.access_file": "", # 关闭访问日志
|
92
|
-
"log.error_file": "", # 关闭错误日志
|
93
|
-
}
|
94
|
-
}
|
95
|
-
)
|
96
|
-
cherrypy.engine.start() # 启动 CherryPy 服务器
|
97
|
-
print(
|
98
|
-
f"{datetime.now().strftime('%H:%M:%S')}|HTTP服务器启动, 端口: \033[32m{port}\033[0m"
|
99
|
-
)
|
100
|
-
if parse.httpfs: # HttpFS参数判断, 是否继续运行
|
101
|
-
cherrypy.engine.block() # 阻止程序退出, 保持HTTP服务运行
|
102
|
-
else:
|
103
|
-
print(
|
104
|
-
f"{datetime.now().strftime('%H:%M:%S')}|HTTP服务器端口: \033[32m{port}\033[0m, \033[31m被占用\033[0m"
|
105
|
-
)
|
106
|
-
if parse.httpfs:
|
107
|
-
sys.exit(0)
|
108
|
-
# 主流程
|
109
|
-
while parse.update_num > 0 or parse.update_num == -1: # 循环主更新
|
110
|
-
# 暂停进程打印
|
111
|
-
gVar.server_process_print_flag[0] = "pause"
|
112
|
-
# 获取YouTube cookie
|
113
|
-
gVar.youtube_cookie = get_youtube_cookie(gVar.channelid_youtube_ids_original)
|
114
|
-
# 更新哔哩哔哩data
|
115
|
-
gVar.channelid_bilibili_ids, gVar.bilibili_data = get_bilibili_data(
|
116
|
-
gVar.channelid_bilibili_ids_original
|
117
|
-
)
|
118
|
-
# 恢复进程打印
|
119
|
-
bottle_app_instance.cherry_print()
|
120
|
-
# 获取原始xml字典和rss文本
|
121
|
-
gVar.xmls_original, gVar.hash_rss_original, gVar.xmls_original_fail = (
|
122
|
-
get_original_rss()
|
123
|
-
)
|
124
|
-
# 初始化原始上传信息
|
125
|
-
if gVar.config["upload"]:
|
126
|
-
if upload_original := get_upload_original():
|
127
|
-
gVar.upload_original = upload_original
|
128
|
-
else:
|
129
|
-
gVar.config["upload"] = False
|
130
|
-
# 更新Youtube和哔哩哔哩频道xml
|
131
|
-
update_youtube_bilibili_rss()
|
132
|
-
# 判断是否有更新内容
|
133
|
-
if gVar.channelid_youtube_ids_update or gVar.channelid_bilibili_ids_update:
|
134
|
-
gVar.update_generate_rss = True
|
135
|
-
if gVar.update_generate_rss:
|
136
|
-
# 根据日出日落修改封面(只适用原封面)
|
137
|
-
channge_icon()
|
138
|
-
# 输出需要更新的信息
|
139
|
-
update_information_display(
|
140
|
-
gVar.channelid_youtube_ids_update,
|
141
|
-
gVar.youtube_content_ytid_update,
|
142
|
-
gVar.youtube_content_ytid_backward_update,
|
143
|
-
"YouTube",
|
144
|
-
)
|
145
|
-
update_information_display(
|
146
|
-
gVar.channelid_bilibili_ids_update,
|
147
|
-
gVar.bilibili_content_bvid_update,
|
148
|
-
gVar.bilibili_content_bvid_backward_update,
|
149
|
-
"BiliBili",
|
150
|
-
)
|
151
|
-
# 暂停进程打印
|
152
|
-
gVar.server_process_print_flag[0] = "pause"
|
153
|
-
# 获取视频格式信息
|
154
|
-
get_video_format()
|
155
|
-
# 恢复进程打印
|
156
|
-
bottle_app_instance.cherry_print()
|
157
|
-
# 删除中断下载的媒体文件
|
158
|
-
if gVar.config["delete_incompletement"]:
|
159
|
-
delete_part(gVar.channelid_youtube_ids | gVar.channelid_bilibili_ids)
|
160
|
-
# 暂停进程打印
|
161
|
-
gVar.server_process_print_flag[0] = "pause"
|
162
|
-
# 下载YouTube和哔哩哔哩视频
|
163
|
-
youtube_and_bilibili_download()
|
164
|
-
# 恢复进程打印
|
165
|
-
bottle_app_instance.cherry_print()
|
166
|
-
# 打印无法保留原节目信息
|
167
|
-
original_rss_fail_print(gVar.xmls_original_fail)
|
168
|
-
# 获取YouTube频道简介
|
169
|
-
get_youtube_introduction()
|
170
|
-
# 暂停进程打印
|
171
|
-
gVar.server_process_print_flag[0] = "pause"
|
172
|
-
# 生成分和主rss
|
173
|
-
create_main_rss()
|
174
|
-
# 恢复进程打印
|
175
|
-
bottle_app_instance.cherry_print()
|
176
|
-
if gVar.config["remove_media"]:
|
177
|
-
# 删除不在rss中的媒体文件
|
178
|
-
remove_file()
|
179
|
-
# 删除已抛弃的媒体文件夹
|
180
|
-
remove_dir()
|
181
|
-
# 补全缺失媒体文件到字典
|
182
|
-
make_up_file()
|
183
|
-
# 按参数获取需要补全的最大个数
|
184
|
-
gVar.make_up_file_format = split_dict(
|
185
|
-
gVar.make_up_file_format,
|
186
|
-
gVar.config["completion_count"],
|
187
|
-
True,
|
188
|
-
)[0]
|
189
|
-
# 暂停进程打印
|
190
|
-
gVar.server_process_print_flag[0] = "pause"
|
191
|
-
# 补全在rss中缺失的媒体格式信息
|
192
|
-
make_up_file_format_mod()
|
193
|
-
# 恢复进程打印
|
194
|
-
bottle_app_instance.cherry_print()
|
195
|
-
# 生成主rss
|
196
|
-
overall_rss = xml_rss(
|
197
|
-
gVar.config["title"],
|
198
|
-
gVar.config["link"],
|
199
|
-
gVar.config["description"],
|
200
|
-
gVar.config["category"],
|
201
|
-
gVar.config["icon"],
|
202
|
-
"\n".join(gVar.all_items),
|
203
|
-
)
|
204
|
-
# 删除无法补全的媒体
|
205
|
-
overall_rss = del_makeup_yt_format_fail(overall_rss)
|
206
|
-
# 保存主rss
|
207
|
-
file_save(overall_rss, f"{gVar.config['filename']}.xml")
|
208
|
-
# 暂停进程打印
|
209
|
-
gVar.server_process_print_flag[0] = "pause"
|
210
|
-
address = gVar.config["address"]
|
211
|
-
filename = gVar.config["filename"]
|
212
|
-
if token := gVar.config["token"]:
|
213
|
-
overall_url = f"{address}/{filename}.xml?token={token}"
|
214
|
-
else:
|
215
|
-
overall_url = f"{address}/{filename}.xml"
|
216
|
-
write_log("总播客已更新", f"地址:\n\033[34m{overall_url}\033[0m")
|
217
|
-
if "main" not in gVar.displayed_QRcode:
|
218
|
-
qr_code(overall_url)
|
219
|
-
gVar.displayed_QRcode.append("main")
|
220
|
-
# 恢复进程打印
|
221
|
-
bottle_app_instance.cherry_print()
|
222
|
-
# 备份主rss
|
223
|
-
backup_zip_save(overall_rss)
|
224
|
-
# 暂停进程打印
|
225
|
-
gVar.server_process_print_flag[0] = "pause"
|
226
|
-
# 下载补全Youtube和哔哩哔哩视频模块
|
227
|
-
make_up_file_mod()
|
228
|
-
# 恢复进程打印
|
229
|
-
bottle_app_instance.cherry_print()
|
230
|
-
else:
|
231
|
-
print(f"{datetime.now().strftime('%H:%M:%S')}|频道无更新内容")
|
232
|
-
|
233
|
-
# 将需要更新转为否
|
234
|
-
gVar.update_generate_rss = False
|
235
|
-
if parse.update_num != -1:
|
236
|
-
parse.update_num -= 1
|
237
|
-
if parse.argument == "a-shell":
|
238
|
-
openserver_process = subprocess.Popen(
|
239
|
-
[
|
240
|
-
"open",
|
241
|
-
f"shortcuts://run-shortcut?name=Podflow&input=text&text={urllib.parse.quote(json.dumps(gVar.shortcuts_url))}",
|
242
|
-
]
|
243
|
-
)
|
244
|
-
# 延时
|
245
|
-
time.sleep(60 + len(gVar.shortcuts_url) * 5)
|
246
|
-
openserver_process.terminate()
|
247
|
-
break
|
248
|
-
elif parse.update_num == 0:
|
249
|
-
break
|
250
|
-
else:
|
251
|
-
# 延时
|
252
|
-
time.sleep(parse.time_delay)
|
253
|
-
# 关闭CherryPy服务器
|
254
|
-
cherrypy.engine.exit()
|
255
|
-
print(f"{datetime.now().strftime('%H:%M:%S')}|Podflow运行结束")
|
17
|
+
main_podcast()
|
256
18
|
|
257
19
|
|
258
20
|
if __name__ == "__main__":
|
Podflow/main_podcast.py
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
# Podflow/main_podcast.py
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
import sys
|
5
|
+
import json
|
6
|
+
import time
|
7
|
+
import urllib
|
8
|
+
import subprocess
|
9
|
+
from datetime import datetime
|
10
|
+
import cherrypy
|
11
|
+
|
12
|
+
# 基本功能模块
|
13
|
+
from Podflow import gVar, parse
|
14
|
+
from Podflow.basic.split_dict import split_dict
|
15
|
+
|
16
|
+
# 网络和 HTTP 模块
|
17
|
+
from Podflow.httpfs.port_judge import port_judge
|
18
|
+
from Podflow.httpfs.app_bottle import bottle_app_instance
|
19
|
+
|
20
|
+
# 下载和视频处理模块
|
21
|
+
from Podflow.download.delete_part import delete_part
|
22
|
+
from Podflow.download_and_build import download_and_build
|
23
|
+
from Podflow.ffmpeg_judge import ffmpeg_judge
|
24
|
+
|
25
|
+
# RSS 和消息处理模块
|
26
|
+
from Podflow.message.save_rss import save_rss
|
27
|
+
from Podflow.message.get_original_rss import get_original_rss
|
28
|
+
from Podflow.message.original_rss_fail_print import original_rss_fail_print
|
29
|
+
from Podflow.message.update_information_display import update_information_display
|
30
|
+
from Podflow.message.update_youtube_bilibili_rss import update_youtube_bilibili_rss
|
31
|
+
from Podflow.message.get_video_format import get_video_format
|
32
|
+
|
33
|
+
# 登录模块
|
34
|
+
from Podflow.bilibili.login import get_bilibili_data
|
35
|
+
from Podflow.youtube.login import get_youtube_cookie
|
36
|
+
|
37
|
+
# 配置和图标模块
|
38
|
+
from Podflow.config.channge_icon import channge_icon
|
39
|
+
from Podflow.config.build_original import build_original
|
40
|
+
|
41
|
+
# 制作和修改文件模块
|
42
|
+
from Podflow.makeup.make_up_file import make_up_file
|
43
|
+
from Podflow.makeup.make_up_file_mod import make_up_file_mod
|
44
|
+
from Podflow.makeup.make_up_file_format_mod import make_up_file_format_mod
|
45
|
+
from Podflow.makeup.del_makeup_format_fail import del_makeup_format_fail
|
46
|
+
|
47
|
+
# 移除模块
|
48
|
+
from Podflow.remove.remove_file import remove_file
|
49
|
+
from Podflow.remove.remove_dir import remove_dir
|
50
|
+
|
51
|
+
# 处理 YouTube 信息模块
|
52
|
+
from Podflow.youtube.build import print_fail_youtube_introduction
|
53
|
+
|
54
|
+
# 长期媒体进行上传模块
|
55
|
+
from Podflow.upload.add_upload import add_upload
|
56
|
+
from Podflow.upload.update_upload import update_upload
|
57
|
+
from Podflow.upload.get_upload_original import get_upload_original
|
58
|
+
|
59
|
+
|
60
|
+
def main_podcast():
|
61
|
+
# 判断是否安装ffmpeg
|
62
|
+
ffmpeg_judge()
|
63
|
+
# 初始化
|
64
|
+
build_original()
|
65
|
+
# http共享
|
66
|
+
port = gVar.config["port"]
|
67
|
+
hostip = "0.0.0.0"
|
68
|
+
if port_judge(hostip, port):
|
69
|
+
# 启动 CherryPy 服务器
|
70
|
+
cherrypy.tree.graft(
|
71
|
+
bottle_app_instance.app_bottle
|
72
|
+
) # 将 Bottle 应用嵌入到 CherryPy 中
|
73
|
+
cherrypy.config.update(
|
74
|
+
{
|
75
|
+
"global": {
|
76
|
+
"tools.sessions.on": True, # 启用会话支持
|
77
|
+
"server.socket_host": hostip, # 监听所有 IP 地址
|
78
|
+
"server.socket_port": port, # 设置监听端口
|
79
|
+
"log.screen": False, # 禁用屏幕日志输出
|
80
|
+
"log.access_file": "", # 关闭访问日志
|
81
|
+
"log.error_file": "", # 关闭错误日志
|
82
|
+
}
|
83
|
+
}
|
84
|
+
)
|
85
|
+
cherrypy.engine.start() # 启动 CherryPy 服务器
|
86
|
+
print(
|
87
|
+
f"{datetime.now().strftime('%H:%M:%S')}|HTTP服务器启动, 端口: \033[32m{port}\033[0m"
|
88
|
+
)
|
89
|
+
if parse.httpfs: # HttpFS参数判断, 是否继续运行
|
90
|
+
cherrypy.engine.block() # 阻止程序退出, 保持HTTP服务运行
|
91
|
+
sys.exit(0)
|
92
|
+
else:
|
93
|
+
print(
|
94
|
+
f"{datetime.now().strftime('%H:%M:%S')}|HTTP服务器端口: \033[32m{port}\033[0m, \033[31m被占用\033[0m"
|
95
|
+
)
|
96
|
+
if parse.httpfs:
|
97
|
+
sys.exit(0)
|
98
|
+
# 主流程
|
99
|
+
while parse.update_num > 0 or parse.update_num == -1: # 循环主更新
|
100
|
+
# 暂停进程打印
|
101
|
+
gVar.server_process_print_flag[0] = "pause"
|
102
|
+
# 获取YouTube cookie
|
103
|
+
gVar.youtube_cookie = get_youtube_cookie(gVar.channelid_youtube_ids_original)
|
104
|
+
# 更新哔哩哔哩data
|
105
|
+
gVar.channelid_bilibili_ids, gVar.bilibili_data = get_bilibili_data(
|
106
|
+
gVar.channelid_bilibili_ids_original
|
107
|
+
)
|
108
|
+
# 恢复进程打印
|
109
|
+
bottle_app_instance.cherry_print()
|
110
|
+
# 获取原始xml字典和rss文本
|
111
|
+
gVar.xmls_original, gVar.hash_rss_original, gVar.xmls_original_fail = (
|
112
|
+
get_original_rss()
|
113
|
+
)
|
114
|
+
# 初始化原始上传信息
|
115
|
+
get_upload_original()
|
116
|
+
# 更新Youtube和哔哩哔哩频道xml
|
117
|
+
update_youtube_bilibili_rss()
|
118
|
+
# 判断是否有更新内容
|
119
|
+
if gVar.channelid_youtube_ids_update or gVar.channelid_bilibili_ids_update:
|
120
|
+
gVar.update_generate_rss = True
|
121
|
+
if gVar.update_generate_rss:
|
122
|
+
# 根据日出日落修改封面(只适用原封面)
|
123
|
+
channge_icon()
|
124
|
+
# 输出需要更新的信息
|
125
|
+
update_information_display(
|
126
|
+
gVar.channelid_youtube_ids_update,
|
127
|
+
gVar.youtube_content_ytid_update,
|
128
|
+
gVar.youtube_content_ytid_backward_update,
|
129
|
+
"YouTube",
|
130
|
+
)
|
131
|
+
update_information_display(
|
132
|
+
gVar.channelid_bilibili_ids_update,
|
133
|
+
gVar.bilibili_content_bvid_update,
|
134
|
+
gVar.bilibili_content_bvid_backward_update,
|
135
|
+
"BiliBili",
|
136
|
+
)
|
137
|
+
# 暂停进程打印
|
138
|
+
gVar.server_process_print_flag[0] = "pause"
|
139
|
+
# 获取视频格式信息
|
140
|
+
get_video_format()
|
141
|
+
# 恢复进程打印
|
142
|
+
bottle_app_instance.cherry_print()
|
143
|
+
# 删除中断下载的媒体文件
|
144
|
+
if gVar.config["delete_incompletement"]:
|
145
|
+
delete_part(gVar.channelid_youtube_ids | gVar.channelid_bilibili_ids)
|
146
|
+
# 暂停进程打印
|
147
|
+
gVar.server_process_print_flag[0] = "pause"
|
148
|
+
# 下载并构建YouTube和哔哩哔哩视频
|
149
|
+
download_and_build()
|
150
|
+
# 添加新媒体至上传列表
|
151
|
+
add_upload()
|
152
|
+
# 恢复进程打印
|
153
|
+
bottle_app_instance.cherry_print()
|
154
|
+
# 打印无法保留原节目信息
|
155
|
+
original_rss_fail_print(gVar.xmls_original_fail)
|
156
|
+
# 打印无法获取youtube频道简介
|
157
|
+
print_fail_youtube_introduction()
|
158
|
+
if gVar.config["remove_media"]:
|
159
|
+
# 删除不在rss中的媒体文件
|
160
|
+
remove_file()
|
161
|
+
# 删除已抛弃的媒体文件夹
|
162
|
+
remove_dir()
|
163
|
+
# 补全缺失媒体文件到字典
|
164
|
+
make_up_file()
|
165
|
+
# 按参数获取需要补全的最大个数
|
166
|
+
gVar.make_up_file_format = split_dict(
|
167
|
+
gVar.make_up_file_format,
|
168
|
+
gVar.config["completion_count"],
|
169
|
+
True,
|
170
|
+
)[0]
|
171
|
+
# 暂停进程打印
|
172
|
+
gVar.server_process_print_flag[0] = "pause"
|
173
|
+
# 补全在rss中缺失的媒体格式信息
|
174
|
+
make_up_file_format_mod()
|
175
|
+
# 恢复进程打印
|
176
|
+
bottle_app_instance.cherry_print()
|
177
|
+
# 删除无法补全的媒体
|
178
|
+
del_makeup_format_fail()
|
179
|
+
# 暂停进程打印
|
180
|
+
gVar.server_process_print_flag[0] = "pause"
|
181
|
+
# 保存rss文件模块
|
182
|
+
save_rss()
|
183
|
+
# 下载补全Youtube和哔哩哔哩视频模块
|
184
|
+
make_up_file_mod()
|
185
|
+
# 恢复进程打印
|
186
|
+
bottle_app_instance.cherry_print()
|
187
|
+
# 更新并保存上传列表
|
188
|
+
update_upload()
|
189
|
+
else:
|
190
|
+
print(f"{datetime.now().strftime('%H:%M:%S')}|频道无更新内容")
|
191
|
+
|
192
|
+
# 将需要更新转为否
|
193
|
+
gVar.update_generate_rss = False
|
194
|
+
if parse.update_num != -1:
|
195
|
+
parse.update_num -= 1
|
196
|
+
if parse.argument == "a-shell":
|
197
|
+
openserver_process = subprocess.Popen(
|
198
|
+
[
|
199
|
+
"open",
|
200
|
+
f"shortcuts://run-shortcut?name=Podflow&input=text&text={urllib.parse.quote(json.dumps(gVar.shortcuts_url))}",
|
201
|
+
]
|
202
|
+
)
|
203
|
+
# 延时
|
204
|
+
time.sleep(60 + len(gVar.shortcuts_url) * 5)
|
205
|
+
openserver_process.terminate()
|
206
|
+
break
|
207
|
+
elif parse.update_num == 0:
|
208
|
+
break
|
209
|
+
else:
|
210
|
+
# 延时
|
211
|
+
time.sleep(parse.time_delay)
|
212
|
+
# 关闭CherryPy服务器
|
213
|
+
cherrypy.engine.exit()
|
214
|
+
print(f"{datetime.now().strftime('%H:%M:%S')}|Podflow运行结束")
|
Podflow/main_upload.py
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Podflow/main_upload.py
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
import sys
|
5
|
+
import threading
|
6
|
+
from Podflow.upload.upload_print import upload_print
|
7
|
+
from Podflow.upload.linked_server import handle_discovery, usable_port
|
8
|
+
|
9
|
+
|
10
|
+
def main_upload():
|
11
|
+
# 服务发现相关配置
|
12
|
+
broadcast_port = 37001 # 服务发现用端口
|
13
|
+
service_port = 5000 # 实际服务端口
|
14
|
+
|
15
|
+
broadcast_port = usable_port(broadcast_port, 37100)
|
16
|
+
service_port = usable_port(service_port, 5050)
|
17
|
+
if broadcast_port and service_port:
|
18
|
+
discovery_thread = threading.Thread(
|
19
|
+
target=handle_discovery,
|
20
|
+
args=(broadcast_port, service_port),
|
21
|
+
)
|
22
|
+
discovery_thread.start()
|
23
|
+
else:
|
24
|
+
if not broadcast_port:
|
25
|
+
upload_print("\033[31m广播端口被占用\033[0m")
|
26
|
+
if not service_port:
|
27
|
+
upload_print("\033[31m服务端口被占用\033[0m")
|
28
|
+
sys.exit(0)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Podflow/makeup/
|
1
|
+
# Podflow/makeup/del_makeup_format_fail.py
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
4
|
import re
|
@@ -6,14 +6,13 @@ from Podflow import gVar
|
|
6
6
|
|
7
7
|
|
8
8
|
# 删除无法补全的媒体模块
|
9
|
-
def
|
9
|
+
def del_makeup_format_fail():
|
10
10
|
for video_id, id_value in gVar.make_up_file_format_fail.items():
|
11
11
|
pattern_video_fail_item = rf"<!-- {id_value} -->(?:(?!<!-- {id_value} -->).)+?<guid>{video_id}</guid>.+?<!-- {id_value} -->"
|
12
12
|
replacement_video_fail_item = f"<!-- {id_value} -->"
|
13
|
-
|
13
|
+
gVar.all_items[id_value]["items"] = re.sub(
|
14
14
|
pattern_video_fail_item,
|
15
15
|
replacement_video_fail_item,
|
16
|
-
|
16
|
+
gVar.all_items[id_value]["items"],
|
17
17
|
flags=re.DOTALL,
|
18
18
|
)
|
19
|
-
return overall_rss
|