Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url filtering configuration #206

Open
serv-inc opened this issue Jan 3, 2024 · 0 comments
Open

Add url filtering configuration #206

serv-inc opened this issue Jan 3, 2024 · 0 comments

Comments

@serv-inc
Copy link

serv-inc commented Jan 3, 2024

Hi, thanks for this.

In case you're interested in enabling the internet blacklist, the following code does this (using the request api):

import requests
from typing import List

common_data = {"xhr": 1, "lang": "de", "page": "kids_blacklist"}

def get(mysid: str) -> List[str]:
    data = dict(common_data)
    data["sid"] = mysid
    data["xhrId"] = "all"
    result = requests.post("http://192.168.178.1/data.lua", data=data)
    return [x['url'] for x in result.json()['data']['list']]


def change(mysid: str, blacklist: List[str]) -> None:
    data = dict(common_data)
    data["listtype"] = "black"
    data["apply"] = "true"
    data["sid"] = mysid
    data["urllist"] = "\n".join(blacklist)
    requests.post("http://192.168.178.1/data.lua", data=data)

The sid was retrieved from

def get_sid(password: str) -> str:
    fc = FritzConnection(address="192.168.178.1", password=password)
    (_, sid) = list(fc.http_interface._get_sid())
    return sid

If you want to use this code, feel welcome. Licensed via MIT license. Or contact me if you need another one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant