# youtube upload api from youtube_upload.client import YoutubeUploader import dataset import sys import codecs fr=codecs.open('c:/tmp/ytfiles.csv','r','utf-8') lines=fr.readlines() fr.close() fnamedict={} for l in lines: elmts=l.split(',') if len(elmts[2])>10: fnamedict[elmts[0].lower().replace('\r','').replace('\n','')]=elmts[2].replace('\r','').replace('\n','').replace("http://youtu.be/",'').replace("https://youtu.be/",'') prefix='P:\\【完整版】幸福空間節目\\#31' fname='31video_1304.mp4' yt=fnamedict[fname.lower()] print(yt) #db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4') db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@127.0.0.1:13317/xoops?charset=utf8mb4') cursor=db.query('select * from youtube_list where youtube_video_id="'+yt+'"') title=None desc=None for c in cursor: print(c) title=c['title'] desc=c['description'] break #uploader = YoutubeUploader() uploader = YoutubeUploader(secrets_file_path='c:\\keys\\.client_secrets.json') uploader.authenticate(access_token='ya29.A0ARrdaM-8J7urxGZFJBi4jt4ORkrCofDLMI3SN_jNfFjt5HlRZnlQ_FCRqQNZupdR0HWhAgzOE92p-AjAaBpKwklGQGxM5m3byAjQsr8qHr237p1lsdWif0kffHt2wpNxowuy5UyrzxbrSsj0zmuzZ5JgthRd',refresh_token='1//0e3GKAc0Xl1V1CgYIARAAGA4SNwF-L9IrMmaPcxVGEA6J-yYeVzx8l9C3op0oiga7Ouw-_b7hv3enOhPwEixoH7pY3efL_aY6cSw') #uploader.authenticate(oauth_path='c:\\keys\\storage.json') # Video options options = { "title" : title, # The video title "description" : desc, # The video description "tags" : [], "publishAt":"2015-01-21T11:20:27.751+00:00", "privacyStatus" : "public", # Video privacy. Can either be "public", "private", or "unlisted" "kids" : False # Specifies if the Video if for kids or not. Defaults to False. # "thumbnailLink" : "https://hhh.com.tw/event170427/images/designer/37.png" # Optional. Specifies video thumbnail. } # "categoryId" : "22", uploader.upload(prefix+"\\"+fname, options) sys.exit() uploader.close()