def upload(self, file, *args, **kwargs) -> str: options = copy.deepcopy(self.options) options.update(kwargs) browser = Firefox(self._cookie_folder, self._extension_folder, headless=True) uploader = BaseYoutubeSeleniumUploader(file, options, browser) was_uploaded, video_id = uploader.upload() if was_uploaded is False: raise VideoWasNotUploaded() if self._playlist: self._insert_to_playlist(video_id) self._logger.info('Video was uploaded {} with options {}'.format( video_id, options)) return video_id
def main(video_path: str, metadata_path: Optional[str] = None, thumbnail: Optional[str] = None): uploader = YouTubeUploader(video_path, metadata_path, thumbnail) was_video_uploaded, video_id = uploader.upload() assert was_video_uploaded
import os import sys from youtube_uploader_selenium import YouTubeUploader work_dir = os.getcwd() all_files = [] for parent, dirnames, filenames in os.walk(work_dir, followlinks=True): for filename in filenames: if filename.endswith('.mp4'): file_path = os.path.join(parent, filename) all_files.append(file_path) # print('文件名:%s' % filename) # print('文件完整路径:%s\n' % file_path) # video_path = './01.mp4' # metadata_path = '123/rockets_metadata.json' for video_path in all_files: uploader = YouTubeUploader(video_path) ## need to do : for in loop and windows path handler # if could do better , we can deploy it to docker was_video_uploaded, video_id = uploader.upload() assert was_video_uploaded
def main(video_path: str, metadict: Optional[defaultdict] = None): uploader = YouTubeUploader(video_path, metadict) was_video_uploaded, video_id = uploader.upload() return was_video_uploaded
import argparse import time from youtube_uploader_selenium import YouTubeUploader from typing import Optional if __name__ == "__main__": # 你自定义profile的路径 ,提前登录然后在使用 cus_profile_dir = "C:\\Users\\isaac\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\vczuw9pi.default-release" # geckodriver 路径 executable_path = "C:\\Program Files\\Mozilla Firefox\\geckodriver.exe" # 日志输出文件,必须保证目录存在, service_log_path = "G:\\tmp\\foxwatch.log" # 创建上传对象 uploader = YouTubeUploader(cus_profile_dir, executable_path, service_log_path) while True: try: # 执行上传 uploader.upload(".\\test.mp4", ".\\健身的国外美女图片_17.json") break except BaseException as e: print("uploader.upload:", e) time.sleep(20) pass pass