blob: 90799234d35219b4020f957548d84bcb9817535e (
plain) (
blame)
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
|
#! /usr/bin/python3
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
import threading
from youload_playlist import YouLoadPlayList
class YouloadApp(App):
def build(self):
layout = BoxLayout(padding=10, orientation='vertical')
# Data members
self.url = "https://youtube.com/playlist?list=PLuZUmvZz4WI78uqT5S71yBHNBMJ97HzhY&si=SI2qN9MgxmmK2rbf"
self.is_downloading = False
self.download_thread = threading.Thread(target=self.download_playlist_thread)
self.stop_download = False
# Url input.
url_input = TextInput(text=self.url, multiline=False)
url_input.bind(text=self.uid_url_input)
# Submit button.
submit = Button(text="Download")
submit.bind(on_press=self.submit_cb)
# Info display.
self.info_display = Label(text="")
# Everything else (:
layout.add_widget(url_input)
layout.add_widget(self.info_display)
layout.add_widget(submit)
return layout
def uid_url_input(self, instance, value):
self.url = value
# Download the videos in a different thread so the ui still works.
def download_playlist_thread(self):
playlist = YouLoadPlayList(self.url)
playlist.prepare_for_download()
self.info_display.text = f"Downloading {self.url}\n"
self.is_downloading = True
# Download each video
for i in range(playlist.video_count):
self.info_display.text += playlist.download_video(i) + "\n"
# Stop this mother fucker
if self.stop_download:
return
self.is_downloading = False
def submit_cb(self, instance):
self.stop_download = False
self.download_thread.start()
def on_stop(self):
self.stop_download = True
|