Project objective
This project demonstrates a seamless integration between B4J and Python through the PyBridge extension to enable online video and audio uploads.
It was designed as a modular base that any developer can adapt, enrich, and redistribute to create a complete tool.
Main features
Download video and audio content via yt_dlp, with configurable options (format, codec, quality, etc.).
Two-way interaction between B4J and Python through the use of the Py.RunCode(...) module.
Customize settings like output folder, media type, format, and playlist item selection.
Clean and modular code, easy to maintain and integrate into other projects.
This project is ideal as a starting point for:
Create a personal or community video/audio download utility
Integrate a multimedia processing module into a B4X application
Prototyping a simplified interface for yt-dlp without a command line
Introducing beginners to Python ⇄ B4X interoperability
Distribution and expansion
The code is freely distributable and modifiable. You can:
Add an error or history management system
Integrate a database or other local library
Add an options menu to set output quality or format
Doing completely what you want
Requirements
B4J with PyBridge installed
KeyValueStore to save paths
Library yt_dlp (pip install yt-dlp) - Python multimedia download library
FFmpeg in the system PATH for audio conversions and extractions
YT_DLP USAGE AND OPTIONS
github.com
Problem encountered
I have not been able to implement a progress bar.
I redirected the logs, but I only have access to them when the process is finished with Wait For
log redirection example:
It would have been interesting to have something like this
Or maybe I don't know all the intricacies of PyBridge yet and it's actually possible to do it.
In this case, I would like to know the solution.
Have fun!
This project demonstrates a seamless integration between B4J and Python through the PyBridge extension to enable online video and audio uploads.
It was designed as a modular base that any developer can adapt, enrich, and redistribute to create a complete tool.
Main features
Download video and audio content via yt_dlp, with configurable options (format, codec, quality, etc.).
Two-way interaction between B4J and Python through the use of the Py.RunCode(...) module.
Customize settings like output folder, media type, format, and playlist item selection.
Clean and modular code, easy to maintain and integrate into other projects.
This project is ideal as a starting point for:
Create a personal or community video/audio download utility
Integrate a multimedia processing module into a B4X application
Prototyping a simplified interface for yt-dlp without a command line
Introducing beginners to Python ⇄ B4X interoperability
Distribution and expansion
The code is freely distributable and modifiable. You can:
Add an error or history management system
Integrate a database or other local library
Add an options menu to set output quality or format
Doing completely what you want
Requirements
B4J with PyBridge installed
KeyValueStore to save paths
Library yt_dlp (pip install yt-dlp) - Python multimedia download library
FFmpeg in the system PATH for audio conversions and extractions
YT_DLP USAGE AND OPTIONS
GitHub - yt-dlp/yt-dlp: A feature-rich command-line audio/video downloader
A feature-rich command-line audio/video downloader - yt-dlp/yt-dlp
Problem encountered
I have not been able to implement a progress bar.
I redirected the logs, but I only have access to them when the process is finished with Wait For
log redirection example:
py:
Py.ImportModule("io")
Py.ImportModule("sys")
.....
buffer = io.StringIO()
sys.stdout = buffer
....
sys.stdout = sys.__stdout__
return buffer.getvalue()
Private Sub btStart_Click
....
Wait For (DoIt.Fetch) Complete (Result As PyWrapper)
TextArea1.Text = Result.Value
....
End Sub
It would have been interesting to have something like this
B4X Py:
Sub Py_OutputReceived(Text As String)
If Text.StartsWith("download") Then
Dim pct As Float = Text.SubString(9).Trim
ProgressBar1.Progress = pct
lblStatus.Text = $"Download: ${pct}%"$
Else
Log(Text) ' To see other releases
End If
End Sub
Sub Py_ErrorReceived(error As String)
Log(error)
End Sub
Sub Py_ExecutionCompleted(Success As Boolean, Result As Object)
Log(Success)
End Sub
Or maybe I don't know all the intricacies of PyBridge yet and it's actually possible to do it.
In this case, I would like to know the solution.
Have fun!
Attachments
Last edited: