Skip to content

Commit ddfc26d

Browse files
committed
testing new function in dev 5
1 parent 36c9304 commit ddfc26d

File tree

8 files changed

+76
-272
lines changed

8 files changed

+76
-272
lines changed

28-downloadVideoYT/testeYt/downloadImage.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

28-downloadVideoYT/testeYt/downloadVideo.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

28-downloadVideoYT/testeYt/main.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
# =- delete all .mp4 and .jpg
1212
system('rm *.mp4')
13-
system('rm video_image/*.jpg')
13+
# system('rm video_image/*.jpg')
1414

1515

1616
class Fr_videos(ttk.Frame):
1717
def __init__(self, parent, link) -> None:
1818
super().__init__(parent)
19-
self.yt = YouTube(link, on_progress_callback=self.progress)
20-
19+
self.yt = YouTube(link)
20+
self.link = link
21+
2122
self.yt_title = self.yt.title
22-
util.download_image(thumbnail_url=self.yt.thumbnail_url, name=self.yt_title)
23+
# util.download_image(thumbnail_url=self.yt.thumbnail_url, name=self.yt_title)
2324

2425
self.image = Image.open(f'./video_image/{self.yt_title}.jpg')
2526
self.image = self.image.resize((180, 100), Image.LANCZOS)
@@ -28,20 +29,23 @@ def __init__(self, parent, link) -> None:
2829

2930
self.lb_image = ttk.Label(self, image=self.imageTk)
3031

31-
self.title1 = ttk.Label(self, text='title:')
3232
self.title2 = ttk.Label(self, text=self.yt_title)
3333
self.progressBar = ttk.Progressbar(self, length=300, maximum=100, mode=DETERMINATE, value=0)
3434

35+
# size_video = self.yt.streams.get_by_itag(17).filesize
36+
size_highResolution = self.yt.streams.get_highest_resolution().filesize
37+
size_highResolution = util.format_bytes(size_highResolution)
38+
self.lb_size = ttk.Label(self, text=f'size:{size_highResolution}')
3539

3640

3741

3842
self.lb_image.grid(row=0, column=0, rowspan=2)
39-
self.title1.grid(row=0, column=1)
4043
self.title2.grid(row=0, column=2)
44+
self.lb_size.grid(row=0, column=3)
45+
4146
self.progressBar.grid(row=1, column=1, columnspan=2)
4247

4348

44-
# def progress(self, n1, n2, n3):
4549
def progress(self, stream, chunk, bytes_remaining):
4650
total_size = stream.filesize
4751
bytes_downloaded = total_size - bytes_remaining
@@ -56,9 +60,18 @@ def progress(self, stream, chunk, bytes_remaining):
5660

5761

5862
def startDownload(self):
59-
print('start download')
60-
video = self.yt.streams.get_highest_resolution()
63+
yt = YouTube(self.link, on_progress_callback=self.progress)
64+
65+
video = yt.streams.get_highest_resolution()
6166
video.download()
67+
68+
def start(self):
69+
th = Thread(target=self.startDownload)
70+
th.start()
71+
72+
73+
74+
6275

6376

6477

@@ -69,24 +82,21 @@ def startDownload(self):
6982

7083
def start():
7184

72-
th1 = Thread(target=fr1.startDownload())
73-
th2 = Thread(target=fr2.startDownload())
74-
th3 = Thread(target=fr3.startDownload())
75-
th1.start()
76-
th2.start()
77-
th3.start()
78-
85+
fr1.start()
86+
# fr2.start()
87+
# fr3.startDownload()
88+
7989
window = ttk.Window()
8090
link1 = 'https://www.youtube.com/watch?v=_p2NvO6KrBs'
8191
link2 = 'https://www.youtube.com/watch?v=ZQ80_j3CXJQ'
82-
link3 = 'https://www.youtube.com/watch?v=ytIZGsm1NXo'
92+
# link3 = 'https://www.youtube.com/watch?v=ytIZGsm1NXo'
8393

8494
fr1 = Fr_videos(window, link1)
85-
fr2 = Fr_videos(window, link2)
86-
fr3 = Fr_videos(window, link3)
95+
# fr2 = Fr_videos(window, link2)
96+
# fr3 = Fr_videos(window, link3)
8797
fr1.pack(ipadx=200)
88-
fr2.pack(ipadx=200)
89-
fr3.pack(ipadx=200)
98+
# fr2.pack(ipadx=200)
99+
# fr3.pack(ipadx=200)
90100

91101
bt_download = ttk.Button(window, text='Download', bootstyle=SUCCESS, command=start)
92102
bt_download.pack()

28-downloadVideoYT/testeYt/main2.py

Lines changed: 0 additions & 203 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import ttkbootstrap as ttk
2+
from ttkbootstrap.constants import *
3+
4+
5+
6+
class Fr_ (ttk.Frame):
7+
def __init__(self, parent, ) -> None:
8+
super().__init__(parent)
9+
10+
11+
12+
self.menu = ttk.Menubutton(self, )
13+
14+
15+
16+
17+
self.menu.grid()
18+
19+
20+
if __name__ == '__main__':
21+
window = ttk.Window('cyborg')
22+
fr = Fr_(window)
23+
fr.pack()
24+
25+
window.bind('q', lambda x: window.quit())
26+
27+
window.mainloop()
28+

28-downloadVideoYT/testeYt/threadingTest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, parent) -> None:
1010

1111

1212
self.lb_load = ttk.Label(self, text='')
13-
self.progressbar = ttk.Progressbar(self, length=400, maximum=100, mode=DETERMINATE)
13+
self.progressbar = ttk.Progressbar(self, length=200, maximum=100, mode=DETERMINATE)
1414

1515

1616
self.lb_load.grid(row=0, column=1)
@@ -26,7 +26,7 @@ def loading(self):
2626
per = self.progressbar['value']
2727
if per >= 100:
2828
self.progressbar.config(bootstyle=SUCCESS,)
29-
self.lb_load.config(text=f'100% completed', bootstyle=SUCCESS)
29+
self.lb_load.config(text=f'completed', bootstyle=SUCCESS)
3030

3131
# self.progressbar.config(value=100, bootstyle=SUCCESS)
3232
# self.progressbar.update()

0 commit comments

Comments
 (0)