mirror of
https://github.com/MeexReay/Youtube2Maker.git
synced 2025-05-05 23:58:02 +03:00
scripts
This commit is contained in:
parent
77f3d57743
commit
5662f1ef1c
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/build
|
||||
/videos/*
|
59
README.md
59
README.md
@ -2,3 +2,62 @@
|
||||
Прога которая делает из флешки переносной ютуб 2 \
|
||||
Это лишь попытка создать чтото похожее на [оригинальный ютуб 2 от Влада Кунякина](https://www.youtube.com/watch?v=Ywywiqissfg) \
|
||||
Если вы хотите получить оригинальный ютуб 2, то [покупайте флешку тут](https://t.me/kunyakin/16)
|
||||
|
||||
## Как собрать
|
||||
|
||||
1. Добавьте все видео в папку `videos/` (смотреть Добавление видео)
|
||||
2. Соберите сайт через `./build.sh`
|
||||
3. Запишите сайт на флешку через dd (замените sdX на тот что из lsblk):
|
||||
```bash
|
||||
sudo dd if=build/youtube2.iso of=/dev/sdX bs=4M status=progress oflag=sync
|
||||
```
|
||||
|
||||
## Добавление видео
|
||||
|
||||
### Скачать из ютуба
|
||||
|
||||
Установите `yt-dlp` для работы скриптов.
|
||||
|
||||
Скачать одно видео:
|
||||
|
||||
```bash
|
||||
./dl-video.sh https://www.youtube.com/watch?v=<video-id>
|
||||
```
|
||||
|
||||
Скачать плейлист:
|
||||
|
||||
```bash
|
||||
./dl-playlist.sh https://www.youtube.com/playlist?list=<playlist-id>
|
||||
```
|
||||
|
||||
К скриптам также можно добавлять аргументы для `yt-dlp`, например `./dl-video.sh ... --cookies-from-browser firefox` для импортирования куки-файлов из файрфокса
|
||||
|
||||
### Ручное добавление
|
||||
|
||||
1. Добавьте json файл `<video-id>.json` в папку `videos/`:
|
||||
```json
|
||||
{
|
||||
"name": "Название видео",
|
||||
"description": "Описание видео",
|
||||
"video-file": "<video-id>.mp4",
|
||||
"image-file": "<video-id>.png",
|
||||
"channel-name": "Название канала",
|
||||
"channel-avatar-file": "<channel-id>.png",
|
||||
}
|
||||
```
|
||||
|
||||
2. Добавьте видео файл `<video-id>.mp4` в папку `videos/`
|
||||
3. Добавьте превью видео `<video-id>.png` в папку `videos/`
|
||||
4. Добавьте `<channel-id>.png` в папку `videos/`
|
||||
|
||||
## Сжатие видео
|
||||
|
||||
Для сжатия всех видео в `.av1` формат, используйте эту ffmpeg команду (если у вас изначальный формат не `.mp4` то замените)
|
||||
|
||||
Используйте скрипт `convert-to-av1.sh`:
|
||||
|
||||
```bash
|
||||
./convert-to-av1.sh
|
||||
```
|
||||
|
||||
Учтите что формат видео `.av1` поддерживается не везде!
|
9
build.sh
Normal file
9
build.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir build
|
||||
cp -r root build/iso
|
||||
cp -r www build/iso/www
|
||||
cp -r videos build/iso/www/videos
|
||||
find videos -type f -name "*.json" | sed 's|^videos/||; s|\.json$||' > build/iso/www/videos.txt
|
||||
truncate -s -1 build/iso/www/videos.txt
|
||||
mkisofs -o build/youtube2.iso -V "Youtube2" -J -r build/iso
|
0
config.json
Normal file
0
config.json
Normal file
9
convert-to-av1.sh
Normal file
9
convert-to-av1.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
for video_file in videos/*.mp4; do
|
||||
base_name=$(basename "$video_file" .mp4)
|
||||
|
||||
ffmpeg -i "$video_file" -c:v libaom-av1 -crf 23 -b:v 0 -cpu-used 4 -g 240 -strict -2 "videos/$base_name.av1.mp4" || exit 1
|
||||
|
||||
mv "videos/$base_name.av1.mp4" "$video_file"
|
||||
done
|
18
dl-playlist.sh
Normal file
18
dl-playlist.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Ошибка: укажите ссылку на плейлист."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PLAYLIST_URL=$1
|
||||
shift
|
||||
|
||||
VIDEO_URLS=$(yt-dlp --flat-playlist -i --print url "$PLAYLIST_URL")
|
||||
|
||||
for VIDEO_URL in $VIDEO_URLS; do
|
||||
echo "Загружаем видео: $VIDEO_URL"
|
||||
./dl-video "$VIDEO_URL" "$@"
|
||||
done
|
||||
|
||||
echo "Плейлист успешно скачан"
|
43
dl-video.sh
Normal file
43
dl-video.sh
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Ошибка: укажите ссылку на видео."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VIDEO_URL=$1
|
||||
shift
|
||||
ADDITIONAL_ARGS="$@"
|
||||
|
||||
VIDEO_ID=$(echo -n "$VIDEO_URL" | md5sum | awk '{print $1}')
|
||||
|
||||
mkdir -p "videos"
|
||||
|
||||
yt-dlp --write-info-json --write-thumbnail \
|
||||
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" \
|
||||
-o "videos/${VIDEO_ID}" "$VIDEO_URL" $ADDITIONAL_ARGS
|
||||
|
||||
NAME=$(jq -r '.fulltitle' "videos/${VIDEO_ID}.info.json")
|
||||
DESCRIPTION=$(jq -r '.description' "videos/${VIDEO_ID}.info.json")
|
||||
CHANNEL_NAME=$(jq -r '.uploader' "videos/${VIDEO_ID}.info.json")
|
||||
CHANNEL_ID=$(jq -r '.channel_id' "videos/${VIDEO_ID}.info.json")
|
||||
CHANNEL_URL=$(jq -r '.uploader_url' "videos/${VIDEO_ID}.info.json")
|
||||
|
||||
yt-dlp --write-thumbnail --skip-download --playlist-items 0 -o "videos/${CHANNEL_ID}" "$CHANNEL_URL" $ADDITIONAL_ARGS
|
||||
|
||||
jq --arg name "$NAME" --arg description "$DESCRIPTION" --arg video_file "${VIDEO_ID}.mp4" \
|
||||
--arg image_file "${VIDEO_ID}.png" --arg channel_name "$CHANNEL_NAME" \
|
||||
--arg channel_avatar_file "${CHANNEL_ID}.png" \
|
||||
'{
|
||||
name: $name,
|
||||
description: $description,
|
||||
"video-file": $video_file,
|
||||
"image-file": $image_file,
|
||||
"channel-name": $channel_name,
|
||||
"channel-avatar-file": $channel_avatar_file
|
||||
}' \
|
||||
"videos/${VIDEO_ID}.info.json" > "videos/${VIDEO_ID}.tmp.json" && mv "videos/${VIDEO_ID}.tmp.json" "videos/${VIDEO_ID}.json"
|
||||
|
||||
rm "videos/${VIDEO_ID}.info.json"
|
||||
|
||||
echo "Видео успешно скачано"
|
3
root/autorun.inf
Normal file
3
root/autorun.inf
Normal file
@ -0,0 +1,3 @@
|
||||
[AutoRun]
|
||||
open=./www/index.html
|
||||
label=Run Youtube2
|
2
root/start.command
Normal file
2
root/start.command
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
open "./www/index.html"
|
6
root/start.desktop
Normal file
6
root/start.desktop
Normal file
@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Name=Run Youtube2
|
||||
Type=Application
|
||||
Exec=xdg-open ./www/index.html
|
||||
Icon=html
|
||||
Terminal=false
|
2
root/start.sh
Normal file
2
root/start.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
xdg-open "./www/index.html"
|
2
root/start.url
Normal file
2
root/start.url
Normal file
@ -0,0 +1,2 @@
|
||||
[InternetShortcut]
|
||||
URL=./www/index.html
|
9
root/start.webloc
Normal file
9
root/start.webloc
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>URL</key>
|
||||
<string>./www/index.html</string>
|
||||
</dict>
|
||||
</plist>
|
11
www/index.html
Normal file
11
www/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Youtube 2</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user