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

简介: 这个批量发布工具支持快手、抖音、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)")
相关文章
|
数据采集 小程序 Python
搞定短视频!批量下载快手视频(附源码)
相信大家都接触了短视频平台,比如某音、某手等平台,竟然大家都熟悉了,那么今天辰哥分享的技术是:在某手上搜索视频,并实现下载!
2169 0
element-plus 树形控件结合下拉列表
要将Element Plus的Tree控件与下拉列表结合起来,可以使用Element Plus的Select控件和Tree控件的插槽来实现。
1092 0
|
数据安全/隐私保护 Python
快手自动上传视频脚本,图文视频批量发布工具,快手批量发布作品软件【python】
快手批量上传工具提供了完整的视频和图文上传功能,包含登录验证、文件上传、标题设置
|
人工智能 数据可视化 程序员
程序员必收藏!Github 167000+ star 的自主AI agent,全自动AI助手,全面覆盖开发效率场景
AutoGPT 是基于 GPT-4 的开源自主 AI 智能代理,全面覆盖开发效率场景。支持任务自动拆解、多轮反馈、插件扩展与记忆管理,具备持续执行能力,适合自动化测试、CI/CD、Web 数据抓取等任务。GitHub 超 176K Star,是当前最热门的 AI Agent 开源项目之一,提供 CLI 与 GUI 双界面,助力开发者提升工作效率。
1826 1
|
9月前
|
人工智能 算法 新能源
从入门到选型:GEO生成式引擎优化科普与优质geo优化服务商推荐
GEO(生成式引擎优化)正取代SEO,助力企业在AI搜索中抢占流量先机。本文解析GEO核心逻辑,对比SEO差异,揭示其提升获客效率2.8倍的潜力,并结合国内外权威数据,分场景推荐适配的优质服务商,助企业从懂原理到会选型,规避布局风险。
|
11月前
|
存储 缓存 安全
探索快手平台:如何通过官方API接口获取作品详细数据
本文介绍如何通过快手开放平台API获取短视频的播放、点赞、评论等详细数据,涵盖账号注册、应用创建、权限申请、接口调用及签名生成方法,并提供Python示例代码与注意事项,助力开发者合规高效地进行内容分析与运营优化。
2274 0
|
Web App开发 数据安全/隐私保护 Python
快手批量发布作品工具,自动上传视频发布软件,python实现自动脚本
这个脚本实现了快手批量上传视频的功能,包含登录、上传视频、添加描述和发布等完整流程
|
安全 网络安全 数据安全/隐私保护
DirectX修复工具增强版,免费的dll修复工具,dll下载,DirectX修复工具下载
DirectX修复工具是一款系统级工具软件,支持Windows XP至Windows 11多个操作系统版本,兼容32位和64位系统。程序可自动调整任务模式,无需用户设置,操作简便,点击即可修复DirectX问题。增强版还支持修复C++运行库问题,提供在线修复版和标准版多种选择。遇到如英雄联盟game_error_directx错误或0xc000007b问题时,使用该工具可有效解决。程序具备扩展功能,可通过下载数据包升级为增强版,并提供详细错误提示与修复方案,适用于多种DirectX及C++异常情况。
6143 4
|
Web App开发 数据安全/隐私保护 Python
抖音快手小红书哔哩哔哩,批量发布作品笔记视频工具,自动发布作品上传笔记视频【python】
这个工具实现了四大平台的视频批量上传功能,包含完整的异常处理和日志记录。使用时需要配置
|
机器学习/深度学习 人工智能 负载均衡
Trae 04.22版本深度解析:Agent能力升级与MCP市场对复杂任务执行的革新
在当今快速发展的AI技术领域,Agent系统正成为自动化任务执行和智能交互的核心组件。Trae作为一款先进的AI协作平台,在04.22版本中带来了重大更新,特别是在Agent能力升级和MCP市场支持方面。本文将深入探讨这些更新如何重新定义复杂任务的执行方式,为开发者提供更强大的工具和更灵活的解决方案。
1876 1

热门文章

最新文章