Fixed date selection, added help menu
This commit is contained in:
28
clipsDump.sh
28
clipsDump.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
while getopts "ab:c:e:ls:f:" OPTION
|
while getopts "ab:c:e:ls:f:h" OPTION
|
||||||
do
|
do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
c)
|
c)
|
||||||
@@ -11,10 +11,8 @@ do
|
|||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
startDate=$OPTARG
|
startDate=$OPTARG
|
||||||
endDate=2999-12-31T23:59:59Z
|
|
||||||
;;
|
;;
|
||||||
e)
|
e)
|
||||||
startDate=1970-01-01T00:00:00Z
|
|
||||||
endDate=$OPTARG
|
endDate=$OPTARG
|
||||||
;;
|
;;
|
||||||
b)
|
b)
|
||||||
@@ -29,9 +27,23 @@ do
|
|||||||
f)
|
f)
|
||||||
save=true
|
save=true
|
||||||
location=$OPTARG
|
location=$OPTARG
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
echo "-a: Downloads all clips for user"
|
||||||
|
echo "-b: Provide streamer's username"
|
||||||
|
echo "-c: Provide Twitch API client ID file"
|
||||||
|
echo "-e: Set clip dump end date"
|
||||||
|
echo "-f: Save clip URLs to file"
|
||||||
|
echo "-h: Help"
|
||||||
|
echo "-l: List Twitch clip URLs"
|
||||||
|
echo "-s: Set clip dump start date"
|
||||||
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo $startDate
|
||||||
|
echo $endDate
|
||||||
|
|
||||||
if [ -z "$clientid" ]
|
if [ -z "$clientid" ]
|
||||||
then
|
then
|
||||||
printf 'Please submit your Twitch API client ID: '
|
printf 'Please submit your Twitch API client ID: '
|
||||||
@@ -77,7 +89,7 @@ then
|
|||||||
else
|
else
|
||||||
url="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100' | jq -r '.data[] | .url')"
|
url="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100' | jq -r '.data[] | .url')"
|
||||||
|
|
||||||
youtube-dl -o "./%(title)s.%(ext)s" $url
|
youtube-dl -o "./%(title)s."$clipID".%(ext)s" $url
|
||||||
fi
|
fi
|
||||||
|
|
||||||
page="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100' | jq -r '.pagination.cursor')"
|
page="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100' | jq -r '.pagination.cursor')"
|
||||||
@@ -92,7 +104,7 @@ then
|
|||||||
else
|
else
|
||||||
url="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&after='$page'' | jq -r '.data[] | .url')"
|
url="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&after='$page'' | jq -r '.data[] | .url')"
|
||||||
|
|
||||||
youtube-dl -o "./%(title)s.%(ext)s" $url
|
youtube-dl -o "./%(title)s."$clipID".%(ext)s" $url
|
||||||
fi
|
fi
|
||||||
|
|
||||||
page="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&after='$page'' | jq -r '.pagination.cursor')"
|
page="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&after='$page'' | jq -r '.pagination.cursor')"
|
||||||
@@ -121,16 +133,16 @@ else
|
|||||||
|
|
||||||
while [ $page != 'null' ]
|
while [ $page != 'null' ]
|
||||||
do
|
do
|
||||||
if [ $list == "true" ]
|
if [ "$list" == "true" ]
|
||||||
then
|
then
|
||||||
curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.data[] | .url'
|
curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.data[] | .url'
|
||||||
elif [ $save == "true" ]
|
elif [ "$save" == "true" ]
|
||||||
then
|
then
|
||||||
curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.data[] | .url' | tee -a $location > /dev/null
|
curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.data[] | .url' | tee -a $location > /dev/null
|
||||||
else
|
else
|
||||||
url="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.data[] | .url')" > /dev/null
|
url="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.data[] | .url')" > /dev/null
|
||||||
|
|
||||||
youtube-dl -o "./%(title)s.%(ext)s" $url
|
youtube-dl -o "./%(title)s."$clipID".%(ext)s" $url
|
||||||
fi
|
fi
|
||||||
|
|
||||||
page="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.pagination.cursor')"
|
page="$(curl -s -H 'Client-ID:'$clientid'' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id='$broadcasterid'&first=100&started_at='$startDate'&ended_at='$endDate'&after='$page'' | jq -r '.pagination.cursor')"
|
||||||
|
|||||||
Reference in New Issue
Block a user