Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
AttributeError: 'str' object has no attribute 'write' en android #22109
Comments
|
I have a very similar issue. When I use youtube-dl without Kivy everything works fine. However, when I try to combine youtube-dl in my Kivy app I receive the following error:
Here is a reproducible example This fails: import youtube_dl
from kivy.app import App
from kivy.uix.button import Button
class MusicApp(App):
def build(self):
return Button(text='Example')
ydl_opts = {
'outtmpl': '%(title)s.%(ext)s',
'audio-format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=xKJkzro8ArA'])When I remove Kivy dependencies it works: import youtube_dl
ydl_opts = {
'outtmpl': '%(title)s.%(ext)s',
'audio-format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=xKJkzro8ArA']) |
|
I am getting the same error. Have anyone of you solved this issue ?? |
I am trying to download audio and videos using kivy. the code works fine in windows and ubuntu but generates an error in android.
This is the code:
importar youtube_dl
import kivy
kivy.require ('1.11.0')
from kivy.app import App
de kivy.uix.boxlayout import BoxLayout
desde kivy.config import Config
Config.set ('gráficos', 'ancho', 400)
Config.set ('gráficos', 'alto', 200)
clase Contenedor_01 (BoxLayout):
def descargarA(self):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=2j3x0VYnehg'])
clase MainApp (aplicación):
def build (self):
return Contenedor_01 ()
if name == ' main ':
MainApp (). run ()
I get this error:
I / python (20086): Android kivy bootstrap hecho. el nombre es I / python principal
(20086): AND: Ran string
I / python (20086): Ejecute el programa de usuario, cambie el directorio y ejecute el punto de entrada
I / python (20086): [ADVERTENCIA] [Config] Versión de configuración anterior detectada (0 en su lugar de 21)
I / python (20086): [ADVERTENCIA] [Config] Actualización de la configuración en progreso.
I / python (20086): [INFO] [Logger] Registro de registro en /data/user/0/org.test.downloadmeapp/files/app/.kivy/logs/kivy_19-08-15_0.txt
I / python (20086 ): [INFO] [Kivy] v1.11.0
I / python (20086): [INFO] [Kivy] instalado en "/data/user/0/org.test.downloadmeapp/files/app/_python_bundle/site-packages/ kivy /init .pyc "
I / python (20086): [INFO] [Python] v3.7.1 (predeterminado, 15 de agosto de 2019, 15:27:31)
I / python (20086): [Clang 6.0.2 (https: // android.googlesource.com/toolchain/clang 183abd29fc496f55
I / python (20086): [INFO] [Python] Intérprete en "android_python"
I / python (20086): [INFO] [Factory] 184 símbolos cargados
I / python (20086) : [INFO] [Imagen] Proveedores: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignorado)
I / python (20086): [INFO] [Window] Proveedor: sdl2
I / python (20086): [INFO] [GL ] Utilizando el sistema gráfico "OpenGL ES 2"
I / python (20086): [INFO] [GL] Backend utilizado
I / python (20086): [INFO] [GL] OpenGL versión <b'OpenGL ES 3.1 V@140.0 (GIT @ Iec24cdb30f) '>
I / python (20086): [INFO] [GL] Proveedor de OpenGL <b'Qualcomm '>
I / python (20086): [INFO] [GL] Procesador de OpenGL <b'Adreno (TM) 405'>
I / python (20086): [INFO] [GL] Versión analizada de OpenGL: 3, 1
I / python (20086): [INFO] [GL] Tamaño máximo de textura <16384>
I / python (20086): [INFO] [GL] Unidades máximas de textura <16>
I / python (20086): [INFO] [Ventana] auto agregar proveedor de entrada sdl2
I / python (20086): [INFO] [Ventana] teclado virtual no permitido, modo único, no acoplado
I / python (20086): [INFO] [Texto] Proveedor: sdl2
I / python (20086): [ADVERTENCIA] [Base] Proveedor desconocido
I / python (20086): [INFO] [Base] Iniciar el bucle principal de la aplicación
I / python (20086): [INFO] [GL] El soporte de textura NPOT está disponible
I / python (20086): [INFO] [Base] Dejando la aplicación en progreso ...
I / python (20086): Traceback (última llamada):
I / python (20086): Archivo "/ home / abrahan / Escritorio /prueba/.buildozer/android/app/main.py ", línea 38, en
I / python (20086): Archivo" /home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python- instala / DownLoadMeApp / kivy / app.py ", línea 855, en ejecución
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 504, en runTouchApp
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/window_sdl2.py", línea 746, en mainloop
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/window_sdl2.py", línea 478, en _mainloop
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 342, en inactivo
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 327, en dispatch_input
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 233, en post_dispatch_input
I / python (20086) : Archivo "kivy / _event.pyx", línea 707, en kivy._event.EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/ python-installs / DownLoadMeApp / kivy / core / window / init .py ", línea 1378, en on_motion
I / python (20086): Archivo" kivy / _event.pyx ", línea 707, en kivy._event.EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/ init .py", línea 1394, en on_touch_down
I / python (20086): Archivo "kivy / _event.pyx", línea 707, en kivy._event.EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android /platform/build/build/python-installs/DownLoadMeApp/kivy/uix/widget.py ", línea 549, en on_touch_down
I / python (20086): Archivo" kivy / _event.pyx ", línea 707, en kivy._event .EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/uix/behaviors/button.py", línea 151,en on_touch_down
I / python (20086): archivo "kivy / _event.pyx", línea 703, en kivy._event.EventDispatcher.dispatch
I / python (20086): archivo "kivy / _event.pyx", línea 1214, en kivy._event .EventObservers.dispatch
I / python (20086): Archivo "kivy / _event.pyx", línea 1098, en kivy._event.EventObservers._dispatch
I / python (20086): Archivo "/ home / abrahan / Escritorio / prueba /. buildozer / android / platform / build / build / python-installs / DownLoadMeApp / kivy / lang / builder.py ", línea 64, en custom_callback
I / python (20086): Archivo" /data/data/org.test.downloadmeapp/ files / app / main.kv ", línea 4, en
I / python (20086): on_press: root.descargarA ()
I / python (20086): File" /home/abrahan/Escritorio/prueba/.buildozer/android/ app / main.py ", línea 29,en descargarA
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 2010, en descarga
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 796, en extract_info
I / python (20086) : Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 530, en extracto
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/youtube.py", línea 1668, en _real_extract
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 794, en _download_webpage
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/youtube.py", línea 274, en _download_webpage_handle
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 660, en _download_webpage_handle
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 602,en _request_webpage
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 922, en report_download_webpage
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 914, en to_screen
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 502, en la pantalla
I / python (20086 ): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 516, en to_stdout
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 505, en _write_string
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/utils.py", línea 3084, en write_string
I / python (20086) : AttributeError: el objeto 'str' no tiene atributo 'write'
I / python (20086): Python para Android finalizó.
I can't solve this problem