1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- # -*- 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]
- text = row[2]
- number = {"audio_id": account_name,"text": text}
- list.append(number)
- list = random.choice(list)
- audio_id = list['audio_id']
- srt = list['text']
- return audio_id, srt
- # 获取抖音 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]
|