Merge lp:~mycompostpile/cairo-dock-plug-ins-extras/YoutubeDl into lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party

Proposed by Brian
Status: Merged
Merged at revision: 279
Proposed branch: lp:~mycompostpile/cairo-dock-plug-ins-extras/YoutubeDl
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 314 lines (+184/-16)
4 files modified
YoutubeDl/YoutubeDl (+27/-14)
YoutubeDl/constantTypes.py (+1/-1)
YoutubeDl/fileDialogs.py (+1/-1)
YoutubeDl/urlListEdit.py (+155/-0)
To merge this branch: bzr merge lp:~mycompostpile/cairo-dock-plug-ins-extras/YoutubeDl
Reviewer Review Type Date Requested Status
Matthieu Baerts Approve
Review via email: mp+109474@code.launchpad.net

Description of the change

Fixed a bug I created when copying and pasting the file dialog for saving the url list.

Cleaned up the menu entries removing the constants for the help menus and adding a right click entry to allow the user to edit the url list.

Added functionality to allow the url list to be edited with a tkinter app. If tkinter is not available then the user is presented with a dialog stating that editing is not possible and why. The editor allows the user to move urls up/down in the list and delete them.

To post a comment you must log in.
Revision history for this message
Brian (mycompostpile) wrote :

Forgot to add the editor file. branch 279 has the file.

Revision history for this message
Matthieu Baerts (matttbe) wrote :

