快手批量发布作品工具,短视频一键发布到多个平台, 自媒体批量发布工具

简介: 这个批量发布工具支持快手、抖音、B站和YouTube平台,使用Selenium实现自动化上传

下载地址:https://www.pan38.com/yun/share.php?code=JCnzE 提取密码:aa98

这个批量发布工具支持快手、抖音、B站和YouTube平台,使用Selenium实现自动化上传。主程序包含视频信息获取、多平台上传和结果记录功能。使用时需要安装Chrome浏览器和对应驱动。

import os
import time
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from configparser import ConfigParser
import json
import hashlib
import logging
from datetime import datetime

class MultiPlatformUploader:
def init(self):
self.config = ConfigParser()
self.config.read('config.ini')
self.setup_logging()
self.driver = None
self.platform_apis = {
'kuaishou': self.upload_to_kuaishou,
'douyin': self.upload_to_douyin,
'bilibili': self.upload_to_bilibili,
'youtube': self.upload_to_youtube
}

def setup_logging(self):
    logging.basicConfig(
        filename='uploader.log',
        level=logging.INFO,
        format='%(asctime)s - %(levelname)s - %(message)s'
    )
    self.logger = logging.getLogger(__name__)

def init_driver(self):
    options = webdriver.ChromeOptions()
    options.add_argument('--disable-notifications')
    options.add_argument('--disable-infobars')
    options.add_argument('--disable-extensions')
    options.add_argument('--disable-gpu')
    options.add_argument('--no-sandbox')
    options.add_argument('--headless')
    self.driver = webdriver.Chrome(options=options)
    self.driver.implicitly_wait(10)

def upload_to_kuaishou(self, video_path, title, tags):
    try:
        self.driver.get('https://www.kuaishou.com/upload')
        upload_btn = self.driver.find_element(By.XPATH, '//input[@type="file"]')
        upload_btn.send_keys(os.path.abspath(video_path))

        title_field = WebDriverWait(self.driver, 30).until(
            EC.presence_of_element_located((By.XPATH, '//textarea[@placeholder="添加标题"]'))
        )
        title_field.send_keys(title)

        if tags:
            tag_field = self.driver.find_element(By.XPATH, '//input[@placeholder="添加标签"]')
            for tag in tags:
                tag_field.send_keys(tag)
                tag_field.send_keys(Keys.ENTER)
                time.sleep(0.5)

        publish_btn = self.driver.find_element(By.XPATH, '//button[contains(text(),"发布")]')
        publish_btn.click()

        WebDriverWait(self.driver, 60).until(
            EC.url_contains('profile')
        )
        self.logger.info(f'Successfully uploaded to Kuaishou: {title}')
        return True
    except Exception as e:
        self.logger.error(f'Error uploading to Kuaishou: {str(e)}')
        return False

def upload_to_douyin(self, video_path, title, tags):
    try:
        self.driver.get('https://creator.douyin.com/creator-micro/content/upload')
        upload_btn = self.driver.find_element(By.XPATH, '//input[@type="file"]')
        upload_btn.send_keys(os.path.abspath(video_path))

        title_field = WebDriverWait(self.driver, 30).until(
            EC.presence_of_element_located((By.XPATH, '//textarea[@placeholder="填写标题"]'))
        )
        title_field.send_keys(title)

        if tags:
            tag_field = self.driver.find_element(By.XPATH, '//input[@placeholder="添加标签"]')
            for tag in tags:
                tag_field.send_keys(tag)
                tag_field.send_keys(Keys.ENTER)
                time.sleep(0.5)

        publish_btn = self.driver.find_element(By.XPATH, '//button[contains(text(),"发布")]')
        publish_btn.click()

        WebDriverWait(self.driver, 60).until(
            EC.url_contains('content/manage')
        )
        self.logger.info(f'Successfully uploaded to Douyin: {title}')
        return True
    except Exception as e:
        self.logger.error(f'Error uploading to Douyin: {str(e)}')
        return False

