от kivy.app Приложение импорта от kivy.lang.builder Импорт Строитель от Kivy.clock Импорт часов Pytube
от kivy.uix.widget Import Widget от kivy.uix.tabbedpanel importpanel import ffpyplayer
KV “:
do_default_tab: False TabbedPanelItem: text: "tab 1" FloatLayout: canvas.before: Color: rgba: rgba("#FF5555") Rectangle: size: self.size pos: self.pos Label: text: "youtube videos downloader".title() size_hint: [None, None] size: self.texture_size pos_hint: {"top":0.94, "center_x":0.5} font_size: "27sp" bold: True canvas.before: Color: rgba: rgba("#000000") Rectangle: size: self.size pos: self.pos TextInput: id: txt_input background_color: [1,1,1,1] pos_hint: {"top":0.8, "center_x":0.5} color: [0,0,0,1] bold: True font_size: "20sp" multiline: False size_hint: [0.85, 0.06] Button: id: save_btn text: "Download" background_normal: "" background_color: [0,0,0,1] color: [1,1,1,1] bold: True font_size: "18sp" pos_hint: {"top":0.7, "center_x":0.5} size_hint: [0.3, 0.08] on_press: app.download_video(txt_input.text) AsyncImage: id: thumbnail pos_hint: {"top":0.4, "center_x":0.5} size_hint: [0.9, 0.2] source: '' Label: id: title text: "video title".title() size_hint: [None, None] size: self.texture_size pos_hint: {"top":0.2, "center_x":0.5} font_size: "20" bold: True color: [0,0,0,1] TabbedPanelItem: text: "tab 2" BoxLayout: orientation: "vertical" VideoPlayer: id: thumbnaild source: ''
“””
Builder.load_string (kv)
класс mylayout (tabbedpanel): проходить
класс myApp (приложение):
def build(self): return Mylayout() def set_assets(self, thumbnail, title): self.root.ids.thumbnail.source = thumbnail self.root.ids.title.text = title def get_video(self, stream): if self.image_loaded == True: stream.download() a = stream.download() print(a) self.root.ids.thumbnaild.source = a # kivymd.toast("video is downloading...", 1) def download_video(self, url): try: yt = pytube.YouTube(url, on_progress_callback=self.progress_func) self.set_assets(yt.thumbnail_url, yt.title) self.image_loaded = True Clock.schedule_once(lambda x: self.get_video(yt.streams.get_highest_resolution()), 3) except: print("error") def progress_func(self, stream, file_handle, bytes_remaining): # size = self.video.filesize # progress = (float(abs(bytes_remaining-size)/size)*float(50)) # print(progress) pass
Если имя == ” Главный “: () app.run ()
Оригинал: “https://dev.to/altronghost/my-kivy-app-dosen-t-work-i-have-make-android-downloder-app-with-builozer-but-app-dosen-t-work-31ll”