# -*- coding: utf-8 -*- # @Time: 2023/12/26 import os import random import sys sys.path.append(os.getcwd()) from common.db import MysqlHelper from common.feishu import Feishu class Material(): # 获取视频链接 存入数据库 @classmethod def insert_user(cls): # 获取抖音视频链接 douyin = Feishu.get_values_batch("prod", "succinct", "iYbVis") # 提取账号昵称和账号主页链接 channel = '抖音' for row in douyin[2:]: platform = row[0] if platform == channel: account_name = row[2] account_link = row[3] user_id = account_link.split("user/")[1] insert_sql = f"""INSERT INTO video_user_id (name, user_id, channel) values ("{account_name}", "{user_id}", "{channel}")""" MysqlHelper.update_values( sql=insert_sql, env="prod", machine="", ) # 随机获取标题 @classmethod def get_title(cls): title = Feishu.get_values_batch("prod", "succinct", "meGnsz") random_item = random.choice(title) cleaned_item = random_item[0].strip("[]'") return cleaned_item # 获取所有音频 @classmethod def get_audio(cls): audio = Feishu.get_values_batch("prod", "succinct", "zucQUM") list = [] for row in audio[1:]: account_name = row[0] list.append(account_name) srt = row[2] if srt == None: continue file_path = f"./video_stitching/video/{account_name}.srt" if os.path.isfile(file_path): continue else: with open(file_path, 'w') as file: # 写入内容到文件中 file.write(srt) return list # 获取抖音 cookie @classmethod def get_douyin_cookie(cls): douyin_token = Feishu.get_values_batch("prod", "succinct", "OpE35G") for item in douyin_token: if item[0] == '抖音': return item[1] @classmethod def get_houtai_cookie(cls): douyin_token = Feishu.get_values_batch("prod", "succinct", "OpE35G") for item in douyin_token: if item[0] == '管理后台': return item[1]