Thank you :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'YoutubeDl/YoutubeDl'
--- YoutubeDl/YoutubeDl 2012-06-04 21:56:31 +0000
+++ YoutubeDl/YoutubeDl 2012-06-09 04:25:29 +0000
@@ -29,6 +29,7 @@
2929
30# if tkinter is available use it otherwise use popup messages.30# if tkinter is available use it otherwise use popup messages.
31import fileDialogs as dialogs31import fileDialogs as dialogs
32from urlListEdit import urlListEditor
3233
33# all constant types are placed in one file and used as needed.34# all constant types are placed in one file and used as needed.
34from constantTypes import PopupTypes35from constantTypes import PopupTypes
@@ -37,9 +38,7 @@
37class Applet(CDApplet):38class Applet(CDApplet):
3839
39 def __init__(self):40 def __init__(self):
40 #super(YoutubeDlPlugin, self).__init__()
41 self.__interval = 60000 # 1 minute (in millisecondes)41 self.__interval = 60000 # 1 minute (in millisecondes)
42 #self.__config = Configuration(os.path.basename(os.path.abspath(".")))
43 self.__timerId = None42 self.__timerId = None
44 self.work_queue = multiprocessing.Queue(1)43 self.work_queue = multiprocessing.Queue(1)
45 self.result_queue = multiprocessing.Queue(2)44 self.result_queue = multiprocessing.Queue(2)
@@ -73,7 +72,6 @@
73 else:72 else:
74 self.icon.SetQuickInfo('')73 self.icon.SetQuickInfo('')
75 if self.__showStatusOnIcon:74 if self.__showStatusOnIcon:
76 #self.icon.SetLabel(self.resultSummary)
77 self.icon.SetLabel("YoutubeDl")75 self.icon.SetLabel("YoutubeDl")
78 self.reload()76 self.reload()
79 self.__setTimer()77 self.__setTimer()
@@ -94,7 +92,6 @@
9492
95 tempString = ' Current Download' + endingCharacter93 tempString = ' Current Download' + endingCharacter
96 if self.activeDownload:94 if self.activeDownload:
97 #tempString = tempString + '\n -> '.join(self.urlList[0]) + endingCharacter
98 tempString = tempString + '\n -> '.join(self.urlList[0]) 95 tempString = tempString + '\n -> '.join(self.urlList[0])
99 rangeStart = 196 rangeStart = 1
100 else:97 else:
@@ -122,18 +119,27 @@
122 "values" : tempString})119 "values" : tempString})
123 else:120 else:
124 self.icon.PopupDialog( {"message" : tempString,121 self.icon.PopupDialog( {"message" : tempString,
125 "icon" : "gtk-stock-edit"},122 "icon" : "gtk-edit"},
126 {"visible" : True,123 {"visible" : True,
127 "multi-lines" : True,124 "multi-lines" : True,
128 "editable" : False, })125 "editable" : False, })
129 self.currentDialog = PopupTypes.infoDialog126 self.currentDialog = PopupTypes.infoDialog
127
128 def editURLs(self):
129 urlEdit=urlListEditor(self.urlList).run()
130 if urlEdit:
131 self.urlList[:] = urlEdit
132 else:
133 if urlEdit is None:
134 self.icon.PopupDialog( {"message" : "python-tk not installed, Editing not possible",
135 "icon" : "gtk-dialog-info"},
136 {"visible" : True,
137 "multi-lines" : True,
138 "editable" : False, })
139 self.currentDialog = PopupTypes.infoDialog
130 return True140 return True
131141
132 def on_middle_click(self):142 def on_middle_click(self):
133 """
134 I set my icon always vissible flag
135 """
136 #super(YoutubeDlPlugin, self).onMiddleClick()
137 if self.__actionOnMiddleClick == 'Open Video Folder':143 if self.__actionOnMiddleClick == 'Open Video Folder':
138 subprocess.call(['xdg-open',self.__videos_directory], shell=False)144 subprocess.call(['xdg-open',self.__videos_directory], shell=False)
139 else:145 else:
@@ -273,6 +279,10 @@
273 {"label": "Clear current URL list", 279 {"label": "Clear current URL list",
274 "icon" : "gtk-delete",280 "icon" : "gtk-delete",
275 "id" : menuEntries.clearURLs })281 "id" : menuEntries.clearURLs })
282 items.append(
283 {"label": "Edit current URL list",
284 "icon" : "gtk-edit",
285 "id" : menuEntries.editURLs })
276 if len(self.urlList) == 0:286 if len(self.urlList) == 0:
277 items.append(287 items.append(
278 {"label": "Load URL list from file", 288 {"label": "Load URL list from file",
@@ -305,6 +315,8 @@
305 "icon" : "gtk-delete"}, 315 "icon" : "gtk-delete"},
306 {"visible" : True } )316 {"visible" : True } )
307 self.currentDialog = PopupTypes.delList317 self.currentDialog = PopupTypes.delList
318 elif iNumEntry == menuEntries.editURLs:
319 self.editURLs()
308 elif iNumEntry == menuEntries.saveURLs:320 elif iNumEntry == menuEntries.saveURLs:
309 self.saveURLs()321 self.saveURLs()
310 elif iNumEntry == menuEntries.loadURLs:322 elif iNumEntry == menuEntries.loadURLs:
@@ -441,15 +453,16 @@
441453
442 def debug(self):454 def debug(self):
443 """455 """
444 Call me one time in the beginning of your script. If you are running Cairo-Dock456 Call me one time in the beginning of your script.
445 from a console window, you'll be able to see what I'm doing.457 If you are running Cairo-Dock from a console window,
458 you'll be able to see what I'm doing.
446 """459 """
447 self.__debugMode = True460 self.__debugMode = True
448461
449462
450 def get_config(self, keyfile):463 def get_config(self, keyfile):
451 """464 """
452 I reload the configuration.465 Reload the configuration.
453 """466 """
454 interval = keyfile.getint('User Interface', 'interval')467 interval = keyfile.getint('User Interface', 'interval')
455 self.__interval = interval * 1000 # convert in millisecondes.468 self.__interval = interval * 1000 # convert in millisecondes.
@@ -479,7 +492,7 @@
479 492
480 def __setTimer(self):493 def __setTimer(self):
481 """494 """
482 I set the time between two checks.495 Set the time between two checks.
483 """496 """
484 self.__removeTimer()497 self.__removeTimer()
485 #self.__timerId = timeout_add(self.__interval, self.doUpdate)498 #self.__timerId = timeout_add(self.__interval, self.doUpdate)
@@ -487,7 +500,7 @@
487 500
488 def __removeTimer(self):501 def __removeTimer(self):
489 """502 """
490 I properly remove the timer.503 Properly remove the timer.
491 """504 """
492 if self.__timerId != None:505 if self.__timerId != None:
493 gobject.source_remove(self.__timerId)506 gobject.source_remove(self.__timerId)
494507
=== modified file 'YoutubeDl/constantTypes.py'
--- YoutubeDl/constantTypes.py 2012-05-31 00:01:58 +0000
+++ YoutubeDl/constantTypes.py 2012-06-09 04:25:29 +0000
@@ -2,7 +2,7 @@
2 (infoDialog, confirmAbort, saveListFilename, getListFilename, delList, showUrlList) = range(0, 6)2 (infoDialog, confirmAbort, saveListFilename, getListFilename, delList, showUrlList) = range(0, 6)
33
4class menuEntries:4class menuEntries:
5 (abortDownload, saveURLs, loadURLs, pauseDownload, enableDownload, clearURLs,helpSubMenu,downloaderHelp,pluginHelp) = range(1,10)5 (abortDownload, saveURLs, loadURLs, pauseDownload, enableDownload, clearURLs, editURLs) = range(7)
66
7class youtube:7class youtube:
8 videoFormats = {"H264 - MP4 at 480p":'18',8 videoFormats = {"H264 - MP4 at 480p":'18',
99
=== modified file 'YoutubeDl/fileDialogs.py'
--- YoutubeDl/fileDialogs.py 2012-06-04 21:56:31 +0000
+++ YoutubeDl/fileDialogs.py 2012-06-09 04:25:29 +0000
@@ -23,7 +23,7 @@
23 options['initialdir'] = initialDirectory23 options['initialdir'] = initialDirectory
24 options['title'] = 'Please select a url list file to save'24 options['title'] = 'Please select a url list file to save'
25 options['parent'] = rootDialog25 options['parent'] = rootDialog
26 fileName = tkFileDialog.askopenfilename(**file_opt)26 fileName = tkFileDialog.asksaveasfilename(**file_opt)
27 rootDialog.destroy()27 rootDialog.destroy()
28 return fileName28 return fileName
2929
3030
=== added file 'YoutubeDl/urlListEdit.py'
--- YoutubeDl/urlListEdit.py 1970-01-01 00:00:00 +0000
+++ YoutubeDl/urlListEdit.py 2012-06-09 04:25:29 +0000
@@ -0,0 +1,155 @@
1#!/usr/bin/env python
2
3try:
4 from Tkinter.junk import *
5 import tkFont
6
7 class urlListEditor(Frame):
8
9 def __init__(self,urlList):
10 self.root = Tk()
11 Frame.__init__(self)
12 self.urlList = False
13 self.root.title("Listbox Operations")
14 self.root.rowconfigure(0, weight=1)
15 self.root.columnconfigure(0, weight=1)
16
17 RWidth=self.root.winfo_screenwidth()
18 RHeight=self.root.winfo_screenheight()
19 self.root.geometry("550x350+300+100")
20 # create the listbox (note that size is in characters)
21 myFont = tkFont.Font ( family="Courier",size=10)
22 self.listbox1 = Listbox(self.root, width=50, height=6, font=myFont)
23 self.listbox1.grid(row=0, column=0,rowspan=2, columnspan=2, sticky=N+S+E+W)
24
25 # create a vertical scrollbar to the right of the listbox
26 self.yscroll = Scrollbar(command=self.listbox1.yview, orient=VERTICAL)
27 #self.yscroll.grid(row=0, column=1, sticky=N+S)
28 self.yscroll.grid(row=0,rowspan=2, column=2, sticky=N+S)
29 self.listbox1.configure(yscrollcommand=self.yscroll.set)
30 # create a horizontal scrollbar to the bottom of the listbox
31 self.xscroll = Scrollbar(command=self.listbox1.xview, orient=HORIZONTAL)
32 self.xscroll.grid(row=2, column=0, columnspan=2, sticky=E+W)
33 self.listbox1.configure(xscrollcommand=self.xscroll.set)
34
35 # button to move a line up in the list box
36 self.button1 = Button(self.root, text='Move Up', command=self.move_up)
37 self.button1.grid(row=0, column=3, sticky=W+N)
38 # button to move a line down in the list box
39 self.button2 = Button(self.root, text='Move Down', command=self.move_down)
40 #self.button2.grid(row=4, column=0, sticky=W)
41 self.button2.grid(row=1, column=3, sticky=W+N)
42 # button to delete a line from the listbox
43 self.button3 = Button(self.root, text='Delete Selected', command=self.delete_item)
44 #self.button3.grid(row=3, column=0, sticky=E)
45 self.button3.grid(row=3, column=0,sticky=W+N)
46 # button to commit changes and close
47 self.button4 = Button(self.root, text='Commit Changes', command=self.save_list)
48 #self.button4.grid(row=4, column=0, sticky=E)
49 self.button4.grid(row=3, column=1,sticky=E+N)
50
51 # left mouse click on a list item to display selection
52 #self.listbox1.bind('<ButtonRelease-1>', self.get_list)
53
54 for item in range(len(urlList)):
55 tempString = ' -> '.join(urlList[item])
56 self.listbox1.insert(END, tempString)
57
58 def run(self):
59 self.mainloop()
60 return self.urlList
61
62 def delete_item(self):
63 """
64 delete a selected line from the listbox
65 """
66 try:
67 # get selected line index
68 index = self.listbox1.curselection()[0]
69 self.listbox1.delete(index)
70 except IndexError:
71 pass
72
73 #def get_list(self,event):
74 #"""
75 #function to read the listbox selection
76 #"""
77 # get selected line index
78 #index = self.listbox1.curselection()[0]
79
80 def set_list(self,event):
81 """
82 insert an edited line from the entry widget
83 back into the listbox
84 """
85 try:
86 index = self.listbox1.curselection()[0]
87 # delete old listbox line
88 self.listbox1.delete(index)
89 except IndexError:
90 index = END
91
92 def move_up(self):
93 """
94 function to sort listbox items case insensitive
95 """
96 try:
97 index = self.listbox1.curselection()[0]
98 if index > 0:
99 newindex = str(int(index) - 1)
100 self.listbox1.insert((int(index) - 1), self.listbox1.get(index))
101 # delete old listbox line
102 self.listbox1.delete(int(index)+1)
103 self.listbox1.select_set(int(index)-1)
104 #self.listbox1.yview(int(index)-1)
105 else:
106 self.listbox1.select_set(0)
107 self.listbox1.yview(0)
108 except IndexError:
109 index = END
110
111 def move_down(self):
112 """
113 function to sort listbox items case insensitive
114 """
115 try:
116 index = self.listbox1.curselection()[0]
117 if index < END:
118 self.listbox1.insert((int(index) + 2), self.listbox1.get(index))
119 # delete old listbox line
120 self.listbox1.delete(index)
121 self.listbox1.select_set(int(index)+1)
122 self.listbox1.yview(int(index)+1)
123 else:
124 self.listbox1.select_set(END)
125 self.listbox1.yview(END)
126 except IndexError:
127 index = END
128
129 def save_list(self):
130 """
131 save the current listbox contents to a file
132 """
133 self.urlList = list()
134 # get a list of listbox lines
135 temp_list = list(self.listbox1.get(0, END))
136 for item in temp_list:
137 tempItem = item.split(" -> ",1)
138 self.urlList.append([tempItem[0].lstrip(),tempItem[1].lstrip()])
139 self.root.destroy()
140
141 def onClose():
142 print "closing"
143 self.root.destroy()
144
145except ImportError:
146 class urlListEditor():
147 def __init__(self,myUrlList):
148 self.urlList = None
149
150 def run(self):
151 return self.urlList
152
153if __name__ == "__main__":
154 root=urlListEditor([['test','1'],['test','2'],['test','3']]).run()
155

Subscribers

People subscribed via source and target branches

to all changes: