Recevoir un backup des MMS sur son ordi

salut
je cherche un moyen de voir/recevoir les MMS sur son ordi
l’idée est que ça se fasse le plus automatiquement possible

les solutions nextcloud sont possibles
les solutions avec scripts aussi
les solutions avec apk aussi
merci

Ça ça fonctionne chez moi sur un viel android optimus rooté et branché sur mon serveur. L’aspect mms ne m’interesse pas trop mais la récupération des SMS est intéressante. J’envois également des SMS avec

#!/usr/bin/python3
from os import system, chdir
from sqlite3 import connect
from datetime import datetime
import sys

chdir("/tmp")

# Copier la base depuis le téléphone
system("adb shell su -c cp /data/data/com.android.providers.telephony/databases/mmssms.db /sdcard")
system("adb pull /sdcard/mmssms.db")

# Connexion à la base SQLite
bd = connect("mmssms.db")
cur = bd.cursor()

#  Récupérer les SMS non lus
cur.execute("SELECT date, address, body FROM sms WHERE read=0 ORDER BY date;")
sms_list = cur.fetchall()

# Récupérer les MMS non lus
cur.execute("""
    SELECT p._id, p.date, a.address 
    FROM pdu p 
    JOIN addr a ON p._id = a.msg_id 
    WHERE p.read=0 AND a.type=137 
    ORDER BY p.date;
""")
mms_list = cur.fetchall()

# Affichage des SMS
if len(sys.argv) > 1:
    sms_list = sms_list[-int(sys.argv[1]):]

