Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use youtube-dl in my own python script. #1129

Closed
yasoob opened this issue Jul 25, 2013 · 2 comments
Closed

How to use youtube-dl in my own python script. #1129

yasoob opened this issue Jul 25, 2013 · 2 comments

Comments

@yasoob
Copy link
Contributor

@yasoob yasoob commented Jul 25, 2013

I have already asked this question earlier and got an answer from @jaimeMF he told me to do

import logging
import youtube_dl

class NoneFile(object):
    '''
    A file-like object that does nothing
    '''
    def write(self,msg):
        pass
    def flush(self,*args,**kaargs):
        pass
    def isatty(self):
        return False

class ScreenFile(NoneFile):
    def write(self,msg):
        logging.debug(msg)

class SimpleFileDownloader(youtube_dl.FileDownloader):
    def __init__(self,*args,**kargs):
        super(SimpleFileDownloader,self).__init__(*args,**kargs)
        self._screen_file=ScreenFile()
        self._ies = youtube_dl.gen_extractors()
        for ie in self._ies:
            ie.set_downloader(self)

But now when we have moved all the extractors in their respective files i get an error while using this method.

>>> url = "http://www.dailymotion.com/video/xy8ddj_zindagi-gulzar-hai-by-hum-tv-episode-16-part-1-3_shortfilms"
>>> fd = SimpleFileDownloader({'outtmpl':'%(title)s'})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __init__
TypeError: __init__() takes exactly 3 arguments (2 given)
@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jul 25, 2013

SimpleFileDownloader class should look like this now:

class SimpleFileDownloader(youtube_dl.YoutubeDL):

You may want to rename it or SimpleYDL or something like that.
In #803 it was splitted in two classes, to separate different tasks, so the problem is not the extractors.

@jaimeMF jaimeMF closed this Jul 25, 2013
@yasoob
Copy link
Contributor Author

@yasoob yasoob commented Jul 25, 2013

Yes thanx it solved the problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.