fix: 将所有后端文件都迁移到 sau_backend 文件夹内
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.baijiahao_uploader.main import baijiahao_setup
|
||||
|
||||
if __name__ == '__main__':
|
||||
account_file = Path(BASE_DIR / "cookies" / "baijiahao_uploader" / "account.json")
|
||||
account_file.parent.mkdir(exist_ok=True)
|
||||
cookie_setup = asyncio.run(baijiahao_setup(str(account_file), handle=True))
|
||||
@@ -0,0 +1,2 @@
|
||||
# cd uploader/bilibili_uploader
|
||||
# biliup.exe -u account.json login
|
||||
@@ -0,0 +1,10 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.douyin_uploader.main import douyin_setup
|
||||
|
||||
if __name__ == '__main__':
|
||||
account_file = Path(BASE_DIR / "cookies" / "douyin_uploader" / "account.json")
|
||||
account_file.parent.mkdir(exist_ok=True)
|
||||
cookie_setup = asyncio.run(douyin_setup(str(account_file), handle=True))
|
||||
@@ -0,0 +1,10 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.ks_uploader.main import ks_setup
|
||||
|
||||
if __name__ == '__main__':
|
||||
account_file = Path(BASE_DIR / "cookies" / "ks_uploader" / "account.json")
|
||||
account_file.parent.mkdir(exist_ok=True)
|
||||
cookie_setup = asyncio.run(ks_setup(str(account_file), handle=True))
|
||||
@@ -0,0 +1,10 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.tencent_uploader.main import weixin_setup
|
||||
|
||||
if __name__ == '__main__':
|
||||
account_file = Path(BASE_DIR / "cookies" / "tencent_uploader" / "account.json")
|
||||
account_file.parent.mkdir(exist_ok=True)
|
||||
cookie_setup = asyncio.run(weixin_setup(str(account_file), handle=True))
|
||||
@@ -0,0 +1,10 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.tk_uploader.main_chrome import tiktok_setup
|
||||
|
||||
if __name__ == '__main__':
|
||||
account_file = Path(BASE_DIR / "cookies" / "tk_uploader" / "account.json")
|
||||
account_file.parent.mkdir(exist_ok=True)
|
||||
cookie_setup = asyncio.run(tiktok_setup(str(account_file), handle=True))
|
||||
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.baijiahao_uploader.main import baijiahao_setup, BaiJiaHaoVideo
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
account_file = Path(BASE_DIR / "cookies" / "baijiahao_uploader" / "account.json")
|
||||
# 获取视频目录
|
||||
folder_path = Path(filepath)
|
||||
# 获取文件夹中的所有文件
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
|
||||
cookie_setup = asyncio.run(baijiahao_setup(account_file, handle=False))
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
thumbnail_path = file.with_suffix('.png')
|
||||
# 打印视频文件名、标题和 hashtag
|
||||
# print(f"视频文件名:{file}")
|
||||
# print(f"标题:{title}")
|
||||
# print(f"Hashtag:{tags}")
|
||||
app = BaiJiaHaoVideo(title, file, tags, publish_datetimes[index], account_file)
|
||||
asyncio.run(app.mainAi(), debug=False)
|
||||
@@ -0,0 +1,42 @@
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.uploader.bilibili_uploader.main import read_cookie_json_file, extract_keys_from_json, random_emoji, BilibiliUploader
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.utils.constant import VideoZoneTypes
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
# how to get cookie, see the file of get_bilibili_cookie.py.
|
||||
account_file = Path(BASE_DIR / "cookies" / "bilibili_uploader" / "account.json")
|
||||
if not account_file.exists():
|
||||
print(f"{account_file.name} 配置文件不存在")
|
||||
exit()
|
||||
cookie_data = read_cookie_json_file(account_file)
|
||||
cookie_data = extract_keys_from_json(cookie_data)
|
||||
|
||||
tid = VideoZoneTypes.SPORTS_FOOTBALL.value # 设置分区id
|
||||
# 获取视频目录
|
||||
folder_path = Path(filepath)
|
||||
# 获取文件夹中的所有文件
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
timestamps = generate_schedule_time_next_day(file_num, 1, daily_times=[16], timestamps=True)
|
||||
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
# just avoid error, bilibili don't allow same title of video.
|
||||
title += random_emoji()
|
||||
tags_str = ','.join([tag for tag in tags])
|
||||
# 打印视频文件名、标题和 hashtag
|
||||
print(f"视频文件名:{file}")
|
||||
print(f"标题:{title}")
|
||||
print(f"Hashtag:{tags}")
|
||||
# I set desc same as title, do what u like.
|
||||
desc = title
|
||||
bili_uploader = BilibiliUploader(cookie_data, file, title, desc, tid, tags, timestamps[index])
|
||||
bili_uploader.upload()
|
||||
|
||||
# life is beautiful don't so rush. be kind be patience
|
||||
time.sleep(30)
|
||||
@@ -0,0 +1,31 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.douyin_uploader.main import douyin_setup, DouYinVideo
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
account_file = Path(BASE_DIR / "cookies" / "douyin_uploader" / "account.json")
|
||||
# 获取视频目录
|
||||
folder_path = Path(filepath)
|
||||
# 获取文件夹中的所有文件
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
|
||||
cookie_setup = asyncio.run(douyin_setup(account_file, handle=False))
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
thumbnail_path = file.with_suffix('.png')
|
||||
# 打印视频文件名、标题和 hashtag
|
||||
print(f"视频文件名:{file}")
|
||||
print(f"标题:{title}")
|
||||
print(f"Hashtag:{tags}")
|
||||
# 暂时没有时间修复封面上传,故先隐藏掉该功能
|
||||
# if thumbnail_path.exists():
|
||||
# app = DouYinVideo(title, file, tags, publish_datetimes[index], account_file, thumbnail_path=thumbnail_path)
|
||||
# else:
|
||||
app = DouYinVideo(title, file, tags, publish_datetimes[index], account_file)
|
||||
asyncio.run(app.main(), debug=False)
|
||||
@@ -0,0 +1,26 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.ks_uploader.main import ks_setup, KSVideo
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
account_file = Path(BASE_DIR / "cookies" / "ks_uploader" / "account.json")
|
||||
# 获取视频目录
|
||||
folder_path = Path(filepath)
|
||||
# 获取文件夹中的所有文件
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
|
||||
cookie_setup = asyncio.run(ks_setup(account_file, handle=False))
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
# 打印视频文件名、标题和 hashtag
|
||||
print(f"视频文件名:{file}")
|
||||
print(f"标题:{title}")
|
||||
print(f"Hashtag:{tags}")
|
||||
app = KSVideo(title, file, tags, publish_datetimes[index], account_file)
|
||||
asyncio.run(app.main(), debug=False)
|
||||
@@ -0,0 +1,28 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.uploader.tencent_uploader.main import weixin_setup, TencentVideo
|
||||
from sau_backend.utils.constant import TencentZoneTypes
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
account_file = Path(BASE_DIR / "cookies" / "tencent_uploader" / "account.json")
|
||||
# 获取视频目录
|
||||
folder_path = Path(filepath)
|
||||
# 获取文件夹中的所有文件
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
|
||||
cookie_setup = asyncio.run(weixin_setup(account_file, handle=True))
|
||||
category = TencentZoneTypes.LIFESTYLE.value # 标记原创需要否则不需要传
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
# 打印视频文件名、标题和 hashtag
|
||||
print(f"视频文件名:{file}")
|
||||
print(f"标题:{title}")
|
||||
print(f"Hashtag:{tags}")
|
||||
app = TencentVideo(title, file, tags, publish_datetimes[index], account_file, category)
|
||||
asyncio.run(app.main(), debug=False)
|
||||
@@ -0,0 +1,30 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
# from tk_uploader.main import tiktok_setup, TiktokVideo
|
||||
from sau_backend.uploader.tk_uploader.main_chrome import tiktok_setup, TiktokVideo
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
account_file = Path(BASE_DIR / "cookies" / "tk_uploader" / "account.json")
|
||||
folder_path = Path(filepath)
|
||||
# get video files from folder
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
|
||||
cookie_setup = asyncio.run(tiktok_setup(account_file, handle=True))
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
thumbnail_path = file.with_suffix('.png')
|
||||
print(f"video_file_name:{file}")
|
||||
print(f"video_title:{title}")
|
||||
print(f"video_hashtag:{tags}")
|
||||
if thumbnail_path.exists():
|
||||
print(f"thumbnail_file_name:{thumbnail_path}")
|
||||
app = TiktokVideo(title, file, tags, publish_datetimes[index], account_file, thumbnail_path)
|
||||
else:
|
||||
app = TiktokVideo(title, file, tags, publish_datetimes[index], account_file)
|
||||
asyncio.run(app.main(), debug=False)
|
||||
@@ -0,0 +1,68 @@
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
|
||||
from xhs import XhsClient
|
||||
|
||||
from sau_backend.conf import BASE_DIR
|
||||
from sau_backend.utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
|
||||
from sau_backend.uploader.xhs_uploader.main import sign_local, beauty_print
|
||||
|
||||
config = configparser.RawConfigParser()
|
||||
config.read(Path(BASE_DIR / "uploader" / "xhs_uploader" / "accounts.ini"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
filepath = Path(BASE_DIR) / "videos"
|
||||
# 获取视频目录
|
||||
folder_path = Path(filepath)
|
||||
# 获取文件夹中的所有文件
|
||||
files = list(folder_path.glob("*.mp4"))
|
||||
file_num = len(files)
|
||||
|
||||
cookies = config['account1']['cookies']
|
||||
xhs_client = XhsClient(cookies, sign=sign_local, timeout=60)
|
||||
# auth cookie
|
||||
# 注意:该校验cookie方式可能并没那么准确
|
||||
try:
|
||||
xhs_client.get_video_first_frame_image_id("3214")
|
||||
except:
|
||||
print("cookie 失效")
|
||||
exit()
|
||||
|
||||
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
|
||||
|
||||
for index, file in enumerate(files):
|
||||
title, tags = get_title_and_hashtags(str(file))
|
||||
# 加入到标题 补充标题(xhs 可以填1000字不写白不写)
|
||||
tags_str = ' '.join(['#' + tag for tag in tags])
|
||||
hash_tags_str = ''
|
||||
hash_tags = []
|
||||
|
||||
# 打印视频文件名、标题和 hashtag
|
||||
print(f"视频文件名:{file}")
|
||||
print(f"标题:{title}")
|
||||
print(f"Hashtag:{tags}")
|
||||
|
||||
topics = []
|
||||
# 获取hashtag
|
||||
for i in tags[:3]:
|
||||
topic_official = xhs_client.get_suggest_topic(i)
|
||||
if topic_official:
|
||||
topic_official[0]['type'] = 'topic'
|
||||
topic_one = topic_official[0]
|
||||
hash_tag_name = topic_one['name']
|
||||
hash_tags.append(hash_tag_name)
|
||||
topics.append(topic_one)
|
||||
|
||||
hash_tags_str = ' ' + ' '.join(['#' + tag + '[话题]#' for tag in hash_tags])
|
||||
|
||||
note = xhs_client.create_video_note(title=title[:20], video_path=str(file),
|
||||
desc=title + tags_str + hash_tags_str,
|
||||
topics=topics,
|
||||
is_private=False,
|
||||
post_time=publish_datetimes[index].strftime("%Y-%m-%d %H:%M:%S"))
|
||||
|
||||
beauty_print(note)
|
||||
# 强制休眠30s,避免风控(必要)
|
||||
sleep(30)
|
||||
Reference in New Issue
Block a user