for l in sms_list:
    date = datetime.utcfromtimestamp(int(l[0]) // 1000)
    print("SMS de", l[1], "à", date.strftime("%d-%m-%Y %H:%M:%S"), ":", l[2])

# Récupération du texte et des fichiers multimédias des MMS
for mms in mms_list:
    mms_id, timestamp, sender = mms
    date = datetime.utcfromtimestamp(int(timestamp))
    
    # Récupérer le texte du MMS
    cur.execute("SELECT text FROM part WHERE mid=? AND ct='text/plain';", (mms_id,))
    mms_text = cur.fetchone()
    text = mms_text[0] if mms_text else "[MMS sans texte]"

    print(f" MMS de {sender} à {date.strftime('%d-%m-%Y %H:%M:%S')} : {text}")

    # Récupérer les fichiers multimédias
    cur.execute("SELECT _data, ct FROM part WHERE mid=? AND _data IS NOT NULL;", (mms_id,))
    media_files = cur.fetchall()

    for media in media_files:
        file_path, content_type = media
        file_name = file_path.split("/")[-1]  # Nom du fichier

        print(f"Fichier reçu ({content_type}): {file_name}")

        # Copier le fichier depuis le téléphone
        system(f"adb shell su -c cp {file_path} /sdcard/{file_name}")
        system(f"adb pull /sdcard/{file_name}")

**# Fermeture de la base**
bd.close()

merci beaucoup

sur mon fairphone sous e/os ton programme nécessite quelques changements:

  1. autoriser le développeur/root
  2. lancer adb root
  3. enlever su -c de tes 2 lignes
  4. enlever WHERE p.read=0 AND a.type=137 pour obtenir les SMS non lus ( a.type aussi? )
  5. chez moi les sms/mms ne sont pas à /data/data/com.android.providers.telephony/databases/mmssms.db ( faire un find -name « mmssms.db » pour trouver l’emplacement)

et puis c’est pas très propre de mettre tout à la racine de ta sdcard :slight_smile:

Par contre ça m’embête d’avoir à être root, mais c’est déjà super.

Perso c’est un téléphone abonnement free à 0€ branché en permanence. Il me sert surtout à envoyer des textos par ordi automatiquement, si le controle d’integrité de ma machine n’est pas bon, j’ai un texto.
Le nom de la table change également.
Pour la racine de la sdcard effectivement, mais vu ce que je fais du téléphone, ça ne m’a pas trop ému

Peut-être cette appli ? (pas besoin d’être root)

By default, binary MMS data (such as images and videos) are exported. The user can choose to exclude them, which will often result in a much smaller ZIP file.

SMS Import / Export does all input and output via the Android Storage Access Framework (SAF). The app should thus be able to import from and export to any location available via the SAF, including both local storage (internal, SD card, or USB attached) as well as cloud storage accessible through the SAF, via either a dedicated app (e.g., the Nextcloud Android App) or Rclone through RSAF.

T’inquiète , je voulais pas critiquer, juste permettre aux autres qui liront de trouver leur solution : elle est super ta solution ; mais je ne la cherche pas pour moi mais pour ma mère qui a du mal parfois à lire ou regarder ses images donc je voudrais les exporter sur ordi le plus automatiquement

J’utilise un webhook pour faire ça. Mon abonnement free me permet de le faire. Et je peux ainsi envoyer un sms d’alerte ou autre sans avoir un abonnement particulier. Je m’en sert pour mon NAS et bientot pour des alertes de supervision et autres.

peux -tu préciser ta méthode,stp.

Meillerue appli android pour l’instant :

car, contrairement à

elle permet de choisir où tu mets l’export et donc d’y accéder sans android/root :
en forçant l’export dans Documents/SMS_MMS/ ; on peut écrire

dateuh=$(date "+%Y-%m-%d")
adb pull /storage/self/primary/Documents/SMS_MMS/calls-${dateuh}.json
adb pull /storage/self/primary/Documents/SMS_MMS/contacts-${dateuh}.json
adb pull /storage/self/primary/Documents/SMS_MMS/messages-${dateuh}.zip

calls.json:

[
  {
    "formatted_number":""
    "duration":""
    "subscription_id":""
    "photo_id":""
    "post_dial_digits":""
    "number":""
    "countryiso":""
    "geocoded_location":""
    "block_reason":""
    "subscription_component_name":""
    "add_for_all_users":""
    "features":""
    "last_modified":""
    "_id":""
    "new":""
    "date":""
    "type":""
    "presentation":""
    "via_number":""
    "normalized_number":""
    "phone_account_address":""
    "phone_account_hidden":""
    "lookup_uri":""
    "transcription_state":""
  },
]

contact.json:

[
  {
    "last_time_contacted": ""
    "pinned": ""
    "display_name_alt": ""
    "sort_key_alt": ""
    "in_visible_group": ""
    "starred": ""
    "phonebook_label": ""
    "is_user_profile": ""
    "has_phone_number": ""
    "display_name_source": ""
    "phonetic_name_style": ""
    "send_to_voicemail": ""
    "lookup": ""
    "phonebook_label_alt": ""
    "contact_last_updated_timestamp": ""
    "phonebook_bucket": ""
    "display_name": ""
    "sort_key": ""
    "in_default_directory": ""
    "times_contacted": ""
    "_id": ""
    "name_raw_contact_id": ""
    "phonebook_bucket_alt": ""
    "raw_contacts": [
      {
        "last_time_contacted": ""
        "pinned": ""
        "account_type": ""
        "aggregation_mode": ""
        "contact_id": ""
        "display_name_alt": ""
        "sort_key_alt": ""
        "starred": ""
        "phonebook_label": ""
        "account_name": ""
        "display_name_source": ""
        "phonetic_name_style": ""
        "send_to_voicemail": ""
        "dirty": ""
        "phonebook_label_alt": ""
        "phonebook_bucket": ""
        "display_name": ""
        "sort_key": ""
        "version": ""
        "deleted": ""
        "raw_contact_is_user_profile": ""
        "times_contacted": ""
        "_id": ""
        "metadata_dirty": ""
        "account_type_and_data_set": ""
        "phonebook_bucket_alt": ""
        "contacts_data": [
          {
            "account_type": ""
            "data_version": ""
            "display_name_alt": ""
            "sort_key_alt": ""
            "last_time_used": ""
            "starred": ""
            "has_phone_number": ""
            "raw_contact_id": ""
            "carrier_presence": ""
            "contact_last_updated_timestamp": ""
            "phonebook_bucket": ""
            "times_used": ""
            "display_name": ""
            "sort_key": ""
            "version": ""
            "in_default_directory": ""
            "times_contacted": ""
            "_id": ""
            "account_type_and_data_set": ""
            "name_raw_contact_id": ""
            "phonebook_bucket_alt": ""
            "last_time_contacted": ""
            "pinned": ""
            "is_primary": ""
            "contact_id": ""
            "in_visible_group": ""
            "phonebook_label": ""
            "account_name": ""
            "display_name_source": ""
            "dirty": ""
            "phonetic_name_style": ""
            "send_to_voicemail": ""
            "lookup": ""
            "phonebook_label_alt": ""
            "is_super_primary": ""
            "data2": ""
            "data1": ""
            "raw_contact_is_user_profile": ""
            "data10": ""
            "mimetype": ""
            "data11": ""
            "hash_id": ""
          },
          {
            "account_type": ""
            "data_version": ""
            "display_name_alt": ""
            "sort_key_alt": ""
            "last_time_used": ""
            "starred": ""
            "has_phone_number": ""
            "raw_contact_id": ""
            "carrier_presence": ""
            "contact_last_updated_timestamp": ""
            "phonebook_bucket": ""
            "times_used": ""
            "display_name": ""
            "sort_key": ""
            "version": ""
            "in_default_directory": ""
            "times_contacted": ""
            "_id": ""
            "account_type_and_data_set": ""
            "name_raw_contact_id": ""
            "phonebook_bucket_alt": ""
            "last_time_contacted": ""
            "pinned": ""
            "is_primary": ""
            "contact_id": ""
            "in_visible_group": ""
            "phonebook_label": ""
            "account_name": ""
            "display_name_source": ""
            "dirty": ""
            "phonetic_name_style": ""
            "send_to_voicemail": ""
            "lookup": ""
            "phonebook_label_alt": ""
            "is_super_primary": ""
            "data4": ""
            "data2": ""
            "data1": ""
            "raw_contact_is_user_profile": ""
            "mimetype": ""
            "hash_id": ""
          }
        ]
      }
    ]
  },
 

messages.zip
contient

  • messages.ndjson :
{"_id":"","thread_id":"","address":"","date":"","date_sent":"","read":"","status":"","type":"","body":"","locked":"","sub_id":"","error_code":"","creator":"","seen":"","__display_name":""}
{"_id":"","thread_id":"","date":"","date_sent":"","msg_box":"","read":"","m_id":"","ct_t":"","ct_l":"","m_cls":"","m_type":"","v":"","m_size":"","pri":"","rr":"","tr_id":"","d_rpt":"","locked":"","sub_id":"","seen":"","creator":"","text_only":"","__sender_address":{"_id":"","msg_id":"","address":"","type":"","charset":"","__display_name":""},"__recipient_addresses":[{"_id":"","msg_id":"","address":"","type":"","charset":"","__display_name":""}],"__parts":[{"_id":"","mid":"","seq":"","ct":"","name":"","chset":"","cid":"","cl":"","text":"<smil>\n\t<head>\n\t\t<layout>\n\t\t\t<root-layout height=\"136\" width=\"174\"\/>\n\t\t\t<region fit=\"meet\" height=\"100%\" left=\"0\" top=\"0\" width=\"100%\" id=\"Image\"\/>\n\t\t<\/layout>\n\t<\/head>\n\t<body>\n\t\t<par dur=\"5000ms\">\n\t\t\t<img src=\"image000000.jpg\" region=\"Image\"\/>\n\t\t<\/par>\n\t<\/body>\n<\/smil>\n"},{"_id":"","mid":"","seq":"","ct":"","name":"","cid":"","cl":"","_data":"\/data\/user_de\/0\/com.android.providers.telephony\/app_parts\/PART_1743167960000_image000000.jpg"}]}
  • data/ qui contient les jpg en .jpg ou en .image

image

Sur la page des options de mon forfait je peux générer cet clef API.

Simple à utiliser.

super
ça marche même avec un wget

Je pense que oui, il n’y a pas de raison. Du moment que la structure de la requête est conforme.
Par contre, bien garder en tête que la clef API est en clair dans la requête.

Malheureusement, c’est souvent le cas dans les webhook.

Ceci dit je n’ai jamais essayé avec un POST plutôt qu’un GET. Il me semble que le Synology fait un GET.