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

Jython Support - locking #8302

Closed
dustinschultz opened this issue Jan 22, 2016 · 7 comments
Closed

Jython Support - locking #8302

dustinschultz opened this issue Jan 22, 2016 · 7 comments
Labels

Comments

@dustinschultz
Copy link

@dustinschultz dustinschultz commented Jan 22, 2016

Hi,

youtube-dl does not work with Jython (http://www.jython.org/), at least on Mac OS X (possibly on Windows). The problem is related to import fcntl which doesn't exist in Jython :(

https://github.com/rg3/youtube-dl/blob/6ec6cb4e956abbd76a6ff42336821770a5fbbcc7/youtube_dl/utils.py#L1219-L1225

Can additional support be added for "soft locking" ... for instance, like in this Python package: https://pypi.python.org/pypi/filelock/

Thanks,
Dustin

@dstftw dstftw added the request label Jan 22, 2016
@mdPlusPlus
Copy link

@mdPlusPlus mdPlusPlus commented Feb 16, 2016

Have you found a workaround for that yet? I'd like to embed youtube-dl in my java youtube downloader.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Feb 16, 2016

Unless you need the --download-archive option, you can just remove that line and change the setproctitle(in the same file) to:

def setproctitle(title):
    return

It seems to work fine.

@mdPlusPlus
Copy link

@mdPlusPlus mdPlusPlus commented Feb 18, 2016

As far as I see editing the setproctitle() is not necessary. I removed the fcntl part however.

Now it works when I don't provide any parameters for ydl_opts, if I do I get the following error:

test
Exception in thread "MainThread" Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "__pyclasspath__/youtube_dl/YoutubeDL.py", line 292, in __init__
AttributeError: 'set' object has no attribute 'get'

Process finished with exit code 1

Line 292 being self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]

My code is the following:

public class Main {
    public static void main(String[] args) {
        PythonInterpreter python = new PythonInterpreter();
        python.exec("print(\"test\")");
        python.exec(
            "from __future__ import unicode_literals\n" +
            "import youtube_dl\n" +
            "\n" +
            "ydl_opts = {'listformats'}\n" +
            "with youtube_dl.YoutubeDL(ydl_opts) as ydl:\n" +
            "   ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])"
        );

    }
}

Any ideas?

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Feb 18, 2016

@mdPlusPlus ydl_opts must be a dictionary: ydl_opts = {'listformats': True}.

@mdPlusPlus
Copy link

@mdPlusPlus mdPlusPlus commented Feb 29, 2016

Thank you, that worked.

@yan12125 yan12125 closed this in 0cae023 Mar 3, 2016
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Mar 3, 2016

Basic Jython support will be included in the next version.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Mar 3, 2016

Known issues on Jython:

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
5 participants
You can’t perform that action at this time.