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

Windows: detect if on metered connection #3005

Open
Safihre opened this issue Dec 23, 2024 · 4 comments
Open

Windows: detect if on metered connection #3005

Safihre opened this issue Dec 23, 2024 · 4 comments

Comments

@Safihre
Copy link
Member

Safihre commented Dec 23, 2024

Description

Maybe usefull to add?
Pause downloading if we detect on metered?

pip install winrt-Windows.Networking.Connectivity
>>> import winrt.windows.networking.connectivity as nc
>>> nc.NetworkInformation.get_internet_connection_profile().get_connection_cost().network_cost_type
<NetworkCostType.UNRESTRICTED: 1>
>>> nc.NetworkInformation.get_internet_connection_profile().get_connection_cost().network_cost_type
<NetworkCostType.FIXED: 2>

>>> def test(*args, **kwargs): print("test")
>>> nc.NetworkInformation.add_network_status_changed(test)
@sanderjo
Copy link
Contributor

So use case: you're downloading via your wifi at home, with stuff still in the Queue. Then you switch to a metered connection, like in the train, and SAB detects and stops downloading?

How much extra MB does that add to SABnzbd's exe? Or is it already imported?

Looks like a niche case to me. When is something a "metered connection"? When a Windows is using the internal SIM / 4G / 5G? Or also if using the wifi hotspot of your phone? Or is that defined by Windows / the user's setting in Windows?

How many users have a metered connection in their laptop, and are worried about usage?

What if you're on "Train Wifi", "Work Wifi", or "Hotel Wifi"? Shouldn't we introduce "Only download if connected via Wifi network X, Y or Z"? And if SAB decides to now download, give a big, big message in the GUI?

@thezoggy
Copy link
Contributor

thezoggy commented Dec 24, 2024

Metered isn't only limited to wifi
https://support.microsoft.com/en-us/windows/metered-connections-in-windows-7b33928f-a144-b265-97b6-f2e95a87c408

Having this option makes sense regardless of a user scenario that could end up using one. But definitely need a message to warn since people may accidentally be on one and be confused why things aren't working.

Ive seen people use metered connections as a way to stop certain software activation stuff from working (on purpose).. so sometimes it gets missused on purpose.

@sanderjo
Copy link
Contributor

website: "You can manually set Wi-Fi and Ethernet network connections to metered if you want to reduce the amount of data used by apps and services on that network. A cellular data network connection is set as metered by default."

That covers the use caes like "Train Wifi". Nice!

@sanderjo
Copy link
Contributor

sanderjo commented Dec 30, 2024

Ah, "metered" is there in Ubuntu too: See screenshot.

And you can check if active netowork connection is metered with:

(EDITED with easier code)

import nmcli
nmcli.disable_use_sudo()
name = nmcli.connection()[0].name # First entry is default route, as man page: The default sorting order is equivalent to --order active:name:path
print(name)
print("metered:", nmcli.connection.show(name)['connection.metered'])

Output:

sander@zwarte:~/nmcli-venv$ bin/python3 check_if_metered.py 
Wired connection 1
metered: unknown

... not metered

sander@zwarte:~/nmcli-venv$ bin/python3 check_if_metered.py 
Vogelnest
metered: yes

... metered

A different Wifi

sander@zwarte:~/nmcli-venv$ bin/python3 check_if_metered.py 
snelweg
metered: no

... not metered

I'm in!

image

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

No branches or pull requests

3 participants