Skip to content

Instantly share code, notes, and snippets.

@Tronix117
Created July 9, 2013 17:04
Show Gist options
  • Save Tronix117/5959151 to your computer and use it in GitHub Desktop.
Save Tronix117/5959151 to your computer and use it in GitHub Desktop.
Download MMS from Bouygues Telecom (useful for Numericable iPhone owner's). Usage: bouyguemms code [yourPhoneNumber [whereToDownload]]. Ex: bouyguemms i9u7sw
#!/bin/sh
PHONE=${2-yourdefaultphonenumber}
CODE=$1
OUTPUT=${3-.}
BASEURL=http://www.lire-mms.bouyguestelecom.fr/mmbox
SESSIONID=`curl -s -X POST -d "msisdn=$PHONE&msgid=$CODE" -D- "$BASEURL/otp.html" -o /dev/null | grep JSESSIONID | cut -d'=' -f2 | cut -f1 -d' ' | tr "\!" "\\\!"`
PAGE=`curl -s --cookie "JSESSIONID=$SESSIONID" "$BASEURL/index.html?act=viewmsg&locale=en&box=MMS&skin=bytel"`
MEDIA=$BASEURL/`echo "$PAGE" | grep \"getMedia | cut -f4 -d'"'`
TEXT=`echo $PAGE | grep '<p id="_text_.*>.*</p>' -o | cut -f2 -d'>' | cut -f1 -d '<'`
ORIG_FILENAME=`echo "$PAGE" | grep "getOtpMedia?id=0" | cut -f2 -d'"'`
FILENAME=$ORIG_FILENAME
N=0
while :
do
if [ -f "$OUTPUT/$FILENAME" ]
then
N=$((N+1))
FILENAME="`echo $ORIG_FILENAME | cut -f1 -d'.'` $N.`echo $ORIG_FILENAME | cut -f2 -d'.'`"
else
break
fi
done
if [[ "$OUTPUT/$FILENAME" == "./" ]]
then
echo "Error: Can't download '$CODE', please try again"
else
echo "$TEXT" > "$OUTPUT/`echo $FILENAME | cut -f1 -d'.'`.txt"
echo "$MEDIA > $OUTPUT/$FILENAME"
curl --cookie "JSESSIONID=$SESSIONID" -o "$OUTPUT/$FILENAME" $MEDIA
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment