-
Notifications
You must be signed in to change notification settings - Fork 9
/
upload.py
116 lines (83 loc) · 3.3 KB
/
upload.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, math
from PyQt4 import QtGui, QtCore
import requests
import simplejson
import upload_ui
import argparse
import uploadvideo as uv
import videoVimeo
# Shows the preview window showcasing the changes made in the editor window
class Upload(QtGui.QStackedWidget) :
closeApp = QtCore.pyqtSignal() #signal , slot to be with caller
def __init__(self, ui):
super(Upload, self).__init__()
self.ui = ui
self.list_of_syn = None
self.youtubeObj = None
def setup_connections(self) :
self.setCurrentIndex(0)
self.ui.seedTagBtn.clicked.connect( self.populateTextBoxWithSynonyms )
self.ui.youtubeBtn.clicked.connect( self.authenticateYoutube )
self.ui.vimeoBtn.clicked.connect( self.authenticateVimeo )
self.ui.nextBtn.clicked.connect( self.next_page )
self.ui.finishBtn.clicked.connect( self.next_page )
def getSynonyms( self, seedTag ):
resp = requests.get("http://suggestqueries.google.com/complete/search?client=youtube&ds=yt&client=firefox&q=" + str(seedTag))
list_of_syn = simplejson.loads(str(resp.text))[1] # [0] is Query word
return list_of_syn[:5] #top 5 suggestions
def populateTextBoxWithSynonyms( self ) :
seedTag = self.ui.seedTagTextBox.text()
self.list_of_syn = self.getSynonyms( seedTag )
string_of_syn = ",".join( self.list_of_syn )
self.ui.textEdit.setText( string_of_syn )
def authenticateYoutube( self ):
args = argparse.Namespace(file="",title="",description="",keywords="",category="",privacyStatus="",auth_host_name='localhost', auth_host_port=[8080, 8090],logging_level='ERROR', noauth_local_webserver=False)
self.youtubeObj = uv.authenticateWithYoutube(args)
if self.youtubeObj is not None :
self.ui.youtubeBtn.setText("Auth successful")
def authenticateVimeo(self) :
videoVimeo.caller = self.caller
videoVimeo.requestOAuth()
self.ui.vimeoBtn.setText("Auth successful")
def next_page(self):
idx = self.currentIndex()
if idx < self.count() - 1:
self.setCurrentIndex(idx + 1)
elif idx is 1 :
self.accept()
else:
self.setCurrentIndex(0)
def accept(self):
if self.caller is not None :
if self.list_of_syn :
self.caller.string_of_tags = str(self.ui.textEdit.toPlainText())
else :
self.caller.string_of_tags = None
#add youtube, vimeo etc here
self.caller.youtubeObj = self.youtubeObj
self.caller.showPublishWidget()
self.closeWidget()
def closeEvent(self, event) :
self.closeWidget()
def closeWidget(self) :
self.closeApp.emit()
self.close()
def showUpload( caller ) :
ui = upload_ui.Ui_StackedWidget()
widget = Upload( ui )
ui.setupUi(widget)
widget.setup_connections()
widget.caller = caller
if caller is not None :
widget.setGeometry( caller.geometry() )
widget.show()
widget.caller.hide()
widget.show()
return widget
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
widget = showUpload(None)
sys.exit(app.exec_())