Last active
October 25, 2019 18:24
-
-
Save micalevisk/9ca5edbaaae42864acaa1259f279968d to your computer and use it in GitHub Desktop.
Get moments from YouNow! https://www.younow.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go to https://www.younow.com and paste the code below on console dev tools | |
const params = { | |
user: 'Iamhannahstone', | |
createdBefore: 0, | |
records: 20, | |
}; | |
fetch(`https://cdn.younow.com/php/api/channel/getInfo/user=${params.user}`) | |
.then(res => res.json()) | |
.then(data => data.userId) | |
.then(function (channelId) { | |
fetch(`https://cdn.younow.com/php/api/moment/profile/channelId=${channelId}/createdBefore=${params.createdBefore}/records=${params.records}`) | |
.then(res => res.json()) | |
.then(({items}) => items.map(item => item.momentsIds || [item.momentId])) | |
.then(console.log); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Micael Levi L. C. (micalevisk) | |
# Usage: ./younow-m3u8_to_mp4.sh <MOMENT_ID> | |
# Example: | |
# ./younow-m3u8_to_mp4.sh 28922577 | |
# will create '28922577.mp4' file | |
set -e | |
FFMPEG_LESS_VERBOSE="ffmpeg -loglevel panic" | |
RM_VERBOSE="rm -v -f" | |
donwload_m3u8() { | |
ID="${1,,}" | |
URL="https://hls.younow.com/momentsplaylists/live/${ID}/${ID}.m3u8" | |
m3u8_filename="${URL##*/}" | |
VIDEO_ID="${m3u8_filename%.*}" | |
TS_URLS_FILENAME="${VIDEO_ID}_ts_urls" | |
wget -v "$URL" -O "$m3u8_filename" | |
grep --color=never -Po '.+\.ts' "$m3u8_filename" > "$TS_URLS_FILENAME" | |
TS_URLS=( $(cat "$TS_URLS_FILENAME") ) | |
$RM_VERBOSE "$m3u8_filename" | |
} | |
## (c) https://unix.stackexchange.com/questions/61132 | |
download_files_from_list() { | |
list_of_urls_filename="$1" | |
wget -q --content-disposition --trust-server-names -i "$list_of_urls_filename" | |
$RM_VERBOSE "$list_of_urls_filename" | |
} | |
TS2MP4() { | |
for i in "${!TS_URLS[@]}" | |
do | |
ts_url="${TS_URLS[$i]}" | |
file="${ts_url##*/}" | |
TS_URLS[$i]="$file" | |
$FFMPEG_LESS_VERBOSE -i "$file" -c copy "${file%.*}.mp4" | |
done | |
$RM_VERBOSE "${TS_URLS[@]}" | |
} | |
## (c) https://stackoverflow.com/questions/7333232 | |
concat_demuxer() { | |
TS_URLS=( "${TS_URLS[@]/.ts/.mp4}" ) ## agora atua como `MP4_FILES` | |
files_to_concat_filename="files_to_concat_${VIDEO_ID}" | |
concat_mp4_filename="${VIDEO_ID}.mp4" | |
printf "file '%s'\n" "${TS_URLS[@]}" > "$files_to_concat_filename" | |
$FFMPEG_LESS_VERBOSE -f concat -i "$files_to_concat_filename" -c copy "${concat_mp4_filename}" | |
$RM_VERBOSE "${TS_URLS[@]}" | |
$RM_VERBOSE "$files_to_concat_filename" | |
[ -f "${concat_mp4_filename}" ] && echo "Created '${concat_mp4_filename}'!" | |
} | |
donwload_m3u8 "$@" | |
download_files_from_list "$TS_URLS_FILENAME" | |
TS2MP4 | |
concat_demuxer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment