Last active
March 9, 2024 09:01
-
-
Save bmedicke/6dc692723212757df27c819d137ccc0b to your computer and use it in GitHub Desktop.
extract ChatGTP aac audio from Chrome's .har files
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 | |
# Check if there are any .har files in the current directory | |
har_files=$(echo *.har) | |
if [ -z "$har_files" ] || [ "$har_files" = "*.har" ]; then | |
echo "No .har files found." | |
exit 1 | |
fi | |
# Iterate over all .har files in the current directory | |
for file in *.har; do | |
# Check if the file actually exists | |
if [ ! -f "$file" ]; then | |
echo "File not found: $file" | |
exit 1 | |
fi | |
# Extract the filename without the extension | |
base_name=$(basename "$file" .har) | |
# Initialize an empty string to accumulate all base64 strings | |
full_base64_string="" | |
# Extract and concatenate all Base64 strings | |
while IFS= read -r line; do | |
full_base64_string+="$line" | |
done < <(jq -r '.log.entries[] | select(.response.content.mimeType == "audio/aac") | .response.content.text' "$file") | |
# Check if the full Base64 string is empty | |
if [ -z "$full_base64_string" ]; then | |
echo "No AAC content found in $file" | |
continue # Skip this file but don't stop the whole script | |
fi | |
# Decode the concatenated Base64 string and save it to a file | |
echo "$full_base64_string" | base64 -d > "${base_name}.aac" | |
# Remove the original .har file | |
rm "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
synthesize?message_id=[...]
select "Save all as HAR with content"./getGPTune.sh