def upload_to_bilibili(self, video_path, title, tags):
    try:
        self.driver.get('https://member.bilibili.com/platform/upload/video/frame')
        upload_btn = self.driver.find_element(By.XPATH, '//input[@type="file"]')
        upload_btn.send_keys(os.path.abspath(video_path))

        title_field = WebDriverWait(self.driver, 30).until(
            EC.presence_of_element_located((By.XPATH, '//input[@placeholder="填写标题"]'))
        )
        title_field.send_keys(title)

        if tags:
            tag_field = self.driver.find_element(By.XPATH, '//input[@placeholder="添加标签"]')
            for tag in tags:
                tag_field.send_keys(tag)
                tag_field.send_keys(Keys.ENTER)
                time.sleep(0.5)

        publish_btn = self.driver.find_element(By.XPATH, '//button[contains(text(),"发布")]')
        publish_btn.click()

        WebDriverWait(self.driver, 60).until(
            EC.url_contains('content/manage')
        )
        self.logger.info(f'Successfully uploaded to Bilibili: {title}')
        return True
    except Exception as e:
        self.logger.error(f'Error uploading to Bilibili: {str(e)}')
        return False

def upload_to_youtube(self, video_path, title, tags):
    try:
        self.driver.get('https://www.youtube.com/upload')
        upload_btn = self.driver.find_element(By.XPATH, '//input[@type="file"]')
        upload_btn.send_keys(os.path.abspath(video_path))

        title_field = WebDriverWait(self.driver, 30).until(
            EC.presence_of_element_located((By.XPATH, '//div[@id="textbox"]'))
        )
        title_field.send_keys(title)

        if tags:
            tag_field = self.driver.find_element(By.XPATH, '//input[@placeholder="添加标签"]')
            for tag in tags:
                tag_field.send_keys(tag)
                tag_field.send_keys(Keys.ENTER)
                time.sleep(0.5)

        next_btn = self.driver.find_element(By.XPATH, '//ytcp-button[@id="next-button"]')
        for _ in range(3):
            next_btn.click()
            time.sleep(1)

        publish_btn = self.driver.find_element(By.XPATH, '//ytcp-button[@id="done-button"]')
        publish_btn.click()

        WebDriverWait(self.driver, 60).until(
            EC.url_contains('upload')
        )
        self.logger.info(f'Successfully uploaded to YouTube: {title}')
        return True
    except Exception as e:
        self.logger.error(f'Error uploading to YouTube: {str(e)}')
        return False

def batch_upload(self, video_path, title, tags=None, platforms=None):
    if not platforms:
        platforms = self.config['DEFAULT']['platforms'].split(',')

    results = {}
    self.init_driver()

    try:
        for platform in platforms:
            if platform.strip() in self.platform_apis:
                start_time = datetime.now()
                success = self.platform_apis[platform.strip()](video_path, title, tags)
                end_time = datetime.now()
                duration = (end_time - start_time).total_seconds()
                results[platform] = {
                    'status': 'success' if success else 'failed',
                    'time_elapsed': duration
                }
            else:
                results[platform] = {
                    'status': 'unsupported',
                    'time_elapsed': 0
                }
    finally:
        if self.driver:
            self.driver.quit()

    return results

def get_video_info(self, video_path):
    file_size = os.path.getsize(video_path) / (1024 * 1024)  # MB
    duration = self.get_video_duration(video_path)
    return {
        'file_size': round(file_size, 2),
        'duration': duration,
        'md5': self.get_file_md5(video_path)
    }

def get_video_duration(self, video_path):
    try:
        import cv2
        cap = cv2.VideoCapture(video_path)
        fps = cap.get(cv2.CAP_PROP_FPS)
        frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
        duration = frame_count / fps
        cap.release()
        return round(duration, 2)
    except:
        return 0

