Skip to content

Commit

Permalink
Add config.useragent to all HTTP requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bevinsky committed Dec 30, 2018
1 parent 657a5af commit b4cbd2c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion manager/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,10 @@ def update_index(self):
url = config.index_route.format(self.id)

try:
requests.get(url, auth=(config.index_user, config.index_pass))
requests.get(url,
headers={'User-Agent': config.user_agent},
auth=(config.index_user, config.index_pass)
)
except:
logging.exception("Failed song indexing ping")

Expand Down
6 changes: 5 additions & 1 deletion manager/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ def tunein(song):
urlparams['title'] = title.encode(
'utf-8') if isinstance(title,
unicode) else title
r = requests.get(url, params=urlparams, timeout=8)
r = requests.get(url,
headers={'User-Agent': config.user_agent},
params=urlparams,
timeout=8
)
r.raise_for_status()
except:
logging.warning("Error when contacting tuneIn API")
Expand Down
11 changes: 6 additions & 5 deletions streamstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def get_status(server_name):
result = {"online": False}
try:
response = requests.get(config.icecast_status,
headers={
'User-Agent': 'Mozilla'
},
headers={'User-Agent': config.user_agent},
timeout=2
)
except requests.HTTPError as e: # rare, mostly 403
Expand All @@ -57,7 +55,10 @@ def get_status(server_name):

# let's get the real listener count from the LB endpoint
try:
lb = requests.get(config.lb_endpoint, timeout=2)
lb = requests.get(config.lb_endpoint,
headers = {'User-Agent': config.user_agent},
timeout=2
)
except:
#print 'ERROR'
#logging.exception("Could not connect to load balancer status")
Expand Down Expand Up @@ -106,7 +107,7 @@ def get_listeners():
mount=config.icecast_mount
),
headers={
'User-Agent': 'Mozilla',
'User-Agent': config.user_agent,
'Referer': '{url}/admin/'.format(url=config.icecast_server),
'Authorization': 'Basic {}'.format(config.stream_admin_auth)
},
Expand Down

0 comments on commit b4cbd2c

Please sign in to comment.