From 70512cf59c888f87f1369d0e317407e66163cf4a Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 23 Nov 2022 18:53:13 -0300 Subject: [PATCH] Removido el script de legado y otras cosas - Se movio el script que usa curl y jq al branch de `legacy` --- README.md | 6 +--- canales/.gitkeep | 0 twtoyt-curl-jq.sh | 53 ----------------------------------- twtoyt-xh-jtc.sh => twtoyt.sh | 8 +++--- 4 files changed, 5 insertions(+), 62 deletions(-) create mode 100644 canales/.gitkeep delete mode 100755 twtoyt-curl-jq.sh rename twtoyt-xh-jtc.sh => twtoyt.sh (94%) diff --git a/README.md b/README.md index 39e2160..b848d6d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ # TwitchToYoutube -Utilidad hecha en bash para subir streams de twitch directamente a youtube. Usando [streamlink](https://github.com/streamlink/streamlink), [youtubeuploader](https://github.com/porjo/youtubeuploader), [cURL](https://curl.se)/[xh](https://github.com/ducaale/xh) y [jq](https://github.com/stedolan/jq)/[jtc](https://github.com/ldn-softdev/jtc) - -⚠️ Nota Importante: Este script tiene 2 versiones, una que funciona con **cURL** y **jq** y otra que utiliza **xh** y **jtc**. - -La mejor es la version que utiliza **xh** y **jtc** por ser mas eficiente y rápido. [Vee aquí](./benchmark.md) +Utilidad hecha en bash para subir streams de twitch directamente a youtube. Usando [streamlink](https://github.com/streamlink/streamlink), [youtubeuploader](https://github.com/porjo/youtubeuploader), [xh](https://github.com/ducaale/xh) y [jtc](https://github.com/ldn-softdev/jtc) *Lo recomendado para usar este programa es tener un servidor o una PC que tenga un internet estable y este encendido 24/7.* diff --git a/canales/.gitkeep b/canales/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/twtoyt-curl-jq.sh b/twtoyt-curl-jq.sh deleted file mode 100755 index bdbb852..0000000 --- a/twtoyt-curl-jq.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# Carga la configuracion desde ./config.sh -source ./config.sh - -echo "Auth de twitch: $twitchauth" -echo "Client-Id de twitch: $clientid" - -# Coloca aca el nombre del streamer de twitch -TWITCH_USER="" - -while true; do - TIME_DATE=[$(date +"%d/%m/%y")] # Formato de la fecha, usando el comando `date`. Ejemplo de como saldria: [31/12/22] - VIDEO_VISIBILITY="public" # Visibilidad del Video. Opciones disponibles: unlisted, private, public - VIDEO_DURATION="11:59:30" # Duración del video, si dura mas de el valor ingresado, se subira en partes divididas (Youtube solo tiene hasta videos de maximo 12 horas) - - STREAMLINK_OPTIONS="best --hls-duration $VIDEO_DURATION --stream-segment-timeout 30 --hls-playlist-reload-attempts 10 --hls-live-restart --twitch-disable-hosting --twitch-disable-reruns -O --loglevel error" # https://streamlink.github.io/cli.html#twitch - - echo "Checkqueando si $TWITCH_USER esta en vivo" - - # Checkea si el streamer esta en vivo usando la API de twitch - checkstream=$(curl -sS -X GET "https://api.twitch.tv/helix/streams?user_login=$TWITCH_USER" -H "Authorization: Bearer $twitchauth" -H "Client-Id: $clientid" | jq -r '.data[].type') - - # Si el streamer esta en vivo, empieza a subir a youtube - if [[ $checkstream = *live* ]]; then - STREAMER_NAME=$TWITCH_USER - VIDEO_PLAYLIST="$STREAMER_NAME VODs" - - TWITCH_USER_ID=$(curl -sS -X GET "https://api.twitch.tv/helix/users?login=$TWITCH_USER" -H "Authorization: Bearer $twitchauth" -H "Client-Id: $clientid" | jq -r '.data[].id') - TWITCH_TITLE=$(curl -sS -X GET "https://api.twitch.tv/helix/channels?broadcaster_id=$TWITCH_USER_ID" -H "Authorization: Bearer $twitchauth" -H "Client-Id: $clientid" | jq -r '.data[].title') - TWITCH_TITLE_CUT=$(echo "$TWITCH_TITLE" | colrm 70 | tr "><" " ") - - VIDEO_DESCRIPTION="Hosteado por Fijxu. https://twitch.tv/$TWITCH_USER \nTitulo Completo: $TWITCH_TITLE \nFecha y hora: $(date +"A las %H:%M horas, día %d/%m/%y") \nDonaciones: https://ko-fi.com/fijxu \nSi eres el streamer que aparece en el VOD y por alguna razon necesitas ocultar o recuperar (nunca borrare los VODs, eso va en contra de mi objetivo, aunque pueden haber excepciones) el VOD, puedes dejar un comentario, enviar un mensaje por Twitch @fijxu o usando el correo de contacto del canal. \n \nEste es un proyecto de caracter personal, me gusta archivar streams de twitch para que nada se pierda, y que todos puedan volver a ver streams del pasado sin problemas. 'Sharing is caring'" # Descripción del video - - echo "Using Twitch user: $TWITCH_USER | ID: $TWITCH_USER_ID" - echo "Titulo del stream: $TWITCH_TITLE" - echo "Titulo del stream cortado: $TWITCH_TITLE_CUT" - echo "" - - # NOMBRE DEL STREAMER (TWITCH) - NOMBRE DEL TITULO CORTADO (por limitaciones de caracteres de youtube) - FECHA - VIDEO_TITLE="$STREAMER_NAME - $TWITCH_TITLE_CUT ~ $TIME_DATE" - - # Crea el archivo JSON usado por youtubeuploader para agregar la información del VOD para Youtube - echo '{"title":"'"$VIDEO_TITLE"'","privacyStatus":"'"$VIDEO_VISIBILITY"'","description":"'"$VIDEO_DESCRIPTION"'","playlistTitles":["'"${VIDEO_PLAYLIST}"'"]}' >/tmp/input."$STREAMER_NAME" - - echo "Titulo actualizado: $VIDEO_TITLE" - echo "En vivo, subiendo a YouTube" - streamlink https://twitch.tv/"$STREAMER_NAME" $STREAMLINK_OPTIONS | youtubeuploader -metaJSON /tmp/input."$STREAMER_NAME" -filename - - else - echo "No hay streams disponibles, reintentando en 10 seg" - fi - sleep 10s - -done diff --git a/twtoyt-xh-jtc.sh b/twtoyt.sh similarity index 94% rename from twtoyt-xh-jtc.sh rename to twtoyt.sh index 6a8f887..0b067e7 100755 --- a/twtoyt-xh-jtc.sh +++ b/twtoyt.sh @@ -1,6 +1,6 @@ #!/bin/bash # Carga la configuracion desde ./config.sh -source ./config.sh +source ../.env echo "Auth de twitch: $twitchauth" echo "Client-Id de twitch: $clientid" @@ -18,15 +18,15 @@ while true; do echo "Checkqueando si $TWITCH_USER esta en vivo" # Checkea si el streamer esta en vivo usando la API de twitch - checkstream=$(xh GET "https://api.twitch.tv/helix/streams?user_login=$TWITCH_USER" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ./jtc -w '[data][:][type]' -qq) + checkstream=$(xh GET "https://api.twitch.tv/helix/streams?user_login=$TWITCH_USER" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ../jtc -w '[data][:][type]' -qq) # Si el streamer esta en vivo, empieza a subir a youtube if [[ $checkstream = *live* ]]; then STREAMER_NAME=$TWITCH_USER VIDEO_PLAYLIST="$STREAMER_NAME VODs" - TWITCH_USER_ID=$(xh GET "https://api.twitch.tv/helix/users?login=$TWITCH_USER" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ./jtc -w '[data][:][id]' -qq) - TWITCH_TITLE=$(xh GET "https://api.twitch.tv/helix/channels?broadcaster_id=$TWITCH_USER_ID" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ./jtc -w '[data][:][title]' -qq) + TWITCH_USER_ID=$(xh GET "https://api.twitch.tv/helix/users?login=$TWITCH_USER" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ../jtc -w '[data][:][id]' -qq) + TWITCH_TITLE=$(xh GET "https://api.twitch.tv/helix/channels?broadcaster_id=$TWITCH_USER_ID" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ../jtc -w '[data][:][title]' -qq) TWITCH_TITLE_CUT=$(echo "$TWITCH_TITLE" | colrm 70 | tr "><" " ") VIDEO_DESCRIPTION="Hosteado por Fijxu. https://twitch.tv/$TWITCH_USER \nTitulo Completo: $TWITCH_TITLE \nFecha y hora: $(date +"A las %H:%M horas, día %d/%m/%y") \nDonaciones: https://ko-fi.com/fijxu \nSi eres el streamer que aparece en el VOD y por alguna razon necesitas ocultar o recuperar (nunca borrare los VODs, eso va en contra de mi objetivo, aunque pueden haber excepciones) el VOD, puedes dejar un comentario, enviar un mensaje por Twitch @fijxu o usando el correo de contacto del canal. \n \nEste es un proyecto de caracter personal, me gusta archivar streams de twitch para que nada se pierda, y que todos puedan volver a ver streams del pasado sin problemas. 'Sharing is caring'" # Descripción del video