mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
honor m3u account user-agent in xc client
This commit is contained in:
parent
5e7427c378
commit
995ae3008c
2 changed files with 15 additions and 8 deletions
|
|
@ -261,7 +261,7 @@ def process_xc_category(account_id, batch, groups, hash_keys):
|
|||
streams_to_update = []
|
||||
stream_hashes = {}
|
||||
|
||||
xc_client = XCClient(account.server_url, account.username, account.password)
|
||||
xc_client = XCClient(account.server_url, account.username, account.password, account.get_user_agent())
|
||||
for group_name, props in batch.items():
|
||||
streams = xc_client.get_live_category_streams(props['xc_id'])
|
||||
for stream in streams:
|
||||
|
|
@ -495,7 +495,7 @@ def refresh_m3u_groups(account_id, use_cache=False, full_refresh=False):
|
|||
|
||||
xc_client = None
|
||||
if account.account_type == M3UAccount.Types.XC:
|
||||
xc_client = XCClient(account.server_url, account.username, account.password)
|
||||
xc_client = XCClient(account.server_url, account.username, account.password, account.get_user_agent())
|
||||
try:
|
||||
xc_client.authenticate()
|
||||
except Exception as e:
|
||||
|
|
@ -818,4 +818,4 @@ def send_m3u_update(account_id, action, progress, **kwargs):
|
|||
'type': 'update',
|
||||
'data': data
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,22 +4,29 @@ class Client:
|
|||
host = ""
|
||||
username = ""
|
||||
password = ""
|
||||
user_agent = ""
|
||||
|
||||
def __init__(self, host, username, password):
|
||||
def __init__(self, host, username, password, user_agent):
|
||||
self.host = host
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.password = user_agent
|
||||
|
||||
def authenticate(self):
|
||||
response = requests.get(f"{self.host}/player_api.php?username={self.username}&password={self.password}")
|
||||
response = requests.get(f"{self.host}/player_api.php?username={self.username}&password={self.password}", headers={
|
||||
'User-Agent': self.user_agent,
|
||||
})
|
||||
return response.json()
|
||||
|
||||
def get_live_categories(self):
|
||||
response = requests.get(f"{self.host}/player_api.php?username={self.username}&password={self.password}&action=get_live_categories")
|
||||
response = requests.get(f"{self.host}/player_api.php?username={self.username}&password={self.password}&action=get_live_categories", headers={
|
||||
'User-Agent': self.user_agent,
|
||||
})
|
||||
return response.json()
|
||||
|
||||
def get_live_category_streams(self, category_id):
|
||||
response = requests.get(f"{self.host}/player_api.php?username={self.username}&password={self.password}&action=get_live_streams&category_id={category_id}")
|
||||
response = requests.get(f"{self.host}/player_api.php?username={self.username}&password={self.password}&action=get_live_streams&category_id={category_id}", headers={
|
||||
'User-Agent': self.user_agent,
|
||||
})
|
||||
return response.json()
|
||||
|
||||
def get_stream_url(self, stream_id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue