mirror of
https://github.com/arkorty/DownLink.git
synced 2026-03-18 00:57:15 +00:00
Add support for instagram
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
"github.com/labstack/echo/middleware"
|
"github.com/labstack/echo/middleware"
|
||||||
@@ -44,8 +45,19 @@ func downloadVideo(c echo.Context) error {
|
|||||||
|
|
||||||
// Download video and audio combined
|
// Download video and audio combined
|
||||||
quality := req.Quality[:len(req.Quality) - 1]
|
quality := req.Quality[:len(req.Quality) - 1]
|
||||||
mergedFormat := fmt.Sprintf("bestvideo[height<=%s]+bestaudio/best[height<=%s]", quality, quality)
|
|
||||||
cmdDownload := exec.Command("./venv/bin/python3", "-m", "yt_dlp", "--cookies", "cookies.txt", "-f", mergedFormat, "--merge-output-format", "mp4", "-o", outputPath, req.URL)
|
var mergedFormat string
|
||||||
|
var cookies string
|
||||||
|
|
||||||
|
if strings.Contains(req.URL, "instagram.com/") {
|
||||||
|
mergedFormat = fmt.Sprintf("bestvideo[width<=%s]+bestaudio/best", quality)
|
||||||
|
cookies = "cookies_i.txt"
|
||||||
|
} else {
|
||||||
|
mergedFormat = fmt.Sprintf("bestvideo[height<=%s]+bestaudio/best[height<=%s]", quality, quality)
|
||||||
|
cookies = "cookies_y.txt"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdDownload := exec.Command("./venv/bin/python3", "-m", "yt_dlp", "--cookies", cookies, "-f", mergedFormat, "--merge-output-format", "mp4", "-o", outputPath, req.URL)
|
||||||
if err := cmdDownload.Run(); err != nil {
|
if err := cmdDownload.Run(); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to download video and audio: %v", err))
|
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to download video and audio: %v", err))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ const DownloadForm = () => {
|
|||||||
const [showConfetti, setShowConfetti] = useState(false);
|
const [showConfetti, setShowConfetti] = useState(false);
|
||||||
const [notification, setNotification] = useState(null);
|
const [notification, setNotification] = useState(null);
|
||||||
|
|
||||||
const isValidYouTubeUrl = (url) => {
|
const isValidUrl = (url) => {
|
||||||
const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+$/;
|
const legalDomains =
|
||||||
return youtubeRegex.test(url);
|
/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be|instagram\.com)\/.+$/;
|
||||||
|
return legalDomains.test(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDownload = async (e) => {
|
const handleDownload = async (e) => {
|
||||||
@@ -24,8 +25,8 @@ const DownloadForm = () => {
|
|||||||
if (!url) {
|
if (!url) {
|
||||||
setNotification("Maybe enter an URL first");
|
setNotification("Maybe enter an URL first");
|
||||||
return;
|
return;
|
||||||
} else if (!isValidYouTubeUrl(url)) {
|
} else if (!isValidUrl(url)) {
|
||||||
setNotification("Doesn't look like YouTube to me");
|
setNotification("Doesn't look like a valid URL to me");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ const Home = () => {
|
|||||||
sequence={[
|
sequence={[
|
||||||
"From YouTube!",
|
"From YouTube!",
|
||||||
1200,
|
1200,
|
||||||
|
"And Instagram",
|
||||||
|
1200,
|
||||||
"Download Now!",
|
"Download Now!",
|
||||||
1200,
|
1200,
|
||||||
"HD Quality!",
|
"HD Quality!",
|
||||||
|
|||||||
Reference in New Issue
Block a user