-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_thread.py
56 lines (40 loc) · 1.26 KB
/
upload_thread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import queue
import time
import PySide2.QtCore as QtCore
from data_manager import DataStore
import gfycat
import streamable
class Thread(QtCore.QThread):
uploaded = QtCore.Signal(tuple)
def __init__(self, q):
super().__init__()
self.q = q
def exit(self):
self.running = False
self.is_paused = False
self.skip = True
self.wait()
def pause(self):
self.is_paused = True
def resume(self):
self.is_paused = False
def run(self):
self.running = True
self.is_paused = False
self.skip = False
while self.running:
try:
highlight_name, platform = self.q.get(timeout=1)
while self.is_paused:
time.sleep(1)
if self.skip:
break
highlight = DataStore.get_highlight(highlight_name)
file_path = highlight['filepath']
if platform == 'gfycat':
video_url = gfycat.upload(file_path)
elif platform == 'streamable':
video_url = streamable.upload(file_path)
self.uploaded.emit((highlight_name, video_url))
except queue.Empty:
continue