Skip to content

Commit

Permalink
Merge pull request #17 from KundKMC/main
Browse files Browse the repository at this point in the history
Fix for Issue #12
  • Loading branch information
MiniGlome authored Aug 28, 2023
2 parents e3eb4cf + 6f55acb commit af2349f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Tiktok_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def getSignatureKey(key, dateStamp, regionName, serviceName):

def AWSsignature(access_key, secret_key, request_parameters, headers, method="GET", payload='', region="us-east-1", service="vod"):
# https://docs.aws.amazon.com/fr_fr/general/latest/gr/sigv4-signed-request-examples.html
canonical_uri = '/'
canonical_uri = '/'
canonical_querystring = request_parameters
canonical_headers = '\n'.join([f"{h[0]}:{h[1]}" for h in headers.items()]) + '\n'
signed_headers = ';'.join(headers.keys())
Expand Down Expand Up @@ -48,7 +48,7 @@ def printError(url, r):

def assertSuccess(url, r):
if r.status_code != 200:
printError(url, r)
printError(url, r)
return r.status_code == 200

def uploadVideo(session_id, video, title, tags, schedule_time=0, verbose=True):
Expand Down Expand Up @@ -197,7 +197,7 @@ def uploadVideo(session_id, video, title, tags, schedule_time=0, verbose=True):
r = session.head(url, headers=headers)
if not assertSuccess(url, r):
return False
x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]
#x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]

params = {
"video_id":video_id,
Expand All @@ -213,7 +213,7 @@ def uploadVideo(session_id, video, title, tags, schedule_time=0, verbose=True):
}
if schedule_time:
params["schedule_time"] = schedule_time
headers = {"X-Secsdk-Csrf-Token": x_csrf_token}
#headers = {"X-Secsdk-Csrf-Token": x_csrf_token}
r = session.post(url, params=params, headers=headers)
if not assertSuccess(url, r):
return False
Expand All @@ -236,4 +236,4 @@ def uploadVideo(session_id, video, title, tags, schedule_time=0, verbose=True):
parser.add_argument("-s", "--schedule_time", type=int, default=0, help="schedule timestamp for video upload")
args = parser.parse_args()

uploadVideo(args.session_id, args.path, args.title, args.tags, args.schedule_time, verbose=True)
uploadVideo(args.session_id, args.path, args.title, args.tags, args.schedule_time, verbose=True)

0 comments on commit af2349f

Please sign in to comment.