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
| ...
# Un double clic dans la liste lancera le téléchargement de la vidéo sélectionner
self.listTele.bind('<Double-1>',self.Tele_Video)
# Un clic droit sur un des élément de la liste va ouvrir la nouvelle fenetre avec la description
self.listTele.bind('<Button-3>', self.AffiheResume_Video)
def choixSite(self, SITE):
global YoutubeRecher, indiceSite
self.entreeRecher=str(self.entreeRecher.get())
self.SITE=self.CchoixSite_.get()
if self.SITE == "Youtube":
self.etat.configure(text="Recherche en cour...")
indiceSite=1
self.entreeRecher=self.entreeRecher.replace(" ", "+")
self.YoutubeRecher="http://www.youtube.com/results?search_type=&search_query="+self.entreeRecher+"&aq=f"
self.VideoCher()
def VideoCher(self):
global Lurlvideo_, LtVideo_
if indiceSite==1:
Source=urllib2.urlopen(self.YoutubeRecher).read()
Lurlvideo_= []
VURLF=0
while 1:
try:
VURLD=Source.index('<a id="video-url-',VURLF)
VURLF=Source.index('" href="', VURLD)
Lurlvideo_.append(Source[VURLD+17:VURLF])
VURLD=VURLF
except: break
LtVideo_=[]
VURLTD=0
while 1:
try:
VURLTD=Source.index('" rel="nofollow"><img title="', VURLTD)
VURLTF=Source.index('" src="', VURLTD)
LtVideo_.append(Source[VURLTD+31:VURLTF])
VURLTD=VURLTF
except: break
self.etat.configure(text="Fin de la recherche", fg='blue')
self.affiche_site()
def affiche_site(self):
listedessites="http://www.youtube.com/watch?v="+Lurlvideo_[1]+" "+LtVideo_[1]
self.listTele.insert(END, listedessites)
for sites in range(len(LtVideo_)-1):
listedessites="http://www.youtube.com/watch?v="+Lurlvideo_[sites+1]+" "+LtVideo_[sites+1]
self.listTele.insert(END,listedessites)
def Tele_Video(self, e):
global Selection
Selection=self.listTele.get(self.listTele.curselection())
Selection=Selection[:41]
t1=Thread_Telechar(self)
t1.start()
def AffiheResume_Video(self, e):
def Fenetre():
global fen, a
a=1
def destroy():
fen.destroy()
a=0
fen=Tk()
Label(fen, text=Resume, bg='light green').pack()
Button(fen, text='Quitter', command=destroy).pack(side=BOTTOM)
fen.mainloop()
Selection=self.listTele.get(self.listTele.curselection())
Selection=Selection[:41]
print Selection
Source=urllib2.urlopen(Selection).read()
ResumD=Source.index('<span class="description">')
ResumF=Source.index('</span>', ResumD)
Resume=Source[ResumD+27:ResumF]
if a==1:
destroy()
else:
Fenetre() |
Partager