Skip to content

Instantly share code, notes, and snippets.

@akira28
Last active April 23, 2019 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akira28/f782a67f38693393536fdf101f41ca91 to your computer and use it in GitHub Desktop.
Save akira28/f782a67f38693393536fdf101f41ca91 to your computer and use it in GitHub Desktop.
#!/bin/bash
i="0"
dateStart=$(date -d "last Tue" "+%Y-%-m-%-d")
dateEnd=$(date -d Sun "+%Y-%-m-%-d")
echo $dateStart
url="https://api.marvel.com/browse/comics?byType=date&isDigital=1&dateStart=${dateStart}&dateEnd=${dateEnd}&offset=0&limit=4000&orderBy=release_date+desc"
result=$(curl "$url")
echo "$url"
filename="${dateStart}.csv"
echo "https://marvel.com/comics/calendar/week/${dateStart}?byZone=marvel_site_zone&offset=0&tab=mu&isDigital=1&byType=date&dateStart=${dateStart}&dateEnd=${dateEnd}&type=&orderBy=release_date+desc&limit=300" > $filename
if [[ $result == *"\"code\":200"* ]]; then
until=$(echo "${result}" | jq ".data.total")
echo "$until"
while (( $i < $until ))
do
echo "$i"
echo $result | tr -d "[:cntrl:]" | jq "[.data.results[$i].digital_id, .data.results[$i].title, .data.results[$i].issue_number, .data.results[$i].release_date, .data.results[$i].date_added_to_digital_comics]" | jq -r '@csv' >> $filename
i=$[$i+1]
done
fi
echo "$filename"
echo "https://marvel.com/comics/calendar/week/${dateStart}?byZone=marvel_site_zone&offset=0&tab=mu&isDigital=1&byType=date&dateStart=${dateStart}&dateEnd=${dateEnd}&type=&orderBy=release_date+desc&limit=300"
edit $filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment