streaming - Python: Record stream and upload to dropbox same time -
i'm recording stream , saving drop-box via python api in 2 steps; 1- record stream , save on local storage 2- pick file local storage , upload drop-box.
i want eliminate local storage, want record stream , same time upload drop-box.
here script,
a function records stream , saves local storage
stream = urllib.request.urlopen(self.stream_url) start_time = datetime.now() dest = open(filename, 'wb') while (datetime.now() - start_time).seconds / 3600 <= self.duration: #print((datetime.datetime.now() - start_time).seconds / 3600) dest.write(stream.read(1024)) return filename and
client = dropbox.dropbox(self.access_token) try: open(file_from, 'rb') f: meta = client.files_upload(f.read(), file_to, mute=true) print("uploaded " + file_to) except exception e: print("failed upload " + file_to) print(e) how can this, tried below didn't work;
while (datetime.now() - start_time).seconds / 3600 <= self.duration: meta = client.files_upload(dest.write(stream.read(1024)), file_to, mute=true)
Comments
Post a Comment