mirror of
https://github.com/arkorty/DownLink.git
synced 2026-03-17 16:51:45 +00:00
Refactor: change Python3 virtual environment path
This commit is contained in:
@@ -26,14 +26,14 @@ RUN apk add --no-cache \
|
|||||||
ffmpeg
|
ffmpeg
|
||||||
|
|
||||||
# Create a virtual environment for Python
|
# Create a virtual environment for Python
|
||||||
RUN python3 -m venv /venv
|
RUN python3 -m venv venv
|
||||||
|
|
||||||
# Activate the virtual environment and install yt-dlp
|
# Activate the virtual environment and install yt-dlp
|
||||||
RUN /venv/bin/pip install --upgrade pip && \
|
RUN ./venv/bin/pip install --upgrade pip && \
|
||||||
/venv/bin/pip install yt-dlp
|
./venv/bin/pip install yt-dlp
|
||||||
|
|
||||||
# Ensure ffmpeg is in the PATH
|
# Ensure ffmpeg is in the PATH
|
||||||
ENV PATH="/usr/bin:/venv/bin:${PATH}"
|
ENV PATH="/usr/bin:${PATH}"
|
||||||
|
|
||||||
# Expose port 8080 to the outside world
|
# Expose port 8080 to the outside world
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type VideoDownloadRequest struct {
|
|||||||
func getBestFormats(url string, targetResolution string) (string, string, error) {
|
func getBestFormats(url string, targetResolution string) (string, string, error) {
|
||||||
log.Printf("Getting best formats for URL: %s, target resolution: %s", url, targetResolution)
|
log.Printf("Getting best formats for URL: %s, target resolution: %s", url, targetResolution)
|
||||||
|
|
||||||
cmd := exec.Command("yt-dlp", "--cookies", "cookies.txt", "--list-formats", url)
|
cmd := exec.Command("./venv/bin/python3", "-m", "yt_dlp", "--cookies", "cookies.txt", "--list-formats", url)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("failed to list formats: %v\nOutput: %s", err, string(output))
|
return "", "", fmt.Errorf("failed to list formats: %v\nOutput: %s", err, string(output))
|
||||||
@@ -93,13 +93,13 @@ func downloadVideo(c echo.Context) error {
|
|||||||
outputPath := filepath.Join(tmpDir, fmt.Sprintf("output_%s.mp4", uid))
|
outputPath := filepath.Join(tmpDir, fmt.Sprintf("output_%s.mp4", uid))
|
||||||
|
|
||||||
// Download video
|
// Download video
|
||||||
cmdVideo := exec.Command("yt-dlp", "--cookies", "cookies.txt", "-f", videoFormat, "-o", videoPath, req.URL)
|
cmdVideo := exec.Command("./venv/bin/python3", "-m", "yt_dlp", "--cookies", "cookies.txt", "-f", videoFormat, "-o", videoPath, req.URL)
|
||||||
if err := cmdVideo.Run(); err != nil {
|
if err := cmdVideo.Run(); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to download video: %v", err))
|
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to download video: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download audio
|
// Download audio
|
||||||
cmdAudio := exec.Command("yt-dlp", "--cookies", "cookies.txt", "-f", audioFormat, "-o", audioPath, req.URL)
|
cmdAudio := exec.Command("./venv/bin/python3", "-m", "yt_dlp", "--cookies", "cookies.txt", "-f", audioFormat, "-o", audioPath, req.URL)
|
||||||
if err := cmdAudio.Run(); err != nil {
|
if err := cmdAudio.Run(); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to download audio: %v", err))
|
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to download audio: %v", err))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user