Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
Added command line argument (-ca/--canada) to override the default ap…
Browse files Browse the repository at this point in the history
…pRegion value (US).

This prevents Canadian subscribers from authenticating.
  • Loading branch information
ebruck committed Jan 3, 2019
1 parent 0726400 commit 291b110
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sxm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)))))

Expand Down

0 comments on commit 291b110

Please # to comment.