Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
gitlab.com/ttpcodes/youtube-dl-go
A Go library that wraps youtube-dl's Python API.
youtube-dl-go
is a simple wrapper to the popular
youtube-dl
application for Python. This allows you to access the youtube-dl
binary
programmatically in any application that you write.
The motivation for creating this library was simple: many of the other pure Go
solutions for downloading YouTube videos were lacking in features or were
woefully out of date, making them difficult to use and implement in actual
projects. By wrapping youtube-dl
with this library, we get easy access to an
already well developed download solution while also having an easy to use API
for our Go applications.
This package is still in a very alpha stage. It is not being actively
developed, as its main purpose is to provide a good youtube-dl
interface for
my other project, Prismriver. That
being said however, I am more than happy to respond to feature requests to
increase the functionality of this library.
All downloads are initiated by creating a Downloader
instance. There is an
Output
function which will allow you to specify where the file is
downloaded, and supports various output templates from youtube-dl
. Downloads
can be run by calling Run
, which blocks the program until the download
completes, or with RunProgress
, which provides channels to track the
download's progress and wait for a completed download.
package main
import (
"fmt"
"gitlab.com/ttpcodes/youtube-dl-go"
)
func main() {
// Guess what my favorite song is as of this writing?
downloader := youtubedl.NewDownloader("https://www.youtube.com/watch?v=Qu_OzBsgRcI")
downloader.Output("~/Downloads/RealOrFake")
path, err := downloader.Run()
if err != nil {
fmt.Print(err)
return
}
fmt.Printf("File was downloaded to %s", path)
// My other favorite song, which I'll use to show channel usage:
downloader2 := youtubedl.NewDownloader("https://www.youtube.com/watch?v=6nDrD2WNSJU")
downloader2.Output("~/Downloads/" + youtubedl.ID)
progressChan, resultChan, err := downloader2.RunProgress()
if err != nil {
fmt.Print(err)
}
for progress := range progressChan {
fmt.Printf("Current progress: %f", progress)
}
result := <- resultChan
if result.Err != nil {
fmt.Print(err)
return
}
fmt.Printf("File 2 was downloaded to %s", result.Path)
}
When run, the program will output something similar to this:
File was downloaded to /home/ttpcodes/Downloads/RealOrFake.mkv
Current progress: 0.000000
Current progress: 0.050000
Current progress: 0.050000
Current progress: 0.100000
Current progress: 0.250000
Current progress: 0.500000
Current progress: 1.000000
Current progress: 1.950000
Current progress: 3.950000
Current progress: 7.900000
Current progress: 15.750000
Current progress: 31.500000
... # Omitted progress lines
Current progress: 60.800000
Current progress: 71.650000
Current progress: 93.300000
Current progress: 100.000000
File 2 was downloaded to /home/ttpcodes/Downloads/6nDrD2WNSJU.mkv
API documentation can be found on GoDoc.
Any Go method of package management should support the installation of this
package. My preferred package management method is dep
:
dep ensure gitlab.com/ttpcodes/youtube-dl-go
This project is licensed under the MIT License.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.