🇫🇷 Ce script Python automatise le comptage des mots et le calcul du temps de lecture pour vos chapitres directement dans une base de données Notion.
🇬🇧 This Python script automates word counting and reading time calculation for your chapters directly in a Notion database.
Votre base de données doit contenir ces deux colonnes (Attention : les noms doivent être exacts) :
Nb Mots(Type: Nombre)Temps de lecture(Type: Texte)
💡 Note : Si vous changez ces noms dans Notion, vous devrez également les modifier dans le code Python.
- Créer une clé d'intégration : Allez sur notion.so/my-integrations.
- Autoriser l'accès : Dans Notion, sur votre page de base de données, cliquez sur
...>Connecter à> Sélectionnez votre intégration. - Installer les dépendances :
pip install httpx
- Configuration du script : Ouvrez
NbMots.pyet remplissez vos clés :NOTION_TOKEN = "VOTRE_SECRET_ICI"DATABASE_ID = "VOTRE_ID_DE_BASE_ICI"
Pour garder un bureau propre et lancer la mise à jour en un clic sans ouvrir de code :
- Créez un fichier
Lancer.batavec le bloc-notes contenant ceci :@echo off REM -- 1. On définit le fichier de log dans le dossier du script -- set "LOGFILE=%~dp0log_synchro.txt" REM -- 2. On change l'encodage de la console pour accepter les accents/emojis -- chcp 65001 >nul REM -- 3. On écrit la date -- echo. >> "%LOGFILE%" echo ====================================================== >> "%LOGFILE%" echo [%date% - %time%] Lancement du script >> "%LOGFILE%" echo Mise a jour du Plan Narratif en cours... REM -- 4. IMPORTANT : On force Python a utiliser l'UTF-8 pour la sortie -- set PYTHONIOENCODING=utf-8-sig REM -- 5. On lance le script -- "C:\chemin\vers\votre\python\python3.11.exe" "c:\chemin\vers\votre\script\NbMots.py" >> "%LOGFILE%" 2>&1 echo. echo C'est fait ! Tes mots sont synchronises. echo (Les details sont dans log_synchro.txt) timeout /t 3
- Créez un raccourci de ce fichier sur votre bureau.
- Faites un clic droit sur le raccourci > Propriétés.
- Dans le champ Cible, ajoutez
cmd /cau tout début de la ligne. - Changez l'icône si vous le souhaitez, puis faites un clic droit > Épingler à la barre des tâches.
- Vous pouvez maintenant supprimer le raccourci du bureau.
Your database must include these two columns:
- Nb Mots (Type:
Number) - Temps de lecture (Type:
Text)
💡 Note: If you change these names in Notion, you must update the variable names inside the Python code.
- Integration Key: Create your token at notion.so/my-integrations.
- Grant Access: In Notion, on your database page, click
...>Connect to> Select your integration. - Dependencies:
pip install httpx
- **Configuration: Fill in your NOTION_TOKEN and DATABASE_ID inside the script.
-
** Create a
Rub.batfile with the path to your script:@echo off REM -- 1. Set log file path to the script's directory -- set "LOGFILE=%~dp0log_synchro.txt" REM -- 2. Change console encoding to support accents/emojis -- chcp 65001 >nul REM -- 3. Write timestamp -- echo. >> "%LOGFILE%" echo ====================================================== >> "%LOGFILE%" echo [%date% - %time%] Script started >> "%LOGFILE%" echo Updating Narrative Outline... REM -- 4. IMPORTANT: Force Python to use UTF-8 for output -- set PYTHONIOENCODING=utf-8-sig REM -- 5. Run the script -- "C:\Path\To\Your\Python\version\python3.11.exe" "c:\Path\To\Your\Python\script\NbMots.py" >> "%LOGFILE%" 2>&1 echo. echo Done! Your word counts are synchronized. echo (Details can be found in log_synchro.txt) timeout /t 3
-
Create a desktop shortcut for this file.
-
Right-click > Properties. In the Target field, add
cmd /cat the very beginning. -
Right-click > Pin to taskbar. You can then delete the desktop shortcut.
🇫🇷 Les contributions sont les bienvenues !
-
Forkez le projet.
-
Créez votre branche (
git checkout -b feature/Amelioration). -
Commitez vos changements (
git commit -m 'Ajout de fonctionnalité'). -
Ouvrez une Pull Request.
🇬🇧 Contributions make the open-source community amazing!
-
Fork the Project.
-
Create you Feature Branch (
git checkout -b feature/Amelioration). -
Commit your changes (
git commit -m 'Ajout de fonctionnalité'). -
Open a Pull Request.