conv2mp4-server.py 文件源码

python
阅读 50 收藏 0 点赞 0 评论 0

项目:conv2mp4-py 作者: Kameecoding 项目源码 文件源码
def drive_upload(source):
    if MEDIA_DIR in source:
        target = os.path.dirname(source.replace(MEDIA_DIR, 'media'))
    else:
        target = os.path.dirname(source.replace(CONVERTED_DIR, 'media'))
    target_copy = target
    to_add = []
    while (not FILES.get(target_copy)):
        to_add.insert(0, os.path.basename(target_copy))
        target_copy = os.path.dirname(target_copy)

    if (to_add):
        for folder in to_add:
            create_folder(folder, FILES[target_copy], target_copy)
            target_copy = os.path.join(target_copy,folder)

    Logger.info("Uploading file: {name} to {target}, with Title: {title}".format(name=source, target=target, title=os.path.basename(source)))
    f = DRIVE.CreateFile({"parents": [{"id": FILES[target]}], "title" : os.path.basename(source)})
    f.SetContentFile(source)
    f.Upload()

    if not f['id']:
        logging.error("Failed to upload file {source}".format(source=source))
        raise Exception("Failed to upload file {source}".format(source=source))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号