My kivy app dosen't work. I have make android downloder app with builozer . But app dosen't work.

altronghost

Albart

Posted on October 9, 2021

My kivy app dosen't work. I have make android downloder app with builozer . But app dosen't work.

from kivy.app import App
from kivy.lang.builder import Builder
from kivy.clock import Clock
import pytube

from kivy.uix.widget import Widget
from kivy.uix.tabbedpanel import TabbedPanel
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: ''
Enter fullscreen mode Exit fullscreen mode

"""

Builder.load_string(KV)

class Mylayout(TabbedPanel):
pass

class MyApp(App):
image_loaded = False

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
Enter fullscreen mode Exit fullscreen mode

if name == "main":
app = MyApp()
app.run()

💖 💪 🙅 🚩
altronghost
Albart

Posted on October 9, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related