I am trying to retrieve a videoplayback URL from a YouTube link. I know this can be done with youtube-dl (youtube-dl --get-url http://www.youtube.com/watch?v=VIDEO_ID
).
youtube-dl is written in Python and I know that it is somehow possible to bridge between Python and Java using Jython or Python-for-Android Py4A. But my question is how am I going to achieve this? Is there some relatively easy way to bridge between these two languages like it is between C and Java through JNI?
2 Answers. yt-dlp appears reasonably safe (hence the >7K stars on Github). It is a fork of youtube-dlc (now also a dead project) which was a fork of youtube-dl . As you can probably tell, it is much more active in terms of development and has many extra features such as better extractors and other options.
On Windows, the user wide configuration file locations are %APPDATA%\youtube-dl\config. txt or C:\Users\<user name>\youtube-dl.
Python can be called from within many popular programming languages. Here is how I would do it in java.
Process py = Runtime.getRuntime().exec("youtube-dl.py");
Another good option is Jython. It is a library for Java that may give you a little more control over what you are doing. Good for if you do plan on making it a whole application as opposed to a small script.
This source shows three ways of executing python code in java
EDIT: Realized you noted Jython in your question but I will leave the source in for others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With