Last active
September 20, 2018 16:52
-
-
Save spookyahell/f1bbed8c14532734eb90f0f46d5135da to your computer and use it in GitHub Desktop.
Wait for proxy to be alive again - uses python VLC bindings to play windows notification sound if available and fetch does not return error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.exceptions import ProxyError | |
import time | |
from time import sleep | |
from importlib import util | |
pyvlc = False | |
if util.find_spec('vlc') != None: | |
from vlc import MediaPlayer, State | |
pyvlc = True | |
def play(): | |
p = MediaPlayer(r'C:\Windows\media\Windows Notify.wav') | |
p.play() | |
while p.get_state() != State.Ended: | |
continue | |
success = False | |
while success is False: | |
try: | |
requests.get('http://ipinfo.io/json', proxies = {'http':$PROXY}, stream=True).headers | |
if pyvlc is True: | |
play() | |
play() | |
except ProxyError: | |
time_str = time.strftime('%D %T') | |
print(f'{time_str} - ProxyError') | |
sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment