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.
GUI #1865
GUI #1865
Comments
|
You can start with this code: #!/usr/bin/env python
from youtube_dl import YoutubeDL
def progress_hook(pr):
print(pr)
ydl_options = {
'outtmpl': u'%(title)s-%(id)s.%(ext)s',
}
with YoutubeDL(ydl_options) as ydl:
ydl.add_default_info_extractors()
ydl.fd.add_progress_hook(progress_hook)
ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])The I'll close the issue, but if you have any suggestion (or find a problem) for making integration easier, feel free to open new issues. |
|
hi, velmurugan On Sat, Nov 30, 2013 at 11:21 AM, Elite notifications@github.com wrote:
|
|
I am getting following errors when using this with Python3.3 and PyQT5 ::
I know this is an known issue (#883) and tried a fluke with the following ::
which failed including the
Pls. post the correct method to get past this roadblock. UPDATE :: The below worked -
|
|
Stuck now at this -
|
|
@Elite The option should be
However, I cannot reproduce the certificate issue, and we'll have to track down what really happens here - is your provider doing something fishy? The UCS-2 error is a limitation of tk. Pick a toolkit that can handle all characters, or filter them out in your logger (simply pass in as |
|
@phihag Thanks, I managed to hunt down the correct ydl_option and edited my answer above. I am very new to python, but I am sure will learn and make my way through using help :) |
|
@phihag Last time I tried |
|
I'm building some kind of graphic interface for the great youtube-dl, I'm using Tkinter and python. Anyway my gui is thinked only to help a friend who really needs to have a GUI for accessing this good binary and the program is at a real early state ( time is always my enemy!! ). Here you have a screenshot of what I'm doing, if you feel interested let me know, we can think about a more general purpose design. |
|
Have you implemented any way to tell the progress of the download to the On Thu, Dec 5, 2013 at 7:53 PM, Giacomo notifications@github.com wrote:
|
|
@grosapepe Can you pls. share your work so we can improve upon it? |
|
sure, which one is the best place? I mean a copy/past of my tk.py file should be enough or is there a better place where to upload files? |
|
@grosapepe A copy-paste here would be fine. |
|
here I post a real basic GUI I created in a few hours; it's just functional programming without any class implementation and built-in calls to the main YTDL classes, I simply controlled the binary with some switches to have a fast and simple solution, much more work can be done. import sys
import os
import subprocess
import re
from Tkinter import *
import tkFileDialog
from glob import glob
from string import split,replace
# test url
# https://www.youtube.com/watch?v=BaW_jenozKc
mycolor = '#FFADDE'
mycolor2 = '#303030'
mycolor3 = '#FFFFFF'
master = Tk()
master.title("youtube-dl GUI")
master.configure(bg=mycolor)
frame = Frame(master,bg=mycolor)
frame.pack()
v = StringVar()
v.set('')
v2= IntVar()
def callback():
link = E1.get()
print link
if re.match('^www', link):
link = 'https://'+link
elif re.match('^http://', link):
link = replace(link,'http://','https://')
else:
link = link
print link
h = setupDownload(link)
v.set(h)
currentdir = os.getcwd()
print link[32:]
downloadedFileName = glob(currentdir+'\\'+link[32:]+'.*')
print downloadedFileName
listPath = split(downloadedFileName[0],'\\')
idFileName = listPath[len(listPath)-1]
saveas(idFileName)
def setupDownload(a):
stdout = subprocess.Popen('youtube-dl.exe ' + a + ' --max-quality=flv --id ', shell=True, stdout=subprocess.PIPE).stdout
output = stdout.read()
return output
def donothing():
filewin = Toplevel(master)
button = Button(filewin, text="Do nothing button")
button.pack()
def checkForUpdates():
stdout = subprocess.Popen('youtube-dl.exe -U ', shell=True, stdout=subprocess.PIPE).stdout
output = stdout.read()
print output
v.set(output)
return output
def saveas(idFileName):
myFormats = [
('An Mp3 File','*.mp3'),
('All files','*.*'),
]
fileName = tkFileDialog.asksaveasfilename(parent=master,filetypes=myFormats ,title="Save the video as...")
if len(fileName ) > 0:
print "saving %s" % fileName
if (v2.get() == 0):
subprocess.call(['ffmpeg', '-i', idFileName , '-f' , 'mp3' , fileName+'.mp3' ])
try:
os.remove(idFileName)
v.set("Finish!!!")
except OSError:
pass
elif (v2.get() == 1):
print idFileName
print fileName
os.rename(idFileName,fileName+idFileName[11:])
v.set('preserving video content')
def main():
# Menu
menubar = Menu(master)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Save as...", command=callback)
filemenu.add_command(label="Close", command=master.quit)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=master.quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = Menu(master, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Cut", command=donothing)
editmenu.add_command(label="Copy", command=donothing)
editmenu.add_command(label="Paste", command=donothing)
editmenu.add_command(label="Delete", command=donothing)
editmenu.add_command(label="Select All", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Check for Updates", command=checkForUpdates)
menubar.add_cascade(label="Edit", menu=editmenu)
# Application
w = Label(frame, text="+++===youtube-dl GUI===+++",font=("Helvetica", 11), bg=mycolor)
w.pack()
L1 = Label(frame, textvariable=v, borderwidth=2,bg=mycolor)#.pack()
L1.pack()
c = Checkbutton(frame, text="Preserve Video", variable=v2)
c.pack()
L2 = Label(frame, text="Insert link: ", font=("Helvetica", 8), bg=mycolor)
L2.pack( side = LEFT)
global E1
E1 = Entry(frame, width=50,bd=3)
E1.insert(0,'https://www.youtube.com/watch?v=BaW_jenozKc')
E1.pack(side = RIGHT)
E1.focus_set()
S1 = Frame(height=2, bd=0, relief=SUNKEN,bg=mycolor)
S1.pack(fill=X, padx=200, pady=10)
B1 = Button(master, text="Get Song!",bg=mycolor2,foreground=mycolor3, width=10, command=callback)
B1.pack()
S2 = Frame(height=2, bd=0, relief=SUNKEN,bg=mycolor)
S2.pack(fill=X, padx=200, pady=10)
master.config(menu=menubar)
mainloop()
if __name__ == '__main__':
main() |
|
@grosapepe If your are going to work on it, you could create a repository, so that people can easily contribute to the code. |
|
@grosapepe Thanks for sharing this but this uses Youtube-dl binary file, since YTDL can be imported as an library as shown and discussed above it would be a more preferred way. |
|
ok, I will consider to create a space for this project; as I said it was controlling the binary and not doing internal calls to the library. Anyway it seems to be not so complicated to rewrite those calls importing the library instead. Anyone who feels to give me some help on it... :) |
|
Here is mine. Uses tk and threading to update progressbar (does not deal with errors). |
|
The script posted by @pulpe seems to be a good start for using the library. If you have any question I'll happily try to help. |
|
ok, it seems we have two nice prototypes and that's it! As I expressed also to @phihag my purpose was to create something really professional that aims to be something similar to the zenmap interface for the nmap binary. |
|
I managed to make a working prototype in PyQT5, pls. tell how to capture any output other then |
|
@Elite Pass in a |
|
OK got it, this works-
|
|
If you search github for For example https://github.com/chummm/ydlqt why don't we fork it? |



Hi,
I see that progress is being made towards making youtube-dl exposed for use in other projects, I am new to python but would definitely want to give this a try and wrap YTDL in my project. Can you pls. provide a basic example to get things started i.e. how to start a download and receive progress updates in my app ?
Thanks