From 5579bffe1928724a849ebd70ef8b583222775fa4 Mon Sep 17 00:00:00 2001 From: Ed Bruck Date: Thu, 3 Jan 2019 09:32:41 -0800 Subject: [PATCH] Added command line argument (-ca/--canada) to override the default appRegion value (US). This prevented Canadian subscribers from authenticating. --- sxm.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sxm.py b/sxm.py index 398b480..90cd2e9 100644 --- a/sxm.py +++ b/sxm.py @@ -12,13 +12,14 @@ class SiriusXM: REST_FORMAT = 'https://player.siriusxm.com/rest/v2/experience/modules/{}' LIVE_PRIMARY_HLS = 'https://siriusxm-priprodlive.akamaized.net' - def __init__(self, username, password): + def __init__(self, username, password, region): self.session = requests.Session() self.session.headers.update({'User-Agent': self.USER_AGENT}) self.username = username self.password = password self.playlists = {} self.channels = None + self.region = region @staticmethod def log(x): @@ -74,7 +75,7 @@ def login(self): 'sxmAppVersion': '3.1802.10011.0', 'browser': 'Safari', 'browserVersion': '11.0.3', - 'appRegion': 'US', + 'appRegion': self.region, 'deviceModel': 'K2WebClient', 'clientDeviceId': 'null', 'player': 'html5', @@ -115,7 +116,7 @@ def authenticate(self): 'sxmAppVersion': '3.1802.10011.0', 'browser': 'Safari', 'browserVersion': '11.0.3', - 'appRegion': 'US', + 'appRegion': self.region, 'deviceModel': 'K2WebClient', 'player': 'html5', 'clientDeviceId': 'null' @@ -355,9 +356,10 @@ def do_GET(self): parser.add_argument('password') parser.add_argument('-l', '--list', required=False, action='store_true', default=False) parser.add_argument('-p', '--port', required=False, default=9999, type=int) + parser.add_argument('-ca', '--canada', required=False, action='store_true', default=False) args = vars(parser.parse_args()) - - sxm = SiriusXM(args['username'], args['password']) + + sxm = SiriusXM(args['username'], args['password'], 'CA' if args['canada'] else 'US') if args['list']: channels = list(sorted(sxm.get_channels(), key=lambda x: (not x.get('isFavorite', False), int(x.get('siriusChannelNumber', 9999)))))