|
@@ -1,23 +1,55 @@
|
|
# youtube upload api
|
|
# youtube upload api
|
|
from youtube_upload.client import YoutubeUploader
|
|
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()
|
|
-uploader = YoutubeUploader(secrets_file_path='c:\\keys\\client_secret_244642730545-m6s4um0g6p3289ig7k92oseusisibnfp.apps.googleusercontent.com.json')
|
|
|
|
|
|
+uploader = YoutubeUploader(secrets_file_path='c:\\keys\\.client_secrets.json')
|
|
|
|
|
|
-uploader.authenticate(access_token='ya29.A0ARrdaM9829B5NAtYwMqfUBXxuYfD6ldW4ANvPuhB00LoMQlWT9v-kU4V0HXugiLLGKw413iM5gRpU1bwRP0iksATPfJyC9bnjOnnOVKGveRZNcl-y_YSqoOpwcMUYem0DlUiXMX-t6DPmt1WiTO-bZwTh-cb',refresh_token='1//0eDV6kUVBHW_VCgYIARAAGA4SNwF-L9IrFgT567AW0kbn36quvdu5NfQrcY-vYAT2xl1dpwP1KOayUQOcgTQCoYG1X7dYh1ye4Gc')
|
|
|
|
|
|
+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')
|
|
#uploader.authenticate(oauth_path='c:\\keys\\storage.json')
|
|
|
|
|
|
# Video options
|
|
# Video options
|
|
options = {
|
|
options = {
|
|
- "title" : "Example title", # The video title
|
|
|
|
- "description" : "Example description", # The video description
|
|
|
|
- "tags" : ["tag1", "tag2", "tag3"],
|
|
|
|
- "categoryId" : "22",
|
|
|
|
|
|
+ "title" : title, # The video title
|
|
|
|
+ "description" : desc, # The video description
|
|
|
|
+ "tags" : [],
|
|
"publishAt":"2015-01-21T11:20:27.751+00:00",
|
|
"publishAt":"2015-01-21T11:20:27.751+00:00",
|
|
"privacyStatus" : "public", # Video privacy. Can either be "public", "private", or "unlisted"
|
|
"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.
|
|
"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.
|
|
# "thumbnailLink" : "https://hhh.com.tw/event170427/images/designer/37.png" # Optional. Specifies video thumbnail.
|
|
}
|
|
}
|
|
|
|
+# "categoryId" : "22",
|
|
|
|
+
|
|
|
|
+uploader.upload(prefix+"\\"+fname, options)
|
|
|
|
+sys.exit()
|
|
|
|
|
|
-# upload video
|
|
|
|
-uploader.upload('C:\\data\\demo\\test.mp4', options)
|
|
|
|
uploader.close()
|
|
uploader.close()
|