Soy principiante en Kivy. Estoy creando una aplicación con Pafy para descargar audio y video de Youtube y obtengo el siguiente error. Estoy usando Python 2.7 y Kivy 1.9.1.
Traceback (most recent call last):
File "ex.py", line 46, in <module>
MyApp().run()
File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 828, in run
runTouchApp()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 487, in runTouchApp
EventLoop.window.mainloop()
File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 403, in mainloop
self._mainloop()
File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 290, in _mainloop
EventLoop.idle()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 330, in idle
self.dispatch_input()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 315, in dispatch_input
post_dispatch_input(*pop(0))
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 281, in post_dispatch_input
wid.dispatch('on_touch_up', me)
File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (/tmp/pip-build-XUuuyR/Kivy/kivy/_event.c:7699)
File "/usr/local/lib/python2.7/dist-packages/kivy/uix/behaviors/button.py", line 138, in on_touch_up
self.dispatch('on_release')
File "kivy/_event.pyx", line 714, in kivy._event.EventDispatcher.dispatch (/tmp/pip-build-XUuuyR/Kivy/kivy/_event.c:7654)
File "kivy/_event.pyx", line 1224, in kivy._event.EventObservers.dispatch (/tmp/pip-build-XUuuyR/Kivy/kivy/_event.c:13497)
File "kivy/_event.pyx", line 1108, in kivy._event.EventObservers._dispatch (/tmp/pip-build-XUuuyR/Kivy/kivy/_event.c:12329)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang.py", line 1557, in custom_callback
exec(__kvlang__.co_value, idmap)
File "./kv/main.kv", line 7, in <module>
on_release: root.Download_Audio()
File "ex.py", line 30, in Download_Audio
audio = pafy.new(link)
File "/usr/local/lib/python2.7/dist-packages/pafy/pafy.py", line 124, in new
return Pafy(url, basic, gdata, size, callback, ydl_opts)
File "/usr/local/lib/python2.7/dist-packages/pafy/backend_youtube_dl.py", line 29, in __init__
super(YtdlPafy, self).__init__(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pafy/backend_shared.py", line 96, in __init__
self._fetch_basic()
File "/usr/local/lib/python2.7/dist-packages/pafy/backend_youtube_dl.py", line 38, in _fetch_basic
self._ydl_info = ydl.extract_info(self.videoid, download=False)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 785, in extract_info
ie_result = ie.extract(url)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 440, in extract
ie_result = self._real_extract(url)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 1537, in _real_extract
ytplayer_config = self._get_ytplayer_config(video_id, video_webpage)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 1248, in _get_ytplayer_config
patterns, webpage, 'ytplayer.config', default=None)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 782, in _search_regex
if not self._downloader.params.get('no_color') and compat_os_name != 'nt' and sys.stderr.isatty():
AttributeError: 'LogFile' object has no attribute 'isatty'
Aquí está mi código:
import kivy
kivy.require('1.9.1')
import pafy
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from os import listdir
kv_path = './kv/'
for kv in listdir(kv_path):
Builder.load_file(kv_path + kv)
class AudioButton(Button):
pass
class VideoButton(Button):
pass
class Container(GridLayout):
display = ObjectProperty()
def Download_Audio(self):
link = self.display.text
audio = pafy.new(link)
archivo = audio.getbestaudio()
archivo.download()
def Download_Video(self):
link = self.display.text
video = pafy.new(link)
archivo1 = video.getbest()
archivo1.download()
class MyApp(App):
def build(self):
self.title = "Downloader"
return Container()
if __name__ == '__main__':
MyApp().run()
Y los archivos .kv:
<Container>:
display: display
rows: 1
BoxLayout:
orientation: "vertical"
AudioButton:
on_press: root.Download_Audio()
VideoButton:
on_press: root.Download_Video()
TextInput:
id: display
font_size: 20
text: 'Link here'
<AudioButton>:
text: "Download Audio"
font_size: 50
<VideoButton>
text: "Download Video"
font_size: 50