initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
yt_download
|
||||||
|
ytdlp-honey.sh
|
2
Makefile
Normal file
2
Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
yt_download:
|
||||||
|
gcc -ansi -I . -L. -ggdb -o yt_download yt_download.c -Wl,-Bstatic -lstrops -Wl,-Bdynamic
|
23
move_audio.sh
Executable file
23
move_audio.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
[[ -z $1 ]] && echo 'No arguments specified' && exit 1
|
||||||
|
|
||||||
|
if [[ -d $1 ]]; then
|
||||||
|
cd "$1"
|
||||||
|
else
|
||||||
|
echo 'Specified path does not exist' && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
folders=("audio" "thumbnails" "metadata" "descriptions")
|
||||||
|
|
||||||
|
for folder in "${folders[@]}"; do
|
||||||
|
[[ ! -d $folder ]] && mkdir "$folder"
|
||||||
|
done
|
||||||
|
|
||||||
|
mv *.opus audio > /dev/null 2>&1
|
||||||
|
mv *.jpg thumbnails > /dev/null 2>&1
|
||||||
|
mv *.jpeg thumbnails > /dev/null 2>&1
|
||||||
|
mv *.png thumbnails > /dev/null 2>&1
|
||||||
|
mv *.webp thumbnails > /dev/null 2>&1
|
||||||
|
mv *.info.json metadata > /dev/null 2>&1
|
||||||
|
mv *.description descriptions > /dev/null 2>&1
|
24
move_video.sh
Executable file
24
move_video.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
[[ -z $1 ]] && echo 'No arguments specified' && exit 1
|
||||||
|
|
||||||
|
if [[ -d $1 ]]; then
|
||||||
|
cd "$1"
|
||||||
|
else
|
||||||
|
echo 'Specified path does not exist' && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
folders=("video" "thumbnails" "metadata" "descriptions" "subs")
|
||||||
|
|
||||||
|
for folder in "${folders[@]}"; do
|
||||||
|
[[ ! -d $folder ]] && mkdir "$folder"
|
||||||
|
done
|
||||||
|
|
||||||
|
mv *.mkv video
|
||||||
|
mv *.jpg thumbnails
|
||||||
|
mv *.jpeg thumbnails
|
||||||
|
mv *.png thumbnails
|
||||||
|
mv *.webp thumbnails
|
||||||
|
mv *.info.json metadata
|
||||||
|
mv *.description descriptions
|
||||||
|
mv *.vtt subs
|
25
yt-dlp_audio.conf
Normal file
25
yt-dlp_audio.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Uses best audio
|
||||||
|
-f bestaudio
|
||||||
|
|
||||||
|
# Extracts the audio
|
||||||
|
--extract-audio
|
||||||
|
|
||||||
|
# Uses best quality
|
||||||
|
--audio-quality 0
|
||||||
|
|
||||||
|
# opus is the best you can get from youtube
|
||||||
|
--audio-format opus
|
||||||
|
|
||||||
|
# Concurrent download of fragments
|
||||||
|
--concurrent-fragments 8
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
--cache-dir /tmp/yt-dlp/cache
|
||||||
|
|
||||||
|
# Cookies
|
||||||
|
--cookies /mnt/youtube/cookies.txt
|
||||||
|
|
||||||
|
# Chill out
|
||||||
|
--sleep-requests 1.25
|
||||||
|
--min-sleep-interval 60
|
||||||
|
--max-sleep-interval 90
|
41
yt-dlp_video.conf
Normal file
41
yt-dlp_video.conf
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# best video and audio
|
||||||
|
-f bestvideo+bestaudio
|
||||||
|
|
||||||
|
# Thumbnail
|
||||||
|
--write-thumbnail
|
||||||
|
--embed-thumbnail
|
||||||
|
|
||||||
|
# Add chapters
|
||||||
|
--embed-chapters
|
||||||
|
|
||||||
|
# Embed info json
|
||||||
|
--write-info-json
|
||||||
|
--embed-info-json
|
||||||
|
|
||||||
|
# Metadata
|
||||||
|
--embed-metadata
|
||||||
|
|
||||||
|
# Description
|
||||||
|
--write-description
|
||||||
|
|
||||||
|
# Subtitles
|
||||||
|
--sub-langs en.*
|
||||||
|
--write-subs
|
||||||
|
--embed-subs
|
||||||
|
|
||||||
|
# Concurrent download of fragments
|
||||||
|
--concurrent-fragments 8
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
--cache-dir /tmp/yt-dlp/cache
|
||||||
|
|
||||||
|
# Cookies
|
||||||
|
--cookies /mnt/youtube/cookies.txt
|
||||||
|
|
||||||
|
# Merge downloaded video and audio into a mkv file
|
||||||
|
--merge-output-format mkv
|
||||||
|
|
||||||
|
# Chill out
|
||||||
|
--sleep-requests 1.25
|
||||||
|
--min-sleep-interval 60
|
||||||
|
--max-sleep-interval 90
|
87
yt_download.c
Normal file
87
yt_download.c
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int download(char *path, char *url, char is_audio) {
|
||||||
|
int ret;
|
||||||
|
char *args[10];
|
||||||
|
args[0] = "yt-dlp";
|
||||||
|
args[1] = "--config-locations";
|
||||||
|
if (is_audio) {
|
||||||
|
args[2] = "/mnt/youtube/yt-dlp_audio.conf";
|
||||||
|
} else {
|
||||||
|
args[2] = "/mnt/youtube/yt-dlp_video.conf";
|
||||||
|
}
|
||||||
|
args[3] = "--download-archive";
|
||||||
|
if (is_audio) {
|
||||||
|
char *buf = malloc(strlen(path) + 1);
|
||||||
|
sprintf(buf, "%s/downloaded_audio.txt", path);
|
||||||
|
args[4] = buf;
|
||||||
|
} else {
|
||||||
|
char *buf = malloc(strlen(path) + 1);
|
||||||
|
sprintf(buf, "%s/downloaded_video.txt", path);
|
||||||
|
args[4] = buf;
|
||||||
|
}
|
||||||
|
args[5] = "--paths";
|
||||||
|
args[6] = path;
|
||||||
|
args[7] = "--yes-playlist";
|
||||||
|
args[8] = url;
|
||||||
|
args[9] = 0;
|
||||||
|
|
||||||
|
int pid = fork();
|
||||||
|
|
||||||
|
if (pid == -1) {
|
||||||
|
printf("Couldn't fork'\n");
|
||||||
|
return 1;
|
||||||
|
} else if (pid > 0) {
|
||||||
|
waitpid(pid, &ret, 0);
|
||||||
|
} else {
|
||||||
|
execvp(args[0], args);
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc != 4) {
|
||||||
|
fprintf(stderr, "Incorred amount of arguments\n");
|
||||||
|
}
|
||||||
|
char *path;
|
||||||
|
char *url;
|
||||||
|
char is_audio;
|
||||||
|
size_t i;
|
||||||
|
for (i = 1; i < 4; i++) {
|
||||||
|
if (argv[i][0] == '-') {
|
||||||
|
if (strcmp(argv[i], "-audio") == 0) {
|
||||||
|
is_audio = 1;
|
||||||
|
} else if (strcmp(argv[i], "-video") == 0) {
|
||||||
|
is_audio = 0;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Invalid option: %s\n", argv[i]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else if (strstr(argv[i], "https://")) {
|
||||||
|
url = argv[i];
|
||||||
|
} else {
|
||||||
|
path = argv[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!path) {
|
||||||
|
fprintf(stderr, "No path specified\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!url) {
|
||||||
|
fprintf(stderr, "No valid url specified\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
ret = download(path, url, is_audio);
|
||||||
|
if (ret != 0) {
|
||||||
|
fprintf(stderr, "Download Failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user