def get_file_md5(self, file_path):
    hash_md5 = hashlib.md5()
    with open(file_path, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hash_md5.update(chunk)
    return hash_md5.hexdigest()

if name == 'main':
uploader = MultiPlatformUploader()
video_path = input('Enter video file path: ')
title = input('Enter video title: ')
tags = input('Enter tags (comma separated): ').split(',')

video_info = uploader.get_video_info(video_path)
print(f"\nVideo Info:")
print(f"Size: {video_info['file_size']} MB")
print(f"Duration: {video_info['duration']} seconds")
print(f"MD5: {video_info['md5']}\n")

print("Available platforms: kuaishou, douyin, bilibili, youtube")
platforms = input('Enter platforms to upload (comma separated, leave empty for all): ')

if platforms:
    platforms = platforms.split(',')
else:
    platforms = None

print("\nStarting upload process...")
results = uploader.batch_upload(video_path, title, tags, platforms)

print("\nUpload Results:")
for platform, result in results.items():
    print(f"{platform}: {result['status']} ({result['time_elapsed']:.2f}s)")
相关文章
element-plus 树形控件结合下拉列表
要将Element Plus的Tree控件与下拉列表结合起来,可以使用Element Plus的Select控件和Tree控件的插槽来实现。
990 0
|
11月前
|
数据安全/隐私保护 Python
快手自动上传视频脚本,图文视频批量发布工具,快手批量发布作品软件【python】
快手批量上传工具提供了完整的视频和图文上传功能,包含登录验证、文件上传、标题设置
|
5月前
|
人工智能 移动开发 安全
“Meta合规通知”成钓鱼新马甲:全球中小企业遭遇精准围猎,账号沦陷后损失远超想象
数字时代,中小微企业频遭仿冒平台通知的钓鱼攻击。黑客利用Meta、微信、抖音等官方名义,通过高仿真邮件与链接,窃取账号权限,实施诈骗。此类攻击滥用合法域名,绕过传统防护,凸显企业数字安全脆弱性。防御需技术升级与流程规范并重,更呼唤平台责任与行业共治。
274 4
|
11月前
|
Web App开发 数据安全/隐私保护 Python
快手批量发布作品工具,自动上传视频发布软件,python实现自动脚本
这个脚本实现了快手批量上传视频的功能,包含登录、上传视频、添加描述和发布等完整流程
|
7月前
|
存储 缓存 安全
探索快手平台:如何通过官方API接口获取作品详细数据
本文介绍如何通过快手开放平台API获取短视频的播放、点赞、评论等详细数据,涵盖账号注册、应用创建、权限申请、接口调用及签名生成方法,并提供Python示例代码与注意事项,助力开发者合规高效地进行内容分析与运营优化。
1506 0
|
11月前
|
机器学习/深度学习 数据安全/隐私保护 计算机视觉
过三色刷脸技术,过三色刷脸技术教程,插件过人脸python分享学习
三色刷脸技术是基于RGB三通道分离的人脸特征提取方法,通过分析人脸在不同颜色通道的特征差异
|
12月前
|
安全 网络安全 数据安全/隐私保护
DirectX修复工具增强版,免费的dll修复工具,dll下载,DirectX修复工具下载
DirectX修复工具是一款系统级工具软件,支持Windows XP至Windows 11多个操作系统版本,兼容32位和64位系统。程序可自动调整任务模式,无需用户设置,操作简便,点击即可修复DirectX问题。增强版还支持修复C++运行库问题,提供在线修复版和标准版多种选择。遇到如英雄联盟game_error_directx错误或0xc000007b问题时,使用该工具可有效解决。程序具备扩展功能,可通过下载数据包升级为增强版,并提供详细错误提示与修复方案,适用于多种DirectX及C++异常情况。
4486 4
|
11月前
|
数据采集 Web App开发 JSON
微博采集评论区数据工具,微博爬取博主粉丝ID抓取,微博提取评论ID博主粉丝列表
这个代码实现了完整的微博数据采集功能,包括评论采集、粉丝ID抓取和评论用户粉丝列表获取
|
机器学习/深度学习 人工智能 负载均衡
Trae 04.22版本深度解析:Agent能力升级与MCP市场对复杂任务执行的革新
在当今快速发展的AI技术领域,Agent系统正成为自动化任务执行和智能交互的核心组件。Trae作为一款先进的AI协作平台,在04.22版本中带来了重大更新,特别是在Agent能力升级和MCP市场支持方面。本文将深入探讨这些更新如何重新定义复杂任务的执行方式,为开发者提供更强大的工具和更灵活的解决方案。
1618 1
|
JSON Java Maven
几个适合Java开发者的免费IDEA插件
【7月更文挑战第15天】以下是适合Java开发者的免费IDEA插件: - **Test Data**: 生成用于单元测试的随机数据,支持多种格式如JSON、CSV等。 - **SonarLint**: 实时检测并修正代码质量问题,提供详细的风险分析。 - **Maven Helper**: 提供pom.xml文件的UI界面,便于管理Maven项目依赖。 - **RestFulTool**: 辅助RESTful服务开发与测试,尤其适合Spring MVC和Spring Boot项目。 - **EnvFile**: 在IDE内部设置运行配置的环境变量,支持YAML、JSON等格式。
653 2