Giter VIP home page Giter VIP logo

python-fritzbox's Introduction

python-fritzbox

Automation scripts for the Fritz!Box by using Python.

Features

Phone books

  • Convert into Fritz!Box XML format
    • VCARD address books (VCF)
    • Thunderbird address books (LDIF)
    • Various other address book formats (CSV)

Phone spam blacklist

  • Import
  • Download phone blacklist from ktipp (https://www.ktipp.ch), which is a phone spam blacklist periodically updated
  • Save into Fritz!Box XML format

Tested hardware

Tested with

  • Fritzbox 5590

Install on Debian (bookworm)

sudo apt-get install python3

git clone https://github.com/pamapa/python-fritzbox.git
cd python-fritzbox
virtualenv -p python3 env
source env/bin/activate
pip install -r requirements.txt

Examples

# Convert a LDIF address book into Fritz!Box XML format:
fritzboxphonebook.py --load mybook.ldif --save mybook.xml

python-fritzbox's People

Contributors

dependabot[bot] avatar pamapa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-fritzbox's Issues

Error: 'dav'

Hi,

i want to use this script to retrieve the address book from a Baïkal CardDAV server, but i only get the error
Error: 'dav'

With debug on, here's the output:

download phonebook from http://192.168.2.242:81/baikal/card.php/addressbooks/USERNAME/default/ get_books(http://192.168.2.242:81/baikal/card.php/addressbooks/USERNAME/default/) Error: 'dav' Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/python_fritzbox-0.2-py3.4.egg/EGG-INFO/scripts/fritzboxphonebook.py", line 115, in <module> args.vip_groups, picture_path, debug=args.debug) File "/usr/local/lib/python3.4/dist-packages/python_fritzbox-0.2-py3.4.egg/fritzbox/CardDAV.py", line 100, in get_books xml = self._get_xml(session, url, settings, debug) File "/usr/local/lib/python3.4/dist-packages/python_fritzbox-0.2-py3.4.egg/fritzbox/CardDAV.py", line 40, in _get_xml if response.headers['DAV'].count('addressbook') == 0: File "/usr/local/lib/python3.4/dist-packages/requests/structures.py", line 54, in __getitem__ return self._store[key.lower()][1] KeyError: 'dav'

The command i use is this:

fritzboxphonebook.py --webdav-url http://192.168.2.242:81/baikal/card.php/addressbooks/USERNAME/default/ --webdav-username USERNAME --webdav-password PASSWORD --save mybook.xml

The lighttpd-log from the Baïkal-Server shows the access:

`10.0.0.1 192.168.2.242:81 - [10/Jan/2018:11:12:57 +0000] "PROPFIND /baikal/card.php/addressbooks/USERNAME/default/ HTTP/1.1" 404 36 "-" "-"

10.0.0.4 192.168.2.242:81 - [10/Jan/2018:11:14:10 +0000] "PROPFIND /baikal/card.php/addressbooks/USERNAME/default/ HTTP/1.1" 404 36 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Lightning/4.7.8"`

1st line: the script
2nd line: access from Thunderbird with SOGo Connector

Thanks,
Felix

error: expected str, bytes or os.PathLike object, not list

Does not work anymore:

Exported thunderbird 91.10.0 addressbook as ldif or csv.

$ fritzboxphonebook.py --load office.ldif --save office.xml --debug
load phonebook from ['office.ldif']
error: expected str, bytes or os.PathLike object, not list
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/python_fritzbox-0.2-py3.9.egg/EGG-INFO/scripts/fritzboxphonebook.py", line 100, in
ext = os.path.splitext(args.load)[1].lower()
File "/usr/lib/python3.9/posixpath.py", line 118, in splitext
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not list

Unsafe Characters have to be escaped

Fritz!Box 7490 showed an import error on an a saved file, due to the following Name:

"Restaurant Royals & Rice"

To get it working i had to escape the unsafe charakters (the '&') to

"Restaurant Royals &amp; Rice"

As i use utf-8 encoding umlauts are no problem, only those Charakters, that are not safe as data in an XML.

Exits with type error if Type of a telefone number or email address is missing

If an entry has a telephone number or an email address without any type information. The program exists with a type error in VCF.py . line 91 resp. line 106.

It would be better to print a warning instead and continue with the next entry in the loop.

Of course such data should not exist in the first place but in my nextcloud addressbook it does.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.