Código de Python - Aplicación para descargar vídeos de YouTube

Requerimientos

Librerias: Tkinter, os, pafy, threading
Requisitos: Se necesita tener instalado (y actualizado) "youtube-dl"

2.0
estrellaestrellaestrellaestrellaestrella(4)

Publicado el 16 de Mayo del 2020gráfica de visualizaciones de la versión: 2.0
7.024 visualizaciones desde el 16 de Mayo del 2020
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# /usr/bin/env python
# -*- coding: utf-8 -*-
# -*- encoding: utf-8 -*-
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from tkinter import messagebox
import os
import pafy
import threading
 
ventana=Tk()
ventana.geometry("712x490")
ventana.configure(background="navajo white")
ventana.title("DESCARGA DESDE YOUTUBE")
URLL=StringVar()
directorio_actual=StringVar()
total_size=0
dif=0
 
def dire_actu():
    directorio_actual.set(os.getcwd())
 
def direc():
    directorio=filedialog.askdirectory()
    if directorio!="":
        os.chdir(directorio)
        directorio_actual.set(os.getcwd())
 
def verif_url():
    try:
        v = pafy.new(URLL.get())
        print(v.title)
        return v
    except:
        messagebox.showwarning("ALGO SALIÓ MAL", "VIDEO NO DISPONIBLE")
        entrada.delete(0,len(URLL.get()))
 
def get(c,v):
    global total_size
    if c == "vid":
        try:
            s = v.getbest(preftype="mp4")
        except:
            s = v.getbest()
    else:
        try:
            s = v.getbestaudio(preftype="m4a")
        except:
            s = v.getbestaudio()
    total_size=s.get_filesize()
    return s
 
def estado(s):
    boton_dire.config(state = s)
    boton_descarga.config(state = s)
    boton_audio.config(state = s)
 
def mycb(total,recvd,ratio,rate,eta):
    global dif
    porcen=(recvd*100/total_size)
    eti_porcent.config(text=((int(porcen),"%")))
    prog.step(porcen-dif)
    dif=porcen
 
def descargando(co,vid):
    global dif
    so = get(co,vid)
    try:
        so.download(quiet=True,callback=mycb)
        messagebox.showinfo("FIN DE DESCARGA","Descarga finalizada con éxito")
    except:
        messagebox.showwarning("ERROR","Se ha producido un error en la descarga")
        prog.step(100)
        entrada.delete(0,len(URLL.get()))
    estado('normal')
    eti.place(x=317,y=180)
    eti_porcent.config(text=" ")
    dif=0
    total_size=0
 
def descarga(co):
    vid = verif_url()
    if vid!=None:
        eti.place(x=306,y=180)
        estado('disabled')
        t1 = threading.Thread(target = descargando , args = (co,vid) )
        t1.start()
 
dire_actu() #LLAMADA A PRIMERA FUNCIÓN A EJECUTAR.
 
entrada=Entry(ventana,font=('Arial',15,'bold'),textvariable=URLL,width=30)
entrada.place(x=196,y=130)
entrada2=Entry(ventana,font=('Arial',8),textvariable=directorio_actual,width=60)
entrada2.place(x=185,y=455)
Label(ventana,width=12,text="DESTINO",bg="navajo white").place(x=314,y=432)
Label(ventana,font=('Arial',30,'bold'),text="YouTube Catcher!",fg="red",bg="navajo white").place(x=193,y=17)
boton_dire=Button(ventana,width=20,text="CAMBIAR DIRECTORIO",bg="pale green",command=direc)
boton_dire.place(x=287,y=270)
boton_descarga=Button(ventana,width=20,text="DESCARGAR VIDEO",bg="pale green",command=lambda:descarga("vid"))
boton_descarga.place(x=287,y=310)
Label(ventana,width=12,text="URL de video",bg="navajo white").place(x=316,y=109)
boton_audio=Button(ventana,width=20,text="EXTRAER AUDIO",bg="pale green",command=lambda:descarga("aud"))
boton_audio.place(x=287,y=350)
eti=Label(ventana,width=12,text="PROGRESO",bg="navajo white")
eti.place(x=317,y=180)
eti_porcent=Label(ventana,width=4,bg="navajo white")
eti_porcent.place(x=392,y=180)
prog=progressbar = ttk.Progressbar(ventana)
prog.place(x=196,y=200,width=335)
 
ventana.mainloop()



Comentarios sobre la versión: 2.0 (4)

Imágen de perfil
16 de Octubre del 2020
estrellaestrellaestrellaestrellaestrella
bastante chulo!!
Responder
Imágen de perfil
18 de Octubre del 2020
estrellaestrellaestrellaestrellaestrella
Gracias :)
Responder
Imágen de perfil
16 de Agosto del 2022
estrellaestrellaestrellaestrellaestrella
Para que funcione correctamente recomiendo una versión anterior de youtube-dl.

Solo corre con:

pip install youtube-dl==2020.12.2
Responder
pepe
17 de Agosto del 2022
estrellaestrellaestrellaestrellaestrella
ytdl
Responder

Comentar la versión: 2.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s6200