Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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