Edit 25/07/2012 : Ce n’est plus nécessaire car Free offre désormais un service pour recevoir sa facture par email…

Pour télécharger les factures Free Mobile et les envoyer par email, j’ai mis en œuvre un script bash conjointement avec l’utilisation de boobill, plugin de weboob (Web Out Of Browser).

 

Installation de boobill

Éditer le fichier /etc/apt/sources.list et y ajouter la ligne suivante :

deb http://debian.weboob.org unstable main

Installation de Weboobs :

sudo aptitude update
sudo aptitude install debian-symlink-keyring
sudo aptitude update
sudo aptitude install weboob python-imaging

On peut ensuite lancer boobill et installer le backend Free Mobile :

boobill
 Warning: there is currently no configured backend for boobill
 Do you want to configure backends? (Y/n): Y
Available modules:
 
 1) [ ] freemobile        Free Mobile website
 2) [ ] nettokom          Nettokom website
 a) --all--               install all backends
 q) --stop--
 
Select a backend to create (q to stop): 1
 
Configuration of backend freemobile
 -----------------------------------
 [login] Account ID: 14861232
 [password] Password (hidden input):
 -----------------------------------
 Backend "freemobile" successfully added.
 
Available modules:
 1) [X] freemobile        Free Mobile website
 2) [ ] nettokom          Nettokom website
 a) --all--               install all backends
 q) --stop--
 
Select a backend to create (q to stop): q
 Right right!
 Welcome to boobill v0.c
 
Copyright(C) 2012 Florent Fourcot
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
Type "help" to display available commands.

 

Utilisation (succincte) de Boobill

Dans le contexte boobill on peut lister les contrats :

boobill> ls
 * (1) 06xxxxxx01 - Forfait Free illimité à 15,99 euros réservé aux abonnés Freebox (freemobile)

Lister les factures du contrat n°1 (le seul) :

boobill> bills 1
 +--------------------------------+------------+--------+------------+
 |               Id               |    Date    | Format |   Label    |
 +--------------------------------+------------+--------+------------+
 | 06xxxxxx01.20120502@freemobile | 2012-05-02 | html   | 02-05-2012 |
 | 06xxxxxx01.20120402@freemobile | 2012-04-02 | html   | 02-04-2012 |
 | 06xxxxxx01.20120302@freemobile | 2012-03-02 | html   | 02-03-2012 |
 +--------------------------------+------------+--------+------------+

Télécharger une de ces factures :

boobill> download 06xxxxxx01.20120502@freemobile

On peut télécharger cette même facture en dehors du contexte boobill directement depuis le bash ainsi (pour quitter boobill, la commande est quit) :

boobill download 06xxxxxx01.20120502@freemobile

 

Script bash

Afin d’automatiser la récupération des factures tous les mois et l’envoi de ces facture par email voici le script que j’ai réalisé :

#!/bin/bash
 
PHONE_NUMBER='06xxxxxx01'
DOWNLOAD_FOLDER=$HOME'/Documents/Facture/FreeMobile/'$(date +"%Y")
MAIL_DEST='monemail@adresse.fr'
 
BILL_DATE=$(date +"%Y%m%d")
BILL_FILE=$PHONE_NUMBER.$BILL_DATE.html
 
[ -d $DOWNLOAD_FOLDER ] || mkdir -p $DOWNLOAD_FOLDER
 
if [[ ! -f $DOWNLOAD_FOLDER/$BILL_FILE ]]; then
        boobill download $PHONE_NUMBER.$BILL_DATE@freemobile
        if [[ -f $BILL_FILE ]]; then
                mv $BILL_FILE $DOWNLOAD_FOLDER/$BILL_FILE
                echo 'Ci-joint la facture Free Mobile du mois de '$(date '+%B') | mutt $MAIL_DEST -s 'Facture '$BILL_DATE -a $DOWNLOAD_FOLDER/$BILL_FILE
        fi
fi

Ne reste plus qu’a planifier le script dans un cron…

 

Sources :

Weboob – Web Out of Browsers

Journal Weboob – la capability collection

Boobill : List your subscriptions, view and download the bill details.

 

PS : Pour tenter une conversion de la facture HTML en PDF, j’ai testé

htmldoc --webpage -f output.pdf ../06xxxxxx01.20120502.html

Mais la mise en forme de tableau n’est pas respecté

 

PS2 : Enfin un article après 3 mois d’absence, mais j’ai changé de travail et je fais toute la journée les choses que je faisais le soir et sur mon temps libre (et en plus je suis payé pour ça)

Les commentaires sont fermés.